Пример #1
0
 public static function getRequestParams()
 {
     if (!is_null(self::$requestParams)) {
         return self::$requestParams;
     }
     $scriptParts = explode('/', $_SERVER['SCRIPT_NAME']);
     $pathParts = array();
     if (isset($_SERVER['PHP_SELF'])) {
         $pathParts = explode('/', $_SERVER['PHP_SELF']);
     }
     $pathParts = array_diff($pathParts, $scriptParts);
     $params = array();
     reset($pathParts);
     while (current($pathParts)) {
         $key = each($pathParts);
         $value = each($pathParts);
         if (!array_key_exists($key['value'], $params)) {
             $params[$key['value']] = $value['value'];
         }
     }
     $post = null;
     if (isset($_SERVER['CONTENT_TYPE'])) {
         if (strtolower($_SERVER['CONTENT_TYPE']) == 'application/json') {
             $requestBody = file_get_contents("php://input");
             if (preg_match('/^\\{.*\\}$/', $requestBody)) {
                 $post = json_decode($requestBody, true);
                 if ($post) {
                     self::$jsonData = $requestBody;
                 }
             }
         } elseif (strpos(strtolower($_SERVER['CONTENT_TYPE']), 'multipart/form-data') === 0 && isset($_POST['json'])) {
             $post = json_decode($_POST['json'], true);
             if ($post) {
                 self::$jsonData = $_POST['json'];
             }
         }
     }
     if (!$post) {
         $post = $_POST;
     }
     self::$requestParams = array_replace_recursive($post, $_FILES, $_GET, $params);
     $v3cacheTruncateParams = kConf::get('v3cache_truncate_time_params', 'local', array());
     $v3cacheTruncateValue = kConf::get('v3cache_truncate_time_value', 'local', 60);
     foreach ($v3cacheTruncateParams as $paramName) {
         if (isset(self::$requestParams[$paramName])) {
             $value = self::$requestParams[$paramName];
             if ($value > $v3cacheTruncateValue) {
                 // don't zero small values which may mean relative time
                 self::$requestParams[$paramName] = $value - $value % $v3cacheTruncateValue;
             }
         }
     }
     return self::$requestParams;
 }
Пример #2
0
 public static function getRequestParams()
 {
     if (!is_null(self::$requestParams)) {
         return self::$requestParams;
     }
     $scriptParts = explode('/', $_SERVER['SCRIPT_NAME']);
     $pathParts = array();
     if (isset($_SERVER['PHP_SELF'])) {
         $pathParts = explode('/', $_SERVER['PHP_SELF']);
     }
     $pathParts = array_diff($pathParts, $scriptParts);
     $params = array();
     reset($pathParts);
     while (current($pathParts)) {
         $key = each($pathParts);
         $value = each($pathParts);
         $params[$key['value']] = $value['value'];
     }
     self::$requestParams = array_merge($params, $_GET, $_POST, $_FILES);
     return self::$requestParams;
 }
Пример #3
0
 public static function getRequestParams()
 {
     if (!is_null(self::$requestParams)) {
         return self::$requestParams;
     }
     $scriptParts = explode('/', $_SERVER['SCRIPT_NAME']);
     $pathParts = array();
     if (isset($_SERVER['PHP_SELF'])) {
         $pathParts = explode('/', $_SERVER['PHP_SELF']);
     }
     $pathParts = array_diff($pathParts, $scriptParts);
     $params = array();
     reset($pathParts);
     while (current($pathParts)) {
         $key = each($pathParts);
         $value = each($pathParts);
         if (!array_key_exists($key['value'], $params)) {
             $params[$key['value']] = $value['value'];
         }
     }
     $post = null;
     if (isset($_SERVER['CONTENT_TYPE'])) {
         if (strtolower($_SERVER['CONTENT_TYPE']) == 'application/json') {
             $requestBody = file_get_contents("php://input");
             if (preg_match('/^\\{.*\\}$/', $requestBody)) {
                 $post = json_decode($requestBody, true);
             }
         } elseif (strpos(strtolower($_SERVER['CONTENT_TYPE']), 'multipart/form-data') === 0 && isset($_POST['json'])) {
             $post = json_decode($_POST['json'], true);
         }
     }
     if (!$post) {
         $post = $_POST;
     }
     self::$requestParams = array_replace_recursive($post, $_FILES, $_GET, $params);
     return self::$requestParams;
 }