Example #1
0
 public function match($uri)
 {
     global $localUri;
     global $conf;
     //URLs used by this component. Other URLs starting with admin/* won't be considered by this module
     $operations = array("menu", "endpoints", "namespaces", "components", "");
     $q = preg_replace('|^' . $conf['basedir'] . '|', '', $localUri);
     $qArr = explode('/', $q);
     if (sizeof($qArr) == 0) {
         return FALSE;
     }
     if ($qArr[0] == "admin" && array_search($qArr[1], $operations) !== FALSE) {
         if ($conf['admin']['pass'] !== FALSE && !$this->auth()) {
             HTTPStatus::send401("Forbidden\n");
             exit(0);
         }
         return $qArr;
     }
     return FALSE;
 }
Example #2
0
 public function match($uri)
 {
     global $conf;
     global $localUri;
     global $lodspk;
     $method = ucwords($_SERVER['REQUEST_METHOD']);
     $uriSegment = str_replace($conf['basedir'], '', $localUri);
     //Check if looking for session validation
     if ($uriSegment === $this->sessionUri) {
         //GET will return the form
         if ($method == "GET") {
             $this->showSessionForm();
             return true;
         }
         //POST will take the data and validate it
         if ($method == "POST") {
             if ($this->validateAuthentication($_POST)) {
                 session_start();
                 $_SESSION['lodspk'] = 1;
                 HTTPStatus::send303($conf['basedir'], '');
                 return false;
             } else {
                 HTTPStatus::send401("Authentication not valid.");
                 return true;
             }
         }
     } else {
         session_start();
         if (isset($_SESSION['lodspk'])) {
             return false;
         } else {
             HTTPStatus::send303($conf['basedir'] . $this->sessionUri, '');
             return true;
         }
     }
 }