Ejemplo n.º 1
0
 /**
  * Creates a new request with values from PHP's super globals.
  *
  * @return Request A new request
  *
  * @api
  */
 public static 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;
 }
Ejemplo n.º 2
0
 function array_strip_slashes($array)
 {
     $result = array();
     foreach ($array as $key => $value) {
         $key = stripslashes($key);
         if (is_array($value)) {
             $result[$key] = array_strip_slashes($value);
         } else {
             $result[$key] = stripslashes($value);
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
function array_strip_slashes($array)
{
    $result = array();
    foreach ($array as $key => $value) {
        $key = stripslashes($key);
        // If the value is an array, we will just recurse back into the
        // function to keep stripping the slashes out of the array,
        // otherwise we will set the stripped value.
        if (is_array($value)) {
            $result[$key] = array_strip_slashes($value);
        } else {
            $result[$key] = stripslashes($value);
        }
    }
    return $result;
}
Ejemplo n.º 4
0
function array_strip_slashes(&$data)
{
    foreach ($data as $key => $row) {
        if (!is_scalar($row)) {
            $data[$key] = array_strip_slashes($row);
        } else {
            $data[$key] = stripslashes($row);
        }
    }
    return $data;
}
*/
$input = array();
switch (Request::method()) {
    case 'GET':
        $input = $_GET;
        break;
    case 'POST':
        $input = $_POST;
        break;
    default:
        if (Request::spoofed()) {
            $input = $_POST;
        } else {
            parse_str(file_get_contents('php://input'), $input);
            if (magic_quotes()) {
                $input = array_strip_slashes($input);
            }
        }
}
/*
|--------------------------------------------------------------------------
| Remove The Spoofer Input
|--------------------------------------------------------------------------
|
| The spoofed request method is removed from the input so it is not in
| the Input::all() or Input::get() results. Leaving it in the array
| could cause unexpected results since the developer won't be
| expecting it to be present.
|
*/
unset($input[Request::spoofer]);
Ejemplo n.º 6
0
*/
Autoloader::namespaces(array('Symfony\\Component\\Console' => path('sys') . 'vendor/Symfony/Component/Console', 'Symfony\\Component\\HttpFoundation' => path('sys') . 'vendor/Symfony/Component/HttpFoundation'));
/*
|--------------------------------------------------------------------------
| 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
|--------------------------------------------------------------------------
|
| Laravel uses the HttpFoundation Symfony component to handle the request
| and response functionality for the framework. This allows us to not
| worry about that boilerplate code and focus on what matters.
|
*/
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
Request::$foundation = RequestFoundation::createFromGlobals();
/*
Ejemplo n.º 7
0
 public static function init()
 {
     //Sanitize inputs
     //.Remove magic quotes
     if (magic_quotes()) {
         $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
         foreach ($magics as &$magic) {
             $magic = array_strip_slashes($magic);
         }
     }
     //.Unset globals
     foreach (array($_GET, $_POST) as $global) {
         if (is_array($global)) {
             foreach ($global as $k => $v) {
                 global ${$k};
                 ${$k} = NULL;
             }
         }
     }
     //.Clean post input
     array_map(function ($v) {
         return Request::clearValue($v);
     }, $_POST);
     //Remove /public/index.html from path_info..
     foreach (array("PATH_INFO", "ORIG_PATH_INFO", "PATH_TRANSLATED", "PHP_SELF") as $k) {
         if (isset($_SERVER[$k])) {
             $_SERVER[$k] = str_replace("/public/index.html", "/", $_SERVER[$k]);
         }
     }
     static::$server = $_SERVER;
     static::$get = $_GET;
     static::$post = $_POST;
     $_GET = null;
     $_POST = null;
     $_SERVER = null;
     $_REQUEST = null;
     //Detect environment
     $list = (require J_PATH . "config" . DS . "environments" . EXT);
     $env = "";
     $envWithWildcard = array_first($list);
     $hosts = array(array_get(static::$server, "HTTP_HOST", "localhost"), array_get(static::$server, "SERVER_NAME", "localhost"), array_get(static::$server, "SERVER_ADDR", "localhost"), gethostname());
     foreach ($hosts as $host) {
         foreach ($list as $k => $v) {
             foreach ((array) $v as $hostname) {
                 if ($hostname != "" && $hostname == $host) {
                     $env = $k;
                     break;
                 } else {
                     if ($hostname == "*") {
                         $envWithWildcard = $k;
                     }
                 }
             }
             if (!empty($env)) {
                 break;
             }
         }
         if (!empty($env)) {
             break;
         }
     }
     if (empty($env)) {
         $env = $envWithWildcard;
     }
     static::$env = $env;
     //Detect method
     $method = strtoupper(array_get(static::$server, "REQUEST_METHOD", "GET"));
     if ($method == "POST" && static::hasReq("_method")) {
         $methodReq = static::req("_method", "POST");
         if (array_search($methodReq, static::$availableMethods) !== false) {
             $method = $methodReq;
         }
     }
     static::$method = $method;
 }