Description : History : - 25/3/9 inital version */ require_once('config.php'); require_once('tools/misc.php'); require_once('tools/xml.php'); /* Remove extra anti-slash */ //$_POST = preg_replace("/\\\\(['\"\\\\])/", "\\1", $_POST); foreach($_POST as $key => $value) if (is_string($value)) $_POST[$key] = str_replace (array ('\"', "\\'"), array ('"', "'"), $value); foreach($_GET as $key => $value) if (is_string($value)) $_GET[$key] = str_replace (array ('\"', "\\'"), array ('"', "'"), $value); /* Get file name */ $page = array(); if (isset($_GET["page"])) $page['file'] = '/' . $_GET["page"]; elseif (isset($_POST["page"])) $page['file'] = $_POST["page"]; else $page['file'] = ""; $page['file'] = rawurldecode($page['file']); if (preg_match('/^\/$/', $page['file'])) $page['file'] = ""; /* Check file type */ $ext = strtolower(substr(strrchr($page['file'], "."), 1)); $ctype = findmimetype($ext); if ($ctype == "directory") { $ctype = ""; $page['file'] = (file_exists($repos . "/" . $page['file'] . "/index.html")) ? $page['file'] . "/index.html" : $page['file'] . "/index.php"; $ext = "php"; } #$page['file'] = preg_replace("/^\/*/", "", $page['file']); /* Check if the file is in the repository, in the spool or in library */ /* ** spool name is set to 'doc' here and also in form/displaydoc.php ** */ $filename = (preg_match("/^\/*admin\//", $page['file'])) ? "./" . $page['file'] : ((preg_match("/^\/*doc\//", $page['file'])) ? $spool . preg_replace("/^\/*doc/", "", $page['file']) : $repos . "/" . $page['file']); $filename = realpath($filename); /* Action logout */ include('actions/logout.php'); /* Check identification */ include('actions/login.php'); /* Check if file exits */ if (!file_exists($filename)) { $page['status'][] = "La page '".$page['file']."' n'existe pas."; $filename = realpath("$repos/404.php"); $ctype = ""; } /* Read associated XML file */ $xmlfile = substr($filename, 0, strrpos($filename, ".")).".xml"; if (!file_exists($xmlfile)) { $xmlfile = realpath(dirname($filename) . "/index.xml"); if (!file_exists($xmlfile)) { $xmlfile = realpath(dirname($filename) . ".xml"); if (!file_exists($xmlfile)) { ## BUG $page['status'][] = "La page '".$page['file']."' n'est pas complète."; $filename = realpath("$repos/404.php"); $ctype = ""; } } } $page = array_merge($page, importxml(@file_get_contents($xmlfile), 'page')); /* Check access */ if (((isset($page["group"])) && (!checkassociation($db, $page["uid"], checkgroup($db, $page["group"])))) || ((isset($page["logged"])) && ($page["logged"] == "logged") && ((!isset($page["uid"])) || ($page["uid"] < 0)))) { $page['status'][] = "La page '".$page['file']."' n'est pas accessible."; $filename = realpath("$repos/401.php"); $xmlfile = file_exists(realpath("$repos/401.xml")) ? realpath("$repos/401.xml") : realpath("$repos/index.xml"); $page = array_merge($page, importxml(@file_get_contents($xmlfile), 'page')); $ctype = ""; } /* Most file types have to be directly downloaded */ if ($ctype) { #header("Pragma: public"); #header("Expires: 0"); #header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); #header("Cache-Control: private",false); header("Content-Type: ".$ctype); #header("Content-Disposition: attachment; filename=\"".basename($filename)."\";"); #header("Content-Transfer-Encoding: binary"); header("Content-Length: ".@filesize($filename)); #set_time_limit(0); $fp = fopen($filename, 'rb'); fpassthru($fp); fclose($fp); exit; } /* Read menu */ $menufile = dirname($filename) . "/menu.xml"; if (!file_exists($menufile)) $menufile = $repos . "/menu.xml"; $menu = importxml(@file_get_contents($menufile), 'menu'); ob_start(); /* Action Edit */ include('actions/edit.php'); /* Page interpretation */ @include($filename); $page['content'] = ob_get_contents(); ob_end_clean(); /* Set MIME type */ /* header("Vary: Accept"); if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) header("Content-Type: application/xhtml+xml; charset=utf-8"); else header("Content-Type: text/html; charset=utf-8"); */ /* loggin */ if (isset($page['status'])) foreach ($page['status'] as $status) logger($logfile, getuserlogin($db, $page["uid"]), $status); /* Display template */ include('tools/template.php');