Пример #1
0
 /**
  * Parse url given by .
  * htaccess to framework params
  * 
  * @author Krzysztof Kalkhoff
  *        
  * @param string $url            
  * @return array
  */
 public static function getParamsFromURL($url)
 {
     $return = array();
     if (!empty($url)) {
         $params = explode("/", $url);
         $params = Formatter::cleanData($params);
         if (count($params) != 0) {
             foreach ($params as $nr => $param) {
                 if (preg_match('/page-(?<number>\\d+)/', $param, $matches)) {
                     // Page
                     $return[self::PARAM_PAGE] = (int) $matches[1];
                 } elseif (preg_match('/lang-(?P<value>.+)/', $param, $matches)) {
                     // Language
                     $return[self::PARAM_LANG] = $matches['value'];
                 } elseif (!isset($return[self::PARAM_CONTROLLER])) {
                     // Module
                     $return[self::PARAM_CONTROLLER] = $param;
                 } elseif (!isset($return[self::PARAM_METHOD])) {
                     // Method
                     $return[self::PARAM_METHOD] = $param;
                 } else {
                     // Method argument
                     if (!array_key_exists(self::PARAM_METHOD_ARGUMENTS, $return)) {
                         $return[self::PARAM_METHOD_ARGUMENTS] = array();
                     }
                     $return[self::PARAM_METHOD_ARGUMENTS][] = $param;
                 }
             }
         }
     }
     return $return;
 }
Пример #2
0
 protected function getDocumentRoot()
 {
     $documentRoot = $_SERVER['DOCUMENT_ROOT'];
     if (Formatter::endsWith($documentRoot, DIRECTORY_SEPARATOR)) {
         $documentRoot = substr($documentRoot, 0, -1);
     }
     return $documentRoot;
 }
 protected function authenticate()
 {
     $hash = Formatter::cleanData($this->getRequest()->getParam(Client::AUTH_PARAM_NAME, Request::TYPE_GET));
     $data = $this->getRequest()->getParams(Request::TYPE_POST);
     return $this->doAuthenticate($hash, $data);
 }