Source for file HttpRequest.php
Documentation is available at HttpRequest.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see http://nettephp.com
- 12: *
- 18: */
- 28: /**
- 29: * HttpRequest provides access scheme for request sent via HTTP.
- 30: *
- 34: *
- 48: */
- 50: {
- 83: /********************* URI ****************d*g**/
- 87: /**
- 88: * Returns URL object.
- 90: */
- 92: {
- 95: }
- 97: }
- 101: /**
- 102: * Sets URL object.
- 105: */
- 107: {
- 112: }
- 116: /**
- 117: * Returns URL object.
- 119: */
- 121: {
- 124: }
- 126: }
- 130: /**
- 131: * Sets request URI filter.
- 136: */
- 138: {
- 146: }
- 148: }
- 152: /**
- 153: * Returns request URI filter.
- 155: */
- 157: {
- 159: }
- 163: /**
- 164: * Detects uri, base path and script path of the request.
- 166: */
- 168: {
- 174: // host & port
- 183: }
- 192: }
- 194: // path & query
- 202: }
- 205: }
- 213: $requestUri = preg_replace(array_keys($this->uriFilter[0]), array_values($this->uriFilter[0]), $requestUri);
- 215: $uri->path = preg_replace(array_keys($this->uriFilter[PHP_URL_PATH]), array_values($this->uriFilter[PHP_URL_PATH]), $tmp[0]);
- 219: // normalized uri
- 222: // detect base URI-path - inspired by Zend Framework (c) Zend Technologies USA Inc. (http://www.zend.com), new BSD license
- 235: // Backtrack up the script_filename to find the portion matching php_self
- 247: }
- 249: // Does the scriptPath have anything in common with the request_uri?
- 251: // whole $scriptPath in URL
- 255: // directory portion of $scriptPath in URL
- 259: // no match whatsoever; set it blank
- 264: // If using mod_rewrite or ISAPI_Rewrite strip the script filename
- 265: // out of scriptPath. $pos !== 0 makes sure it is not matching a value
- 266: // from PATH_INFO or QUERY_STRING
- 271: }
- 274: }
- 278: /********************* query, post, files & cookies ****************d*g**/
- 282: /**
- 283: * Returns variable provided to the script via URL query ($_GET).
- 284: * If no key is passed, returns the entire array.
- 288: */
- 290: {
- 293: }
- 303: }
- 304: }
- 308: /**
- 309: * Returns variable provided to the script via POST method ($_POST).
- 310: * If no key is passed, returns the entire array.
- 314: */
- 316: {
- 319: }
- 329: }
- 330: }
- 334: /**
- 335: * Returns HTTP POST data in raw format (only for "application/x-www-form-urlencoded").
- 337: */
- 339: {
- 341: }
- 345: /**
- 346: * Returns uploaded file.
- 349: */
- 351: {
- 354: }
- 362: }
- 363: }
- 365: }
- 369: /**
- 370: * Returns uploaded files.
- 372: */
- 374: {
- 377: }
- 380: }
- 384: /**
- 385: * Returns variable provided to the script via HTTP cookies.
- 389: */
- 391: {
- 394: }
- 404: }
- 405: }
- 409: /**
- 410: * Returns variables provided to the script via HTTP cookies.
- 412: */
- 414: {
- 417: }
- 420: }
- 424: /**
- 425: * Recursively converts and checks encoding.
- 429: */
- 431: {
- 435: }
- 436: }
- 440: /**
- 441: * Initializes $this->query, $this->files, $this->cookies and $this->files arrays
- 443: */
- 445: {
- 450: $this->query = $filter ? filter_input_array(INPUT_GET, FILTER_UNSAFE_RAW) : (empty($_GET) ? array() : $_GET);
- 451: }
- 452: $this->post = $filter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST);
- 453: $this->cookies = $filter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE);
- 461: // remove fucking quotes and check (and optionally convert) encoding
- 471: }
- 474: // invalid key -> ignore
- 483: }
- 491: }
- 493: }
- 495: }
- 497: }
- 498: }
- 499: }
- 501: }
- 504: // structure $files and create HttpUploadedFile objects
- 512: }
- 513: }
- 522: }
- 525: }
- 528: }
- 540: }
- 541: }
- 544: }
- 548: /********************* method & headers ****************d*g**/
- 552: /**
- 553: * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
- 555: */
- 557: {
- 559: }
- 563: /**
- 564: * Checks if the request method is the given one.
- 567: */
- 569: {
- 570: return isset($_SERVER['REQUEST_METHOD']) ? strcasecmp($_SERVER['REQUEST_METHOD'], $method) === 0 : FALSE;
- 571: }
- 575: /**
- 576: * Checks if the request method is POST.
- 578: */
- 580: {
- 582: }
- 586: /**
- 587: * Return the value of the HTTP header. Pass the header name as the
- 588: * plain, HTTP-specified header name (e.g. 'Accept-Encoding').
- 592: */
- 594: {
- 601: }
- 602: }
- 606: /**
- 607: * Returns all HTTP headers.
- 609: */
- 611: {
- 613: // lazy initialization
- 621: }
- 622: }
- 623: }
- 624: }
- 626: }
- 630: /**
- 631: * Returns referrer.
- 633: */
- 635: {
- 638: }
- 642: /**
- 643: * Is the request is sent via secure channel (https).
- 645: */
- 647: {
- 649: }
- 653: /**
- 654: * Is AJAX request?
- 656: */
- 658: {
- 660: }
- 664: /**
- 665: * Returns the IP address of the remote client.
- 667: */
- 669: {
- 671: }
- 675: /**
- 676: * Returns the host of the remote client.
- 678: */
- 680: {
- 684: }
- 686: }
- 689: }
- 693: /**
- 694: * Parse Accept-Language header and returns prefered language.
- 697: */
- 699: {
- 706: preg_match_all('#(' . implode('|', $langs) . ')(?:-[^\s,;=]+)?\s*(?:;\s*q=([0-9.]+))?#', $s, $matches);
- 710: }
- 718: }
- 719: }
- 722: }
- 724: }