update
This commit is contained in:
+26
-24
@@ -30,23 +30,8 @@ class Request
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function __construct()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
{
|
|
||||||
$request_uri = @parse_url($_SERVER['REQUEST_URI'] ?? '');
|
|
||||||
$add_get = [];
|
|
||||||
|
|
||||||
if (isset($request_uri['query'])) {
|
|
||||||
parse_str($request_uri['query'], $add_get);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_GET = array_merge($_GET, $add_get);
|
|
||||||
$_REQUEST = array_merge($_REQUEST, $add_get);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//$this->init_payload();
|
|
||||||
//$this->init_file();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// common
|
// common
|
||||||
@@ -56,14 +41,14 @@ class Request
|
|||||||
*/
|
*/
|
||||||
public function is_cli()
|
public function is_cli()
|
||||||
{
|
{
|
||||||
return \php_sapi_name() === 'cli';
|
return php_sapi_name() === 'cli';
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function is_cli_server()
|
public function is_cli_server()
|
||||||
{
|
{
|
||||||
return \php_sapi_name() === 'cli-server';
|
return php_sapi_name() === 'cli-server';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,14 +195,18 @@ class Request
|
|||||||
return isset($_SERVER['HTTP_' . strtoupper($key)]);
|
return isset($_SERVER['HTTP_' . strtoupper($key)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET
|
// QUERY
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($key = '', $default = null)
|
public function query_all() {
|
||||||
|
return $_GET;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function query($key = '', $default = null)
|
||||||
{
|
{
|
||||||
if ($key === '') {
|
if ($key === '') {
|
||||||
return $_GET;
|
return $_GET;
|
||||||
@@ -229,7 +218,7 @@ class Request
|
|||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function has_get($key)
|
public function has_query($key)
|
||||||
{
|
{
|
||||||
return isset($_GET[$key]);
|
return isset($_GET[$key]);
|
||||||
}
|
}
|
||||||
@@ -238,13 +227,17 @@ class Request
|
|||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set_get($key, $value)
|
public function set_query($key, $value)
|
||||||
{
|
{
|
||||||
$_GET[$key] = $value;
|
$_GET[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
|
|
||||||
|
public function post_all() {
|
||||||
|
return $_POST;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
@@ -278,6 +271,11 @@ class Request
|
|||||||
|
|
||||||
// COOKIE
|
// COOKIE
|
||||||
|
|
||||||
|
public function cookie_all()
|
||||||
|
{
|
||||||
|
return $_COOKIE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
@@ -311,6 +309,11 @@ class Request
|
|||||||
|
|
||||||
// SESSION
|
// SESSION
|
||||||
|
|
||||||
|
public function session_all()
|
||||||
|
{
|
||||||
|
return $_SESSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $prefix
|
* @param string $prefix
|
||||||
* @param int $ttl
|
* @param int $ttl
|
||||||
@@ -318,8 +321,6 @@ class Request
|
|||||||
*/
|
*/
|
||||||
public function session_start($prefix = 'sess_', $ttl = 86400)
|
public function session_start($prefix = 'sess_', $ttl = 86400)
|
||||||
{
|
{
|
||||||
//session_set_save_handler(new \Nightmare\Session\Storage\Apcu($prefix, $ttl));
|
|
||||||
|
|
||||||
if (PHP_SESSION_ACTIVE === session_status()) {
|
if (PHP_SESSION_ACTIVE === session_status()) {
|
||||||
throw new RuntimeException('Failed to start the session: already started by PHP.');
|
throw new RuntimeException('Failed to start the session: already started by PHP.');
|
||||||
}
|
}
|
||||||
@@ -328,6 +329,7 @@ class Request
|
|||||||
throw new RuntimeException('Failed to start the session.');
|
throw new RuntimeException('Failed to start the session.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
|
|||||||
Reference in New Issue
Block a user