use wcf\system\exception\SystemException;
use wcf\system\language\LanguageFactory;
use wcf\system\package\PackageInstallationDispatcher;
+use wcf\system\request\RouteHandler;
use wcf\system\session\SessionFactory;
use wcf\system\session\SessionHandler;
use wcf\system\style\StyleHandler;
public static function getRequestURI() {
// resolve path and query components
$scriptName = $_SERVER['SCRIPT_NAME'];
- if (empty($_SERVER['PATH_INFO'])) {
+ $pathInfo = RouteHandler::getPathInfo();
+ if (empty($pathInfo)) {
// bug fix if URL omits script name and path
$scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
}
protected function initAuth() {
// this is a work-around since neither RequestHandler
// nor RouteHandler are populated right now
- $pathInfo = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : '';
+ $pathInfo = RouteHandler::getPathInfo();
if (empty($pathInfo) || !preg_match('~^/(ACPCaptcha|Login|Logout)/~', $pathInfo)) {
if (WCF::getUser()->userID == 0) {
// build redirect path
*/
protected static $path = '';
+ /**
+ * current path info component
+ * @var string
+ */
+ protected static $pathInfo = '';
+
/**
* HTTP protocol, either 'http://' or 'https://'
* @var string
* @return boolean
*/
public function matches() {
- $pathInfo = '';
- if (isset($_SERVER['ORIG_PATH_INFO'])) {
- $pathInfo = $_SERVER['ORIG_PATH_INFO'];
-
- // in some configurations ORIG_PATH_INFO contains the path to the file
- // if the intended PATH_INFO component is empty
- if (!empty($pathInfo)) {
- if (isset($_SERVER['SCRIPT_NAME']) && ($pathInfo == $_SERVER['SCRIPT_NAME'])) {
- $pathInfo = '';
- }
-
- if (isset($_SERVER['PHP_SELF']) && ($pathInfo == $_SERVER['PHP_SELF'])) {
- $pathInfo = '';
- }
-
- if (isset($_SERVER['SCRIPT_URL']) && ($pathInfo == $_SERVER['SCRIPT_URL'])) {
- $pathInfo = '';
- }
- }
- }
- else if (isset($_SERVER['PATH_INFO'])) {
- $pathInfo = $_SERVER['PATH_INFO'];
- }
-
foreach ($this->routes as $route) {
if (RequestHandler::getInstance()->isACPRequest() != $route->isACP()) {
continue;
}
- if ($route->matches($pathInfo)) {
+ if ($route->matches(self::getPathInfo())) {
$this->routeData = $route->getRouteData();
$this->isDefaultController = $this->routeData['isDefaultController'];
return self::$path;
}
+
+ /**
+ * Returns current path info component.
+ *
+ * @return string
+ */
+ public static function getPathInfo() {
+ if (empty(self::$pathInfo)) {
+ if (isset($_SERVER['ORIG_PATH_INFO'])) {
+ self::$pathInfo = $_SERVER['ORIG_PATH_INFO'];
+
+ // in some configurations ORIG_PATH_INFO contains the path to the file
+ // if the intended PATH_INFO component is empty
+ if (!empty(self::$pathInfo)) {
+ if (isset($_SERVER['SCRIPT_NAME']) && (self::$pathInfo == $_SERVER['SCRIPT_NAME'])) {
+ self::$pathInfo = '';
+ }
+
+ if (isset($_SERVER['PHP_SELF']) && (self::$pathInfo == $_SERVER['PHP_SELF'])) {
+ self::$pathInfo = '';
+ }
+
+ if (isset($_SERVER['SCRIPT_URL']) && (self::$pathInfo == $_SERVER['SCRIPT_URL'])) {
+ self::$pathInfo = '';
+ }
+ }
+ }
+ else if (isset($_SERVER['PATH_INFO'])) {
+ self::$pathInfo = $_SERVER['PATH_INFO'];
+ }
+ }
+
+ return self::$pathInfo;
+ }
}