/** * @param $command * @return bool */ public function checkCliCommand($command) { $isMatch = false; foreach ($this->cliRoutes as $rule => $settings) { $matches = array(); if (preg_match($rule, $command, $matches)) { Get::setParams('module', $settings['module']); Get::setParams('controller', $settings['controller']); Get::setParams('action', $settings['action']); $route['matches'] = array(); foreach ($settings['matches'] as $key => $varName) { if (empty($varName)) { continue; } if (isset($matches[$key])) { $_GET[$varName] = $matches[$key]; } } $isMatch = true; return true; } } if (!$isMatch) { $this->checkCliCommand('/404'); } }
/** * @return string */ public function getUri() { $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $uri = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $uriRequest = strpos($uri, Safan::handler()->baseUrl); if ($uriRequest !== false) { $uri = substr($uri, strlen(Safan::handler()->baseUrl) - $uriRequest); } //Get Variables if (strpos($uri, '?') !== false) { $uriVars = parse_str(substr(strstr($uri, '?'), 1), $outPutVars); //Generate Get variables foreach ($outPutVars as $key => $value) { if ($key != 'module' && $key != 'controller' && $key != 'action') { Get::setParams($key, $value); } } //Generate main uri $uri = strstr($uri, '?', true); } return $uri; }