/** * 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 $mosConfig_absolute_path; josSpoofCheck(null, null, 'request'); $id = str_replace(array('\\', '/'), '', $id); $basepath = $mosConfig_absolute_path . '/language/'; $xmlfile = $basepath . $id . '.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(); echo $filename; if (file_exists($basepath . $filename)) { echo '<br />Deletando: ' . $basepath . $filename; $result = unlink($basepath . $filename); } echo intval($result); } } } } else { HTML_installer::showInstallMessage('ID do idioma vazio, não é possível remover arquivos', 'Desistalação - erro', $this->returnTo($option, 'language', $client)); exit; } // remove XML file from front @unlink($xmlfile); 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 $mosConfig_absolute_path, $adminLanguage; $id = str_replace(array('\\', '/'), '', $id); $basepath = $mosConfig_absolute_path . '/language/'; $xmlfile = $basepath . $id . '.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(); echo $filename; if (file_exists($basepath . $filename)) { echo '<br />' . $adminLanguage->A_INSTALL_LANG_DELETING . ': ' . $basepath . $filename; $result = unlink($basepath . $filename); } echo intval($result); } } } } else { HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_LANG_NOREMOVE, $adminLanguage->A_INSTALL_LANG_UN_ERR, $this->returnTo($option, 'language', $client)); exit; } // remove XML file from front @unlink($xmlfile); return true; }
/** * 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; }
/** * 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('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; } }
/** * Language uninstall method * @param int The id of the module * @param string The URL option * @param int The client id */ function language_uninstall($id, $option, $client = 0) { $id = str_replace(array('\\', '/'), '', $id); $basepath = mamboCore::get('mosConfig_absolute_path') . '/language/'; $xmlfile = $basepath . $id . '.xml'; // see if there is an xml install file, must be same name as element if (file_exists($xmlfile)) { $parser =& new mosUninstallXML($xmlfile); $parser->uninstall(); $ret = $parser->errors->getMaxLevel() < _MOS_ERROR_FATAL; HTML_installer::showInstallMessage($parser->errors->getErrors(), T_('Uninstall language - ') . ($ret ? T_('Success') : T_('Error')), returnTo($option, 'language', $client)); } else { $message = new mosError(T_('Language id empty, cannot remove files'), _MOS_ERROR_FATAL); HTML_installer::showInstallMessage($message, T_('Uninstall - error'), "index2.php?option=com_languages"); } exit; }
/** * Install a template from a directory * @param string The URL option */ function installFromDirectory($installerClass, $option, $element, $client) { josSpoofCheck(); $userfile = mosGetParam($_REQUEST, 'userfile', ''); if (!$userfile) { mosRedirect("index2.php?option={$option}&element=module", "Por favor, selecione um diretório"); } $installer = new $installerClass(); $path = mosPathName($userfile); if (!is_dir($path)) { $path = dirname($path); } $ret = $installer->install($path); HTML_installer::showInstallMessage($installer->getError(), 'Novo envio ' . $element . ' - ' . ($ret ? 'Sucesso' : 'Erro'), $installer->returnTo($option, $element, $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; 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; } }
/** * 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; } } } } }
/** * 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; } } } }
/** * 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; }
/** * 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; }
/** * Install a template from a directory * @param string The URL option */ function installFromDirectory($installerClass, $option, $element, $client) { global $adminLanguage; $userfile = mosGetParam($_REQUEST, 'userfile', ''); if (!$userfile) { mosRedirect("index2.php?option={$option}&element=module", $adminLanguage->A_INSTALL_SELECT_DIR); } $installer = new $installerClass(); $path = mosPathName($userfile); if (!is_dir($path)) { $path = dirname($path); } $ret = $installer->install($path); HTML_installer::showInstallMessage($installer->getError(), $adminLanguage->A_INSTALL_UPLOAD_NEW . $element . ' - ' . ($ret ? $adminLanguage->A_INSTALL_SUCCESS : $adminLanguage->A_INSTALL_ERROR), $installer->returnTo($option, $element, $client)); }