2017-12-22 18:39:21 +00:00
|
|
|
<?php
|
|
|
|
if(!function_exists("base_url")) {
|
|
|
|
function base_url() {
|
2018-03-14 04:35:11 +00:00
|
|
|
return get_config_value("base_url");
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 18:39:21 +00:00
|
|
|
|
2018-03-14 04:35:11 +00:00
|
|
|
if(!function_exists("base_api_url")) {
|
|
|
|
function base_api_url() {
|
|
|
|
return get_config_value("base_api_url");
|
2017-12-22 18:39:21 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-22 18:41:14 +00:00
|
|
|
|
|
|
|
if(!function_exists("get_uri")) {
|
|
|
|
function get_uri() {
|
2018-03-15 02:53:34 +00:00
|
|
|
$requests = get_requests();
|
|
|
|
|
2017-12-22 18:41:14 +00:00
|
|
|
$request_uri = '';
|
2017-12-31 16:16:24 +00:00
|
|
|
if(!array_key_empty("REQUEST_URI", $_SERVER)) {
|
|
|
|
$request_uri = $requests["_URI"];
|
2017-12-22 18:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $request_uri;
|
|
|
|
}
|
|
|
|
}
|
2017-12-31 17:24:39 +00:00
|
|
|
|
2018-03-15 02:53:34 +00:00
|
|
|
if(!function_exists("read_requests")) {
|
|
|
|
function read_requests() {
|
2017-12-31 17:24:39 +00:00
|
|
|
$requests = array(
|
|
|
|
"_ALL" => $_REQUEST,
|
|
|
|
"_POST" => $_POST,
|
|
|
|
"_GET" => $_GET,
|
|
|
|
"_URI" => !array_key_empty("REQUEST_URI", $_SERVER) ? $_SERVER["REQUEST_URI"] : ''
|
|
|
|
);
|
|
|
|
|
2018-02-21 04:46:50 +00:00
|
|
|
// with security module
|
|
|
|
if(function_exists("get_clean_xss")) {
|
|
|
|
foreach($requests['_GET'] as $k=>$v) {
|
|
|
|
if(is_string($v)) {
|
|
|
|
$requests['_GET'][$k] = get_clean_xss($v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 17:24:39 +00:00
|
|
|
return $requests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-15 02:53:34 +00:00
|
|
|
if(!function_exists("get_requests")) {
|
2018-03-15 03:47:15 +00:00
|
|
|
function get_requests() {
|
|
|
|
global $requests;
|
|
|
|
$requests = is_array($requests) ? $requests : read_requests();
|
|
|
|
return $requests;
|
|
|
|
}
|
2018-03-15 02:53:34 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 10:57:23 +00:00
|
|
|
if(!function_exists("redirect_uri")) {
|
|
|
|
function redirect_uri($uri, $permanent=false) {
|
|
|
|
header('Location: ' . $uri, true, $permanent ? 301 : 302);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-15 02:53:34 +00:00
|
|
|
if(!function_exists("get_requested_value")) {
|
2018-03-15 03:34:26 +00:00
|
|
|
function get_requested_value($name, $scope="all", $escape_quotes=true, $escape_tags=false) {
|
2018-03-15 02:53:34 +00:00
|
|
|
$requests = get_requests();
|
2018-03-15 03:47:15 +00:00
|
|
|
|
2018-03-15 02:53:34 +00:00
|
|
|
$value = "";
|
|
|
|
$method = "";
|
|
|
|
|
|
|
|
switch($scope) {
|
|
|
|
case "all":
|
2018-03-15 02:54:08 +00:00
|
|
|
$method = "_ALL";
|
2018-03-15 02:53:34 +00:00
|
|
|
break;
|
|
|
|
case "post":
|
|
|
|
$method = "_POST";
|
|
|
|
break;
|
|
|
|
case "get":
|
|
|
|
$method = "_GET";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$method = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// set validated value
|
2018-03-15 03:37:16 +00:00
|
|
|
if(!empty($method)) {
|
|
|
|
$value = array_key_empty($name, $requests[$method]) ? $value : $requests[$method][$name];
|
|
|
|
|
2018-03-15 03:54:19 +00:00
|
|
|
if(is_string($value)) {
|
|
|
|
// security: set escape quotes
|
|
|
|
if($escape_quotes == true) {
|
|
|
|
$value = addslashes($value);
|
|
|
|
}
|
2018-03-15 03:34:26 +00:00
|
|
|
|
2018-03-15 03:54:19 +00:00
|
|
|
// security: set escape tags
|
|
|
|
if($escape_tags == true) {
|
|
|
|
$value = htmlspecialchars($value);
|
|
|
|
}
|
2018-03-15 03:37:16 +00:00
|
|
|
}
|
2018-03-15 03:34:26 +00:00
|
|
|
}
|
2018-03-15 02:53:34 +00:00
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-22 04:05:09 +00:00
|
|
|
if(!function_exists("get_array")) {
|
|
|
|
function get_array($arr) {
|
|
|
|
return is_array($arr) ? $arr : array();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-15 02:53:34 +00:00
|
|
|
$requests = read_requests();
|