24 foreach ( $values as $key => $value ) {
25 $accessor=
"set" . ucfirst($key);
26 if (method_exists($object, $accessor)) {
27 $object->$accessor($value);
28 $object->_rest[$key]=$value;
39 self::setValuesToObject($object,$_GET);
48 self::setValuesToObject($object,$_POST);
56 public static function getPost($function=
"htmlentities") {
57 return array_map($function, $_POST);
65 \parse_str(\file_get_contents(
'php://input'), $put);
74 $method=\strtolower($_SERVER[
'REQUEST_METHOD']);
81 return self::getInput();
90 $headers=getallheaders();
91 if (isset($headers[
"content-type"])) {
92 return $headers[
"content-type"];
102 return (isset($_SERVER[
'HTTP_X_REQUESTED_WITH']) && !empty($_SERVER[
'HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER[
'HTTP_X_REQUESTED_WITH']) ==
'xmlhttprequest');
110 return $_SERVER[
'REQUEST_METHOD'] ===
'POST';
118 return stripos($_SERVER[
'HTTP_REFERER'], $_SERVER[
'SERVER_NAME']) === FALSE;
126 $contentType=self::getContentType();
127 return \stripos($contentType,
"json") !==
false;
136 public static function get($key, $default=NULL) {
137 return isset($_GET[$key]) ? $_GET[$key] : $default;
146 public static function post($key, $default=NULL) {
147 return isset($_POST[$key]) ? $_POST[$key] : $default;
152 $siteUrl=\rtrim($config[
"siteUrl"],
'/');
156 return $siteUrl . $url;
160 return \explode(
"/", $_GET[
"c"]);
168 return \strtolower($_SERVER[
'REQUEST_METHOD']);
172 $url=\str_replace(
"\\",
"/", $url);
173 return \str_replace(
"//",
"/", $url);
static isPost()
Returns true if the request is sent by the POST method.
static getMethod()
Returns the http method.
static setGetValuesToObject($object)
Affects member to member the values of $_GET to the members of the object $object $object must have a...
static getDatas()
Returns the query data, regardless of the method.
static getContentType()
Returns the request content-type header.
static setValuesToObject($object, $values=null)
Affects member to member the values of the associative array $values to the members of the object $ob...
static getPost($function="htmlentities")
Call a cleaning function on the post.
static post($key, $default=NULL)
Returns the value of the $key variable passed by the post method or $default if the $key variable doe...
static isAjax()
Returns true if the request is an Ajax request.
static setPostValuesToObject($object)
Affects member to member the values of $_POST to the members of the object $object $object must have ...
static isJSON()
Returns true if request contentType is set to json.
static getInput()
Returns the query data, for PUT, DELETE PATCH methods.
static isCrossSite()
Returns true if the request is cross site.
static startswith($hay, $needle)