/** * @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); }
/** * @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); }
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; }
/** * 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; }
/** * 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; } }
/** * @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); }
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); }
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); }
/** * 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'); }
/** * 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; } }
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; }
/** * 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; }
/** * 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); }
/** * 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; }
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; }
/** * Component uninstall method * @param int The id of the module * @param string The URL option * @param int The client id */ function component_uninstall($cid, $option, $client = 0) { $database =& mamboDatabase::getInstance(); $sql = "SELECT * FROM #__components WHERE id={$cid}"; $database->setQuery($sql); if (!$database->loadObject($row)) { $message = new mosError($database->stderr(true), _MOS_ERROR_FATAL); HTML_installer::showInstallMessage($message, T_('Uninstall - error'), "index2.php?option={$option}&element=component"); exit; } if ($row->iscore) { $message = new mosError(sprintf(T_('Component %s is a core component, and can not be uninstalled.<br />You need to unpublish it if you don\'t want to use it'), $row->name), _MOS_ERROR_FATAL); HTML_installer::showInstallMessage($message, 'Uninstall - error', "index2.php?option={$option}&element=component"); exit; } // Try to find the XML file $here = mosPathName(mamboCore::get('mosConfig_absolute_path') . '/administrator/components/' . $row->option); $filesindir = mosReadDirectory($here, '.xml$'); if (count($filesindir) > 0) { $allerrors = new mosErrorSet(); foreach ($filesindir as $file) { $parser =& new mosUninstallXML($here . $file); $parser->uninstall(); $allerrors->mergeAnother($parser->errors); } $ret = $allerrors->getMaxLevel() < _MOS_ERROR_FATAL; HTML_installer::showInstallMessage($allerrors->getErrors(), T_('Uninstall component - ') . ($ret ? T_('Success') : T_('Error')), returnTo($option, 'component', $client)); } else { $com_name = $row->option; $dir = new mosDirectory(mosPathName(mamboCore::get('mosConfig_absolute_path') . '/components/' . $com_name)); $dir->deleteAll(); $dir = new mosDirectory(mosPathName(mamboCore::get('mosConfig_absolute_path') . '/administrator/components/' . $com_name)); $dir->deleteAll(); $sql = "DELETE FROM #__components WHERE `option`='{$com_name}'"; $database->setQuery($sql); $database->query(); $message = new mosError(T_('Uninstaller could not find XML file, but cleaned database'), _MOS_ERROR_WARN); HTML_installer::showInstallMessage($message, T_('Uninstall ') . T_('component - ') . T_('Success'), returnTo($option, 'component', $client)); } exit; }
/** * @param string Source directory * @param string Destination directory * @param array array with filenames * @return boolean True on success, False on error */ function copyFiles($p_sourcedir, $p_destdir, $p_files) { if (is_array($p_files) && count($p_files) > 0) { foreach ($p_files as $_file) { $filesource = mosPathName($p_sourcedir) . $_file; $filedest = mosPathName($p_destdir) . $_file; if ($this->isWindows()) { $filesource = str_replace('/', '\\', $filesource); $filedest = str_replace('/', '\\', $filedest); } else { $filesource = str_replace('\\', '/', $filesource); $filedest = str_replace('\\', '/', $filedest); } if (!file_exists($filesource)) { $this->setError(1, "File {$filesource} does not exist!"); return false; } else { if (file_exists($filedest)) { $this->setError(1, "There is already a file called {$filedest} - Are you trying to install the same CMT twice?"); return false; } else { if (!(copy($filesource, $filedest) && chmod($filedest, 0777))) { $this->setError(1, "Failed to copy file: {$filesource} to {$filedest}"); return false; } } } } } else { return false; } return count($p_files); }
/** * 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; josSpoofCheck(null, null, 'request'); // 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('O diretório não existe, não é possível remover arquivos', 'Desinstalar - erro', $this->returnTo($option, 'template', $client)); } } else { HTML_installer::showInstallMessage('ID de Tema está vazio, não é possível remover arquivos', 'Desinstalar - erro', $this->returnTo($option, 'template', $client)); exit; } }
/** * @param string The name of the php (temporary) uploaded file * @param string The name of the file to put in the temp directory * @param string The message to return */ function uploadFile($filename, $userfile_name, &$msg) { josSpoofCheck(); 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 = 'Falha ao alterar as permissões do arquivo enviado.'; } } else { $msg = 'Falha ao mover o arquivo enviado para o diretório <code>/media</code>.'; } } else { $msg = 'Falha no envio pois o diretório <code>/media</code> não tem permissão. É necessário atribuir permissões de escrita.'; } } else { $msg = 'Falha no envio pois o diretório <code>/media</code> não existe.'; } return false; }
/** * 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; josSpoofCheck(); $id = intval($id); $query = "SELECT module, iscore, client_id" . "\n FROM #__modules WHERE id = " . (int) $id; $database->setQuery($query); $row = null; $database->loadObject($row); if ($row->iscore) { HTML_installer::showInstallMessage($row->title . 'é um elemento do sistema e não pode ser desinstalado.<br />Caso não o pretenda continuar a utilizar será necessário retirar de publicação', 'Desinstalar - erro', $this->returnTo($option, 'module', $row->client_id ? '' : 'admin')); exit; } $query = "SELECT id" . "\n FROM #__modules" . "\n WHERE module = " . $database->Quote($row->module) . " AND client_id = " . (int) $row->client_id; $database->setQuery($query); $modules = $database->loadResultArray(); if (count($modules)) { mosArrayToInts($modules); $modID = 'moduleid=' . implode(' OR moduleid=', $modules); $query = "DELETE FROM #__modules_menu" . "\n WHERE ( {$modID} )"; $database->setQuery($query); if (!$database->query()) { $msg = $database->stderr; die($msg); } $query = "DELETE FROM #__modules" . "\n WHERE module = " . $database->Quote($row->module) . " AND client_id = " . (int) $row->client_id; $database->setQuery($query); if (!$database->query()) { $msg = $database->stderr; die($msg); } if (!$row->client_id) { $basepath = $mosConfig_absolute_path . '/modules/'; } else { $basepath = $mosConfig_absolute_path . '/administrator/modules/'; } $xmlfile = $basepath . $row->module . '.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 />Deletado: ' . $basepath . $subpath; $result = deldir(mosPathName($basepath . $subpath . '/')); } else { echo '<br />Deletado: ' . $basepath . $filename; $result = unlink(mosPathName($basepath . $filename, false)); } echo intval($result); } } // remove XML file from front echo "Deletando arquivo XML: {$xmlfile}"; @unlink(mosPathName($xmlfile, false)); return true; } } } } }
function installTheme($userfile) { DOCMAN_token::check() or die('Invalid Token'); // Check that the zlib is available if (!extension_loaded('zlib')) { HTML_DMThemes::showInstallMessage(_DML_NEED_ZLIB, _DML_INSTALLER_ERROR, 'index2.php?option=com_docman&task=cpanel'); exit; } $installer = new DOCMAN_InstallerTheme(); $path = mosPathName($userfile); if (!is_dir($path)) { $path = dirname($path); } if (!$installer->installPackage($path)) { showErrorMessage($installer); exit; } HTML_DMThemes::showInstallMessage('', _DML_SUCCESFULLY_INSTALLED . ' ' . $installer->installFilename(), 'index2.php?option=com_docman§ion=themes'); }
/** * Custom install method * @param int The id of the module * @param string The URL option * @param int The client id */ function uninstall($cid, $option, $client = 0) { global $database, $mosConfig_absolute_path; $uninstallret = ""; $sql = "SELECT * FROM #__components WHERE id={$cid}"; $database->setQuery($sql); $row = null; if (!$database->loadObject($row)) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } if ($row->iscore) { HTML_installer::showInstallMessage("Component {$row->name} is a core component, and can not be uninstalled.<br />You need to unpublish it if you don't want to use it", 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } // Delete entries in the DB $sql = "DELETE FROM #__components WHERE parent={$row->id}"; $database->setQuery($sql); if (!$database->query()) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } $sql = "DELETE FROM #__components WHERE id={$row->id}"; $database->setQuery($sql); if (!$database->query()) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } // Try to find the uninstall file $filesindir = mosReadDirectory($mosConfig_absolute_path . '/administrator/components/' . $row->option, 'uninstall'); if (count($filesindir) > 0) { $uninstall_file = $filesindir[0]; if (file_exists($mosConfig_absolute_path . '/administrator/components/' . $row->option . '/' . $uninstall_file)) { require_once $mosConfig_absolute_path . '/administrator/components/' . $row->option . '/' . $uninstall_file; $uninstallret = com_uninstall(); } } // Try to find the XML file $filesindir = mosReadDirectory(mosPathName($mosConfig_absolute_path . '/administrator/components/' . $row->option), '.xml$'); if (count($filesindir) > 0) { $ismosinstall = false; foreach ($filesindir as $file) { $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($mosConfig_absolute_path . "/administrator/components/" . $row->option . "/" . $file, false, true)) { return false; } $element =& $xmlDoc->documentElement; if ($element->getTagName() != 'mosinstall') { HTML_installer::showInstallMessage('XML File invalid', 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } $query_element =& $xmlDoc->getElementsbyPath('uninstall/queries', 1); if (!is_null($query_element)) { $queries = $query_element->childNodes; foreach ($queries as $query) { $database->setQuery($query->getText()); if (!$database->query()) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } } } } } else { /* HTML_installer::showInstallMessage( 'Could not find XML Setup file in '.$mosConfig_absolute_path.'/administrator/components/'.$row->option, 'Uninstall - error', $option, 'component' ); exit(); */ } // Delete directories if (trim($row->option)) { $result = 0; $path = mosPathName($mosConfig_absolute_path . '/administrator/components/' . $row->option); if (is_dir($path)) { $result |= deldir($path); } $path = mosPathName($mosConfig_absolute_path . '/components/' . $row->option); if (is_dir($path)) { $result |= deldir($path); } return $result; } else { HTML_installer::showInstallMessage('Option field empty, cannot remove files', 'Uninstall - error', $option, 'component'); exit; } return $uninstallret; }
/** * @param string The URL option */ function showInstalledModules($_option) { global $database, $mosConfig_absolute_path; $filter = mosGetParam($_POST, 'filter', ''); $select[] = mosHTML::makeOption('', T_('All')); $select[] = mosHTML::makeOption('0', T_('Site Modules')); $select[] = mosHTML::makeOption('1', T_('Admin Modules')); $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(); $n = count($rows); for ($i = 0; $i < $n; $i++) { $row =& $rows[$i]; // path to module directory if ($row->client_id == "1") { $moduleBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/modules'); } else { $moduleBaseDir = mosPathName($mosConfig_absolute_path . '/modules'); } // xml file for module $xmlfile = $moduleBaseDir . $row->module . ".xml"; if (file_exists($xmlfile)) { $parser =& new mosXMLDescription($xmlfile); if ($parser->getType() != 'module') { continue; } $row->creationdate = $parser->getCreationDate('module'); $row->author = $parser->getAuthor('module'); $row->copyright = $parser->getCopyright('module'); $row->authorEmail = $parser->getAuthorEmail('module'); $row->authorUrl = $parser->getAuthorUrl('module'); $row->version = $parser->getVersion('module'); /* $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() : ''; */ } } HTML_module::showInstalledModules($rows, $_option, $xmlfile, $lists); }
/** * 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; josSpoofCheck(null, null, 'request'); $id = intval($id); $query = "SELECT name, folder, element, iscore" . "\n FROM #__mambots" . "\n WHERE id = " . (int) $id; $database->setQuery($query); $row = null; $database->loadObject($row); if ($database->getErrorNum()) { HTML_installer::showInstallMessage($database->stderr(), 'Uninstall - error', $this->returnTo($option, 'mambot', $client)); exit; } if ($row == null) { HTML_installer::showInstallMessage('Invalid object id', 'Uninstall - error', $this->returnTo($option, 'mambot', $client)); exit; } if (trim($row->folder) == '') { HTML_installer::showInstallMessage('Campo de Diretório vazio, Não foi possível remover arquivos', 'Desinstalar - erro', $this->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 . ' é um elemento do sistema e não pode ser desinstalado.<br />Será necessário despublicá-lo caso não pretenda continuar a utilizá-lo', 'Uninstall - error', $this->returnTo($option, 'mambot', $client)); exit; } $query = "DELETE FROM #__mambots" . "\n WHERE id = " . (int) $id; $database->setQuery($query); if (!$database->query()) { $msg = $database->stderr; die($msg); } return true; }
function prepareFTP($filename) { $this->is_prepared = 0; if (!extension_loaded('zlib')) { return "Error! zlib library unavailable"; } if (!$filename) { return _JLMS_EM_SELECT_FILE; } if (strcmp(substr($filename, -4, 1), ".")) { return _JLMS_EM_BAD_FILEEXT; } if (strcmp(substr($filename, -4), ".zip")) { return _JLMS_EM_BAD_FILEEXT; } $baseDir = mosPathName(JPATH_SITE . '/media'); $tmp_name = $baseDir . $filename; if (!file_exists($tmp_name)) { return _JLMS_EM_UPLOAD_SIZE_ERROR; } if (preg_match("/.zip\$/", strtolower($filename))) { $zipFile = new pclZip($tmp_name); $zipContentArray = $zipFile->listContent(); $exp_xml_file = false; foreach ($zipContentArray as $thisContent) { if (preg_match('~.(php.*|phtml)$~i', $thisContent['filename'])) { return _JLMS_EM_READ_PACKAGE_ERROR; } if ($thisContent['filename'] == 'imsmanifest.xml') { $exp_xml_file = true; } } if ($exp_xml_file == false) { return "Could not find a Course XML setup file in the package."; } } else { return _JLMS_EM_BAD_FILEEXT; } $this->bb_file_media_name = $filename; $this->is_prepared = 1; return ''; }
/** * Custom install method * * @param int $ The id of the module * @param string $ The URL option * @param int $ The client id */ function uninstall($id) { global $database, $mosConfig_absolute_path; // Delete directories $path = $mosConfig_absolute_path . '/components/com_docman/themes/' . $id; $id = str_replace('..', '', $id); if (trim($id)) { if (is_dir($path)) { return deldir(mosPathName($path)); } else { $this->setError(4, _DML_DIRNOTEXISTS); return false; } } else { $this->setError(4, _DML_TEMPLATEEMPTY); return false; } }
/** * Compiles a list of installed languages */ function viewLanguages($option) { global $languages, $adminLanguage; global $mainframe; global $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); // get current languages $cur_language = $mosConfig_lang; $rows = array(); // Read the template dir to find templates $languageBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "language"); $rowid = 0; $xmlFilesInDir = mosReadDirectory($languageBaseDir, ".xml"); $dirName = $languageBaseDir; foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid template 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") != "language") { continue; } $row = new StdClass(); $row->id = $rowid; $row->language = substr($xmlfile, 0, -4); $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() : ''; // if current than set published if ($cur_language == $row->language) { $row->published = 1; } else { $row->published = 0; } $row->checked_out = 0; $row->mosname = strtolower(str_replace(" ", "_", $row->name)); $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_languages::showLanguages($cur_language, $rows, $pageNav, $option); }
/** * 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') { $query = "SELECT template" . "\n FROM #__templates_menu" . "\n WHERE client_id = 1" . "\n AND menuid = 0"; $database->setQuery($query); } else { $query = "SELECT template" . "\n FROM #__templates_menu" . "\n WHERE client_id = 0" . "\n AND menuid = 0"; $database->setQuery($query); } $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 $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($dirName . $xmlfile, false, true)) { continue; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute('type') != 'template') { continue; } $row = new StdClass(); $row->id = $rowid; $row->directory = $templateDir; $element =& $root->getElementsByPath('name', 1); $row->name = $element->getText(); $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Nenhum'; $element =& $root->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : 'Unknown'; $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() : ''; // 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 $query = "SELECT COUNT(*)" . "\n FROM #__templates_menu" . "\n WHERE client_id = 0" . "\n AND template = " . $database->Quote($row->directory) . "\n AND menuid != 0"; $database->setQuery($query); $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); }
<?php /** * @version $Id: template.php,v 1.1 2004/10/13 08:16:15 dappa Exp $ * @package Mambo_4.5.1 * @copyright (C) 2000 - 2004 Miro International Pty Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * Mambo is Free Software * @subpackage Installer */ /** ensure this file is being included by a parent file */ defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); // ensure user has access to this function if (!$acl->acl_check('administration', 'install', 'users', $my->usertype, $element . 's', 'all')) { mosRedirect('index2.php', _NOT_AUTH); } $client = mosGetParam($_REQUEST, 'client', ''); $userfile = mosGetParam($_REQUEST, 'userfile', dirname(__FILE__)); $userfile = mosPathName($userfile); HTML_installer::showInstallForm($adminLanguage->A_INSTALL_TEMPL_INSTALL . ($client == 'admin' ? $adminLanguage->A_INSTALL_TEMPL_ADMIN_TEMPL : $adminLanguage->A_INSTALL_TEMPL_SITE_TEMPL), $option, 'template', $client, $userfile, '<a href="index2.php?option=com_templates&client=' . $client . '">' . $adminLanguage->A_INSTALL_TEMPL_BACKTTO_TEMPL . '</a>'); ?> <table class="content"> <?php writableCell('media'); writableCell('administrator/templates'); writableCell('templates'); writableCell('images/stories'); ?> </table>
/** * 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 module, iscore, client_id FROM #__modules WHERE id = '{$id}'"); $row = null; $database->loadObject($row); if ($row->iscore) { HTML_installer::showInstallMessage($row->title . 'is a core module, and can not be uninstalled.<br />You need to unpublish it if you don\'t want to use it', 'Uninstall - error', $this->returnTo($option, 'module', $row->client_id ? '' : 'admin')); exit; } $database->setQuery("SELECT id FROM #__modules WHERE module = '{$row->module}'"); $modules = $database->loadResultArray(); if (count($modules)) { $database->setQuery("DELETE FROM #__modules_menu" . "\nWHERE moduleid IN ('" . implode("','", $modules) . "')"); if (!$database->query()) { $msg = $database->stderr; die($msg); } } $database->setQuery("DELETE FROM #__modules WHERE module = '{$row->module}'"); if (!$database->query()) { $msg = $database->stderr; die($msg); } $basepath = $mosConfig_absolute_path . '/modules/'; $xmlfile = $basepath . $row->module . '.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)); return true; } } } }