本文整理汇总了PHP中JoomlapackHelperUtils::TranslateWinPath方法的典型用法代码示例。如果您正苦于以下问题:PHP JoomlapackHelperUtils::TranslateWinPath方法的具体用法?PHP JoomlapackHelperUtils::TranslateWinPath怎么用?PHP JoomlapackHelperUtils::TranslateWinPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JoomlapackHelperUtils
的用法示例。
在下文中一共展示了JoomlapackHelperUtils::TranslateWinPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Implements the init method of JoomlapackFilter
*
*/
function init()
{
$jreg =& JFactory::getConfig();
$configuration =& JoomlapackModelRegistry::getInstance();
$this->_skipContainedDirectoriesFilter = array();
$temp = $this->_loadFilters();
if (DS == '\\') {
if (is_array($temp)) {
foreach ($temp as $filter) {
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TranslateWinPath(JPATH_SITE . DS . $filter);
}
}
} else {
if (is_array($temp)) {
foreach ($temp as $filter) {
$this->_skipContainedDirectoriesFilter[] = JPATH_SITE . DS . $filter;
}
}
}
// Add temporary and output directories
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JoomlapackHelperUtils::TranslateWinPath($configuration->get('OutputDirectory')));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JoomlapackHelperUtils::TranslateWinPath($configuration->getTemporaryDirectory()));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JoomlapackHelperUtils::TranslateWinPath($jreg->getValue('config.tmp_path')));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JoomlapackHelperUtils::TranslateWinPath(JPATH_CACHE));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JoomlapackHelperUtils::TranslateWinPath(JPATH_ADMINISTRATOR . DS . 'cache'));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JoomlapackHelperUtils::TranslateWinPath(JPATH_ROOT . DS . 'cache'));
// Hack: add the same paths untranslated
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash($configuration->get('OutputDirectory'));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash($configuration->getTemporaryDirectory());
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash($jreg->getValue('config.tmp_path'));
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JPATH_CACHE);
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JPATH_ADMINISTRATOR . DS . 'cache');
$this->_skipContainedDirectoriesFilter[] = JoomlapackHelperUtils::TrimTrailingSlash(JPATH_ROOT . DS . 'cache');
}
示例2: WriteLog
/**
* Writes a line to the log, if the log level is high enough
*
* @param int|bool $level The log level (_JP_LOG_XX constants). Use FALSE to pause logging, TRUE to resume logging
* @param string $message The message to write to the log
*/
function WriteLog($level, $message)
{
static $configuredLoglevel;
static $site_root;
if (empty($site_root)) {
if (!class_exists('JoomlapackHelperUtils')) {
jpimport('helpers.utils', true);
}
$site_root = JoomlapackHelperUtils::TranslateWinPath(JPATH_SITE);
}
if (empty($configuredLoglevel) or $level === true) {
// Load the registry
if (!class_exists('JoomlapackModelRegistry')) {
jpimport('models.registry', true);
}
$registry =& JoomlapackModelRegistry::getInstance();
// Fetch log level
$configuredLoglevel = $registry->get('logLevel');
}
if ($level === false) {
// Pause logging
$configuredLogLevel = false;
return;
}
// Catch paused logging
if ($configuredLoglevel === false) {
return;
}
if ($configuredLoglevel >= $level && $configuredLoglevel != 0) {
$logName = JoomlapackLogger::logName();
$message = str_replace(JPATH_SITE, "<root>", $message);
$message = str_replace($site_root, "<root>", $message);
// Fix 2.4 - Also replace the translated path on Windows machines
$message = str_replace("\n", ' \\n ', $message);
// Fix 1.1.1 - Handle (error) messages containing newlines (by nicholas)
switch ($level) {
case _JP_LOG_ERROR:
$string = "ERROR |";
break;
case _JP_LOG_WARNING:
$string = "WARNING |";
break;
case _JP_LOG_INFO:
$string = "INFO |";
break;
default:
$string = "DEBUG |";
break;
}
$string .= @strftime("%y%m%d %T") . "|{$message}\r\n";
$fp = @fopen($logName, "at");
if (!($fp === FALSE)) {
@fwrite($fp, $string);
@fclose($fp);
}
}
}
示例3: jimport
function &getFolders($folder)
{
//JoomlapackLogger::WriteLog(_JP_LOG_DEBUG,'Getting folder list for '.($folder));
jimport('joomla.filesystem.folder');
$temp = JFolder::folders($folder, '.', false, true, array('.', '..'));
$ret = array();
if (!empty($temp)) {
foreach ($temp as $file) {
$ret[] = JPISWINDOWS ? JoomlapackHelperUtils::TranslateWinPath($file) : $file;
}
}
return $ret;
}
示例4: init
/**
* Loads the file filters off the database and stores them in the _singleFileFilters array
*
*/
function init()
{
$configuration =& JoomlapackModelRegistry::getInstance();
$temp = $this->_loadFilters();
$this->_singleFileFilters = array();
if (DS == '\\') {
if (is_array($temp)) {
foreach ($temp as $filter) {
$this->_singleFileFilters[] = JoomlapackHelperUtils::TranslateWinPath(JPATH_SITE . DS . $filter);
}
}
} else {
if (is_array($temp)) {
foreach ($temp as $filter) {
$this->_singleFileFilters[] = JPATH_SITE . DS . $filter;
}
}
}
}
示例5: init
/**
* Implements the init method of JoomlapackFilter
*
*/
function init()
{
$configuration =& JoomlapackModelRegistry::getInstance();
$temp = $this->_loadFilters();
$this->_folderFilters = array();
if (DS == '\\') {
if (is_array($temp)) {
foreach ($temp as $filter) {
$this->_folderFilters[] = JoomlapackHelperUtils::TranslateWinPath(JPATH_SITE . DS . $filter);
}
}
} else {
if (is_array($temp)) {
foreach ($temp as $filter) {
$this->_folderFilters[] = JPATH_SITE . DS . $filter;
}
}
}
// Add any leftover installation directory to exclusion filters. THIS SHOULD NEVER BE NECESSARY ON A REAL SITE!
$this->_folderFilters[] = JoomlapackHelperUtils::TranslateWinPath(JPATH_SITE . DS . 'installation');
}
示例6: array
function &getFolders($folder)
{
// Initialize variables
$arr = array();
$false = false;
if (!is_dir($folder)) {
return $false;
}
$counter = 0;
$registry =& JoomlapackModelRegistry::getInstance();
$maxCounter = $registry->get('mnMaxFragmentFiles', 50) * 2;
$cube =& JoomlapackCUBE::getInstance();
$allowBreakflag = $cube->operationCounter != 0;
$handle = @opendir($folder);
// If directory is not accessible, just return FALSE
if ($handle === FALSE) {
JoomlapackLogger::WriteLog(_JP_LOG_WARNING, 'Unreadable directory ' . $dirName);
return $false;
}
while (($file = @readdir($handle)) !== false && !$this->BREAKFLAG) {
$dir = $folder . DS . $file;
$isDir = is_dir($dir);
if ($isDir && $file != '.' && $file != '..') {
$data = JPISWINDOWS ? JoomlapackHelperUtils::TranslateWinPath($dir) : $dir;
if ($data) {
$arr[] = $data;
}
}
$counter++;
if ($counter >= $maxCounter) {
$this->BREAKFLAG = true && $allowBreakflag;
}
}
@closedir($handle);
return $arr;
}
示例7: _prepare
/**
* Implements the _prepare() abstract method
*
*/
function _prepare()
{
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Starting _prepare()");
$cube =& JoomlapackCUBE::getInstance();
// Grab the EFF filters
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting off-site directory inclusion filters (EFF)");
jpimport('models.eff', true);
$effModel = new JoomlapackModelEff();
$this->_extraDirs =& $effModel->getMapping();
// Add the mapping text file if there are EFFs defined!
if (count($this->_extraDirs) > 0) {
// We add a README.txt file in our virtual directory...
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Creating README.txt in the EFF virtual folder");
$virtualContents = JText::_('EFF_MAPTEXT_INTRO') . "\n\n";
foreach ($this->_extraDirs as $dir) {
$virtualContents .= JText::sprintf('EFF_MAPTEXT_LINE', $dir['vdir'], $dir['fsdir']) . "\n";
}
// Add the file to our archive
$registry =& JoomlapackModelRegistry::getInstance();
$provisioning =& $cube->getProvisioning();
$archiver =& $provisioning->getArchiverEngine();
$archiver->addVirtualFile('README.txt', $registry->get('effvfolder'), $virtualContents);
}
// Get the directory exclusion filters - this only needs to be done once
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting exclusion filters");
$this->_loadAndCacheFilters();
if ($this->getError()) {
return false;
}
// FIX 1.1.0 $mosConfig_absolute_path may contain trailing slashes or backslashes incompatible with exclusion filters
// FIX 1.2.2 Some hosts yield an empty string on realpath(JPATH_SITE)
// FIX 2.2 On Windows, realpath might fail
jpimport('helpers.utils', true);
// FIX 2.4: Make an assumption (wild guess...)
if (JPATH_BASE == '/administrator') {
$cube->addWarning("Your site's root is an empty string. I am trying a workaround.");
$jpath_site_real = '/';
} else {
// Fix 2.4: Make sure that $jpath_site_real contains something even if realpath fails
$jpath_site_real = @realpath(trim(JPATH_SITE));
$jpath_site_real = $jpath_site_real === false ? trim(JPATH_SITE) : $jpath_site_real;
$jpath_site_real = JoomlapackHelperUtils::TranslateWinPath($jpath_site_real);
}
if ($jpath_site_real == '') {
// The JPATH_SITE is resolved to an empty string; attempt a workaround
// Windows hosts
if (DIRECTORY_SEPARATOR == '\\') {
if (trim(JPATH_SITE) != '' && trim(JPATH_SITE) != '\\' && trim(JPATH_SITE) != '/') {
$cube->addWarning("The site's root couldn't be normalized on a Windows host. Attempting workaround (filters might not work)");
$jpath_site_real = JPATH_SITE;
// Forcibly use the configured JPATH_SITE
} else {
$cube->addWarning("The normalized path to your site's root seems to be an empty string; I will attempt a workaround (Windows host)");
$jpath_site_real = '/';
// Start scanning from filesystem root (workaround mode)
}
} else {
$cube->addWarning("The normalized path to your site's root seems to be an empty string; I will attempt a workaround (*NIX host)");
# Fix 2.1 Since JPATH_SITE is an empty string, shouldn't I begin scanning from the FS root, for crying out loud? What was I thinking putting JPATH_SITE there?
$jpath_site_real = '/';
// Start scanning from filesystem root (workaround mode)
}
}
// Fix 2.4.b1 : Add the trailing slash
if (substr($jpath_site_real, -1) != '/' && !empty($jpath_site_real)) {
$jpath_site_real .= '/';
}
$this->_directoryList[] = $jpath_site_real;
// Start scanning from Joomla! root, as decided above
$this->_doneScanning = false;
// Instruct the class to scan for files and directories
$this->_doneSubdirectoryScanning = true;
$this->_doneFileScanning = true;
$this->_addPath = '';
// No added path for main site
// Fix 2.4.b1 -- Since JPATH_SITE might have been post-processed, used the post-processed variable instead
$this->_removePath = $jpath_site_real;
// Remove absolute path to site's root for main site
$this->setState('prepared');
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: prepared");
}
示例8: save
/**
* Saves or updates an EFF entry
*
* @param object $fromObject If set, use data from this object, instead of the request
* @access public
* @return bool True on success
*/
function save($fromObject = null)
{
jpimport('helpers.utils', true);
// Get active profile
$session =& JFactory::getSession();
$profile = $session->get('profile', null, 'joomlapack');
if (!is_object($fromObject)) {
// Map from $_REQUEST
$id = JRequest::getVar('id', null);
// Create a table
$fromObject = array('id' => $id, 'profile' => $profile, 'class' => 'eff', 'value' => JoomlapackHelperUtils::TranslateWinPath(JRequest::getVar('fsdir')));
}
// Load table class
$table =& $this->getTable('Inclusion');
// Assign from data and save the inclusion filter record
if (!$table->save($fromObject)) {
$this->setError($table->getError());
return false;
}
return true;
}
示例9: sanitizeFilePath
/**
* Converts a potential Windows-style path to UNIX-style
*
* @param string $filePath The filepath
* @return string The sanitized filepath
*/
function sanitizeFilePath($filePath)
{
if (!class_exists('JoomlapackHelperUtils')) {
jpimport('helpers.utils', true);
}
return JoomlapackHelperUtils::TranslateWinPath($filePath);
}
示例10: getExpandedTarName
/**
* Expands the archive's template name and returns an absolute path
*
* @param string $extension The extension to append, defaults to '.zip'
* @return string The absolute filename of the archive file requested
* @static
*/
function getExpandedTarName($extension = '.zip', $fullPath = true)
{
$configuration =& JoomlapackModelRegistry::getInstance();
// Get the proper extension
$templateName = $configuration->get('TarNameTemplate');
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Archive template name: {$templateName}");
// Get current date/time and express it in user's timezone
jimport('joomla.utilities.date');
$user =& JFactory::getUser();
$userTZ = $user->getParam('timezone', 0);
$dateNow = new JDate();
$dateNow->setOffset($userTZ);
// Parse [DATE] tag
$dateExpanded = $dateNow->toFormat("%Y%m%d");
$templateName = str_replace("[DATE]", $dateExpanded, $templateName);
// Parse [TIME] tag
$timeExpanded = $dateNow->toFormat("%H%M%S");
$templateName = str_replace("[TIME]", $timeExpanded, $templateName);
// Parse [HOST] tag
$uri =& JURI::getInstance();
$host = $uri->getHost();
$host = empty($host) ? 'unknown_host' : $uri->getHost();
$templateName = str_replace("[HOST]", $_SERVER['SERVER_NAME'], $templateName);
// Parse [RANDOM] tag
$templateName = str_replace("[RANDOM]", md5(microtime()), $templateName);
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Expanded template name: {$templateName}");
if ($fullPath) {
$path = $configuration->get('OutputDirectory') . DS . $templateName . $extension;
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Calculated archive absolute path: {$path}");
return JoomlapackHelperUtils::TranslateWinPath($path);
} else {
return $templateName . $extension;
}
}
示例11: _addRemovePaths
/**
* Removes the $p_remove_dir from $p_filename, while prepending it with $p_add_dir.
* Largely based on code from the pclZip library.
* @access private
*/
function _addRemovePaths($p_filename, $p_remove_dir, $p_add_dir)
{
$p_filename = JoomlapackHelperUtils::TranslateWinPath($p_filename);
$p_remove_dir = $p_remove_dir == '' ? '' : JoomlapackHelperUtils::TranslateWinPath($p_remove_dir);
//should fix corrupt backups, fix by nicholas
if (!($p_remove_dir == "")) {
if (substr($p_remove_dir, -1) != '/') {
$p_remove_dir .= "/";
}
if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
$p_remove_dir = "./" . $p_remove_dir;
}
if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
$v_compare = $this->_PathInclusion($p_remove_dir, $p_filename);
if ($v_compare > 0) {
if ($v_compare == 2) {
$v_stored_filename = "";
} else {
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
}
}
} else {
$v_stored_filename = $p_filename;
}
if (!($p_add_dir == "")) {
if (substr($p_add_dir, -1) == "/") {
$v_stored_filename = $p_add_dir . $v_stored_filename;
} else {
$v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
}
}
return $v_stored_filename;
}
示例12: array
/**
* Returns a mapping array. Each array element is a hash array with these keys:
* 'id' (unique ID), 'fsdir' (Filesystem directory = source), 'vdir' (Virtual directory = target).
*
* @return unknown
*/
function &getMapping()
{
$objectList = $this->getEFFList(true);
$ret = array();
if (is_array($objectList)) {
foreach ($objectList as $effObject) {
$newRecord = array();
$newRecord['id'] = $effObject->id;
// Process [ROOTPARENT]
$fsdir = $effObject->value;
if (substr($fsdir, 0, 12) == '[ROOTPARENT]') {
$rootparent = @realpath(JPATH_SITE . DS . '..');
if (!empty($rootparent) && substr($rootparent, -1) == DS) {
$rootparent = substr($rootparent, 0, -1);
}
$fsdir = $rootparent . substr($fsdir, 12);
}
// Change all slashes to UNIX-style
jpimport('helpers.utils', true);
$fsdir = JoomlapackHelperUtils::TranslateWinPath($fsdir);
// Add the absolute path to the record
$newRecord['fsdir'] = $fsdir;
// Get the directory name
$lastSlash = strrpos($fsdir, '/');
$dirName = substr($fsdir, $lastSlash + 1, strlen($fsdir) - $lastSlash);
$newRecord['vdir'] = $newRecord['id'] . "-{$dirName}";
$ret[] = $newRecord;
}
}
return $ret;
}
示例13: array
function &getFolders($folder)
{
// Was the breakflag set BEFORE starting? -- This workaround is required due to PHP5 defaulting to assigning variables by reference
$breakflag_before_process = $this->BREAKFLAG ? true : false;
// Reset break flag before continuing
$this->BREAKFLAG = false;
// Initialize variables
$arr = array();
$false = false;
if (!is_dir($folder)) {
return $false;
}
$counter = 0;
$registry =& JoomlapackModelRegistry::getInstance();
$maxCounter = $registry->get('mnMaxFragmentFiles', 50) * 2;
$cube =& JoomlapackCUBE::getInstance();
$allowBreakflag = $cube->operationCounter != 0 && !$breakflag_before_process;
$handle = @opendir($folder);
// If directory is not accessible, just return FALSE
if ($handle === FALSE) {
$cube =& JoomlapackCUBE::getInstance();
$cube->addWarning('Unreadable directory ' . $folder);
return $false;
}
while (($file = @readdir($handle)) !== false && !$this->BREAKFLAG) {
if ($file != '.' && $file != '..') {
// # Fix 2.4: Do not add DS if we are on the site's root and it's an empty string
$ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DS ? '' : DS;
$dir = $folder . $ds . $file;
$isDir = is_dir($dir);
if ($isDir) {
$data = JPISWINDOWS ? JoomlapackHelperUtils::TranslateWinPath($dir) : $dir;
if ($data) {
$arr[] = $data;
}
}
}
$counter++;
if ($counter >= $maxCounter) {
$this->BREAKFLAG = $allowBreakflag;
}
}
@closedir($handle);
return $arr;
}
示例14: _getDirContents_opendir
function _getDirContents_opendir($dirName, $shellFilter = null)
{
$handle = @opendir($dirName);
// If directory is not accessible, just return FALSE
if ($handle === FALSE) {
$cube =& JoomlapackCUBE::getInstance();
$cube->addWarning('Unreadable directory ' . $dirName);
$false = false;
return $false;
}
// Initialize return array
$retArray = array();
// FIX 1.2.1 -- Remove trailing slash -- Rolled back as of 2.4.b2
# if( (substr($dirName,-1,1) == '/') || (substr($dirName,-1,1) == '\\')) $dirName = substr($dirName,0,strlen($dirName)-1);
// Fix 2.4.b2: Do not add double slash
$ds = $dirName == '' || $dirName == '/' || @substr($dirName, -1) == '/' || @substr($dirName, -1) == DS ? '' : '/';
while (!(($filename = readdir($handle)) === false)) {
$match = is_null($shellFilter);
$match = !$match ? fnmatch($shellFilter, $filename) : true;
if ($match) {
$retArray[] = JPISWINDOWS ? JoomlapackHelperUtils::TranslateWinPath($dirName . $ds . $filename) : $dirName . $ds . $filename;
}
}
@closedir($handle);
return $retArray;
}
示例15: _getDirContents_opendir
function _getDirContents_opendir($dirName, $shellFilter = null)
{
$handle = @opendir($dirName);
// If directory is not accessible, just return FALSE
if ($handle === FALSE) {
JoomlapackLogger::WriteLog(_JP_LOG_WARNING, 'Unreadable directory ' . $dirName);
$false = false;
return $false;
}
// Initialize return array
$retArray = array();
// FIX 1.2.1 -- Remove trailing slash
if (substr($dirName, -1, 1) == '/' || substr($dirName, -1, 1) == '\\') {
$dirName = substr($dirName, 0, strlen($dirName) - 1);
}
while (!(($filename = readdir($handle)) === false)) {
$match = is_null($shellFilter);
$match = !$match ? fnmatch($shellFilter, $filename) : true;
if ($match) {
$retArray[] = JPISWINDOWS ? JoomlapackHelperUtils::TranslateWinPath($dirName . DIRECTORY_SEPARATOR . $filename) : $dirName . DIRECTORY_SEPARATOR . $filename;
}
}
@closedir($handle);
return $retArray;
}