Example #1
0
 public function initialize(IConfigParameter $configuration)
 {
     if (get_magic_quotes_gpc()) {
         HelpFunctions::strips($_GET);
         HelpFunctions::strips($_POST);
         HelpFunctions::strips($_COOKIE);
         HelpFunctions::strips($_REQUEST);
     }
     $this->_requestMethod = $_SERVER['REQUEST_METHOD'];
     if ($this->_requestMethod == 'GET') {
         $this->_request = $_GET;
     } elseif ($this->_requestMethod == 'POST') {
         $this->_request = $_POST;
     } else {
         $this->_request = array();
     }
     $this->_username = $this->getSubDomain($configuration->get('base_host'));
     $this->_rewrite = (bool) $configuration->get('rewrite');
     if ($this->_rewrite) {
         $request_key = $configuration->get('request_key');
         $this->_param_delimiter = $configuration->get('param_delimiter');
         $this->_value_delimiter = $configuration->get('value_delimiter');
         $query = $_GET[$request_key];
         $d = explode($this->_param_delimiter, $query);
         if (isset($d[0]) && strlen($d[0])) {
             $this->_current_action = trim($d[0]);
             unset($d[0]);
             // unset controller key
             foreach ($d as $item) {
                 $tmp = explode($this->_value_delimiter, $item);
                 if (isset($tmp[0])) {
                     $v0 = trim($tmp[0]);
                     $v1 = isset($tmp[1]) ? trim($tmp[1]) : null;
                     if (strlen($v0)) {
                         $this->_request_by_number[] = $v0;
                     }
                     if (strlen($v1 !== null)) {
                         if ($this->_requestMethod == 'GET' || $this->_requestMethod == 'POST' && !isset($this->_request[$v0])) {
                             $this->_request[$v0] = $v1;
                         }
                     }
                 }
             }
         }
     } else {
         die(__METHOD__ . "::" . __LINE__ . "::Non-rewrite mode need some changes after last modification this manager!!!!");
         $this->_request_controller_key = $configuration->get('request_service_key');
         // Only for non-rewrite mode
         $this->_request_action_key = $configuration->get('request_action_key');
         // Only for non-rewrite mode
         if (!$this->_request_controller_key) {
             throw new ConfigurationException('HttpRequest, non-rewrite mode: service key at request not configured');
         }
         if (isset($this->_request[$this->_request_controller_key])) {
             $this->_current_controller = $this->_request[$this->_request_controller_key];
         }
     }
     $this->_files = $_FILES;
     Project::setRequest($this);
     $this->_common_config($configuration);
 }