mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
More detailed Request info in Exceptions.
This commit is contained in:
parent
7cca7b0810
commit
93d2ffe5c9
@ -187,6 +187,43 @@
|
||||
|
||||
<!-- Request -->
|
||||
<div class="content" id="request">
|
||||
<?php global $request; ?>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 10em">Path</td>
|
||||
<td><?= $request->uri ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HTTP Method</td>
|
||||
<td><?= $request->getMethod(true) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IP Address</td>
|
||||
<td><?= $request->getIPAddress() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 10em">Is AJAX Request?</td>
|
||||
<td><?= $request->isAJAX() ? 'yes' : 'no' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Is CLI Request?</td>
|
||||
<td><?= $request->isCLI() ? 'yes' : 'no' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Is Secure Request?</td>
|
||||
<td><?= $request->isSecure() ? 'yes' : 'no' ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>User Agent</td>
|
||||
<td><?= $request->getUserAgent() ?></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<?php $empty = true; ?>
|
||||
<?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?>
|
||||
<?php if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) continue; ?>
|
||||
@ -227,6 +264,31 @@
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $headers = $request->getHeaders(); ?>
|
||||
<?php if (! empty($headers)) : ?>
|
||||
<?php natsort($headers) ?>
|
||||
|
||||
<h3>Headers</h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Header</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($headers as $name => $value) : ?>
|
||||
<tr>
|
||||
<td><?= esc($name, 'html') ?></td>
|
||||
<td><?= esc($request->getHeaderLine($name), 'html') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Response -->
|
||||
|
@ -48,7 +48,8 @@ class Exceptions
|
||||
*/
|
||||
public function exceptionHandler(\Throwable $exception)
|
||||
{
|
||||
// Get Exception Info
|
||||
// Get Exception Info - these are available
|
||||
// directly in the template that's displayed.
|
||||
$type = get_class($exception);
|
||||
$code = $exception->getCode();
|
||||
$message = $exception->getMessage();
|
||||
@ -76,7 +77,7 @@ class Exceptions
|
||||
$templates_path = '';
|
||||
if (empty($templates_path))
|
||||
{
|
||||
$templates_path = APPPATH.'views'.DIRECTORY_SEPARATOR.'errors'.DIRECTORY_SEPARATOR;
|
||||
$templates_path = APPPATH.'views/errors/';
|
||||
}
|
||||
|
||||
// Make a nicer title based on the type of Exception.
|
||||
@ -84,7 +85,7 @@ class Exceptions
|
||||
|
||||
if (is_cli())
|
||||
{
|
||||
$templates_path .= 'cli'.DIRECTORY_SEPARATOR;
|
||||
$templates_path .= 'cli/';
|
||||
|
||||
// CLI will never accessed by general public
|
||||
// while in production.
|
||||
@ -93,7 +94,7 @@ class Exceptions
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 401 Unauthorized', true, 500);
|
||||
$templates_path .= 'html'.DIRECTORY_SEPARATOR;
|
||||
$templates_path .= 'html/';
|
||||
}
|
||||
|
||||
if (ob_get_level() > $this->ob_level + 1)
|
||||
|
@ -155,7 +155,7 @@ class IncomingRequest extends Request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($index = null, $filter = null)
|
||||
public function getGet($index = null, $filter = null)
|
||||
{
|
||||
return $this->fetchGlobal(INPUT_GET, $index, $filter);
|
||||
}
|
||||
@ -170,7 +170,7 @@ class IncomingRequest extends Request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function post($index = null, $filter = null)
|
||||
public function getPost($index = null, $filter = null)
|
||||
{
|
||||
return $this->fetchGlobal(INPUT_POST, $index, $filter);
|
||||
}
|
||||
@ -185,7 +185,7 @@ class IncomingRequest extends Request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function postGet($index = null, $filter = null)
|
||||
public function getPostGet($index = null, $filter = null)
|
||||
{
|
||||
// Use $_POST directly here, since filter_has_var only
|
||||
// checks the initial POST data, not anything that might
|
||||
@ -205,7 +205,7 @@ class IncomingRequest extends Request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPost($index = null, $filter = null)
|
||||
public function getGetPost($index = null, $filter = null)
|
||||
{
|
||||
// Use $_GET directly here, since filter_has_var only
|
||||
// checks the initial GET data, not anything that might
|
||||
|
@ -56,7 +56,7 @@ class Request extends Message implements RequestInterface
|
||||
// e.g. client_ip, proxy_ip1, proxy_ip2, etc.
|
||||
sscanf($spoof, '%[^,]', $spoof);
|
||||
|
||||
if ( ! $this->validIP($spoof))
|
||||
if ( ! $this->isValidIP($spoof))
|
||||
{
|
||||
$spoof = NULL;
|
||||
}
|
||||
@ -86,7 +86,7 @@ class Request extends Message implements RequestInterface
|
||||
}
|
||||
|
||||
// We have a subnet ... now the heavy lifting begins
|
||||
isset($separator) OR $separator = $this->validIP($this->ipAddress, 'ipv6') ? ':' : '.';
|
||||
isset($separator) OR $separator = $this->isValidIP($this->ipAddress, 'ipv6') ? ':' : '.';
|
||||
|
||||
// If the proxy entry doesn't match the IP protocol - skip it
|
||||
if (strpos($proxy_ips[$i], $separator) === FALSE)
|
||||
@ -150,7 +150,7 @@ class Request extends Message implements RequestInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $this->validIP($this->ipAddress))
|
||||
if ( ! $this->isValidIP($this->ipAddress))
|
||||
{
|
||||
return $this->ipAddress = '0.0.0.0';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user