Ejemplo n.º 1
0
 function parseParamsAjax($params = array())
 {
     if (is_array($params) && !empty($params)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             if (function_exists('s2_stripslashes_deep')) {
                 $params['form'] = s2_stripslashes_deep($params);
             } else {
                 $params['form'] = stripslashes_deep($params);
             }
         } else {
             $form = $params;
             $params = array_merge($params, array('form' => $form));
         }
         // array check to prevent weird error with form being a mosParameters object in J1.0.x
         if (is_array($params['form']) && isset($params['form']['data'])) {
             $params['data'] = Sanitize::stripEscape($params['form']['data']);
             unset($params['form']['data']);
         }
     } elseif (is_string($params)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             return stripslashes($params);
         }
     }
     return $params;
 }
Ejemplo n.º 2
0
 /**
  * Returns array of GET and POST parameters. GET parameters are taken from given URL.
  *
  * @param string $fromUrl URL to mine for parameter information.
  * @return array Parameters found in POST and GET.
  * @access public
  */
 function parseParams($fromUrl = '')
 {
     $params = array();
     $params['data'] = array();
     isset($_COOKIE) and ini_get('magic_quotes_gpc') == 1 and $_COOKIE = s2_stripslashes_deep($_COOKIE);
     if (isset($_POST)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             if (function_exists('s2_stripslashes_deep')) {
                 $params['form'] = s2_stripslashes_deep($_POST);
             } else {
                 $params['form'] = stripslashes_deep($_POST);
             }
         } else {
             $params['form'] = $_POST;
         }
         if (isset($params['form']['_method'])) {
             if (isset($_SERVER) && !empty($_SERVER)) {
                 $_SERVER['REQUEST_METHOD'] = $params['form']['_method'];
             } else {
                 $_ENV['REQUEST_METHOD'] = $params['form']['_method'];
             }
             unset($params['form']['_method']);
         }
     }
     if (isset($params['form']['data'])) {
         $params['data'] = Sanitize::stripEscape($params['form']['data']);
         unset($params['form']['data']);
     }
     if (isset($_GET)) {
         if (ini_get('magic_quotes_gpc') == 1) {
             $url = s2_stripslashes_deep($_GET);
         } else {
             $url = $_GET;
         }
         if (isset($params['url'])) {
             $params['url'] = array_merge($params['url'], $url);
         } else {
             $params['url'] = $url;
         }
     }
     foreach ($_FILES as $name => $data) {
         if ($name != 'data') {
             $params['form'][$name] = $data;
         }
     }
     if (isset($_FILES['data'])) {
         foreach ($_FILES['data'] as $key => $data) {
             foreach ($data as $model => $fields) {
                 foreach ($fields as $field => $value) {
                     $params['data'][$model][$field][$key] = $value;
                 }
             }
         }
     }
     if (isset($params['data']['controller'])) {
         $params['controller'] = Sanitize::getString($params['data'], 'controller');
         $params['action'] = Sanitize::getString($params['data'], 'action');
     }
     $Router =& S2Router::getInstance();
     $Router->app = $this->app;
     $params = S2Router::parse($params);
     foreach ($params['url'] as $key => $value) {
         if ($key != 'url') {
             $params[$key] = $value;
         }
     }
     return $params;
 }