本文整理汇总了PHP中FileUtil::getRealPath方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::getRealPath方法的具体用法?PHP FileUtil::getRealPath怎么用?PHP FileUtil::getRealPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::getRealPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLoggable
/**
* Get the loggable with the given name.
*
* @param string $loggableName
*
* @return Loggable
* @throws SystemException
*/
public static function getLoggable($loggableName)
{
if (self::$loggablesData == null) {
self::loadLoggables();
}
if (!isset(self::$loggables[$loggableName])) {
if (!isset(self::$loggablesData[$loggableName])) {
throw new SystemException("Unable to find loggable '" . $loggableName . "'");
}
$loggableData = self::$loggablesData[$loggableName];
// calculate class path
$path = '';
if (empty($loggableData['packageDir'])) {
$path = WCF_DIR;
} else {
$path = FileUtil::getRealPath(WCF_DIR . $loggableData['packageDir']);
}
// include class file
if (!file_exists($path . $loggableData['classPath'])) {
throw new SystemException("Unable to find class file '" . $path . $loggableData['classPath'] . "'");
}
require_once $path . $loggableData['classPath'];
// create instance
$className = StringUtil::getClassName($loggableData['classPath']);
if (!class_exists($className)) {
throw new SystemException("Unable to find class '" . $className . "'");
}
self::$loggables[$loggableName] = new $className(null, $loggableData);
// save memory ;)
unset(self::$loggablesData[$loggableName]);
}
return self::$loggables[$loggableName];
}
示例2: loadSearchTypeObjects
/**
* Loads the search type objects.
*/
public static function loadSearchTypeObjects()
{
if (self::$searchTypeObjects !== null) {
return;
}
// get cache
WCF::getCache()->addResource('searchableMessageTypes-' . PACKAGE_ID, WCF_DIR . 'cache/cache.searchableMessageTypes-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderSearchableMessageType.class.php');
self::$searchTypeData = WCF::getCache()->get('searchableMessageTypes-' . PACKAGE_ID);
// get objects
self::$searchTypeObjects = array();
foreach (self::$searchTypeData as $type) {
// calculate class path
$path = '';
if (empty($type['packageDir'])) {
$path = WCF_DIR;
} else {
$path = FileUtil::getRealPath(WCF_DIR . $type['packageDir']);
}
// include class file
if (!file_exists($path . $type['classPath'])) {
throw new SystemException("unable to find class file '" . $path . $type['classPath'] . "'", 11000);
}
require_once $path . $type['classPath'];
// create instance
$className = StringUtil::getClassName($type['classPath']);
if (!class_exists($className)) {
throw new SystemException("unable to find class '" . $className . "'", 11001);
}
self::$searchTypeObjects[$type['typeName']] = new $className();
}
}
示例3: validate
/**
* @see Form::validate()
*/
public function validate()
{
parent::validate();
// validate class path
if (empty($this->classPath)) {
throw new UserInputException('classPath');
}
try {
$package = new Package($this->packageID);
if (!@file_exists(FileUtil::getRealPath(WCF_DIR . $package->getDir() . $this->classPath))) {
throw new UserInputException('classPath', 'doesNotExist');
}
} catch (SystemException $e) {
throw new UserInputException('classPath', 'doesNotExist');
}
try {
CronjobEditor::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
} catch (SystemException $e) {
// extract field name
$fieldName = '';
if (preg_match("/cronjob attribute '(.*)'/", $e->getMessage(), $match)) {
$fieldName = $match[1];
}
throw new UserInputException($fieldName, 'notValid');
}
}
示例4: readData
/**
* @see Page::readData()
*/
public function readData()
{
AbstractForm::readData();
if (!count($_POST)) {
if (isset($_GET['values']) && is_array($_GET['values'])) {
$this->values = $_GET['values'];
$this->submit();
}
}
// get path to category icons
foreach ($this->cachedCategories as $key => $category) {
// add icon path
if (!empty($category['categoryIconM'])) {
// get relative path
$path = '';
if (empty($category['packageDir'])) {
$path = RELATIVE_WCF_DIR;
} else {
$path = FileUtil::getRealPath(RELATIVE_WCF_DIR . $category['packageDir']);
}
$this->cachedCategories[$key]['categoryIconM'] = $path . $category['categoryIconM'];
}
}
// get categories
$this->categories = $this->getOptionTree('profile');
if (count($this->categories) == 0) {
$this->options = $this->getCategoryOptions('profile');
}
// insert default values
foreach ($this->activeOptions as $name => $option) {
if (isset($this->values[$name])) {
$this->activeOptions[$name]['optionValue'] = $this->values[$name];
}
}
}
示例5: getOptionTree
/**
* Returns the tree of options.
*
* @return array
*/
public function getOptionTree($parentCategoryName = '', User $user)
{
$options = array();
if (isset($this->categoryStructure[$parentCategoryName])) {
// get super categories
foreach ($this->categoryStructure[$parentCategoryName] as $superCategoryName) {
$superCategory = $this->categories[$superCategoryName];
// add icon path
if (!empty($superCategory['categoryIconM'])) {
// get relative path
$path = '';
if (empty($superCategory['packageDir'])) {
$path = RELATIVE_WCF_DIR;
} else {
$path = FileUtil::getRealPath(RELATIVE_WCF_DIR . $superCategory['packageDir']);
}
$superCategory['categoryIconM'] = $path . $superCategory['categoryIconM'];
}
$superCategory['options'] = $this->getCategoryOptions($superCategoryName, $user);
if (count($superCategory['options']) > 0) {
$options[$superCategoryName] = $superCategory;
}
}
}
return $options;
}
示例6: getAvailableSuspensionTypes
/**
* Returns a list of available suspension types.
*
* @return array<SuspensionType>
*/
public static function getAvailableSuspensionTypes()
{
if (self::$availableSuspensionTypes === null) {
WCF::getCache()->addResource('suspensionTypes-' . PACKAGE_ID, WCF_DIR . 'cache/cache.suspensionTypes-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderSuspensionTypes.class.php');
$types = WCF::getCache()->get('suspensionTypes-' . PACKAGE_ID);
foreach ($types as $type) {
// get path to class file
if (empty($type['packageDir'])) {
$path = WCF_DIR;
} else {
$path = FileUtil::getRealPath(WCF_DIR . $type['packageDir']);
}
$path .= $type['classFile'];
// include class file
if (!class_exists($type['className'])) {
if (!file_exists($path)) {
throw new SystemException("Unable to find class file '" . $path . "'", 11000);
}
require_once $path;
}
// instance object
if (!class_exists($type['className'])) {
throw new SystemException("Unable to find class '" . $type['className'] . "'", 11001);
}
self::$availableSuspensionTypes[$type['suspensionType']] = new $type['className']();
}
}
return self::$availableSuspensionTypes;
}
示例7: readDiskInfo
/**
* Reads the disk quota info
*
* @param integer $pow
* @param integer $dec
* @return array
*/
public static function readDiskInfo($pow = 2, $dec = 2)
{
$diskInformation = array();
if (function_exists('disk_free_space') && function_exists('disk_total_space')) {
$root = '';
if ($tmp = @disk_total_space($_SERVER["DOCUMENT_ROOT"])) {
$root = $_SERVER["DOCUMENT_ROOT"];
} else {
$sql = "SELECT packageDir FROM wcf" . WCF_N . "_package\n \t\t\tWHERE packageID = " . PACKAGE_ID;
$row = WCF::getDB()->getFirstRow($sql);
$root = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
}
if (!empty($root)) {
$diskInformation['totalSpace'] = round(disk_total_space($root) / pow(1024, $pow), $dec);
$diskInformation['freeSpace'] = round(disk_free_space($root) / pow(1024, $pow), $dec);
$diskInformation['usedSpace'] = round($diskInformation['totalSpace'] - $diskInformation['freeSpace'], $dec);
if ($diskInformation['totalSpace'] > 0) {
$diskInformation['freeQuota'] = round($diskInformation['freeSpace'] * 100 / $diskInformation['totalSpace'], $dec);
$diskInformation['usedQuota'] = round($diskInformation['usedSpace'] * 100 / $diskInformation['totalSpace'], $dec);
} else {
$diskInformation['freeQuota'] = $diskInformation['usedQuota'] = 0;
}
}
}
return $diskInformation;
}
示例8: parseMenuItems
/**
* Parses the menu items.
*/
protected function parseMenuItems()
{
foreach ($this->menuItems as $parentMenuItem => $items) {
foreach ($items as $key => $item) {
if (!empty($item['menuItemLink']) || !empty($item['menuItemIcon'])) {
// get relative path
$path = '';
if (empty($item['packageDir'])) {
$path = RELATIVE_WCF_DIR;
} else {
$path = FileUtil::getRealPath(RELATIVE_WCF_DIR . $item['packageDir']);
}
// add package id and session id to link
if (!empty($item['menuItemLink'])) {
$item['menuItemLink'] = $this->parseMenuItemLink($item['menuItemLink'], $path);
}
if (!empty($item['menuItemIcon'])) {
$item['menuItemIcon'] = $this->parseMenuItemIcon($item['menuItemIcon'], $path);
}
$this->menuItems[$parentMenuItem][$key] = $item;
}
$this->menuItemList[$item['menuItem']] =& $this->menuItems[$parentMenuItem][$key];
}
}
}
示例9: loadTaggables
/**
* Loads the taggable objects.
*/
protected function loadTaggables()
{
if ($this->taggables !== null) {
return;
}
// get cache
WCF::getCache()->addResource('taggables-' . PACKAGE_ID, WCF_DIR . 'cache/cache.taggables-' . PACKAGE_ID . '.php', WCF_DIR . 'lib/system/cache/CacheBuilderTaggable.class.php');
$this->taggablesData = WCF::getCache()->get('taggables-' . PACKAGE_ID);
// get objects
$this->taggables = array();
foreach ($this->taggablesData as $type) {
// calculate class path
$path = '';
if (empty($type['packageDir'])) {
$path = WCF_DIR;
} else {
$path = FileUtil::getRealPath(WCF_DIR . $type['packageDir']);
}
// include class file
if (!file_exists($path . $type['classPath'])) {
throw new SystemException("unable to find class file '" . $path . $type['classPath'] . "'", 11000);
}
require_once $path . $type['classPath'];
// create instance
$className = StringUtil::getClassName($type['classPath']);
if (!class_exists($className)) {
throw new SystemException("unable to find class '" . $className . "'", 11001);
}
$this->taggables[$type['taggableID']] = new $className($type['taggableID'], $type['name']);
}
}
示例10: deleteFolders
/**
* Deletes the folders of this template pack.
*/
public function deleteFolders()
{
// default template dir
$folders = array(WCF_DIR . 'templates/' . $this->templatePackFolderName);
// get package dirs
$sql = "SELECT\tpackageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tpackageDir <> ''";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
$folders[] = $packageDir . 'templates/' . $this->templatePackFolderName;
}
// rename folders
foreach ($folders as $folder) {
if (file_exists($folder)) {
// empty folder
$files = glob(FileUtil::addTrailingSlash($folder) . '*');
if (is_array($files)) {
foreach ($files as $file) {
@unlink($file);
}
}
// delete foler
@rmdir($folder);
}
}
}
示例11: getLocationObject
/**
* Returns a object of a location class.
*
* @param array $location
* @param Location
*/
protected function getLocationObject($location)
{
if (!isset($this->locationObjects[$location['locationName']])) {
// get path
$path = '';
if (empty($location['packageDir'])) {
$path = WCF_DIR;
} else {
$path = FileUtil::getRealPath(WCF_DIR . $location['packageDir']);
}
require_once $path . $location['classPath'];
$this->locationObjects[$location['locationName']] = new $location['className']();
}
return $this->locationObjects[$location['locationName']];
}
示例12: 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']);
}
}
}
}
}
示例13: install
/**
* Runs a script.
*/
public function install()
{
parent::install();
// get installation path of package
$sql = "SELECT\tpackageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID();
$packageDir = WCF::getDB()->getFirstRow($sql);
$packageDir = $packageDir['packageDir'];
// get relative path of script
$scriptTag = $this->installation->getXMLTag('script');
$path = FileUtil::getRealPath(WCF_DIR . $packageDir);
// run script
$this->run($path . $scriptTag['cdata']);
// delete script
if (@unlink($path . $scriptTag['cdata'])) {
// delete file log entry
$sql = "DELETE FROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t\tWHERE\t\tpackageID = " . $this->installation->getPackageID() . "\n\t\t\t\t\t\tAND filename = '" . escapeString($scriptTag['cdata']) . "'";
WCF::getDB()->sendQuery($sql);
}
}
示例14: 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();
}
}
示例15: getData
/**
* @see CacheBuilder::getData()
*/
public function getData($cacheResource)
{
list($cache, $packageID, $styleID) = explode('-', $cacheResource['cache']);
$data = array();
// get active package
require_once WCF_DIR . 'lib/acp/package/Package.class.php';
$activePackage = new Package($packageID);
$activePackageDir = FileUtil::getRealPath(WCF_DIR . $activePackage->getDir());
// get package dirs
$packageDirs = array();
$sql = "SELECT\t\tDISTINCT packageDir\r\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency dependency\r\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\r\n\t\t\tON\t\t(package.packageID = dependency.dependency)\r\n\t\t\tWHERE\t\tdependency.packageID = " . $packageID . "\r\n\t\t\t\t\tAND packageDir <> ''\r\n\t\t\tORDER BY\tpriority DESC";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$packageDirs[] = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
}
$packageDirs[] = WCF_DIR;
// get style icon path
$iconDirs = array();
$sql = "SELECT\tvariableValue\r\n\t\t\tFROM\twcf" . WCF_N . "_style_variable\r\n\t\t\tWHERE\tstyleID = " . $styleID . "\r\n\t\t\t\tAND variableName = 'global.icons.location'";
$row = WCF::getDB()->getFirstRow($sql);
if (!empty($row['variableValue'])) {
$iconDirs[] = FileUtil::addTrailingSlash($row['variableValue']);
}
if (!in_array('icon/', $iconDirs)) {
$iconDirs[] = 'icon/';
}
// get icons
foreach ($packageDirs as $packageDir) {
$relativePackageDir = $activePackageDir != $packageDir ? FileUtil::getRelativePath($activePackageDir, $packageDir) : '';
foreach ($iconDirs as $iconDir) {
$path = FileUtil::addTrailingSlash($packageDir . $iconDir);
$icons = self::getIconFiles($path);
foreach ($icons as $icon) {
$icon = str_replace($path, '', $icon);
if (!isset($data[$icon])) {
$data[$icon] = $relativePackageDir . $iconDir . $icon;
}
}
}
}
return $data;
}