auth->getAuth()) // return "login"; } var $sess; // the session id. var $dir = '/mnt/pdcshare/admin/handbook/'; var $items = array(); function start($request) { if (isset($_GET['file'])) { $this->outputFile(); exit; } $this->sess = $_REQUEST['sess']; $dir = $this->dir; if (isset($_GET['dir'])) { if (substr($_GET['dir'],0,strlen($dir)) != $dir) { return; } $dir = $_GET['dir']; } //echo $dir; //exit; $dh = opendir($dir); while (($file = readdir($dh)) !== false) { if ($file{0} == '.') { continue; } if ($file == 'CVS') { continue; } $node = new StdClass; $node->name = $file; $node->dir = $dir; $node->isDir = is_dir($dir.$file); $this->items[] = $node; } $this->items = array_reverse($this->items); } function output() { header('Content-Type: text/xml'); parent::output(); } function outputFile() { $dir = $this->dir; $file = $_GET['file']; if (strpos($file,'..') || (substr($file,0,strlen($dir)) != $dir)) { echo 'Access denied!'; exit; } if (preg_match('/\.php$/', $file)) { highlight_file($file); exit; } if (preg_match('/\.html$/', $file)) { //header('Content-Type: text/xml'); echo file_get_contents($file); //echo htmlspecialchars(); exit; } if (preg_match('/\.(xml|js|css)$/', $file)) { header('Content-Type: text/plain'); echo file_get_contents($file); //echo htmlspecialchars(); } if (preg_match('/\.(png|jpeg|jpg|gif)$/', $file,$args)) { //print_r($args); header("Content-type: image/".$args[1]); $fh = fopen($file,'r'); echo fread($fh,filesize($file)); fclose($fh); //$partial = str_replace('/var/www/','',$file); // echo 'Location: **http://'.$_SERVER['SERVER_NAME'].'/',$partial . '***'; //header('Location: http://'.$_SERVER['SERVER_NAME'].'/'.$partial); exit; //echo htmlspecialchars(); } if (preg_match('/\.(doc)$/', $file,$args)) { $out = basename($file) . '.html'; if (!file_exists('/tmp/'.$out)) { $exec = 'wvHtml --targetdir=/tmp ' . escapeshellarg($file). ' ' . $out; // echo "run $exec"; exec($exec); }header('Content-Type: text/html; charset=utf-8'); echo file_get_contents('/tmp/' . $out); exit; } echo "Display not supported $file"; } } ?>