Public access

This commit is contained in:
Abdussamed 2023-04-02 14:10:58 +03:00
parent 8e17db2908
commit 7dda364127
5 changed files with 45 additions and 45 deletions

View File

@ -16,7 +16,7 @@
public static $data = []; public static $data = [];
public static $query = []; public static $query = [];
public static $ready = false; public static $ready = false;
function __construct() public function __construct()
{ {
if(!Request::$ready) if(!Request::$ready)
{ {
@ -30,11 +30,11 @@
$this->mutateRequest(); $this->mutateRequest();
} }
} }
function getJSONRequest() public function getJSONRequest()
{ {
return json_decode(file_get_contents('php://input'), true); return json_decode(file_get_contents('php://input'), true);
} }
function mutateRequest() public function mutateRequest()
{ {
if(Request::$contentType == "application/json") if(Request::$contentType == "application/json")
{ {
@ -49,71 +49,71 @@
Request::$query = $_GET; Request::$query = $_GET;
}; };
} }
function contentType() public function contentType()
{ {
return Request::$contentType; return Request::$contentType;
} }
function method() public function method()
{ {
return Request::$method; return Request::$method;
} }
function get($name) public function get($name)
{ {
return Request::$query[$name] ?? null; return Request::$query[$name] ?? null;
} }
function has($name) public function has($name)
{ {
return $this->input($name) !== null; return $this->input($name) !== null;
} }
function post($name) public function post($name)
{ {
return Request::$data[$name] ?? null; return Request::$data[$name] ?? null;
} }
function input($name) public function input($name)
{ {
return Request::staticGet($name) ?? Request::staticPost($name) ?? null; return Request::staticGet($name) ?? Request::staticPost($name) ?? null;
} }
function staticContentType() public function staticContentType()
{ {
return $this->contentType(); return $this->contentType();
} }
function staticMethod() public function staticMethod()
{ {
return $this->method(); return $this->method();
} }
function staticGet($name) public function staticGet($name)
{ {
return $this->get($name); return $this->get($name);
} }
function staticHeaders() public function staticHeaders()
{ {
return Request::$headers; return Request::$headers;
} }
function staticFile() public function staticFile()
{ {
return Request::$file; return Request::$file;
} }
function staticSession() public function staticSession()
{ {
return Request::$session; return Request::$session;
} }
function staticCookie() public function staticCookie()
{ {
return Request::$cookie; return Request::$cookie;
} }
function staticPost($name) public function staticPost($name)
{ {
return $this->post($name); return $this->post($name);
} }
function staticInput($name) public function staticInput($name)
{ {
return $this->input($name); return $this->input($name);
} }
function staticHas($name) public function staticHas($name)
{ {
return $this->has($name); return $this->has($name);
} }
function getAttribute($name) public function getAttribute($name)
{ {
return Request::staticInput($name); return Request::staticInput($name);
} }

View File

@ -4,24 +4,24 @@
use ReflectionHook; use ReflectionHook;
static $_attributes = []; static $_attributes = [];
static $readyHeaders = false; static $readyHeaders = false;
function __construct() public function __construct()
{ {
if(!RequestCookie::$readyHeaders) if(!RequestCookie::$readyHeaders)
{ {
RequestCookie::$_attributes = (array) $_COOKIE; RequestCookie::$_attributes = (array) $_COOKIE;
}; };
} }
function setAttribute($name, $value, $time = '+1 years') public function setAttribute($name, $value, $time = '+1 years')
{ {
$formarly = strtolower($name); $formarly = strtolower($name);
setcookie($name, $value, strtotime( $time )); setcookie($name, $value, strtotime( $time ));
} }
function getAttribute($name) public function getAttribute($name)
{ {
$formarly = strtolower($name); $formarly = strtolower($name);
return RequestCookie::$_attributes[$formarly]; return RequestCookie::$_attributes[$formarly];
} }
function removeAttribute($name) public function removeAttribute($name)
{ {
$this->setAttribute($name, 0, "-1 days"); $this->setAttribute($name, 0, "-1 days");
} }

View File

@ -5,7 +5,7 @@
use ReflectionHook; use ReflectionHook;
public static $ready = false; public static $ready = false;
public static $files = []; public static $files = [];
function __construct() public function __construct()
{ {
if(!RequestFile::$ready) if(!RequestFile::$ready)
{ {

View File

@ -4,7 +4,7 @@
use ReflectionHook; use ReflectionHook;
static $_attributes = []; static $_attributes = [];
static $readyHeaders = false; static $readyHeaders = false;
function __construct() public function __construct()
{ {
if(!RequestHeader::$readyHeaders) if(!RequestHeader::$readyHeaders)
{ {
@ -26,12 +26,12 @@
$requestHeader = new static; $requestHeader = new static;
$requestHeader->{$name} = $value; $requestHeader->{$name} = $value;
} }
function setAttribute($name, $value) public function setAttribute($name, $value)
{ {
$formarly = ucfirst(strtolower($name)); $formarly = ucfirst(strtolower($name));
header("$formarly: $value"); header("$formarly: $value");
} }
function getAttribute($name) public function getAttribute($name)
{ {
$formarly = ucfirst(strtolower($name)); $formarly = ucfirst(strtolower($name));
return RequestHeader::$_attributes[$formarly] ?? null; return RequestHeader::$_attributes[$formarly] ?? null;

View File

@ -7,45 +7,45 @@
static $lifetime = '+7 days'; static $lifetime = '+7 days';
static $cookiename = 'session'; static $cookiename = 'session';
static $ready = false; static $ready = false;
function __contruct() public function __contruct()
{ {
session_set_cookie_params(strtotime(static::$lifetime)); session_set_cookie_params(strtotime(static::$lifetime));
session_name(static::$cookiename); session_name(static::$cookiename);
Session::$ready = true; Session::$ready = true;
} }
function staticStart() public function staticStart()
{ {
session_start(); session_start();
} }
function staticFlush() public function staticFlush()
{ {
session_commit(); session_commit();
} }
function staticDestroy() public function staticDestroy()
{ {
session_destroy(); session_destroy();
} }
function staticReset() public function staticReset()
{ {
session_reset(); session_reset();
} }
function staticSet($name, $value) public function staticSet($name, $value)
{ {
$_SESSION[$name] = $value; $_SESSION[$name] = $value;
} }
function staticGet($name) public function staticGet($name)
{ {
return $_SESSION[$name]; return $_SESSION[$name];
} }
function staticDelete($name) public function staticDelete($name)
{ {
unset($_SESSION[$name]); unset($_SESSION[$name]);
} }
function staticHas($name) public function staticHas($name)
{ {
return isset($_SESSION[$name]); return isset($_SESSION[$name]);
} }
function staticAdd($name, $item) public function staticAdd($name, $item)
{ {
if(!Session::has($name)) if(!Session::has($name))
{ {
@ -53,7 +53,7 @@
} }
$_SESSION[$name][] = $item; $_SESSION[$name][] = $item;
} }
function staticPop($name, $item) public function staticPop($name, $item)
{ {
if(!$this->has($name)) if(!$this->has($name))
{ {
@ -61,7 +61,7 @@
} }
return array_pop($_SESSION[$name]); return array_pop($_SESSION[$name]);
} }
function staticShift($name, $item) public function staticShift($name, $item)
{ {
if(!!$this->has($name)) if(!!$this->has($name))
{ {
@ -69,7 +69,7 @@
} }
return array_shift($_SESSION[$name]); return array_shift($_SESSION[$name]);
} }
function staticUnshift($name, $item) public function staticUnshift($name, $item)
{ {
if(!!$this->has($name)) if(!!$this->has($name))
{ {
@ -80,7 +80,7 @@
...$_SESSION[$name] ...$_SESSION[$name]
]; ];
} }
function staticMerge($name, $item) public function staticMerge($name, $item)
{ {
if(!!$this->has($name)) if(!!$this->has($name))
{ {
@ -91,11 +91,11 @@
...$item ...$item
]; ];
} }
function staticPath($path) public function staticPath($path)
{ {
session_save_path($path); session_save_path($path);
} }
function staticStatus() public function staticStatus()
{ {
switch(session_status()) switch(session_status())
{ {
@ -107,7 +107,7 @@
} }
} }
} }
function staticInit() public function staticInit()
{ {
if(!Session::$ready) if(!Session::$ready)
{ {