/** * @param string $type * @param JInstallerAdapterComponent $parent * * @return bool */ public function preFlight($type, $parent) { parent::preFlight($type, $parent); /* Uninstall the depracated plugin OSCARootCertificates. * The parent method can't be used because the old plugin * has a bug that doesn't allow to use the native uninstall method. */ jimport('joomla.filesystem.folder'); $success = false; // Remove the files $path = JPATH_SITE . '/plugins/system/oscarootcertificates'; if (JFolder::exists($path)) { $success = JFolder::delete($path); } // Remove the database row $db = JFactory::getDbo(); $queryWhere = array($db->qn('type') . ' = ' . $db->q('plugin'), $db->qn('element') . ' = ' . $db->q('oscarootcertificates'), $db->qn('folder') . ' = ' . $db->q('system')); $query = $db->getQuery(true)->select('COUNT(*)')->from('#__extensions')->where($queryWhere); $db->setQuery($query); if ((int) $db->loadResult() > 0) { $query = $db->getQuery(true)->delete('#__extensions')->where($queryWhere); $db->setQuery($query); $success = $db->execute(); } // Displays the success message if ((bool) $success) { $this->setMessage('Uninstalling system plugin OSCARootCertificates was successful'); } return true; }
/** * doExecute * * @return void */ protected function doExecute() { jimport('joomla.filesystem.folder'); $folder = $this->getArgument(0, '/'); $path = JPATH_BASE . '/cache/' . trim($folder, '/\\'); $path = realpath($path); if (!$path) { $this->out('Path: "' . $folder . '" not found.'); return; } $this->out('Clearing cache files...'); if ($path != realpath(JPATH_BASE . '/cache')) { \JFolder::delete($path); } else { $files = new \FilesystemIterator($path); foreach ($files as $file) { if ($file->getBasename() == 'index.html') { continue; } if ($file->isFile()) { unlink((string) $file); } else { \JFolder::delete((string) $file); } } } $this->out(sprintf('Path: %s cleaned.', $path)); return; }
public function run($app) { // remove obsolete elements foreach (array('video', 'gallery', 'facebookilike', 'itempublishup') as $element) { if ($folder = $app->path->path('media:zoo/elements/' . $element)) { JFolder::delete($folder); } } // rename _itempublishup to _itempublish_up in config files foreach ($app->path->files('root:', true, '/positions\\.config/') as $file) { if (preg_match('#renderer\\/item\\/#', $file)) { $changed = false; if (!($path = $app->path->path('root:' . $file))) { continue; } $data = $app->data->create(file_get_contents($path)); if (!empty($data)) { foreach ($data as $layout => $positions) { foreach ($positions as $position => $elements) { foreach ($elements as $index => $element) { if (isset($element['element']) && $element['element'] == '_itempublishup') { $data[$layout][$position][$index]['element'] = '_itempublish_up'; $changed = true; } } } } } if ($changed) { $data = (string) $data; JFile::write($app->path->path('root:' . $file), $data); } } } }
function com_install() { $mainframe = JFactory::getApplication(); jimport('joomla.filesystem.folder'); // Initialize variables jimport('joomla.client.helper'); $FTPOptions = JClientHelper::getCredentials('ftp'); $language = JFactory::getLanguage(); $language->load('com_jce_imgmanager_ext', JPATH_SITE); $cache = $mainframe->getCfg('tmp_path'); // Check for tmp folder if (!JFolder::exists($cache)) { // Create if does not exist if (!JFolder::create($cache)) { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error'); } } // Check if folder exists and is writable or the FTP layer is enabled if (JFolder::exists($cache) && (is_writable($cache) || $FTPOptions['enabled'] == 1)) { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_CACHE_DESC')); } else { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error'); } // Check for GD if (!function_exists('gd_info')) { $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_GD_DESC'), 'error'); } else { $info = gd_info(); $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_GD_DESC') . ' - ' . $info['GD Version']); } // remove wideimage folder if (JFolder::exists(dirname(__FILE) . '/classes/wideimage')) { @JFolder::delete(dirname(__FILE) . '/classes/wideimage'); } }
public function uninstall($parent) { // Remove all Nucleus files manually as file installer only uninstalls files. $manifest = $parent->getManifest(); // Loop through all elements and get list of files and folders foreach ($manifest->fileset->files as $eFiles) { $target = (string) $eFiles->attributes()->target; $targetFolder = empty($target) ? JPATH_ROOT : JPATH_ROOT . '/' . $target; // Check if all children exists if (count($eFiles->children()) > 0) { // Loop through all filenames elements foreach ($eFiles->children() as $eFileName) { if ($eFileName->getName() == 'folder') { $folder = $targetFolder . '/' . $eFileName; $files = JFolder::files($folder, '.', false, true); foreach ($files as $name) { JFile::delete($name); } $subFolders = JFolder::folders($folder, '.', false, true); foreach ($subFolders as $name) { JFolder::delete($name); } } } } } return true; }
function preflight($type, $parent) { // Get the extension ID $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('extension_id')->from('#__extensions')->where($db->qn('element') . ' = ' . $db->q('com_eventgallery')); $db->setQuery($query); $eid = $db->loadResult(); if ($eid != null) { // Get the schema version $query = $db->getQuery(true); $query->select('version_id')->from('#__schemas')->where('extension_id = ' . $eid); $db->setQuery($query); $version = $db->loadResult(); if (version_compare($version, '3.3.2', 'gt')) { $msg = "<p>Downgrades are not supported. Please install the same or a newer version.</p>"; JError::raiseWarning(100, $msg); return false; } } $folders = array(JPATH_ROOT . '/administrator/components/com_eventgallery/controllers', JPATH_ROOT . '/administrator/components/com_eventgallery/media', JPATH_ROOT . '/administrator/components/com_eventgallery/models', JPATH_ROOT . '/administrator/components/com_eventgallery/views', JPATH_ROOT . '/administrator/components/com_eventgallery/sql', JPATH_ROOT . '/components/com_eventgallery/controllers', JPATH_ROOT . '/components/com_eventgallery/helpers', JPATH_ROOT . '/components/com_eventgallery/language', JPATH_ROOT . '/components/com_eventgallery/library', JPATH_ROOT . '/components/com_eventgallery/media', JPATH_ROOT . '/components/com_eventgallery/models', JPATH_ROOT . '/components/com_eventgallery/tests', JPATH_ROOT . '/components/com_eventgallery/views'); $files = array(JPATH_ROOT . '/language/en-GB/en-GB.com_eventgallery.ini', JPATH_ROOT . '/language/de-DE/de-DE.com_eventgallery.ini', JPATH_ROOT . '/administrator/language/en-GB/en-GB.com_eventgallery.ini', JPATH_ROOT . '/administrator/language/en-GB/en-GB.com_eventgallery.sys.ini'); foreach ($folders as $folder) { if (JFolder::exists($folder)) { JFolder::delete($folder); } } foreach ($files as $file) { if (JFolder::exists($file)) { JFolder::delete($file); } } $this->_copyCliFiles($parent); }
public function uninstall($adapter) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); // Delete plugin files $folder = JPATH_PLUGINS . '/system/' . $this->_ext; if (JFolder::exists($folder)) { JFolder::delete($folder); } // Delete plugin language files $lang_folder = JPATH_ADMINISTRATOR . '/language'; $languages = JFolder::folders($lang_folder); foreach ($languages as $lang) { $file = $lang_folder . '/' . $lang . '/' . $lang . '.plg_system_' . $this->_ext . '.ini'; if (JFile::exists($file)) { JFile::delete($file); } $file = $lang_folder . '/' . $lang . '/' . $lang . '.plg_system_' . $this->_ext . '.sys.ini'; if (JFile::exists($file)) { JFile::delete($file); } } $db = JFactory::getDbo(); $query = $db->getQuery(true)->delete('#__extensions')->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))->where($db->quoteName('element') . ' = ' . $db->quote($this->_ext)); $db->setQuery($query); $db->execute(); }
/** * unzip the file * @return bool */ public function unzip() { JRequest::checkToken() or die('Invalid Token'); $appl = JFactory::getApplication(); // if folder doesn't exist - create it! if (!JFolder::exists($this->pathUnzipped)) { JFolder::create($this->pathUnzipped); } else { // let us remove all previous unzipped files $folders = JFolder::folders($this->pathUnzipped); foreach ($folders as $folder) { JFolder::delete($this->pathUnzipped . '/' . $folder); } } $file = JFolder::files($this->pathArchive); $result = JArchive::extract($this->pathArchive . '/' . $file[0], $this->pathUnzipped . '/' . $file[0]); if ($result) { // scan unzipped folders if we find zip file -> unzip them as well $this->unzipAll($this->pathUnzipped . '/' . $file[0]); $message = 'COM_JEDCHECKER_UNZIP_SUCCESS'; } else { $message = 'COM_JEDCHECKER_UNZIP_FAILED'; } $appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message)); return $result; }
function cleanupInstall($userfile_name, $resultdir) { if (file_exists($resultdir)) { JFolder::delete($resultdir); unlink(DOCMAN_Compat::mosPathName(JPATH_ROOT . DS . 'media' . DS . $userfile_name, false)); } }
public function purge() { $user = JFactory::getUser(); if (!$user->authorise('core.admin', 'com_djmediatools')) { echo JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'); exit(0); } $files = JFolder::files(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('index.html', '.svn', 'CVS', '.DS_Store', '__MACOSX')); $errors = array(); if (count($files) > 0) { foreach ($files as $file) { if (!JFile::delete($file)) { $errors[] = $file; } } } $folders = JFolder::folders(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('.', '..')); if (count($folders) > 0) { $folders = array_reverse($folders); foreach ($folders as $key => $folder) { JFolder::delete($folder); } } if (count($errors) > 0) { echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_NOT_BEEN_DELETED', count($errors)); } else { echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_BEEN_DELETED', count($files)); } }
public function process($limitstart = 0) { $folders = $this->getFolders(); $target_folder = isset($folders[$limitstart]) ? $folders[$limitstart] : null; if (!$target_folder) { return true; } $path = str_replace(JPATH_SITE, '', $target_folder); // Check if the target folder exists if (!JFolder::exists($target_folder)) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_NOT_FOUND', $path); return false; } // Check if the destination folder exists if (JFolder::exists($target_folder . '3')) { if (!JFolder::delete($target_folder . '3')) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_EXISTS', $path . '3'); return false; } } if (!JFolder::move($target_folder, $target_folder . '3')) { $this->success = false; $this->log[] = JText::sprintf('COM_PFMIGRATOR_FOLDER_RENAME_FAILED', $path); return false; } $this->log[] = JText::sprintf('COM_PFMIGRATOR_RENAME_FOLDER_SUCCESS', $path, $path . '3'); return true; }
private function _removeObsoleteFilesAndFolders($icagendaRemoveFiles) { // Remove files jimport('joomla.filesystem.file'); if (!empty($icagendaRemoveFiles['files'])) { foreach ($icagendaRemoveFiles['files'] as $file) { $f = JPATH_ROOT . '/' . $file; if (!JFile::exists($f)) { continue; } JFile::delete($f); } } // Remove folders jimport('joomla.filesystem.file'); if (!empty($icagendaRemoveFiles['folders'])) { foreach ($icagendaRemoveFiles['folders'] as $folder) { $f = JPATH_ROOT . '/' . $folder; if (!JFolder::exists($f)) { continue; } JFolder::delete($f); } } }
function com_install() { $db = JFactory::getDBO(); // Install System plugin $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_noixacl' . DS . 'plugins' . DS . 'system' . DS; $dest = JPATH_ROOT . DS . 'plugins' . DS . 'system' . DS; $res = JFile::copy($src . 'noixacl.php', $dest . 'noixacl.php'); $res = $res && JFile::copy($src . 'noixacl.xml', $dest . 'noixacl.xml'); $db->setQuery("INSERT INTO #__plugins\r\n\t (id, name, element, folder, access, ordering, published, iscore, client_id, checked_out, checked_out_time, params)\r\n\t VALUES ('', 'noixACL - System Plugin 2.0.10', 'noixacl', 'system', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '')"); $res = $res && $db->query(); if (!$res) { JError::raiseWarning(100, JText::_('NoixACL System plugin not installed. Please install it manually from the following folder') . ': ' . $src); } else { JFolder::delete($src); } // Install User plugin $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_noixacl' . DS . 'plugins' . DS . 'user' . DS; $dest = JPATH_ROOT . DS . 'plugins' . DS . 'user' . DS; $res = JFile::copy($src . 'noixacl.php', $dest . 'noixacl.php'); $res = $res && JFile::copy($src . 'noixacl.xml', $dest . 'noixacl.xml'); $db->setQuery("INSERT INTO #__plugins\r\n\t (id, name, element, folder, access, ordering, published, iscore, client_id, checked_out, checked_out_time, params)\r\n\t VALUES ('', 'noixACL - User Plugin 2.0.10', 'noixacl', 'user', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '')"); $res = $res && $db->query(); if (!$res) { JError::raiseWarning(100, JText::_('NoixACL User plugin not installed. Please install it manually from the following folder') . ': ' . $src); } else { JFolder::delete($src); } }
public function resetThumbs() { $items = self::getItems(); //Get Params $params = JComponentHelper::getParams('com_spsimpleportfolio'); $square = strtolower($params->get('square', '600x600')); $rectangle = strtolower($params->get('rectangle', '600x400')); $tower = strtolower($params->get('tower', '600x800')); $cropratio = $params->get('cropratio', 4); if (count($items)) { //Removing old thumbs foreach ($items as $item) { $folder = JPATH_ROOT . '/images/spsimpleportfolio/' . $item->alias; if (JFolder::exists($folder)) { JFolder::delete($folder); } } //Creating Thumbs foreach ($items as $item) { $image = JPATH_ROOT . '/' . $item->image; $path = JPATH_ROOT . '/images/spsimpleportfolio/' . $item->alias; if (!file_exists($path)) { JFolder::create($path, 0755); } $sizes = array($square, $rectangle, $tower); $image = new JImage($image); $image->createThumbs($sizes, $cropratio, $path); } } $this->setRedirect('index.php?option=com_config&view=component&component=com_spsimpleportfolio&path=&return=' . base64_encode('index.php?option=com_spsimpleportfolio'), 'Thumbnails generated.'); }
/** * @param (string) $type * @param (object) $parent */ public function postflight($type, $parent) { $folder = sprintf('%s/components/com_krizalys_countries', JPATH_SITE); if (!JFolder::delete($folder)) { echo JText::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $folder) . '<br />'; } }
public function purge() { $db = JFactory::getDbo(); $user = JFactory::getUser(); if (!$user->authorise('core.admin', 'com_djmediatools')) { echo JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'); exit(0); } $files = JFolder::files(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('index.html', '.svn', 'CVS', '.DS_Store', '__MACOSX')); $errors = array(); if (count($files) > 0) { foreach ($files as $file) { if (!JFile::delete($file)) { $errors[] = $db->quote(JPath::clean(str_replace(JPATH_ROOT, '', $file))); } } } $folders = JFolder::folders(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('.', '..')); if (count($folders) > 0) { $folders = array_reverse($folders); foreach ($folders as $key => $folder) { JFolder::delete($folder); } } if (count($errors) > 0) { $db->setQuery("DELETE FROM #__djmt_resmushit WHERE path NOT IN (" . implode(',', $errors) . ")"); $db->query(); echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_NOT_BEEN_DELETED', count($errors)); } else { $db->setQuery("DELETE FROM #__djmt_resmushit"); $db->query(); echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_BEEN_DELETED', count($files)); } }
public function install(InputInterface $input, OutputInterface $output) { $app = Bootstrapper::getApplication($this->target_dir); // Output buffer is used as a guard against Joomla including ._ files when searching for adapters // See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html ob_start(); $installer = $app->getInstaller(); foreach ($this->extension as $package) { $remove = false; if (is_file($package)) { $result = \JInstallerHelper::unpack($package); $directory = isset($result['dir']) ? $result['dir'] : false; $remove = true; } else { $directory = $package; } if ($directory !== false) { $path = realpath($directory); if (!file_exists($path)) { $output->writeln("<info>File not found: " . $directory . "</info>\n"); continue; } try { $installer->install($path); } catch (\Exception $e) { $output->writeln("<info>Caught exception during install: " . $e->getMessage() . "</info>\n"); } if ($remove) { \JFolder::delete($path); } } } ob_end_clean(); }
/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @return void */ protected function tearDown() { JFolder::delete(JPATH_TESTS . '/tmp/language'); unset($this->object); unset($this->inspector); parent::tearDown(); }
public function postflight($type, $parent) { // Clear Joomla system cache. /** @var JCache|JCacheController $cache */ $cache = JFactory::getCache(); $cache->clean('_system'); // Clear Gantry5 cache. $path = JFactory::getConfig()->get('cache_path', JPATH_SITE . '/cache') . '/gantry5'; if (is_dir($path)) { JFolder::delete($path); } // Make sure that PHP has the latest data of the files. clearstatcache(); // Remove all compiled files from opcode cache. if (function_exists('opcache_reset')) { @opcache_reset(); } elseif (function_exists('apc_clear_cache')) { @apc_clear_cache(); } if ($type == 'uninstall') { return true; } /** @var JInstallerAdapter $parent */ $manifest = $parent->getManifest(); // Enable and lock extensions to prevent uninstalling them individually. $this->prepareExtensions($manifest, 1); // Make sure that all file formats used by Gantry 5 are editable from template manager. $this->adjustTemplateSettings(); return true; }
public function delete(&$pks) { $dispatcher = JEventDispatcher::getInstance(); $pks = (array) $pks; $table = $this->getTable(); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $db = JFactory::getDbo(); // Include the content plugins for the on delete events. JPluginHelper::importPlugin('content'); // Iterate the items to delete each one. foreach ($pks as $i => $pk) { if ($table->load($pk)) { if ($this->canDelete($table)) { $context = $this->option . '.' . $this->name; // Trigger the onContentBeforeDelete event. $result = $dispatcher->trigger($this->event_before_delete, array($context, $table)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } $query = $db->getQuery(true); $query->select($db->quoteName('file_name'))->from($db->quoteName('#__simplefilemanager'))->where($db->quoteName('id') . ' = ' . $pk); $db->setQuery($query); $file_name = $db->loadResult(); if (!$table->delete($pk)) { $this->setError($table->getError()); return false; } else { if (!JFile::delete($file_name)) { JFactory::getApplication()->enqueueMessage(JText::_('COM_SIMPLEFILEMANAGER_ERROR_DELETING') . ': ' . $file_name, 'error'); } else { $path_parts = pathinfo($file_name); JFolder::delete($path_parts['dirname']); } } // Trigger the onContentAfterDelete event. $dispatcher->trigger($this->event_after_delete, array($context, $table)); } else { // Prune items that you can't change. unset($pks[$i]); $error = $this->getError(); if ($error) { JLog::add($error, JLog::WARNING, 'jerror'); return false; } else { JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING, 'jerror'); return false; } } } else { $this->setError($table->getError()); return false; } } // Clear the component's cache $this->cleanCache(); return true; }
/** * Method to dispatch special template framework * @param string $templateAuthor */ public static function dispatchTemplateFramework($templateAuthor) { $cacheFolder = JPATH_ROOT . '/cache'; if (is_file($cacheFolder) && JFolder::delete($cacheFolder)) { } else { //JFolder::create($cacheFolder); } }
function removeBackupTemplate($templateName) { $templatesPath = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'templates' . DS; $backups = JFolder::folders($templatesPath, '^' . $templateName . '_bak[0-9]'); foreach ($backups as $backup) { JFolder::delete($templatesPath . $backup); } }
public function uninstall($parent) { // remove media folder if (JFolder::exists(JPATH_ROOT . '/media/zoo/applications/')) { JFolder::delete(JPATH_ROOT . '/media/zoo/applications/'); } return true; }
public function __construct(KConfig $options) { parent::__construct($options); $identifier = $options->identifier; $type = $identifier->type; $package = $identifier->package; $admin = JPATH_ADMINISTRATOR . '/components/' . $type . '_' . $package; $site = JPATH_ROOT . '/components/' . $type . '_' . $package; $media = JPATH_ROOT . '/media/' . $type . '_' . $package; $xmls = JFolder::files(JPATH_ADMINISTRATOR . '/components/' . $type . '_' . $package, '.xml$', 0, true); foreach ($xmls as $manifest) { $xml = simplexml_load_file($manifest); if (isset($xml['type'])) { break; } } if (empty($xml)) { return; } if (!$xml->deleted) { return; } KLoader::load('lib.joomla.filesystem.folder'); KLoader::load('lib.joomla.filesystem.file'); if ($xml->deleted->admin) { foreach ($xml->deleted->admin->children() as $name => $item) { if ($name == 'folder' && JFolder::exists($admin . '/' . $item)) { JFolder::delete($admin . '/' . $item); } if ($name == 'file' && JFile::exists($admin . '/' . $item)) { JFile::delete($admin . '/' . $item); } } } if ($xml->deleted->site) { if ($xml->deleted->site['removed'] && JFolder::exists($site)) { JFolder::delete($site); } foreach ($xml->deleted->site->children() as $name => $item) { if ($name == 'folder' && JFolder::exists($site . '/' . $item)) { JFolder::delete($site . '/' . $item); } if ($name == 'file' && JFile::exists($site . '/' . $item)) { JFile::delete($site . '/' . $item); } } } if ($xml->deleted->media) { foreach ($xml->deleted->media->children() as $name => $item) { if ($name == 'folder' && JFolder::exists($media . '/' . $item)) { JFolder::delete($media . '/' . $item); } if ($name == 'file' && JFile::exists($media . '/' . $item)) { JFile::delete($media . '/' . $item); } } } }
function postflight($type, $parent) { if (version_compare(JVERSION, '3.0.0', '>')) { $messages = array(); // Import required modules jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); jimport('joomla.filesystem.file'); //$db = JFactory::getDBO(); //$query = "ALTER TABLE #__k2_items ADD FULLTEXT(extra_fields)"; //$db->setQuery($query); //$db->query(); // Get packages $p_dir = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_jak2filter' . DS . 'packages'); // Did you give us a valid directory? if (!is_dir($p_dir)) { $messages[] = JText::_('Package directory(Related modules, plugins) is missing'); } else { $subpackages = JFolder::files($p_dir); $result = true; $installer = new JInstaller(); if ($subpackages) { $app = JFactory::getApplication(); $templateDir = 'templates/' . $app->getTemplate(); foreach ($subpackages as $zpackage) { if (JFile::getExt($p_dir . DS . $zpackage) != "zip") { continue; } $subpackage = JInstallerHelper::unpack($p_dir . DS . $zpackage); if ($subpackage) { $type = JInstallerHelper::detectType($subpackage['dir']); if (!$type) { $messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::_($zpackage . " Not valid package") . '</span>'; $result = false; } if (!$installer->install($subpackage['dir'])) { // There was an error installing the package $messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Error')) . '</span>'; } else { $messages[] = '<img src="' . $templateDir . '/images/admin/tick.png" alt="" width="16" height="16" /> <span style="color:#00FF00;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Success')) . '</span>'; } if (!is_file($subpackage['packagefile'])) { $subpackage['packagefile'] = $p_dir . DS . $subpackage['packagefile']; } if (is_dir($subpackage['extractdir'])) { JFolder::delete($subpackage['extractdir']); } if (is_file($subpackage['packagefile'])) { JFile::delete($subpackage['packagefile']); } } } } JFolder::delete($p_dir); } } }
/** * Deletes paths from the current path * * @param string $listFolder The image directory to delete a file from * @since 1.5 */ function delete() { global $mainframe; JRequest::checkToken('request') or jexit('Invalid Token'); // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Get some data from the request $tmpl = JRequest::getCmd('tmpl'); $paths = JRequest::getVar('rm', array(), '', 'array'); $folder = JRequest::getVar('folder', '', '', 'path'); // Initialize variables $msg = array(); $ret = true; if (count($paths)) { foreach ($paths as $path) { if ($path !== JFile::makeSafe($path)) { JError::raiseWarning(100, JText::_('Unable to delete:') . htmlspecialchars($path, ENT_COMPAT, 'UTF-8') . ' ' . JText::_('WARNDIRNAME')); continue; } $fullPath = JPath::clean(JA_WORKING_DATA_FOLDER . DS . $folder . DS . $path); if (is_file($fullPath)) { $ret |= !JFile::delete($fullPath); } else { if (is_dir($fullPath)) { $files = JFolder::files($fullPath, '.', true); $canDelete = true; foreach ($files as $file) { if ($file != 'index.html') { $canDelete = false; } } if ($canDelete) { $ret |= !JFolder::delete($fullPath); } else { //allow remove folder not empty on local repository $ret2 = JFolder::delete($fullPath); $ret |= !$ret2; if ($ret2 == false) { JError::raiseWarning(100, JText::_('Unable to delete:') . $fullPath); } } } } } } if ($ret) { JError::raiseNotice(200, JText::_('Successfully delete a seleted item(s).')); } if ($tmpl == 'component') { // We are inside the iframe $mainframe->redirect('index.php?option=' . JACOMPONENT . '&view=repolist&folder=' . $folder . '&tmpl=component'); } else { $mainframe->redirect('index.php?option=' . JACOMPONENT . '&view=repolist&folder=' . $folder); } }
/** * */ public function clearCache() { $path = JPATH_SITE . DS . 'cache' . DS . 'leo'; jimport('joomla.filesystem.folder'); if (is_dir($path)) { JFolder::delete($path); return true; } return false; }
/** * Uninstall Application * * @param Application $application * @since 2.0 * @throws InstallHelperException */ public function uninstallApplication(Application $application) { $group = $application->getGroup(); if ($this->_applicationExists($group)) { throw new InstallHelperException('Delete existing applications first.'); } if (!($directory = $this->app->path->path("applications:{$group}")) || !JFolder::delete($directory)) { throw new InstallHelperException('Unable to delete directory: (' . $directory . ')'); } }
public static function deleteFolder($folder) { if (JCOMMENTS_JVERSION == '1.0') { @rmdir($folder); } else { jimport('joomla.filesystem.folder'); return JFolder::delete($folder); } return true; }
/** * {@inheritdoc} */ protected function _delete($path) { $path = $this->_realpath($path); jimport('joomla.filesystem.folder'); if (is_dir($path)) { JFolder::delete($path); } elseif (file_exists($path)) { @unlink($path); } }