本文整理汇总了PHP中Wind::getRootPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Wind::getRootPath方法的具体用法?PHP Wind::getRootPath怎么用?PHP Wind::getRootPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wind
的用法示例。
在下文中一共展示了Wind::getRootPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sortFile
private function sortFile($file)
{
$directory = $this->_getDefaultDirectory();
$sort = array('HTML', 'ATTACH', 'TPL', 'THEMES', 'ACLOUD', 'WINDID', 'REP', 'SRV', 'LIB', 'HOOK', 'EXT', 'APPS', 'CONF', 'DATA', 'SRC', 'PUBLIC');
$strtr = array();
$localDirectory = @(include Wind::getRealPath('CONF:directory.php', true));
foreach ($sort as $v) {
if ($directory[$v] == $localDirectory[$v]) {
continue;
}
$search = PwSystemHelper::relative(WEKIT_PATH . $directory[$v]);
$strtr[$search] = Wind::getRootPath($v);
}
$_file = ROOT_PATH . $file;
foreach ($strtr as $search => $replace) {
if (0 === strpos($_file, $search)) {
$file = str_replace(ROOT_PATH, '', $replace . substr($_file, strlen($search)));
break;
}
}
return $file;
}
示例2: sortDirectory
/**
* 根据现有目录结构调整升级包目录
*
* @param array $fileList
*/
public function sortDirectory($fileList)
{
$this->_log('start to sort the directory');
$sourceDir = $this->tmpPath . DIRECTORY_SEPARATOR . $this->target;
$directoryFile = $sourceDir . DIRECTORY_SEPARATOR . 'conf/directory.php';
$directory = @(include $directoryFile);
if (!is_array($directory)) {
return new PwError('APPCENTER:upgrade.directory.fail');
}
$this->_log('the remote directory is:' . var_export($directory, true));
$root = Wind::getRealDir('ROOT:');
$sort = array('TPL', 'THEMES', 'ACLOUD', 'WINDID', 'REP', 'SRV', 'LIB', 'HOOK', 'EXT', 'APPS', 'CONF', 'DATA', 'SRC', 'PUBLIC');
$strtr = array();
$localDirectory = @(include Wind::getRealPath('CONF:directory.php', true));
foreach ($sort as $v) {
if ($directory[$v] == $localDirectory[$v]) {
continue;
}
$search = PwSystemHelper::relative(WEKIT_PATH . str_replace('/', DIRECTORY_SEPARATOR, $directory[$v]));
$strtr[rtrim($search, '/\\')] = rtrim(Wind::getRootPath($v), '/\\');
}
$this->_log('way of moving directory' . var_export($strtr, true));
if (!($sourceMd5 = WindFile::read($sourceDir . DIRECTORY_SEPARATOR . 'conf/md5sum'))) {
return new PwError('APPCENTER:upgrade.target.hash.fail');
}
$sourceMd5 = PwSystemHelper::resolveMd5($sourceMd5);
// md5sum
$data = '';
foreach ($sourceMd5 as $v => $md5) {
$v = trim($v, '/');
$v = str_replace('/', DIRECTORY_SEPARATOR, $v);
$_v = ROOT_PATH . $v;
$file = $v;
foreach ($strtr as $search => $replace) {
if (0 === strpos($_v, $search)) {
$file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search)));
$file = str_replace('//', '/', $file);
break;
}
}
$data .= PwSystemHelper::md5content($md5, $file);
}
WindFile::write($sourceDir . DIRECTORY_SEPARATOR . 'conf/md5sum', $data);
$moveList = $newFileList = array();
$url = PwApplicationHelper::acloudUrl(array('a' => 'forward', 'do' => 'getVersionHash', 'pwversion' => $this->local));
/* 从线上获取当前版本的所有文件md5 */
/* $result = PwApplicationHelper::requestAcloudData($url);
if ($result['code'] !== '0' || !$result['info']) return new PwError(array('APPCENTER:upgrade.version.hash.fail', array($result['msg']))); */
if (!($tmp = WindFile::read(CONF_PATH . 'md5sum'))) {
return new PwError('APPCENTER:upgrade.hash.fail');
}
$md5List = PwSystemHelper::resolveMd5($tmp);
$this->_log('obtain the md5 list of current version');
foreach ($fileList as $v) {
$v = trim($v, '/');
$v = str_replace('/', DIRECTORY_SEPARATOR, $v);
$_v = $root . $v;
$file = $v;
foreach ($strtr as $search => $replace) {
if (0 === strpos($_v, $search)) {
$file = str_replace($root, '', $replace . substr($_v, strlen($search)));
$file = str_replace('//', '/', $file);
$moveList[$v] = $file;
break;
}
}
$newFileList[$file] = $md5List[str_replace(DIRECTORY_SEPARATOR, '/', $file)];
}
$this->_log('files need to move ' . var_export($moveList, true));
$relativePath_1 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH, Wind::getRealPath('SRC:wekit'));
$relativePath_2 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH . 'aCloud', Wind::getRealPath('SRC:wekit'));
foreach ($moveList as $old => $new) {
WindFolder::mkRecur(dirname($sourceDir . DIRECTORY_SEPARATOR . $new));
copy($sourceDir . DIRECTORY_SEPARATOR . $old, $sourceDir . DIRECTORY_SEPARATOR . $new);
WindFile::del($sourceDir . DIRECTORY_SEPARATOR . $old);
if ('.php' === substr($old, -4) && !strncasecmp($old, 'www' . DIRECTORY_SEPARATOR, 4)) {
$content = WindFile::read($sourceDir . DIRECTORY_SEPARATOR . $new);
if (strpos($content, '../../src/wekit.php')) {
$content = str_replace('../../src/wekit.php', $relativePath_2, $content);
} else {
$content = str_replace('../src/wekit.php', $relativePath_1, $content);
}
// $content = str_replace('../src/wekit.php',
// Wind::getRealPath('SRC:wekit'), $content);
WindFile::write($sourceDir . DIRECTORY_SEPARATOR . $new, $content);
}
}
// 目录文件
if ($directory != $localDirectory) {
$directory = array_merge($directory, $localDirectory);
$temp = "<?php\r\n defined('WEKIT_VERSION') or exit(403);\r\n return ";
$temp .= WindString::varToString($directory) . ";\r\n?>";
WindFile::write($directoryFile, $temp);
}
Wekit::cache()->set('system_upgrade_replace', 1);
//.........这里部分代码省略.........
示例3: _checkFileRight
/**
* 检查目录权限
*
* @return array
*/
private function _checkFileRight()
{
$rootdir = Wind::getRootPath('ROOT');
$files_writeble[] = CONF_PATH;
$files_writeble[] = DATA_PATH;
//数据缓存目录
$files_writeble[] = DATA_PATH . 'cache/';
$files_writeble[] = DATA_PATH . 'compile/';
$files_writeble[] = DATA_PATH . 'log/';
$files_writeble[] = DATA_PATH . 'tmp/';
$files_writeble[] = DATA_PATH . 'design/';
$files_writeble[] = EXT_PATH;
//扩展应用目录
$files_writeble[] = ATTACH_PATH;
//本地附近目录
$files_writeble[] = HTML_PATH;
//本地静态文件可写目录
$files_writeble[] = THEMES_PATH;
//风格目录
$files_writeble[] = THEMES_PATH . 'extres/';
$files_writeble[] = THEMES_PATH . 'forum/';
$files_writeble[] = THEMES_PATH . 'portal/';
$files_writeble[] = THEMES_PATH . 'site/';
$files_writeble[] = THEMES_PATH . 'space/';
$files_writeble[] = PUBLIC_PATH . 'windid/attachment/';
$files_writeble[] = $this->_getDatabaseFile();
$files_writeble[] = $this->_getFounderFile();
//$files_writeble[] = $this->_getWindidFile();
$files_writeble = array_unique($files_writeble);
sort($files_writeble);
$writable = array();
foreach ($files_writeble as $file) {
$key = str_replace($rootdir, '', $file);
$isWritable = $this->_checkWriteAble($file) ? true : false;
if ($isWritable) {
$flag = false;
foreach ($writable as $k => $v) {
if (0 === strpos($key, $k)) {
$flag = true;
}
}
$flag || ($writable[$key] = $isWritable);
} else {
$writable[$key] = $isWritable;
}
}
return $writable;
}
示例4: resolvedPath
/**
* 解析资源文件路径信息
*
* @param string $package
* @return string
*/
protected function resolvedPath($package)
{
$this->path || ($this->path = Wind::getRootPath(Wind::getAppName()));
$this->language || ($this->language = $this->getRequest()->getAcceptLanguage());
$path = $this->path . '/' . $this->language . '/' . strtolower($package);
$path = Wind::getRealDir(trim($path, '/'), true);
return $path;
}
示例5: _checkFileRight
/**
* 检查目录权限
*
* @return array
*/
private function _checkFileRight()
{
$rootdir = Wind::getRootPath('ROOT');
$files_writeble[] = CONF_PATH;
$files_writeble[] = DATA_PATH;
//数据缓存目录
$files_writeble[] = DATA_PATH . 'cache/';
$files_writeble[] = DATA_PATH . 'compile/';
$files_writeble[] = DATA_PATH . 'log/';
$files_writeble[] = DATA_PATH . 'tmp/';
$files_writeble[] = DATA_PATH . 'design/';
$files_writeble[] = EXT_PATH;
//扩展应用目录
$files_writeble[] = ATTACH_PATH;
//本地附近目录
$files_writeble[] = HTML_PATH;
//本地静态文件可写目录
$files_writeble[] = THEMES_PATH;
//风格目录
$files_writeble[] = THEMES_PATH . 'extres/';
$files_writeble[] = THEMES_PATH . 'forum/';
$files_writeble[] = THEMES_PATH . 'portal/';
$files_writeble[] = THEMES_PATH . 'site/';
$files_writeble[] = THEMES_PATH . 'space/';
$files_writeble[] = $this->_getDatabaseFile();
$files_writeble[] = $this->_getFounderFile();
$files_writeble[] = $this->_getWindidFile();
$files_writeble = array_unique($files_writeble);
sort($files_writeble);
$writable = array();
foreach ($files_writeble as $file) {
$key = str_replace($rootdir, '', $file);
$writable[$key] = $this->_checkWriteAble($file) ? true : false;
}
return $writable;
}