本文整理汇总了PHP中FileUtil::addTrailingSlash方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::addTrailingSlash方法的具体用法?PHP FileUtil::addTrailingSlash怎么用?PHP FileUtil::addTrailingSlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::addTrailingSlash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new Installer object.
*
* @param string $targetDir extract the files in this dir
* @param string $source name of the source tar archive
* @param FileHandler $fileHandler
* @param string $folder extract only the files from this subfolder
*/
public function __construct($targetDir, $source, $fileHandler = null, $folder = '')
{
$this->targetDir = FileUtil::addTrailingSlash($targetDir);
$this->source = $source;
$this->folder = $folder;
$this->fileHandler = $fileHandler;
$this->install();
}
示例2: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['templatePackName'])) {
$this->templatePackName = StringUtil::trim($_POST['templatePackName']);
}
if (isset($_POST['templatePackFolderName'])) {
$this->templatePackFolderName = StringUtil::trim($_POST['templatePackFolderName']);
}
if (!empty($this->templatePackFolderName)) {
$this->templatePackFolderName = FileUtil::addTrailingSlash($this->templatePackFolderName);
}
if (isset($_POST['parentTemplatePackID'])) {
$this->parentTemplatePackID = intval($_POST['parentTemplatePackID']);
}
}
示例3: execute
/**
* @see EventListener::execute()
*/
public function execute($eventObj, $className, $eventName) {
if (!MODULE_ROUTER) return;
// get base
$segments = explode('/', FileUtil::addTrailingSlash(PAGE_URL), 4);
if (!empty($segments[3])) $this->base .= $segments[3];
// load routes
WCF::getCache()->addResource(
'routes-'.PACKAGE_ID,
WCF_DIR.'cache/cache.routes-'.PACKAGE_ID.'.php',
WCF_DIR.'lib/system/cache/CacheBuilderRoutes.class.php'
);
$this->routes = WCF::getCache()->get('routes-'.PACKAGE_ID);
ob_start(array($this, 'rewrite'));
}
示例4: getHeadRevision
/**
* @see SCM::getHeadRevision()
*/
public static function getHeadRevision($url, array $loginDetails = array(), array $options = array())
{
try {
self::validateGitPath();
// not very nice or fast method to find out, but it should work
self::checkout($url, GIT_TEMPORARY_DIRECTORY, $loginDetails, $options);
$dir = explode('/', $url);
$dir = str_replace('.git', '', $dir[count($dir) - 1]);
$headdir = explode(" ", file_get_contents(FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(GIT_TEMPORARY_DIRECTORY)) . $dir . '/.git/HEAD'));
$return = file_get_contents(FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(GIT_TEMPORARY_DIRECTORY)) . $dir . '/.git/' . trim($headdir[1]));
$dir = DirectoryUtil::getInstance(FileUtil::addTrailingSlash(GIT_TEMPORARY_DIRECTORY) . $dir);
$dir->removeComplete();
return $return;
} catch (GitException $e) {
throw $e;
} catch (SystemException $e) {
}
}
示例5: resetFile
/**
* Deletes relevant options.inc.php's
*
* @param array<integer> $packageIDArray
*/
public static function resetFile($packageIDArray = PACKAGE_ID)
{
if (!is_array($packageIDArray)) {
$packageIDArray = array($packageIDArray);
}
$sql = "SELECT\t\tpackage.packageID, package.packageDir\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = package_dependency.packageID)\n\t\t\tWHERE\t\tpackage_dependency.dependency IN (" . implode(',', $packageIDArray) . ")\n\t\t\t\t\tAND package.standalone = 1\n\t\t\t\t\tAND package.package <> 'com.woltlab.wcf'\n\t\t\tGROUP BY \tpackage.packageID";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$filename = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $row['packageDir'])) . self::FILENAME;
if (file_exists($filename)) {
if (!@touch($filename, 1)) {
if (!@unlink($filename)) {
self::rebuildFile($filename, $row['packageID']);
}
}
}
}
}
示例6: uninstall
/**
* Uninstalls the templates of this package.
*/
public function uninstall()
{
// create templates list
$templates = array();
// get templates from log
$sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_template\n\t\t\tWHERE \tpackageID = " . $this->installation->getPackageID();
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$files[] = 'templates/' . $row['templateName'] . '.tpl';
}
if (count($files) > 0) {
// delete template files
$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->getDir()));
$deleteEmptyDirectories = $this->installation->getPackage()->isStandalone();
$this->installation->deleteFiles($packageDir, $files, false, $deleteEmptyDirectories);
// delete log entries
parent::uninstall();
}
}
示例7: readParameters
/**
* @see Page::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (isset($_REQUEST['userID'])) {
$this->userID = intval($_REQUEST['userID']);
}
require_once WCF_DIR . 'lib/data/user/UserProfile.class.php';
$this->user = new UserProfile($this->userID, null, null, null);
if (!$this->user->userID) {
require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
throw new IllegalLinkException();
}
// Löschen
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
if ($this->user->userID != WCF::getUser()->userID && !WCF::getUser()->getPermission('mod.wantedPoster.canDeleteEntries')) {
require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
throw new PermissionDeniedException();
} else {
$uwp = new UserWantedPosterData($this->userID);
$uwp->deleteEntry($_REQUEST['userID']);
// forward
header('Location: ' . FileUtil::addTrailingSlash(dirname(WCF::getSession()->requestURI)) . 'index.php?page=UserWantedPosterList' . SID_ARG_2ND_NOT_ENCODED);
exit;
}
} else {
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'lock' || $_REQUEST['action'] == 'unlock')) {
if (!WCF::getUser()->getPermission('mod.wantedPoster.canLockEntries')) {
require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
throw new PermissionDeniedException();
} else {
$uwp = new UserWantedPosterData($this->userID);
if ($_REQUEST['action'] == 'lock') {
$uwp->lockEntry($_REQUEST['userID']);
} else {
$uwp->unlockEntry($_REQUEST['userID']);
}
// forward
header('Location: ' . FileUtil::addTrailingSlash(dirname(WCF::getSession()->requestURI)) . 'index.php?page=UserWantedPosterList' . SID_ARG_2ND_NOT_ENCODED);
exit;
}
}
}
}
示例8: readData
/**
* @see Page::readData()
*/
public function readData()
{
parent::readData();
// validate
if (!is_dir(CMS_DIR . 'cms_files/') or !is_readable(CMS_DIR . 'cms_files')) {
throw new NamedUserException(WCF::getLanguage()->get('cms.filemanager.invalidDir'));
}
$directory = DirectoryUtil::getInstance(CMS_DIR . 'cms_files/');
$this->fileList = $directory->getFilesObj();
foreach ($this->fileList as $fileInfo) {
if ($fileInfo->isDir()) {
$this->dirObjects[$fileInfo->getPathname()] = new RecursiveDirectoryIterator(FileUtil::addTrailingSlash($fileInfo->getPathname()));
}
}
print_r($this->dirObjects);
// display warning if no htaccess file exists
if (!file_exists(CMS_DIR . 'cms_files/.htaccess')) {
WCF::getTPL()->assign('displayNoHtaccessWarning');
}
}
示例9: execute
/**
* @see EventListener::execute()
*/
public function execute($eventObj, $className, $eventName) {
if (!MODULE_ROUTER) return;
// get base
$segments = explode('/', FileUtil::addTrailingSlash(PAGE_URL), 4);
if (!empty($segments[3])) $this->base .= $segments[3];
// load routes
WCF::getCache()->addResource(
'routes-'.PACKAGE_ID,
WCF_DIR.'cache/cache.routes-'.PACKAGE_ID.'.php',
WCF_DIR.'lib/system/cache/CacheBuilderRoutes.class.php'
);
$this->routes = WCF::getCache()->get('routes-'.PACKAGE_ID);
// get request
$request = $_SERVER['REQUEST_URI'];
$_ = explode($this->base, $request, 2);
$request = $_[count($_)-1];
if (StringUtil::indexOf($request, 'index.php') === 0)
return false;
// get route which suits best for the request
if (!$route = $this->getRouteByRequest($request))
throw new SystemException('No route');
// set variables
foreach ($route[0][1] as $isset) {
if (!isset($route[0][2][$isset]) && isset($route[1][$isset])) {
$_GET[$isset] = $route[1][$isset];
$_REQUEST[$isset] = $route[1][$isset];
}
}
// set predefined variables
foreach ($route[0][2] as $key => $value) {
$_GET[$key] = $value;
$_REQUEST[$key] = $value;
}
}
示例10: getIconFiles
protected static function getIconFiles($path)
{
$files = array();
if (is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($path . $file)) {
$files = array_merge($files, self::getIconFiles(FileUtil::addTrailingSlash($path . $file)));
} else {
if (preg_match('/\\.png$/', $file)) {
$files[] = $path . $file;
}
}
}
closedir($dh);
}
}
return $files;
}
示例11: readFormParameters
/**
* @see Form::readFormParameters()
*/
public function readFormParameters()
{
parent::readFormParameters();
if (isset($_POST['name'])) {
$this->name = StringUtil::trim($_POST['name']);
}
if (isset($_POST['sourceDirectory'])) {
$this->sourceDirectory = StringUtil::trim($_POST['sourceDirectory']);
}
$this->sourceDirectory = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator($this->sourceDirectory));
if (isset($_POST['buildDirectory'])) {
$this->buildDirectory = StringUtil::trim($_POST['buildDirectory']);
}
$this->buildDirectory = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator($this->buildDirectory));
if (isset($_POST['position'])) {
$this->position = intval($_POST['position']);
}
if (isset($_POST['scm'])) {
$this->scm = StringUtil::trim($_POST['scm']);
}
if (isset($_POST['useSubversion'])) {
$this->useSubversion = intval($_POST['useSubversion']);
}
if (isset($_POST['url'])) {
$this->url = StringUtil::trim($_POST['url']);
}
if (isset($_POST['username'])) {
$this->username = StringUtil::trim($_POST['username']);
}
if (isset($_POST['password'])) {
$this->password = StringUtil::trim($_POST['password']);
}
if (isset($_POST['trustServerCert'])) {
$this->trustServerCert = intval($_POST['trustServerCert']);
}
if (isset($_POST['enableCheckout'])) {
$this->enableCheckout = intval($_POST['enableCheckout']);
}
}
示例12: validate
/**
* Validate Settings
*
* @return true
*/
public function validate()
{
parent::validate();
// set table prefix
$this->settings['tablePrefix'] = $this->settings['tablePrefix'];
try {
$this->getDB()->sendQuery("SELECT COUNT(*) FROM " . $this->dbPrefix . $this->settings['tablePrefix'] . "pfpost");
} catch (Exception $e) {
throw new UserInputException('tablePrefix', 'invalid');
}
// source path
$tmpPath = FileUtil::addTrailingSlash($this->settings['sourcePath']);
if ($this->data['avatars']) {
if (!@file_exists($tmpPath . 'moderate.php')) {
$tmpPath = FileUtil::addTrailingSlash(dirname($tmpPath));
if (!@file_exists($tmpPath . 'moderate.php')) {
throw new UserInputException('sourcePath', 'invalid');
}
}
}
$this->settings['sourcePath'] = $tmpPath;
return true;
}
示例13: __construct
/**
* @param mixed $source
* @param string $file
* @param boolean $readArchive
* @param boolean $readReferencedPackages
*/
public function __construct($source, $file, $readArchive = false, $readReferencedPackages = true)
{
if ($source instanceof Source) {
$this->source = $source;
} else {
if ($source === null) {
throw new SystemException('No source given.');
}
$source = intval($source);
// check if a sourceID is given
if ($source) {
$this->source = new Source($source);
} else {
if (!$readArchive) {
throw new SystemException('Missing sourceID');
}
}
}
$this->file = StringUtil::trim($file);
if ($readArchive) {
// extract package.xml from archive
$this->readArchive();
// there is no need to read optional or required packages
$this->skipPackages = true;
} else {
if (!$readReferencedPackages) {
$this->skipPackages = true;
}
$this->file = FileUtil::getRealPath(FileUtil::addTrailingSlash($this->source->sourceDirectory . $this->file)) . 'package.xml';
if (!file_exists($this->file) || !is_readable($this->file)) {
throw new SystemException('package.xml missing in ' . str_replace('package.xml', '', $this->file) . '.');
}
}
// read package information
$this->readPackageXml($readArchive);
}
示例14: clear
/**
* @see CacheSource::clear()
*/
public function clear($directory, $filepattern, $forceDelete = false)
{
$this->loadLog();
$pattern = preg_quote(FileUtil::addTrailingSlash($directory), '%') . str_replace('*', '.*', str_replace('.', '\\.', $filepattern));
foreach ($this->cacheResources as $cacheResource) {
if (preg_match('%^' . $pattern . '$%i', $cacheResource)) {
$this->getAdapter()->getMemcache()->delete($cacheResource);
$this->removeFromLog($cacheResource);
}
}
}
示例15: export
/**
* Exports this style.
*
* @param boolean $templates
* @param boolean $images
* @param boolean $icons
*/
public function export($templates = false, $images = false, $icons = false)
{
// create style tar
require_once WCF_DIR . 'lib/system/io/TarWriter.class.php';
$styleTarName = FileUtil::getTemporaryFilename('style_', '.tgz');
$styleTar = new TarWriter($styleTarName, true);
// append style preview image
if ($this->image && @file_exists(WCF_DIR . $this->image)) {
$styleTar->add(WCF_DIR . $this->image, '', FileUtil::addTrailingSlash(dirname(WCF_DIR . $this->image)));
}
// create style info file
$string = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE style SYSTEM \"http://www.woltlab.com/DTDs/SXF/style.dtd\">\n<style>\n";
// general block
$string .= "\t<general>\n";
$string .= "\t\t<stylename><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleName) : $this->styleName) . "]]></stylename>\n";
// style name
if ($this->styleDescription) {
$string .= "\t\t<description><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleDescription) : $this->styleDescription) . "]]></description>\n";
}
// style description
if ($this->styleVersion) {
$string .= "\t\t<version><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleVersion) : $this->styleVersion) . "]]></version>\n";
}
// style version
if ($this->styleDate) {
$string .= "\t\t<date><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleDate) : $this->styleDate) . "]]></date>\n";
}
// style date
if ($this->image) {
$string .= "\t\t<image><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', basename($this->image)) : basename($this->image)) . "]]></image>\n";
}
// style preview image
if ($this->copyright) {
$string .= "\t\t<copyright><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->copyright) : $this->copyright) . "]]></copyright>\n";
}
// copyright
if ($this->license) {
$string .= "\t\t<license><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->license) : $this->license) . "]]></license>\n";
}
// license
$string .= "\t</general>\n";
// author block
$string .= "\t<author>\n";
if ($this->authorName) {
$string .= "\t\t<authorname><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->authorName) : $this->authorName) . "]]></authorname>\n";
}
// author name
if ($this->authorURL) {
$string .= "\t\t<authorurl><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->authorURL) : $this->authorURL) . "]]></authorurl>\n";
}
// author URL
$string .= "\t</author>\n";
// files block
$string .= "\t<files>\n";
$string .= "\t\t<variables>variables.xml</variables>\n";
// variables
if ($templates && $this->templatePackID) {
$string .= "\t\t<templates>templates.tar</templates>\n";
}
// templates
if ($images) {
$string .= "\t\t<images>images.tar</images>\n";
}
// images
if ($icons) {
$string .= "\t\t<icons>icons.tar</icons>\n";
}
// icons
$string .= "\t</files>\n";
$string .= "</style>";
// append style info file to style tar
$styleTar->addString(self::INFO_FILE, $string);
unset($string);
// create variable list
$string = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE variables SYSTEM \"http://www.woltlab.com/DTDs/SXF/variables.dtd\">\n<variables>\n";
// get variables
$variables = $this->getVariables();
$exportImages = array();
foreach ($variables as $name => $value) {
// search images
if ($images && $value) {
if (preg_match_all('~([^/\\s\\$]+\\.(?:gif|jpg|jpeg|png))~i', $value, $matches)) {
$exportImages = array_merge($exportImages, $matches[1]);
}
}
$string .= "\t<variable name=\"" . StringUtil::encodeHTML($name) . "\"><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $value) : $value) . "]]></variable>\n";
}
$string .= "</variables>";
// append variable list to style tar
$styleTar->addString('variables.xml', $string);
unset($string);
if ($templates && $this->templatePackID) {
require_once WCF_DIR . 'lib/data/template/TemplatePack.class.php';
//.........这里部分代码省略.........