当前位置: 首页>>代码示例>>PHP>>正文


PHP FileUtil::removeLeadingSlash方法代码示例

本文整理汇总了PHP中wcf\util\FileUtil::removeLeadingSlash方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::removeLeadingSlash方法的具体用法?PHP FileUtil::removeLeadingSlash怎么用?PHP FileUtil::removeLeadingSlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wcf\util\FileUtil的用法示例。


在下文中一共展示了FileUtil::removeLeadingSlash方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rebuild

	/**
	 * Assigns a list of applications to a group and computes cookie domain and path.
	 */
	public function rebuild() {
		if (empty($this->objects)) {
			$this->readObjects();
		}
		
		$sql = "UPDATE	wcf".WCF_N."_application
			SET	cookieDomain = ?,
				cookiePath = ?
			WHERE	packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		
		// calculate cookie path
		$domains = array();
		foreach ($this->objects as $application) {
			if (!isset($domains[$application->domainName])) {
				$domains[$application->domainName] = array();
			}
			
			$domains[$application->domainName][$application->packageID] = explode('/', FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($application->domainPath)));
		}
		
		WCF::getDB()->beginTransaction();
		foreach ($domains as $domainName => $data) {
			$path = null;
			foreach ($data as $domainPath) {
				if ($path === null) {
					$path = $domainPath;
				}
				else {
					foreach ($path as $i => $part) {
						if (!isset($domainPath[$i]) || $domainPath[$i] != $part) {
							// remove all following elements including current one
							foreach ($path as $j => $innerPart) {
								if ($j >= $i) {
									unset($path[$j]);
								}
							}
							
							// skip to next domain
							continue 2;
						}
					}
				}
			}
			
			$path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(implode('/', $path)));
			
			foreach (array_keys($data) as $packageID) {
				$statement->execute(array(
					$domainName,
					$path,
					$packageID
				));
			}
		}
		WCF::getDB()->commitTransaction();
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:60,代码来源:ApplicationAction.class.php

示例2: rebuild

 /**
  * Assigns a list of applications to a group and computes cookie domain and path.
  */
 public function rebuild()
 {
     if (empty($this->objects)) {
         $this->readObjects();
     }
     $sql = "UPDATE\twcf" . WCF_N . "_application\n\t\t\tSET\tcookieDomain = ?,\n\t\t\t\tcookiePath = ?\n\t\t\tWHERE\tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     // calculate cookie path
     $domains = array();
     $regex = new Regex(':[0-9]+');
     foreach ($this->objects as $application) {
         $domainName = $application->domainName;
         if (StringUtil::endsWith($regex->replace($domainName, ''), $application->cookieDomain)) {
             $domainName = $application->cookieDomain;
         }
         if (!isset($domains[$domainName])) {
             $domains[$domainName] = array();
         }
         $domains[$domainName][$application->packageID] = explode('/', FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($application->domainPath)));
     }
     WCF::getDB()->beginTransaction();
     foreach ($domains as $domainName => $data) {
         $path = null;
         foreach ($data as $domainPath) {
             if ($path === null) {
                 $path = $domainPath;
             } else {
                 foreach ($path as $i => $part) {
                     if (!isset($domainPath[$i]) || $domainPath[$i] != $part) {
                         // remove all following elements including current one
                         foreach ($path as $j => $innerPart) {
                             if ($j >= $i) {
                                 unset($path[$j]);
                             }
                         }
                         // skip to next domain
                         continue 2;
                     }
                 }
             }
         }
         $path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(implode('/', $path)));
         foreach (array_keys($data) as $packageID) {
             $statement->execute(array($domainName, $path, $packageID));
         }
     }
     WCF::getDB()->commitTransaction();
     // rebuild templates
     LanguageFactory::getInstance()->deleteLanguageCache();
     // reset application cache
     ApplicationCacheBuilder::getInstance()->reset();
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:55,代码来源:ApplicationAction.class.php

示例3: getFileLocation

 /**
  * Returns available location path.
  * 
  * @param	string		$location
  * @return	string
  */
 protected static function getFileLocation($location)
 {
     $location = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($location));
     $location = WCF_DIR . $location;
     $index = null;
     do {
         $directory = $location . ($index === null ? '' : $index);
         if (!is_dir($directory)) {
             @mkdir($directory, 0777, true);
             FileUtil::makeWritable($directory);
             return FileUtil::addTrailingSlash($directory);
         }
         $index = $index === null ? 2 : $index + 1;
     } while (true);
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:21,代码来源:StyleEditor.class.php

示例4: getRequestURI

 /**
  * Returns the URI of the current page.
  * 
  * @return	string
  */
 public static function getRequestURI()
 {
     if (URL_LEGACY_MODE) {
         // resolve path and query components
         $scriptName = $_SERVER['SCRIPT_NAME'];
         $pathInfo = RouteHandler::getPathInfo();
         if (empty($pathInfo)) {
             // bug fix if URL omits script name and path
             $scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
         }
         $path = str_replace('/index.php', '', str_replace($scriptName, '', $_SERVER['REQUEST_URI']));
         if (!StringUtil::isUTF8($path)) {
             $path = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $path);
         }
         $path = FileUtil::removeLeadingSlash($path);
         $baseHref = self::getTPL()->get('baseHref');
         if (!empty($path) && mb_strpos($path, '?') !== 0) {
             $baseHref .= 'index.php/';
         }
         return $baseHref . $path;
     } else {
         $url = preg_replace('~^(https?://[^/]+)(?:/.*)?$~', '$1', self::getTPL()->get('baseHref'));
         $url .= $_SERVER['REQUEST_URI'];
         return $url;
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:31,代码来源:WCF.class.php

示例5: install

 /**
  * Starts the extracting of the files.
  */
 protected function install()
 {
     $this->createTargetDir();
     // open source archive
     $tar = new Tar($this->source);
     // distinct directories and files
     $directories = array();
     $files = array();
     foreach ($tar->getContentList() as $index => $file) {
         if (empty($this->folder) || mb_strpos($file['filename'], $this->folder) === 0) {
             if (!empty($this->folder)) {
                 $file['filename'] = str_replace($this->folder, '', $file['filename']);
             }
             // remove leading slash
             $file['filename'] = FileUtil::removeLeadingSlash($file['filename']);
             if ($file['type'] == 'folder') {
                 // remove trailing slash
                 $directories[] = FileUtil::removeTrailingSlash($file['filename']);
             } else {
                 $files[$index] = $file['filename'];
             }
         }
     }
     $this->checkFiles($files);
     // now create the directories
     $errors = array();
     foreach ($directories as $dir) {
         try {
             $this->createDir($dir);
         } catch (SystemException $e) {
             $errors[] = $e->getMessage();
         }
     }
     // now untar all files
     foreach ($files as $index => $file) {
         try {
             $this->createFile($file, $index, $tar);
         } catch (SystemException $e) {
             $errors[] = $e->getMessage();
         }
     }
     if (!empty($errors)) {
         throw new SystemException('error(s) during the installation of the files.', 0, implode("<br />", $errors));
     }
     $this->logFiles($files);
     // close tar
     $tar->close();
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:51,代码来源:Installer.class.php

示例6: searchWcfDir

 /**
  * Searches the wcf dir.
  */
 protected function searchWcfDir()
 {
     if (self::$wcfDir) {
         $wcfDir = self::$wcfDir;
     } else {
         $wcfDir = FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR) . 'wcf/';
     }
     $invalidDirectory = false;
     if (@is_file($wcfDir . 'lib/system/WCF.class.php')) {
         $invalidDirectory = true;
     }
     // domain
     $domainName = '';
     if (!empty($_SERVER['SERVER_NAME'])) {
         $domainName = 'http://' . $_SERVER['SERVER_NAME'];
     }
     // port
     if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) {
         $domainName .= ':' . $_SERVER['SERVER_PORT'];
     }
     // script url
     $installScriptUrl = '';
     if (!empty($_SERVER['REQUEST_URI'])) {
         $installScriptUrl = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash(FileUtil::unifyDirSeparator(dirname($_SERVER['REQUEST_URI']))));
     }
     WCF::getTPL()->assign(array('nextStep' => 'unzipFiles', 'invalidDirectory' => $invalidDirectory, 'wcfDir' => $wcfDir, 'domainName' => $domainName, 'installScriptUrl' => $installScriptUrl, 'installScriptDir' => FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR)));
     WCF::getTPL()->display('stepSearchWcfDir');
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:31,代码来源:WCFSetup.class.php

示例7: searchWcfDir

 /**
  * Searches the wcf dir.
  */
 protected function searchWcfDir()
 {
     $foundDirectory = '';
     if (self::$wcfDir) {
         $wcfDir = self::$wcfDir;
     } else {
         if ($foundDirectory = FileUtil::scanFolder(INSTALL_SCRIPT_DIR, "WCF.class.php", true)) {
             $foundDirectory = $wcfDir = FileUtil::unifyDirSeperator(dirname(dirname(dirname($foundDirectory))) . '/');
             if (dirname(dirname($wcfDir)) . '/' == TMP_DIR) {
                 $foundDirectory = false;
                 $wcfDir = FileUtil::unifyDirSeperator(INSTALL_SCRIPT_DIR) . 'wcf/';
             }
         } else {
             $wcfDir = FileUtil::unifyDirSeperator(INSTALL_SCRIPT_DIR) . 'wcf/';
         }
     }
     // domain
     $domainName = '';
     if (!empty($_SERVER['SERVER_NAME'])) {
         $domainName = 'http://' . $_SERVER['SERVER_NAME'];
     }
     // port
     if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) {
         $domainName .= ':' . $_SERVER['SERVER_PORT'];
     }
     // script url
     $installScriptUrl = '';
     if (!empty($_SERVER['REQUEST_URI'])) {
         $installScriptUrl = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash(FileUtil::unifyDirSeperator(dirname($_SERVER['REQUEST_URI']))));
     }
     WCF::getTPL()->assign(array('nextStep' => 'unzipFiles', 'foundDirectory' => $foundDirectory, 'wcfDir' => $wcfDir, 'domainName' => $domainName, 'installScriptUrl' => $installScriptUrl, 'installScriptDir' => FileUtil::unifyDirSeperator(INSTALL_SCRIPT_DIR)));
     WCF::getTPL()->display('stepSearchWcfDir');
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:36,代码来源:WCFSetup.class.php

示例8: validate

	/**
	 * @see	wcf\form\IForm::validate()
	 */
	public function validate() {
		parent::validate();
		
		if (empty($this->domainName)) {
			throw new UserInputException('domainName');
		}
		else {
			$regex = new Regex('^https?\://');
			$this->domainName = FileUtil::removeTrailingSlash($regex->replace($this->domainName, ''));
			$this->cookieDomain = FileUtil::removeTrailingSlash($regex->replace($this->cookieDomain, ''));
			
			// domain may not contain path components
			$regex = new Regex('[/#\?&]');
			if ($regex->match($this->domainName)) {
				throw new UserInputException('domainName', 'containsPath');
			}
			else if ($regex->match($this->cookieDomain)) {
				throw new UserInputException('cookieDomain', 'containsPath');
			}
			
			// check if cookie domain shares the same domain (may exclude subdomains)
			if (!StringUtil::endsWith($this->domainName, $this->cookieDomain)) {
				throw new UserInputException('cookieDomain', 'notValid');
			}
		}
		
		if (empty($this->domainPath)) {
			$this->cookiePath = '';
		}
		else {
			// strip first and last slash
			$this->domainPath = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($this->domainPath));
			$this->cookiePath = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($this->cookiePath));
			
			if (!empty($this->cookiePath) && ($this->domainPath != $this->cookiePath)) {
				// check if cookie path is contained within domain path
				if (!StringUtil::startsWith($this->domainPath, $this->cookiePath)) {
					throw new UserInputException('cookiePath', 'notValid');
				}
			}
		}
		
		// add slashes
		$this->domainPath = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($this->domainPath));
		$this->cookiePath = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($this->cookiePath));
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:49,代码来源:ApplicationEditForm.class.php

示例9: getRequestURI

	/**
	 * Returns the URI of the current page.
	 *
	 * @return	string
	 */
	public static function getRequestURI() {
		// resolve path and query components
		$scriptName = $_SERVER['SCRIPT_NAME'];
		if (empty($_SERVER['PATH_INFO'])) {
			// bug fix if URL omits script name and path
			$scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
		}
		
		$path = str_replace('/index.php', '', str_replace($scriptName, '', $_SERVER['REQUEST_URI']));
		if (!StringUtil::isASCII($path) && !StringUtil::isUTF8($path)) {
			$path = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $path);
		}
		$path = FileUtil::removeLeadingSlash($path);
		$baseHref = self::getTPL()->get('baseHref');
		
		if (!empty($path) && StringUtil::indexOf($path, '?') !== 0) {
			$baseHref .= 'index.php/';
		}
		
		return $baseHref . $path;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:26,代码来源:WCF.class.php

示例10: readFormParameters

 /**
  * @see	\wcf\page\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     I18nHandler::getInstance()->readValues();
     if (I18nHandler::getInstance()->isPlainValue('smileyTitle')) {
         $this->smileyTitle = I18nHandler::getInstance()->getValue('smileyTitle');
     }
     if (isset($_POST['showOrder'])) {
         $this->showOrder = intval($_POST['showOrder']);
     }
     if (isset($_POST['categoryID'])) {
         $this->categoryID = intval($_POST['categoryID']);
     }
     if (isset($_POST['smileyCode'])) {
         $this->smileyCode = StringUtil::trim($_POST['smileyCode']);
     }
     if (isset($_POST['aliases'])) {
         $this->aliases = StringUtil::unifyNewlines(StringUtil::trim($_POST['aliases']));
     }
     if (isset($_POST['smileyPath'])) {
         $this->smileyPath = FileUtil::removeLeadingSlash(StringUtil::trim($_POST['smileyPath']));
     }
     if (isset($_POST['uploadedFilename'])) {
         $this->uploadedFilename = StringUtil::trim($_POST['uploadedFilename']);
     }
     if (isset($_FILES['fileUpload'])) {
         $this->fileUpload = $_FILES['fileUpload'];
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:32,代码来源:SmileyAddForm.class.php


注:本文中的wcf\util\FileUtil::removeLeadingSlash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。