From cd8e6f45e4ea931cc58fa459db26083c8d9c1055 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 16 Apr 2018 11:14:10 +0900 Subject: [PATCH] Update uri.php --- system/uri.php | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/system/uri.php b/system/uri.php index 871a60c..9d3b217 100644 --- a/system/uri.php +++ b/system/uri.php @@ -173,28 +173,12 @@ if(!function_exists("read_requests")) { } if(!function_exists("get_requested_value")) { - function get_requested_value($name, $scope="all", $escape_quotes=true, $escape_tags=false) { + function get_requested_value($name, $method="_ALL", $escape_quotes=true, $escape_tags=false) { + $value = ""; $requests = get_requests(); - $value = ""; - $method = ""; - - switch($scope) { - case "all": - $method = "_ALL"; - break; - case "post": - $method = "_POST"; - break; - case "get": - $method = "_GET"; - break; - default: - $method = ""; - } - // set validated value - if(!empty($method)) { + if(array_key_exists($method, $requests)) { $value = array_key_empty($name, $requests[$method]) ? $value : $requests[$method][$name]; if(is_string($value)) { @@ -214,6 +198,34 @@ if(!function_exists("get_requested_value")) { } } +if(!function_exists("get_requested_values")) { + function get_requested_values($names, $method="_ALL", $escape_quotes=true, $escape_tags=false) { + $values = array(); + + if(is_array($names)) { + foreach($names as $name) { + $values[$name] = get_requested_value($name); + } + } + + return $values; + } +} + +if(!function_exists("get_binded_requests")) { + function get_binded_requests($rules, $method="_ALL") { + $data = array(); + + foreach($rules as $k=>$v) { + if(!empty($v)) { + $data[$v] = get_requested_value($k); + } + } + + return $data; + } +} + if(!function_exists("get_array")) { function get_array($arr) { return is_array($arr) ? $arr : array();