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


PHP FileUtil::removeLeadingSlash方法代码示例

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


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

示例1: promptPackageDir

 /**
  * Prompts for installation directory.
  *
  * @return	string		package dir
  */
 protected function promptPackageDir()
 {
     $packageDir = $errorField = $errorType = '';
     if (isset($_POST['send'])) {
         if (isset($_POST['packageDir'])) {
             $packageDir = StringUtil::trim($_POST['packageDir']);
         }
         // error handling
         try {
             $dir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator($packageDir));
             // package can not be installed into the wcf directory
             if (FileUtil::unifyDirSeperator(WCF_DIR) == $dir) {
                 throw new UserInputException('packageDir', 'wcfDirLocked');
             }
             // this package is a standalone package and needs its own package directory
             $relativePackageDir = FileUtil::getRelativePath(WCF_DIR, $dir);
             $sql = "SELECT \tCOUNT(*) AS count\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\t\tWHERE\tpackageDir = '" . escapeString($relativePackageDir) . "'";
             $alreadyInstalled = WCF::getDB()->getFirstRow($sql);
             if ($alreadyInstalled['count'] > 0) {
                 throw new UserInputException('packageDir', 'alreadyInstalled');
             }
             // check writing property
             if (@file_exists($dir) && !@is_writable($dir)) {
                 throw new UserInputException('packageDir', 'notWritable');
             }
             return $relativePackageDir;
         } catch (UserInputException $e) {
             $errorField = $e->getField();
             $errorType = $e->getType();
         }
     } else {
         // make default dir
         //$packageNameParts = explode('.', $this->installation->getPackage()->getPackage());
         //$packageDir = FileUtil::getRealPath(WCF_DIR.'../'.$packageNameParts[count($packageNameParts) - 1]);
         $packageDir = FileUtil::getRealPath(WCF_DIR . '../');
     }
     // 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'];
     }
     // wcf url
     $wcfUrl = '';
     if (!empty($_SERVER['REQUEST_URI'])) {
         $wcfUrl = FileUtil::removeTrailingSlash(FileUtil::getRealPath(FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash(dirname($_SERVER['REQUEST_URI']))) . '/' . RELATIVE_WCF_DIR));
     }
     WCF::getTPL()->assign(array('packageDir' => $packageDir, 'errorField' => $errorField, 'errorType' => $errorType, 'domainName' => $domainName, 'wcfUrl' => $wcfUrl, 'wcfDir' => FileUtil::unifyDirSeperator(WCF_DIR)));
     WCF::getTPL()->display('packageInstallationPromptPackageDir');
     exit;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:59,代码来源:FilesPackageInstallationPlugin.class.php

示例2: writeDummyFile

 /**
  * Writes a dummy file in the selected ftp directory.
  * Returns the file of the dummy file or null on failure.
  * 
  * @param 	FTP 		$ftp
  * @return	string		$filename
  */
 protected static function writeDummyFile(FTP $ftp)
 {
     $dummyUploadFile = FileUtil::getTemporaryFilename('ftpDummy_', '.dat');
     @touch($dummyUploadFile);
     $destFile = FileUtil::removeLeadingSlash(strrchr($dummyUploadFile, '/'));
     if (@(!$ftp->put($destFile, $dummyUploadFile, FTP_ASCII))) {
         @unlink($dummyUploadFile);
         return null;
     }
     @unlink($dummyUploadFile);
     return $destFile;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:19,代码来源:FTPUtil.class.php

示例3: 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))) . '/');
         } 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:joaocustodio,项目名称:EmuDevstore-1,代码行数:32,代码来源:WCFSetup.class.php

示例4: install

 /**
  * Starts the extracting of the files.
  */
 protected function install()
 {
     $this->checkTargetDir();
     $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) || StringUtil::indexOf($file['filename'], $this->folder) === 0) {
             if (!empty($this->folder)) {
                 $file['filename'] = StringUtil::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[] = array('file' => $dir, 'code' => $e->getCode(), 'message' => $e->getMessage());
         }
     }
     // now untar all files
     foreach ($files as $index => $file) {
         try {
             $this->createFile($file, $index, $tar);
         } catch (SystemException $e) {
             $errors[] = array('file' => $file, 'code' => $e->getCode(), 'message' => $e->getMessage());
         }
     }
     if (count($errors) > 0) {
         throw new SystemException('error(s) during the installation of the files.', 11111, $errors);
     }
     $this->logFiles($files);
     // close tar
     $tar->close();
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:52,代码来源:Installer.class.php


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