Esempio n. 1
0
 private function parseUrl()
 {
     $uri = !empty($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI'];
     $adjustedRoot = strpos($uri, "/latest") === 0 ? str_replace(VERSION_INTERNAL_API, "latest", ROOT_API) : ROOT_API;
     $fullRequestPath = \Bolt\Strings::replaceOverlap($adjustedRoot, $uri);
     $path = str_replace($adjustedRoot, "", $fullRequestPath);
     $bits = explode("/", $path);
     for ($loop = 0; $loop < count($bits); $loop++) {
         $bit = $bits[$loop];
         if ($bit == "") {
             unset($bits[$loop]);
         }
     }
     $path = implode("/", $bits);
     $divider = strpos($path, "?");
     if ($divider === false) {
         $info['baseUrl'] = $path;
     } else {
         list($info['baseUrl'], $info['queryString']) = explode("?", $path);
     }
     return $info['baseUrl'];
 }
Esempio n. 2
0
 public function check($info)
 {
     if ($info->controller === null) {
         return false;
     }
     foreach ($this->request as $key => $value) {
         if ($this->request[$key] !== null) {
             if ($info->{$key} === null) {
                 return false;
             }
             if (\Bolt\Strings::isRegex($this->request[$key]) === true) {
                 if (preg_replace($this->request[$key], "", $info->{$key}) !== "") {
                     return false;
                 }
             } else {
                 if ($this->request[$key] !== $info->{$key}) {
                     return false;
                 }
             }
         }
     }
     return true;
 }