Overview

Namespaces

  • None
  • PHP
  • Wei
    • Validator

Classes

  • Apc
  • App
  • ArrayCache
  • Asset
  • Base
  • BaseCache
  • Bicache
  • Cache
  • Config
  • Cookie
  • Couchbase
  • Counter
  • Db
  • DbCache
  • E
  • Env
  • Error
  • FileCache
  • Gravatar
  • Http
  • Lock
  • Logger
  • Memcache
  • Memcached
  • MongoCache
  • Password
  • PhpError
  • Pinyin
  • Record
  • Redis
  • Request
  • Response
  • Router
  • SafeUrl
  • Session
  • Soap
  • T
  • Ua
  • Upload
  • Url
  • Uuid
  • Validate
  • View
  • WeChatApp
  • Wei
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Wei Framework
  4:  *
  5:  * @copyright   Copyright (c) 2008-2013 Twin Huang
  6:  * @license     http://opensource.org/licenses/mit-license.php MIT License
  7:  */
  8: 
  9: namespace Wei;
 10: 
 11: /**
 12:  * A service that handles the HTTP request data
 13:  *
 14:  * The methods are derived from code of the Zend Framework (2.1-dev 2013-04-01)
 15:  *   * getBaseUrl
 16:  *   * getRequestUri
 17:  *   * detectBaseUrl
 18:  *   * detectRequestUri
 19:  *
 20:  * @link      https://github.com/zendframework/zf2/blob/master/library/Zend/Http/PhpEnvironment/Request.php
 21:  * @link      http://github.com/zendframework/zf2 for the canonical source repository
 22:  * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 23:  * @license   http://framework.zend.com/license/new-bsd New BSD License
 24:  *
 25:  * @author      Twin Huang <twinhuang@qq.com>
 26:  */
 27: class Request extends Base implements \ArrayAccess, \Countable, \IteratorAggregate
 28: {
 29:     /**
 30:      * The request parameters, equals to $_REQUEST when $fromGlobal is true
 31:      *
 32:      * @var array
 33:      */
 34:     protected $data = array();
 35: 
 36:     /**
 37:      * The URL query parameters, equal to $_GET when $fromGlobal is true
 38:      *
 39:      * @var array
 40:      */
 41:     protected $gets = array();
 42: 
 43:     /**
 44:      * The HTTP request parameters, equal to $_POST when $fromGlobal is true
 45:      *
 46:      * @var array
 47:      */
 48:     protected $posts = array();
 49: 
 50:     /**
 51:      * The cookie parameters, equal to $_COOKIE when $fromGlobal is true
 52:      *
 53:      * @var array
 54:      */
 55:     protected $cookies = array();
 56: 
 57:     /**
 58:      * The server parameters, equal to $_SERVER when $fromGlobal is true
 59:      *
 60:      * @var array
 61:      */
 62:     protected $servers = array();
 63: 
 64:     /**
 65:      * The upload file parameters, equal to $_FILES when $fromGlobal is true
 66:      *
 67:      * @var array
 68:      */
 69:     protected $files = array();
 70: 
 71:     /**
 72:      * The request message body
 73:      *
 74:      * @var string
 75:      */
 76:     protected $content;
 77: 
 78:     /**
 79:      * Whether create request parameter from PHP global variable
 80:      *
 81:      * @var bool
 82:      */
 83:     protected $fromGlobal = true;
 84: 
 85:     /**
 86:      * Whether overwrite the request method when "_method" request parameter is present
 87:      *
 88:      * @var bool
 89:      */
 90:     protected $overwriteMethod = true;
 91: 
 92:     /**
 93:      * Whether add "X-Requested-With: XMLHttpRequest" header when "_ajax" request parameter is present
 94:      *
 95:      * @var
 96:      */
 97:     protected $overwriteAjax = true;
 98: 
 99:     /**
100:      * @var string
101:      */
102:     protected $baseUrl;
103: 
104:     /**
105:      * @var string
106:      */
107:     protected $pathInfo;
108: 
109:     /**
110:      * @var string
111:      */
112:     protected $requestUri;
113: 
114:     /**
115:      * The HTTP request method
116:      *
117:      * @var string
118:      */
119:     protected $method;
120: 
121:     /**
122:      * Constructor
123:      *
124:      * @param array $options
125:      */
126:     public function __construct(array $options = array())
127:     {
128:         parent::__construct($options);
129: 
130:         // Create parameters from super global variables on default
131:         if ($this->fromGlobal) {
132:             $this->gets     = &$_GET;
133:             $this->posts    = &$_POST;
134:             $this->cookies  = &$_COOKIE;
135:             $this->servers  = &$_SERVER;
136:             $this->files    = &$_FILES;
137:             $this->data     = &$_REQUEST;
138:         }
139: 
140:         if ($this->overwriteMethod && $method = $this->get('_method')) {
141:             $this->setMethod($method);
142:         }
143: 
144:         if ($this->overwriteAjax && $this->get('_ajax')) {
145:             $this->setServer('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest');
146:         }
147:     }
148: 
149:     /**
150:      * Returns a *stringify* or user defined($default) parameter value
151:      *
152:      * @param  string $name    The parameter name
153:      * @param  mixed  $default The default parameter value if the parameter does not exist
154:      * @return string|null  The parameter value
155:      */
156:     public function __invoke($name, $default = '')
157:     {
158:         return isset($this->data[$name]) ? (string)$this->data[$name] : $default;
159:     }
160: 
161:     /**
162:      * Returns a *stringify* or user defined($default) parameter value
163:      *
164:      * @param  string $name    The parameter name
165:      * @param  mixed  $default The default parameter value if the parameter does not exist
166:      * @return string|null  The parameter value
167:      */
168:     public function get($name, $default = null)
169:     {
170:         return $this->__invoke($name, $default);
171:     }
172: 
173:     /**
174:      * Returns a integer value in the specified range
175:      *
176:      * @param string $name The parameter name
177:      * @param integer|null $min The min value for the parameter
178:      * @param integer|null $max The max value for the parameter
179:      * @return int The parameter value
180:      */
181:     public function getInt($name, $min = null, $max = null)
182:     {
183:         $value = (int) $this($name);
184: 
185:         if (!is_null($min) && $value < $min) {
186:             return $min;
187:         } elseif (!is_null($max) && $value > $max) {
188:             return $max;
189:         }
190: 
191:         return $value;
192:     }
193: 
194:     /**
195:      * Returns a parameter value in the specified array, if not in, returns the
196:      * first element instead
197:      *
198:      * @param string $name The parameter name
199:      * @param array $array The array to be search
200:      * @return mixed The parameter value
201:      */
202:     public function getInArray($name, array $array)
203:     {
204:         $value = $this->get($name);
205:         return in_array($value, $array) ? $value : $array[key($array)];
206:     }
207: 
208:     /**
209:      * Set parameter value
210:      *
211:      * @param string|array $name The parameter name or A key-value array
212:      * @param mixed $value The parameter value
213:      * @return $this
214:      */
215:     public function set($name, $value = null)
216:     {
217:         if (!is_array($name)) {
218:             $this->data[$name] = $value;
219:         } else {
220:             foreach ($name as $key => $value) {
221:                 $this->data[$key] = $value;
222:             }
223:         }
224:         return $this;
225:     }
226: 
227:     /**
228:      * Remove parameter by specified name
229:      *
230:      * @param string $name The parameter name
231:      * @return $this
232:      */
233:     public function remove($name)
234:     {
235:         unset($this->data[$name]);
236:         return $this;
237:     }
238: 
239:     /**
240:      * Clear all parameter data
241:      *
242:      * @return $this
243:      */
244:     public function clear()
245:     {
246:         $this->data = array();
247:         return $this;
248:     }
249: 
250:     /**
251:      * Check if the offset exists
252:      *
253:      * @param  string $offset
254:      * @return bool
255:      */
256:     public function offsetExists($offset)
257:     {
258:         return isset($this->data[$offset]);
259:     }
260: 
261:     /**
262:      * Get the offset value
263:      *
264:      * @param  string $offset
265:      * @return mixed
266:      */
267:     public function offsetGet($offset)
268:     {
269:         return isset($this->data[$offset]) ? $this->data[$offset] : null;
270:     }
271: 
272:     /**
273:      * Set the offset value
274:      *
275:      * @param string $offset
276:      * @param mixed  $value
277:      * @return mixed
278:      */
279:     public function offsetSet($offset, $value)
280:     {
281:         return $this->data[$offset] = $value;
282:     }
283: 
284:     /**
285:      * Unset the offset
286:      *
287:      * @param string $offset
288:      */
289:     public function offsetUnset($offset)
290:     {
291:         unset($this->data[$offset]);
292:     }
293: 
294:     /**
295:      * Merge data from array
296:      *
297:      * @param  array            $array
298:      * @return $this
299:      */
300:     public function fromArray(array $array = array())
301:     {
302:         $this->data = $array;
303:         return $this;
304:     }
305: 
306:     /**
307:      * Return the source array of the object
308:      *
309:      * @return array
310:      */
311:     public function toArray()
312:     {
313:         return $this->data;
314:     }
315: 
316:     /**
317:      * Return the length of data
318:      *
319:      * @return int the length of data
320:      */
321:     public function count()
322:     {
323:         return count($this->data);
324:     }
325: 
326:     /**
327:      * Returns the request scheme
328:      *
329:      * @return string
330:      */
331:     public function getScheme()
332:     {
333:         if ('on' === strtolower($this->getServer('HTTPS')) || 1 == $this->getServer('HTTPS')) {
334:             return 'https';
335:         } else {
336:             return 'http';
337:         }
338:     }
339: 
340:     /**
341:      * Returns the request host
342:      *
343:      * @return string
344:      */
345:     public function getHost()
346:     {
347:         return $this->getServer('HTTP_HOST')
348:             ?: $this->getServer('SERVER_NAME')
349:             ?: $this->getServer('REMOTE_ADDR');
350:     }
351: 
352:     /**
353:      * Set the request URI.
354:      *
355:      * @param  string $requestUri
356:      * @return self
357:      */
358:     public function setRequestUri($requestUri)
359:     {
360:         $this->requestUri = $requestUri;
361:         return $this;
362:     }
363: 
364:     /**
365:      * Get the request URI.
366:      *
367:      * @return string
368:      */
369:     public function getRequestUri()
370:     {
371:         if ($this->requestUri === null) {
372:             $this->requestUri = $this->detectRequestUri();
373:         }
374:         return $this->requestUri;
375:     }
376: 
377:     /**
378:      * Set the base URL.
379:      *
380:      * @param  string $baseUrl
381:      * @return self
382:      */
383:     public function setBaseUrl($baseUrl)
384:     {
385:         $this->baseUrl = rtrim($baseUrl, '/');
386:         return $this;
387:     }
388: 
389:     /**
390:      * Get the base URL.
391:      *
392:      * @return string
393:      */
394:     public function getBaseUrl()
395:     {
396:         if ($this->baseUrl === null) {
397:             $this->setBaseUrl($this->detectBaseUrl());
398:         }
399:         return $this->baseUrl;
400:     }
401: 
402:     /**
403:      * Set the path info
404:      *
405:      * @param string $pathInfo
406:      * @return $this
407:      */
408:     public function setPathInfo($pathInfo)
409:     {
410:         $this->pathInfo = $pathInfo;
411:         return $this;
412:     }
413: 
414:     /**
415:      * Return request path info
416:      *
417:      * @return string
418:      */
419:     public function getPathInfo()
420:     {
421:         if ($this->pathInfo === null) {
422:             $this->pathInfo = $this->detectPathInfo();
423:         }
424:         return $this->pathInfo;
425:     }
426: 
427:     /**
428:      * Returns the full URL, which contains scheme://domain[:port]/[baseUrl][PathInfo][?queryString]
429:      *
430:      * The full URL do not contain the fragment, for it never sent to the server
431:      *
432:      * @return string
433:      */
434:     public function getUrl()
435:     {
436:         return $this->getSchemeAndHost() . $this->getRequestUri();
437:     }
438: 
439:     /**
440:      * Returns scheme and host which contains scheme://domain[:port]
441:      *
442:      * @return string
443:      */
444:     public function getSchemeAndHost()
445:     {
446:         $port = $this->getServer('SERVER_PORT');
447:         if ($port == 80 || $port == 433 || empty($port)) {
448:             $port = '';
449:         } else {
450:             $port = ':' . $port;
451:         }
452:         return $this->getScheme() . '://' . $this->getHost() . $port;
453:     }
454: 
455:     /**
456:      * Generates absolute URL for specified path
457:      *
458:      * @param string $path
459:      * @return string
460:      */
461:     public function getUrlFor($path)
462:     {
463:         return $this->getSchemeAndHost() . $path;
464:     }
465: 
466:     /**
467:      * Returns the client IP address
468:      *
469:      * If the IP could not receive from the server parameter, or the IP address
470:      * is not valid, return the $default value instead
471:      *
472:      * @link http://en.wikipedia.org/wiki/X-Forwarded-For
473:      * @param  string $default The default ip address
474:      * @return string
475:      */
476:     public function getIp($default = '0.0.0.0')
477:     {
478:         $ip = $this->getServer('HTTP_X_FORWARDED_FOR')
479:             ? current(explode(',', $this->getServer('HTTP_X_FORWARDED_FOR'))) : $this->getServer('HTTP_CLIENT_IP')
480:             ?: $this->getServer('REMOTE_ADDR');
481: 
482:         return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : $default;
483:     }
484: 
485:     /**
486:      * Returns the HTTP request method
487:      *
488:      * @return string
489:      */
490:     public function getMethod()
491:     {
492:         if (null === $this->method) {
493:             $this->method = $this->getServer('REQUEST_METHOD', 'GET');
494:         }
495:         return $this->method;
496:     }
497: 
498:     /**
499:      * Set the HTTP request method
500:      *
501:      * @param string $method The value of method
502:      * @return $this
503:      */
504:     public function setMethod($method)
505:     {
506:         $this->method = $method;
507:         return $this;
508:     }
509: 
510:     /**
511:      * Check if the current request method is the specified string
512:      *
513:      * @param string $method The method name to be compared
514:      * @return bool
515:      */
516:     public function isMethod($method)
517:     {
518:         return !strcasecmp($method, $this->getMethod());
519:     }
520: 
521:     /**
522:      * Check if the current request method is GET
523:      *
524:      * @return bool
525:      */
526:     public function isGet()
527:     {
528:         return $this->isMethod('GET');
529:     }
530: 
531:     /**
532:      * Check if the current request method is POST
533:      *
534:      * @return bool
535:      */
536:     public function isPost()
537:     {
538:         return $this->isMethod('POST');
539:     }
540: 
541:     /**
542:      * Check if the current request is an ajax(XMLHttpRequest) request
543:      *
544:      * @return bool
545:      */
546:     public function isAjax()
547:     {
548:         return 'xmlhttprequest' == strtolower($this->getServer('HTTP_X_REQUESTED_WITH'));
549:     }
550: 
551:     /**
552:      * Returns the HTTP parameters reference
553:      *
554:      * @param string $type The parameter type, could be get, post, cookie, or server
555:      * @return array The parameters array
556:      * @throws \InvalidArgumentException When parameter type is unknown
557:      */
558:     public function &getParameterReference($type)
559:     {
560:         if (in_array($type, array('get', 'post', 'cookie', 'server', 'file'))) {
561:             return $this->{$type . 's'};
562:         }
563: 
564:         throw new \InvalidArgumentException(sprintf('Unknown parameter type "%s"', $type));
565:     }
566: 
567:     /**
568:      * Returns the request message body
569:      *
570:      * @return string
571:      */
572:     public function getContent()
573:     {
574:         if (null === $this->content && $this->fromGlobal) {
575:             $this->content = file_get_contents('php://input');
576:         }
577:         return $this->content;
578:     }
579: 
580:     /**
581:      * Set the request message body
582:      *
583:      * @param string $content
584:      * @return $this
585:      */
586:     public function setContent($content)
587:     {
588:         $this->content = $content;
589:         return $this;
590:     }
591: 
592:     /**
593:      * Returns the request message string
594:      *
595:      * @return string
596:      */
597:     public function __toString()
598:     {
599:         $header = '';
600:         foreach ($this->getHeaders() as $name => $value) {
601:             $name = implode('-', array_map('ucfirst', explode('_', strtolower($name))));
602:             $header .= $name . ': ' . $value . "\r\n";
603:         }
604:         return $this->getServer('REQUEST_METHOD') . ' ' . $this->getUrl() . ' ' . $this->getServer('SERVER_PROTOCOL') . "\r\n"
605:             . $header
606:             . $this->getContent();
607:     }
608: 
609:     /**
610:      * Return the server and execution environment parameter value ($_SERVER)
611:      *
612:      * @param string $name The name of parameter
613:      * @param mixed $default The default parameter value if the parameter does not exist
614:      * @return mixed
615:      */
616:     public function getServer($name, $default = null)
617:     {
618:         return isset($this->servers[$name]) ? $this->servers[$name] : $default;
619:     }
620: 
621:     /**
622:      * Set the server and execution environment parameter value ($_SERVER)
623:      *
624:      * @param string $name
625:      * @param string $value
626:      * @return $this
627:      */
628:     public function setServer($name, $value)
629:     {
630:         $this->servers[$name] = $value;
631:         return $this;
632:     }
633: 
634:     /**
635:      * Return the URL query parameter value ($_GET)
636:      *
637:      * @param string $name The name of parameter
638:      * @param mixed $default The default parameter value if the parameter does not exist
639:      * @return mixed
640:      */
641:     public function getQuery($name, $default = null)
642:     {
643:         return isset($this->gets[$name]) ? $this->gets[$name] : $default;
644:     }
645: 
646:     /**
647:      * Set the URL query parameter value ($_GET)
648:      *
649:      * @param string $name
650:      * @param string $value
651:      * @return $this
652:      */
653:     public function setQuery($name, $value)
654:     {
655:         $this->gets[$name] = $value;
656:         return $this;
657:     }
658: 
659:     /**
660:      * Return the URL query parameter values ($_GET)
661:      *
662:      * @return array
663:      */
664:     public function &getQueries()
665:     {
666:         return $this->gets;
667:     }
668: 
669:     /**
670:      * Return the HTTP request parameters value ($_POST)
671:      *
672:      * @param string $name The name of parameter
673:      * @param mixed $default The default parameter value if the parameter does not exist
674:      * @return mixed
675:      */
676:     public function getPost($name, $default = null)
677:     {
678:         return isset($this->posts[$name]) ? $this->posts[$name] : $default;
679:     }
680: 
681:     /**
682:      * Set the HTTP request parameters value ($_POST)
683:      *
684:      * @param string $name
685:      * @param string $value
686:      * @return $this
687:      */
688:     public function setPost($name, $value)
689:     {
690:         $this->posts[$name] = $value;
691:         return $this;
692:     }
693: 
694:     /**
695:      * Returns the HTTP request headers
696:      *
697:      * @return array
698:      */
699:     public function getHeaders()
700:     {
701:         $headers = array();
702:         foreach ($this->servers as $name => $value) {
703:             if (0 === strpos($name, 'HTTP_')) {
704:                 $headers[substr($name, 5)] = $value;
705:             }
706:         }
707:         return $headers;
708:     }
709: 
710:     /**
711:      * Check if the request page is specified page
712:      *
713:      * @param string $page
714:      * @return bool
715:      */
716:     public function isPage($page)
717:     {
718:         return ltrim($this->getPathInfo()) === $page;
719:     }
720: 
721:     /**
722:      * Detect the base URI for the request
723:      *
724:      * Looks at a variety of criteria in order to attempt to autodetect a base
725:      * URI, including rewrite URIs, proxy URIs, etc.
726:      *
727:      * @return string
728:      */
729:     protected function detectRequestUri()
730:     {
731:         $requestUri = null;
732: 
733:         // Check this first so IIS will catch.
734:         $httpXRewriteUrl = $this->getServer('HTTP_X_REWRITE_URL');
735:         if ($httpXRewriteUrl !== null) {
736:             $requestUri = $httpXRewriteUrl;
737:         }
738: 
739:         // Check for IIS 7.0 or later with ISAPI_Rewrite
740:         $httpXOriginalUrl = $this->getServer('HTTP_X_ORIGINAL_URL');
741:         if ($httpXOriginalUrl !== null) {
742:             $requestUri = $httpXOriginalUrl;
743:         }
744: 
745:         // IIS7 with URL Rewrite: make sure we get the unencoded url
746:         // (double slash problem).
747:         $iisUrlRewritten = $this->getServer('IIS_WasUrlRewritten');
748:         $unencodedUrl    = $this->getServer('UNENCODED_URL', '');
749:         if ('1' == $iisUrlRewritten && '' !== $unencodedUrl) {
750:             return $unencodedUrl;
751:         }
752: 
753:         // HTTP proxy requests setup request URI with scheme and host [and port]
754:         // + the URL path, only use URL path.
755:         if (!$httpXRewriteUrl) {
756:             $requestUri = $this->getServer('REQUEST_URI');
757:         }
758: 
759:         if ($requestUri !== null) {
760:             return preg_replace('#^[^/:]+://[^/]+#', '', $requestUri);
761:         }
762: 
763:         // IIS 5.0, PHP as CGI.
764:         $origPathInfo = $this->getServer('ORIG_PATH_INFO');
765:         if ($origPathInfo !== null) {
766:             $queryString = $this->getServer('QUERY_STRING', '');
767:             if ($queryString !== '') {
768:                 $origPathInfo .= '?' . $queryString;
769:             }
770:             return $origPathInfo;
771:         }
772: 
773:         return '/';
774:     }
775: 
776:     /**
777:      * Auto-detect the base path from the request environment
778:      *
779:      * Uses a variety of criteria in order to detect the base URL of the request
780:      * (i.e., anything additional to the document root).
781:      *
782:      * The base URL includes the schema, host, and port, in addition to the path.
783:      *
784:      * @return string
785:      */
786:     protected function detectBaseUrl()
787:     {
788:         $baseUrl        = null;
789:         $filename       = $this->getServer('SCRIPT_FILENAME', '');
790:         $scriptName     = $this->getServer('SCRIPT_NAME');
791:         $phpSelf        = $this->getServer('PHP_SELF');
792:         $origScriptName = $this->getServer('ORIG_SCRIPT_NAME');
793: 
794:         if ($scriptName !== null && basename($scriptName) === $filename) {
795:             $baseUrl = $scriptName;
796:         } elseif ($phpSelf !== null && basename($phpSelf) === $filename) {
797:             $baseUrl = $phpSelf;
798:         } elseif ($origScriptName !== null && basename($origScriptName) === $filename) {
799:             // 1and1 shared hosting compatibility.
800:             $baseUrl = $origScriptName;
801:         } else {
802:             // Backtrack up the SCRIPT_FILENAME to find the portion
803:             // matching PHP_SELF.
804: 
805:             $baseUrl  = '/';
806:             $basename = basename($filename);
807:             if ($basename) {
808:                 $path     = ($phpSelf ? trim($phpSelf, '/') : '');
809:                 $baseUrl .= substr($path, 0, strpos($path, $basename)) . $basename;
810:             }
811:         }
812: 
813:         // Does the base URL have anything in common with the request URI?
814:         $requestUri = $this->getRequestUri();
815: 
816:         // Full base URL matches.
817:         if (0 === strpos($requestUri, $baseUrl)) {
818:             return $baseUrl;
819:         }
820: 
821:         // Directory portion of base path matches.
822:         $baseDir = str_replace('\\', '/', dirname($baseUrl));
823:         if (0 === strpos($requestUri, $baseDir)) {
824:             return $baseDir;
825:         }
826: 
827:         $truncatedRequestUri = $requestUri;
828: 
829:         if (false !== ($pos = strpos($requestUri, '?'))) {
830:             $truncatedRequestUri = substr($requestUri, 0, $pos);
831:         }
832: 
833:         $basename = basename($baseUrl);
834: 
835:         // No match whatsoever
836:         if (empty($basename) || false === strpos($truncatedRequestUri, $basename)) {
837:             return '';
838:         }
839: 
840:         // If using mod_rewrite or ISAPI_Rewrite strip the script filename
841:         // out of the base path. $pos !== 0 makes sure it is not matching a
842:         // value from PATH_INFO or QUERY_STRING.
843:         if (strlen($requestUri) >= strlen($baseUrl)
844:             && (false !== ($pos = strpos($requestUri, $baseUrl)) && $pos !== 0)
845:         ) {
846:             $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
847:         }
848: 
849:         return $baseUrl;
850:     }
851: 
852:     /**
853:      * Detect the path info for the request
854:      *
855:      * @return string
856:      */
857:     protected function detectPathInfo()
858:     {
859:         $uri = $this->getRequestUri();
860: 
861:         $pathInfo = '/' . trim(substr($uri, strlen($this->getBaseUrl())), '/');
862: 
863:         if (false !== $pos = strpos($pathInfo, '?')) {
864:             $pathInfo = substr($pathInfo, 0, $pos);
865:         }
866:         return $pathInfo;
867:     }
868: 
869:     /**
870:      * Retrieve an array iterator
871:      *
872:      * @return \ArrayIterator
873:      */
874:     public function getIterator()
875:     {
876:         return new \ArrayIterator($this->data);
877:     }
878: }
879: 
Wei Framework API documentation generated by ApiGen