本文整理汇总了PHP中mosPathName函数的典型用法代码示例。如果您正苦于以下问题:PHP mosPathName函数的具体用法?PHP mosPathName怎么用?PHP mosPathName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mosPathName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showInstalledModules
/**
* @param string The URL option
*/
function showInstalledModules($_option)
{
global $database, $mosConfig_absolute_path, $adminLanguage;
$filter = mosGetParam($_POST, 'filter', '');
$select[] = mosHTML::makeOption('', $adminLanguage->A_COMP_MOD_ALL);
$select[] = mosHTML::makeOption('0', $adminLanguage->A_MENU_SITE_MOD);
$select[] = mosHTML::makeOption('1', $adminLanguage->A_INSTALL_MOD_ADMIN_MOD);
$lists['filter'] = mosHTML::selectList($select, 'filter', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $filter);
if ($filter == NULL) {
$and = '';
} else {
if (!$filter) {
$and = "\n AND client_id = '0'";
} else {
if ($filter) {
$and = "\n AND client_id = '1'";
}
}
}
$database->setQuery("SELECT id, module, client_id" . "\n FROM #__modules" . "\n WHERE module LIKE 'mod_%' AND iscore='0'" . $and . "\n GROUP BY module, client_id" . "\n ORDER BY client_id, module");
$rows = $database->loadObjectList();
$id = 0;
foreach ($rows as $row) {
// path to module directory
if ($row->client_id == "1") {
$moduleBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "administrator/modules");
} else {
$moduleBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "modules");
}
// xml file for module
$xmlfile = $moduleBaseDir . "/" . $row->module . ".xml";
$xmlDoc =& new DOMIT_Lite_Document();
$xmlDoc->resolveErrors(true);
if (!$xmlDoc->loadXML($xmlfile, false, true)) {
continue;
}
$element =& $xmlDoc->documentElement;
if ($element->getTagName() != 'mosinstall') {
continue;
}
if ($element->getAttribute("type") != "module") {
continue;
}
$element =& $xmlDoc->getElementsByPath('creationDate', 1);
$row->creationdate = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('author', 1);
$row->author = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('copyright', 1);
$row->copyright = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('authorEmail', 1);
$row->authorEmail = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('authorUrl', 1);
$row->authorUrl = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('version', 1);
$row->version = $element ? $element->getText() : '';
$rows[$id] = $row;
$id++;
}
HTML_module::showInstalledModules($rows, $_option, $id, $xmlfile, $lists);
}
示例2: showInstalledComponents
/**
* @param string The URL option
*/
function showInstalledComponents($option)
{
global $database, $mosConfig_absolute_path;
$database->setQuery("SELECT *" . "\n FROM #__components" . "\n WHERE parent = 0 AND iscore = 0" . "\n ORDER BY name");
$rows = $database->loadObjectList();
// Read the component dir to find components
$componentBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/components');
$componentDirs = mosReadDirectory($componentBaseDir);
$n = count($rows);
for ($i = 0; $i < $n; $i++) {
$row =& $rows[$i];
$dirName = mosPathName($componentBaseDir . $row->option);
$xmlFilesInDir = mosReadDirectory($dirName, '.xml$');
foreach ($xmlFilesInDir as $xmlfile) {
// Read the file to see if it's a valid component XML file
$parser =& new mosXMLDescription($dirName . $xmlfile);
if ($parser->getType() != 'component') {
continue;
}
$row->creationdate = $parser->getCreationDate('component');
$row->author = $parser->getAuthor('component');
$row->copyright = $parser->getCopyright('component');
$row->authorEmail = $parser->getAuthorEmail('component');
$row->authorUrl = $parser->getAuthorUrl('component');
$row->version = $parser->getVersion('component');
$row->mosname = strtolower(str_replace(" ", "_", $row->name));
}
}
HTML_component::showInstalledComponents($rows, $option);
}
示例3: mosReadDirectory
function mosReadDirectory($path, $filter = '.', $recurse = false, $fullpath = false)
{
$arr = array();
if (!@is_dir($path)) {
return $arr;
}
$handle = opendir($path);
while ($file = readdir($handle)) {
$dir = mosPathName($path . '/' . $file, false);
$isDir = is_dir($dir);
if ($file != "." && $file != "..") {
if (preg_match("/{$filter}/", $file)) {
if ($fullpath) {
$arr[] = trim(mosPathName($path . '/' . $file, false));
} else {
$arr[] = trim($file);
}
}
if ($recurse && $isDir) {
$arr2 = mosReadDirectory($dir, $filter, $recurse, $fullpath);
$arr = array_merge($arr, $arr2);
}
}
}
closedir($handle);
asort($arr);
return $arr;
}
示例4: extractBackupArchive
/**
* jlms_zip_operation.php
* (c) JoomaLMS eLearning Software http://www.joomlalms.com/
**/
function extractBackupArchive($archivename, $extractdir)
{
$base_Dir = mosPathName(JPATH_SITE . '/media');
$archivename = mosPathName($archivename, false);
if (preg_match('/\\.zip$/i', $archivename)) {
require_once _JOOMLMS_FRONT_HOME . "/includes/libraries/lms.lib.zip.php";
$backupfile = new PclZip($archivename);
$ret = $backupfile->extract(PCLZIP_OPT_PATH, $extractdir);
}
return true;
}
示例5: uninstall
/**
* Custom install method
* @param int The id of the module
* @param string The URL option
* @param int The client id
*/
function uninstall($id, $option, $client = 0)
{
global $database, $mosConfig_absolute_path;
// Delete directories
$path = $mosConfig_absolute_path . ($client == 'admin' ? '/administrator' : '') . '/templates/' . $id;
$id = str_replace('..', '', $id);
if (trim(id)) {
if (is_dir($path)) {
return deldir(mosPathName($path));
} else {
HTML_installer::showInstallMessage('Directory does not exist, cannot remove files', 'Uninstall - error', $this->returnTo($option, 'template', $client));
}
} else {
HTML_installer::showInstallMessage('Template id is empty, cannot remove files', 'Uninstall - error', $this->returnTo($option, 'template', $client));
exit;
}
}
示例6: showInstalledComponents
/**
* @param string The URL option
*/
function showInstalledComponents($option)
{
global $database, $mosConfig_absolute_path;
$database->setQuery("SELECT *" . "\n FROM #__components" . "\n WHERE parent = 0 AND iscore = 0" . "\n ORDER BY name");
$rows = $database->loadObjectList();
// Read the component dir to find components
$componentBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/components');
$componentDirs = mosReadDirectory($componentBaseDir);
$id = 0;
foreach ($rows as $row) {
$dirName = $componentBaseDir . $row->option;
$xmlFilesInDir = mosReadDirectory($dirName, '.xml');
foreach ($xmlFilesInDir as $xmlfile) {
// Read the file to see if it's a valid component XML file
$xmlDoc =& new DOMIT_Lite_Document();
$xmlDoc->resolveErrors(true);
if (!$xmlDoc->loadXML($dirName . '/' . $xmlfile, false, true)) {
continue;
}
$element =& $xmlDoc->documentElement;
if ($element->getTagName() != 'mosinstall') {
continue;
}
if ($element->getAttribute("type") != "component") {
continue;
}
$element =& $xmlDoc->getElementsByPath('creationDate', 1);
$row->creationdate = $element ? $element->getText() : 'Unknown';
$element =& $xmlDoc->getElementsByPath('author', 1);
$row->author = $element ? $element->getText() : 'Unknown';
$element =& $xmlDoc->getElementsByPath('copyright', 1);
$row->copyright = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('authorEmail', 1);
$row->authorEmail = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('authorUrl', 1);
$row->authorUrl = $element ? $element->getText() : '';
$element =& $xmlDoc->getElementsByPath('version', 1);
$row->version = $element ? $element->getText() : '';
$row->mosname = strtolower(str_replace(" ", "_", $row->name));
$rows[$id] = $row;
}
$id++;
}
HTML_component::showInstalledComponents($rows, $option);
}
示例7: deldir
function deldir($dir)
{
$current_dir = opendir($dir);
$old_umask = umask(0);
while ($entryname = readdir($current_dir)) {
if ($entryname != '.' and $entryname != '..') {
if (is_dir($dir . $entryname)) {
deldir(mosPathName($dir . $entryname));
} else {
@chmod($dir . $entryname, 0777);
unlink($dir . $entryname);
}
}
}
umask($old_umask);
closedir($current_dir);
return rmdir($dir);
}
示例8: showInstalledMambots
function showInstalledMambots($_option)
{
global $database, $mosConfig_absolute_path;
$query = "SELECT id, name, folder, element, client_id" . "\n FROM #__mambots" . "\n WHERE iscore = 0" . "\n ORDER BY folder, name";
$database->setQuery($query);
$rows = $database->loadObjectList();
// path to mambot directory
$mambotBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "mambots");
$id = 0;
$n = count($rows);
for ($i = 0; $i < $n; $i++) {
$row =& $rows[$i];
// xml file for module
$xmlfile = $mambotBaseDir . "/" . $row->folder . '/' . $row->element . ".xml";
if (file_exists($xmlfile)) {
$xmlDoc = new DOMIT_Lite_Document();
$xmlDoc->resolveErrors(true);
if (!$xmlDoc->loadXML($xmlfile, false, true)) {
continue;
}
$root =& $xmlDoc->documentElement;
if ($root->getTagName() != 'mosinstall') {
continue;
}
if ($root->getAttribute("type") != "mambot") {
continue;
}
$element =& $root->getElementsByPath('creationDate', 1);
$row->creationdate = $element ? $element->getText() : '';
$element =& $root->getElementsByPath('author', 1);
$row->author = $element ? $element->getText() : '';
$element =& $root->getElementsByPath('copyright', 1);
$row->copyright = $element ? $element->getText() : '';
$element =& $root->getElementsByPath('authorEmail', 1);
$row->authorEmail = $element ? $element->getText() : '';
$element =& $root->getElementsByPath('authorUrl', 1);
$row->authorUrl = $element ? $element->getText() : '';
$element =& $root->getElementsByPath('version', 1);
$row->version = $element ? $element->getText() : '';
}
}
HTML_mambot::showInstalledMambots($rows, $_option, $id, $xmlfile);
}
示例9: install
/**
* Custom install method
* @param boolean True if installing from directory
*/
function install($p_fromdir = null)
{
global $mosConfig_absolute_path, $database;
if (!$this->preInstallCheck($p_fromdir, 'language')) {
return false;
}
$xml = $this->xmlDoc();
// Set some vars
$e =& $xml->getElementsByPath('name', 1);
$this->elementName($e->getText());
$this->elementDir(mosPathName($mosConfig_absolute_path . "/language/"));
// Find files to copy
if ($this->parseFiles('files', 'language') === false) {
return false;
}
if ($e =& $xml->getElementsByPath('description', 1)) {
$this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
}
return $this->copySetupFile('front');
}
示例10: getBasePath
/**
* Gets the base path for the client
* @param mixed A client identifier
* @param boolean True (default) to add traling slash
*/
function getBasePath($client = 0, $addTrailingSlash = true)
{
switch ($client) {
case '0':
case 'site':
case 'front':
default:
return mosPathName(JPATH_SITE, $addTrailingSlash);
break;
case '2':
case 'installation':
return mosPathName(JPATH_INSTALLATION, $addTrailingSlash);
break;
case '1':
case 'admin':
case 'administrator':
return mosPathName(JPATH_ADMINISTRATOR, $addTrailingSlash);
break;
}
}
示例11: uploadFile
function uploadFile($filename, $userfile_name, &$msg)
{
global $mosConfig_absolute_path;
$baseDir = mosPathName($mosConfig_absolute_path . '/media');
if (file_exists($baseDir)) {
if (is_writable($baseDir)) {
if (move_uploaded_file($filename, $baseDir . $userfile_name)) {
if (mosChmod($baseDir . $userfile_name)) {
return true;
} else {
$msg = 'Failed to change the permissions of the uploaded file.';
}
} else {
$msg = 'Failed to move uploaded file to <code>/media</code> directory.';
}
} else {
$msg = 'Upload failed as <code>/media</code> directory is not writable.';
}
} else {
$msg = 'Upload failed as <code>/media</code> directory does not exist.';
}
return false;
}
示例12: extractArchive
/**
* Extracts the package archive file
* @return boolean True on success, False on error
*/
function extractArchive($filename)
{
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path');
$base_Dir = mosPathName($mosConfig_absolute_path . '/media');
$this->archiveName = $base_Dir . $filename;
$tmpdir = uniqid('install_');
$this->extractDir = $this->cleanDir = mosPathName($base_Dir . uniqid('install_'));
if (eregi('.zip$', $filename)) {
// Extract functions
require_once $mosConfig_absolute_path . '/administrator/includes/pcl/pclzip.lib.php';
require_once $mosConfig_absolute_path . '/administrator/includes/pcl/pclerror.lib.php';
//require_once( $mosConfig_absolute_path . '/administrator/includes/pcl/pcltrace.lib.php' );
//require_once( $mosConfig_absolute_path . '/administrator/includes/pcl/pcltar.lib.php' );
$zipfile = new PclZip($this->archiveName);
$ret = $zipfile->extract(PCLZIP_OPT_PATH, $this->extractDir);
if ($ret == 0) {
$this->errors->addErrorDetails(sprintf(T_('Installer unrecoverable ZIP error %s in %s'), $zipfile->errorName(true), $this->archiveName), _MOS_ERROR_FATAL);
return false;
}
} else {
require_once $mosConfig_absolute_path . '/includes/Archive/Tar.php';
$archive =& new Archive_Tar($this->archiveName);
$archive->setErrorHandling(PEAR_ERROR_PRINT);
if (!$archive->extractModify($this->extractDir, '')) {
$this->errors->addErrorDetails(sprintf(T_('Installer unrecoverable TAR error in %s'), $this->archiveName), _MOS_ERROR_FATAL);
return false;
}
}
// Try to find the correct install dir. in case that the package have subdirs
// Save the install dir for later cleanup
$dir =& new mosDirectory($this->extractDir);
$singledir = $dir->soleDir();
if ($singledir) {
$this->extractDir = mosPathName($this->extractDir . $singledir);
}
return true;
}
示例13: viewTemplates
/**
* Compiles a list of installed, version 4.5+ templates
*
* Based on xml files found. If no xml file found the template
* is ignored
*/
function viewTemplates($option, $client)
{
global $database, $mainframe;
global $mosConfig_absolute_path, $mosConfig_list_limit;
$limit = $mainframe->getUserStateFromRequest('viewlistlimit', 'limit', $mosConfig_list_limit);
$limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0);
if ($client == 'admin') {
$templateBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/templates');
} else {
$templateBaseDir = mosPathName($mosConfig_absolute_path . '/templates');
}
$rows = array();
// Read the template dir to find templates
$templateDirs = mosReadDirectory($templateBaseDir);
$id = intval($client == 'admin');
if ($client == 'admin') {
$database->setQuery("SELECT template FROM #__templates_menu WHERE client_id='1' AND menuid='0'");
} else {
$database->setQuery("SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'");
}
$cur_template = $database->loadResult();
$rowid = 0;
// Check that the directory contains an xml file
foreach ($templateDirs as $templateDir) {
$dirName = mosPathName($templateBaseDir . $templateDir);
$xmlFilesInDir = mosReadDirectory($dirName, '.xml$');
foreach ($xmlFilesInDir as $xmlfile) {
// Read the file to see if it's a valid template XML file
$parser =& new mosXMLDescription($dirName . $xmlfile);
if ($parser->getType() != 'template') {
continue;
}
$row = new StdClass();
$row->id = $rowid;
$row->directory = $templateDir;
$row->creationdate = $parser->getCreationDate('template');
$row->name = $parser->getName('template');
$row->author = $parser->getAuthor('template');
$row->copyright = $parser->getCopyright('template');
$row->authorEmail = $parser->getAuthorEmail('template');
$row->authorUrl = $parser->getAuthorUrl('template');
$row->version = $parser->getVersion('template');
/*
$element = &$xmlDoc->getElementsByPath('name', 1 );
$row->name = $element->getText();
$element = &$xmlDoc->getElementsByPath('creationDate', 1);
$row->creationdate = $element ? $element->getText() : 'Unknown';
$element = &$xmlDoc->getElementsByPath('author', 1);
$row->author = $element ? $element->getText() : 'Unknown';
$element = &$xmlDoc->getElementsByPath('copyright', 1);
$row->copyright = $element ? $element->getText() : '';
$element = &$xmlDoc->getElementsByPath('authorEmail', 1);
$row->authorEmail = $element ? $element->getText() : '';
$element = &$xmlDoc->getElementsByPath('authorUrl', 1);
$row->authorUrl = $element ? $element->getText() : '';
$element = &$xmlDoc->getElementsByPath('version', 1);
$row->version = $element ? $element->getText() : '';
*/
// Get info from db
if ($cur_template == $templateDir) {
$row->published = 1;
} else {
$row->published = 0;
}
$row->checked_out = 0;
$row->mosname = strtolower(str_replace(' ', '_', $row->name));
// check if template is assigned
$database->setQuery("SELECT count(*) FROM #__templates_menu WHERE client_id='0' AND template='{$row->directory}' AND menuid<>'0'");
$row->assigned = $database->loadResult() ? 1 : 0;
$rows[] = $row;
$rowid++;
}
}
require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
$pageNav = new mosPageNav(count($rows), $limitstart, $limit);
$rows = array_slice($rows, $pageNav->limitstart, $pageNav->limit);
HTML_templates::showTemplates($rows, $pageNav, $option, $client);
}
示例14: uninstall
/**
* Custom install method
* @param int The id of the module
* @param string The URL option
* @param int The client id
*/
function uninstall($id, $option, $client = 0)
{
global $database, $mosConfig_absolute_path;
$id = intval($id);
$database->setQuery("SELECT name, folder, element, iscore FROM #__mambots WHERE id = '{$id}'");
$row = null;
$database->loadObject($row);
if ($database->getErrorNum()) {
HTML_installer::showInstallMessage($database->stderr(), 'Uninstall - error', $installer->returnTo($option, 'mambot', $client));
exit;
}
if (trim($row->folder) == '') {
HTML_installer::showInstallMessage('Folder field empty, cannot remove files', 'Uninstall - error', $installer->returnTo($option, 'mambot', $client));
exit;
}
$basepath = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/';
$xmlfile = $basepath . $row->element . '.xml';
// see if there is an xml install file, must be same name as element
if (file_exists($xmlfile)) {
$this->i_xmldoc =& new DOMIT_Lite_Document();
$this->i_xmldoc->resolveErrors(true);
if ($this->i_xmldoc->loadXML($xmlfile, false, true)) {
$mosinstall =& $this->i_xmldoc->documentElement;
// get the files element
$files_element =& $mosinstall->getElementsByPath('files', 1);
if (!is_null($files_element)) {
$files = $files_element->childNodes;
foreach ($files as $file) {
// delete the files
$filename = $file->getText();
if (file_exists($basepath . $filename)) {
$parts = pathinfo($filename);
$subpath = $parts['dirname'];
if ($subpath != '' && $subpath != '.' && $subpath != '..') {
echo '<br />Deleting: ' . $basepath . $subpath;
$result = deldir(mosPathName($basepath . $subpath . '/'));
} else {
echo '<br />Deleting: ' . $basepath . $filename;
$result = unlink(mosPathName($basepath . $filename, false));
}
echo intval($result);
}
}
// remove XML file from front
echo "Deleting XML File: {$xmlfile}";
@unlink(mosPathName($xmlfile, false));
// define folders that should not be removed
$sysFolders = array('content', 'search');
if (!in_array($row->folder, $sysFolders)) {
// delete the non-system folders if empty
if (count(mosReadDirectory($basepath)) < 1) {
deldir($basepath);
}
}
}
}
}
if ($row->iscore) {
HTML_installer::showInstallMessage($row->name . ' is a core element, and cannot be uninstalled.<br />You need to unpublish it if you don\'t want to use it', 'Uninstall - error', $this->returnTo($option, 'mambot', $client));
exit;
}
$database->setQuery("DELETE FROM #__mambots WHERE id = '{$id}'");
if (!$database->query()) {
$msg = $database->stderr;
die($msg);
}
return true;
}
示例15: validatePath
function validatePath($path)
{
if ($path) {
$path = mosPathName($path);
if (!is_dir($path)) {
$path = dirname($path);
}
if (@substr($path, -1) != "/") {
$path = $path . "/";
}
$handle = @opendir($path);
if ($handle) {
closedir($handle);
} else {
$path = false;
}
} else {
$path = false;
}
if (!$path) {
$this->_err = _DML_DIRPROBLEM2 . ": {$path}";
}
return $path;
}