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: {
- 113: }
- 117: /**
- 118: * Returns URL object.
- 120: */
- 122: {
- 125: }
- 127: }
- 131: /**
- 132: * Sets request URI filter.
- 137: */
- 139: {
- 147: }
- 149: }
- 153: /**
- 154: * Returns request URI filter.
- 156: */
- 158: {
- 160: }
- 164: /**
- 165: * Detects uri, base path and script path of the request.
- 167: */
- 169: {
- 175: // host & port
- 184: }
- 193: }
- 195: // path & query
- 203: }
- 206: }
- 214: $requestUri = preg_replace(array_keys($this->uriFilter[0]), array_values($this->uriFilter[0]), $requestUri);
- 216: $uri->path = preg_replace(array_keys($this->uriFilter[PHP_URL_PATH]), array_values($this->uriFilter[PHP_URL_PATH]), $tmp[0]);
- 220: // normalized uri
- 223: // detect base URI-path - inspired by Zend Framework (c) Zend Technologies USA Inc. (http://www.zend.com), new BSD license
- 237: // Backtrack up the script_filename to find the portion matching php_self
- 248: }
- 250: // Does the scriptPath have anything in common with the request_uri?
- 252: // whole $scriptPath in URL
- 256: // directory portion of $scriptPath in URL
- 260: // no match whatsoever; set it blank
- 265: // If using mod_rewrite or ISAPI_Rewrite strip the script filename
- 266: // out of scriptPath. $pos !== 0 makes sure it is not matching a value
- 267: // from PATH_INFO or QUERY_STRING
- 272: }
- 275: }
- 279: /********************* query, post, files & cookies ****************d*g**/
- 283: /**
- 284: * Returns variable provided to the script via URL query ($_GET).
- 285: * If no key is passed, returns the entire array.
- 289: */
- 291: {
- 294: }
- 304: }
- 305: }
- 309: /**
- 310: * Returns variable provided to the script via POST method ($_POST).
- 311: * If no key is passed, returns the entire array.
- 315: */
- 317: {
- 320: }
- 330: }
- 331: }
- 335: /**
- 336: * Returns HTTP POST data in raw format (only for "application/x-www-form-urlencoded").
- 338: */
- 340: {
- 342: }
- 346: /**
- 347: * Returns uploaded file.
- 350: */
- 352: {
- 355: }
- 358: }
- 362: /**
- 363: * Returns uploaded files.
- 365: */
- 367: {
- 370: }
- 373: }
- 377: /**
- 378: * Returns variable provided to the script via HTTP cookies.
- 382: */
- 384: {
- 387: }
- 397: }
- 398: }
- 402: /**
- 403: * Returns variables provided to the script via HTTP cookies.
- 405: */
- 407: {
- 410: }
- 413: }
- 417: /**
- 418: * Recursively converts and checks encoding.
- 422: */
- 424: {
- 428: }
- 430: }
- 434: /**
- 435: * Initializes $this->query, $this->files, $this->cookies and $this->files arrays
- 437: */
- 439: {
- 444: $this->query = $filter ? filter_input_array(INPUT_GET, FILTER_UNSAFE_RAW) : (empty($_GET) ? array() : $_GET);
- 445: }
- 446: $this->post = $filter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST);
- 447: $this->cookies = $filter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE);
- 455: // remove fucking quotes and check (and optionally convert) encoding
- 465: }
- 468: // invalid key -> ignore
- 477: }
- 485: }
- 487: }
- 489: }
- 491: }
- 492: }
- 493: }
- 495: }
- 498: // structure $files and create HttpUploadedFile objects
- 506: }
- 507: }
- 516: }
- 519: }
- 522: }
- 534: }
- 535: }
- 538: }
- 542: /********************* method & headers ****************d*g**/
- 546: /**
- 547: * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
- 549: */
- 551: {
- 553: }
- 557: /**
- 558: * Checks if the request method is the given one.
- 561: */
- 563: {
- 564: return isset($_SERVER['REQUEST_METHOD']) ? strcasecmp($_SERVER['REQUEST_METHOD'], $method) === 0 : FALSE;
- 565: }
- 569: /**
- 570: * Checks if the request method is POST.
- 572: */
- 574: {
- 576: }
- 580: /**
- 581: * Return the value of the HTTP header. Pass the header name as the
- 582: * plain, HTTP-specified header name (e.g. 'Accept-Encoding').
- 586: */
- 588: {
- 595: }
- 596: }
- 600: /**
- 601: * Returns all HTTP headers.
- 603: */
- 605: {
- 607: // lazy initialization
- 615: }
- 616: }
- 617: }
- 618: }
- 620: }
- 624: /**
- 625: * Returns referrer.
- 627: */
- 629: {
- 632: }
- 636: /**
- 637: * Is the request is sent via secure channel (https).
- 639: */
- 641: {
- 643: }
- 647: /**
- 648: * Is AJAX request?
- 650: */
- 652: {
- 654: }
- 658: /**
- 659: * Returns the IP address of the remote client.
- 661: */
- 663: {
- 665: }
- 669: /**
- 670: * Returns the host of the remote client.
- 672: */
- 674: {
- 678: }
- 680: }
- 683: }
- 687: /**
- 688: * Parse Accept-Language header and returns prefered language.
- 691: */
- 693: {
- 700: preg_match_all('#(' . implode('|', $langs) . ')(?:-[^\s,;=]+)?\s*(?:;\s*q=([0-9.]+))?#', $s, $matches);
- 704: }
- 712: }
- 713: }
- 716: }
- 718: }