Esempio n. 1
0
 /**
  * Returns absolute domain path.
  * 
  * @param	array		$removeComponents
  * @return	string
  */
 public static function getPath(array $removeComponents = array())
 {
     if (empty(self::$path)) {
         self::$path = FileUtil::addTrailingSlash(dirname($_SERVER['SCRIPT_NAME']));
     }
     if (!empty($removeComponents)) {
         $path = explode('/', self::$path);
         foreach ($path as $index => $component) {
             if (empty($path[$index])) {
                 unset($path[$index]);
             }
             if (in_array($component, $removeComponents)) {
                 unset($path[$index]);
             }
         }
         return '/' . implode('/', $path) . '/';
     }
     return self::$path;
 }
Esempio n. 2
0
 /**
  * Returns current path info component.
  * 
  * @return	string
  */
 public static function getPathInfo()
 {
     if (self::$pathInfo === null) {
         self::$pathInfo = '';
         if (!URL_LEGACY_MODE || RequestHandler::getInstance()->isACPRequest()) {
             // WCF 2.1: ?Foo/Bar/
             if (!empty($_SERVER['QUERY_STRING'])) {
                 // don't use parse_str as it replaces dots with underscores
                 $components = explode('&', $_SERVER['QUERY_STRING']);
                 for ($i = 0, $length = count($components); $i < $length; $i++) {
                     $component = $components[$i];
                     $pos = mb_strpos($component, '=');
                     if ($pos !== false && $pos + 1 === mb_strlen($component)) {
                         $component = mb_substr($component, 0, -1);
                         $pos = false;
                     }
                     if ($pos === false) {
                         self::$pathInfo = urldecode($component);
                         break;
                     }
                 }
             }
         }
         // WCF 2.0: index.php/Foo/Bar/
         if (URL_LEGACY_MODE && !RequestHandler::getInstance()->isACPRequest() || RequestHandler::getInstance()->isACPRequest() && empty(self::$pathInfo)) {
             if (isset($_SERVER['PATH_INFO'])) {
                 self::$pathInfo = $_SERVER['PATH_INFO'];
             } else {
                 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 = '';
                         }
                     }
                 }
             }
         }
     }
     return self::$pathInfo;
 }