fix magic quotes.
This commit is contained in:
parent
6234905e4c
commit
8d16916630
|
@ -55,6 +55,27 @@
|
|||
|
||||
error_reporting(-1);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Magic Quotes Strip Slashes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still
|
||||
| be enabled on the server. To account for this, we will strip slashes
|
||||
| on all input arrays if magic quotes are enabled for the server.
|
||||
|
|
||||
*/
|
||||
|
||||
if (magic_quotes())
|
||||
{
|
||||
$magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
|
||||
|
||||
foreach ($magics as &$magic)
|
||||
{
|
||||
$magic = array_strip_slashes($magic);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The HttpFoundation Request
|
||||
|
@ -66,9 +87,9 @@
|
|||
|
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request as FoundationRequest;
|
||||
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
|
||||
|
||||
Request::$foundation = FoundationRequest::createFromGlobals();
|
||||
Request::$foundation = RequestFoundation::createFromGlobals();
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
class LaravelRequest extends Request {
|
||||
|
||||
/**
|
||||
* Creates a new request with values from PHP's super globals.
|
||||
*
|
||||
* @return Request A new request
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
static public function createFromGlobals()
|
||||
{
|
||||
$request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
|
||||
|
||||
if (0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
|
||||
&& in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
|
||||
) {
|
||||
parse_str($request->getContent(), $data);
|
||||
if (magic_quotes()) $data = array_strip_slashes($data);
|
||||
$request->request = new ParameterBag($data);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue