/**
  * extract,clean and dequote any given get/post-parameters
  * find out which controller and view we should use
  * @param string $url raw url (see dispatch())
  */
 private function constructParams($url)
 {
     $paramList = explode('/', $url);
     while (count($paramList) > 0 && '' == $paramList[count($paramList) - 1]) {
         array_pop($paramList);
     }
     $ajax = 0;
     if (isset($paramList[0]) && $paramList[0] == 'ajax') {
         array_shift($paramList);
         $ajax = 1;
     }
     $controller = "main";
     if (isset($paramList[0]) && !empty($paramList[0])) {
         $controller = strtolower(array_shift($paramList));
     }
     $action = '';
     if (isset($paramList[0]) && !empty($paramList[0])) {
         $action = strtolower(array_shift($paramList));
     } else {
         if (isset($paramList[0])) {
             unset($paramList[0]);
         }
     }
     $this->params['pass'] = $paramList;
     $kataUrl = is($_GET['kata'], '');
     unset($_GET['kata']);
     if (!empty($_GET)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $this->params['url'] = kataFunc::stripslashes_deep($_GET);
         } else {
             $this->params['url'] = $_GET;
         }
     }
     if (!empty($_POST)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $this->params['form'] = kataFunc::stripslashes_deep($_POST);
         } else {
             $this->params['form'] = $_POST;
         }
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $ajax = 1;
     }
     $this->params['controller'] = $controller;
     $this->params['action'] = $action;
     $this->params['https'] = env('HTTPS') != '' ? 1 : 0;
     $this->params['ajax'] = $ajax;
     if (php_sapi_name() == 'cli') {
         $this->params['type'] = 'cli';
     } else {
         $this->params['type'] = env('REQUEST_METHOD');
     }
     $this->params['raw'] = $kataUrl;
 }
 /**
  * extract,clean and dequote any given get/post-parameters
  * find out which controller and view we should use
  * @param string $url raw url (see dispatch())
  */
 private function constructParams($url, $routes = null)
 {
     //do we have routes?
     if (!empty($routes) && is_array($routes)) {
         krsort($routes);
         if (!empty($routes[$url])) {
             $url = $routes[$url];
         } else {
             foreach ($routes as $old => $new) {
                 //					if (($old != '') && ($old.'/' == substr($url, 0, strlen($old.'/')))) {
                 if ($old != '' && $old == substr($url, 0, strlen($old))) {
                     $url = $new . substr($url, strlen($old));
                     break;
                 }
             }
             //foreach
         }
         //!empty
         // does route-target have a query-string? parse it
         $x = strpos($url, '?');
         if (false !== $x) {
             $result = array();
             parse_str(substr($url, $x + 1), $result);
             $_GET = array_merge($_GET, $result);
             $url = substr($url, 0, $x - 1);
         }
     }
     $paramList = explode('/', $url);
     while (count($paramList) > 0 && '' == $paramList[count($paramList) - 1]) {
         array_pop($paramList);
     }
     if (isset($paramList[0]) && $paramList[0] == 'ajax') {
         array_shift($paramList);
         $this->params['isAjax'] = 1;
     } else {
         $this->params['isAjax'] = 0;
     }
     $controller = "main";
     if (isset($paramList[0]) && !empty($paramList[0])) {
         $controller = strtolower(array_shift($paramList));
     }
     $action = '';
     if (isset($paramList[0]) && !empty($paramList[0])) {
         $action = strtolower(array_shift($paramList));
     } else {
         if (isset($paramList[0])) {
             unset($paramList[0]);
         }
     }
     $this->params['pass'] = $paramList;
     $kataUrl = is($_GET['kata'], '');
     unset($_GET['kata']);
     if (!empty($_GET)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $this->params['url'] = kataFunc::stripslashes_deep($_GET);
         } else {
             $this->params['url'] = $_GET;
         }
     }
     $this->params['callUrl'] = $kataUrl;
     if (!empty($_POST)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $this->params['form'] = kataFunc::stripslashes_deep($_POST);
         } else {
             $this->params['form'] = $_POST;
         }
     }
     $this->params['controller'] = $controller;
     $this->params['action'] = $action;
 }