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(); }
function getPackageFromUpload() { $install_file = JRequest::getVar('package', null, 'files', 'array'); if (!(bool) ini_get('file_uploads')) { $msg = 'File upload function is disabled, please enable it in file "php.ini"'; JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg)); return false; } if (!extension_loaded('zlib')) { $msg = 'Zlib library is disabled, please enable it in file "php.ini"'; JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg)); return false; } if ($install_file['name'] == '') { $msg = 'The package is not selected, please download and select it'; JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg)); return false; } if (JFile::getExt($install_file['name']) != 'zip') { $msg = 'The package has incorrect format, please use exactly the file you downloaded'; JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg)); return false; } $tmp_dest = JPATH_ROOT . DS . 'tmp' . DS . $install_file['name']; $tmp_src = $install_file['tmp_name']; if (!JFile::upload($tmp_src, $tmp_dest)) { $msg = 'Folder "tmp" is Unwritable, please set it to Writable (chmod 777). You can set the folder back to Unwritable after sample data installation'; JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg)); return false; } $package = JInstallerHelper::unpack($tmp_dest); return $package; }
private function installGiantExtensionsPlugin() { $pluginPath = dirname(__FILE__) . '/plg_content_giantcontent.zip'; $installResult = JInstallerHelper::unpack($pluginPath); if (empty($installResult)) { $app = JFactory::getApplication(); $app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error'); return false; } $installer = new JInstaller(); $installer->setOverwrite(true); if (!$installer->install($installResult['extractdir'])) { $app = JFactory::getApplication(); $app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error'); return false; } $db = JFactory::getDBO(); $db->setQuery('UPDATE #__extensions SET enabled = 1 WHERE type = "plugin" AND folder = "content" AND element = "giantcontent"'); $db->query(); if ($db->getErrorNum()) { $app = JFactory::getApplication(); $app->enqueueMessage('Giant Content can not enable "Content - Giant Content" plugin. Please enable plugin manually in the plugin manager.', 'warning'); } return true; }
protected function runSQL($source, $file) { $db = JFactory::getDbo(); $driver = strtolower($db->name); if ($driver == 'mysqli') { $driver = 'mysql'; } elseif ($driver == 'sqlsrv') { $driver = 'sqlazure'; } $sqlfile = $source . '/sql/' . $driver . '/' . $file; if (file_exists($sqlfile)) { $buffer = file_get_contents($sqlfile); if ($buffer !== false) { $queries = JInstallerHelper::splitSql($buffer); foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->execute()) { JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true))); } } } } } }
function querySQL($buffer) { $db =& JFactory::getDBO(); // Graceful exit and rollback if read not successful if ($buffer === false) { return false; } // Create an array of queries from the sql file jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) == 0) { // No queries to process return 0; } // Process each query in the $queries array (split out of sql file). foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->query()) { JError::raiseWarning(1, 'JInstaller::install: ' . JText::_('SQL Error') . " " . $db->stderr(true)); return false; } } } return true; }
function update($parent) { $db = JFactory::getDBO(); if (method_exists($parent, 'extension_root')) { $sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql'; } else { $sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql'; } // Don't modify below this line $buffer = file_get_contents($sqlfile); if ($buffer !== false) { jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) != 0) { foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->query()) { CJFunctions::throw_error(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), 1); return false; } } } } } echo '<p>' . JText::sprintf('COM_CJBLOG_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>'; }
function postflight($type, $parent) { if ($type == 'update') { $sqlfile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'install.rsform.utf8.sql'; $buffer = file_get_contents($sqlfile); if ($buffer === false) { JError::raiseWarning(1, JText::_('JLIB_INSTALLER_ERROR_SQL_READBUFFER')); return false; } jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) == 0) { // No queries to process return 0; } $db =& JFactory::getDBO(); // Process each query in the $queries array (split out of sql file). foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->query()) { JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true))); return false; } } } } }
/** * Download and install */ function install($id, $url) { if (!is_string($url)) { return JText::_('NNEM_ERROR_NO_VALID_URL'); } $url = 'http://' . str_replace('http://', '', $url); if (!($target = JInstallerHelper::downloadPackage($url))) { return JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE'); } $target = JFactory::getConfig()->get('tmp_path') . '/' . $target; NNFrameworkFunctions::loadLanguage('com_installer', JPATH_ADMINISTRATOR); jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); // Get an installer instance $installer = JInstaller::getInstance(); // Unpack the package $package = JInstallerHelper::unpack($target); // Cleanup the install files if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['packagefile']); // Install the package if (!$installer->install($package['dir'])) { // There was an error installing the package return JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))); } return true; }
function installPluginTableByThemeName($themeName) { jimport('joomla.filesystem.file'); $sqlFile = JPATH_PLUGINS . DS . $this->_pluginType . DS . $themeName . DS . $this->_installFile; if (JFile::exists($sqlFile)) { $objJNSUtils = JSNISFactory::getObj('classes.jsn_is_utils'); $buffer = $objJNSUtils->readFileToString($sqlFile); if ($buffer === false) { return false; } jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) == 0) { JError::raiseWarning(100, $sqlFile . JText::_(' not exits')); return 0; } foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $this->_db->setQuery($query); if (!$this->_db->query()) { JError::raiseWarning(100, 'JInstaller::install: ' . JText::_('SQL Error') . " " . $this->_db->stderr(true)); return false; } } } return true; } else { JError::raiseWarning(100, $sqlFile . JText::_(' not exits')); return false; } }
function update($parent) { $db = JFactory::getDBO(); if (method_exists($parent, 'extension_root')) { $sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql'; } else { $sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql'; } // Don't modify below this line $buffer = file_get_contents($sqlfile); if ($buffer !== false) { jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) != 0) { foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->query()) { JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true))); return false; } } } } } echo '<p>' . JText::_('COM_COMMUNITYSURVEYS_UPDATE_TEXT') . '</p>'; $parent->getParent()->setRedirectURL('index.php?option=com_communitysurveys&view=dashboard'); }
function update($parent) { $db = JFactory::getDBO(); if (method_exists($parent, 'extension_root')) { $sqlfile = $parent->getPath('extension_root') . '/sql/install.mysql.sql'; } else { $sqlfile = $parent->getParent()->getPath('extension_root') . '/sql/install.mysql.sql'; } // Don't modify below this line $buffer = file_get_contents($sqlfile); if ($buffer !== false) { jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) != 0) { foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->query()) { JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true))); return false; } } } } } }
function _installPackage() { $installer = JSNISInstaller::getInstance(); if ($this->_packageExtract) { $objJSNPlugins = JSNISFactory::getObj('classes.jsn_is_plugins'); $countSource = count($this->_listCurrentSources); $currentSources = array(); if ($countSource) { for ($i = 0; $i < $countSource; $i++) { $item = $this->_listCurrentSources[$i]; $currentSources[$item->element] = $objJSNPlugins->getXmlFile($item); } } if (!$installer->install($this->_packageExtract['dir'])) { $this->_msgError = JText::_('INSTALLER_IMAGE_SOURCE_PACKAGE_UNSUCCESSFULLY_INSTALLED'); $this->_error = true; return false; } $this->_upgradeSourceDB($currentSources, $installer); if (!is_file($this->_packageExtract['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $this->_packageExtract['packagefile']; } JInstallerHelper::cleanupInstall($this->_packageExtract['packagefile'], $this->_packageExtract['extractdir']); } }
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); } } }
public function update() { // Make sure there are updates available $updates = $this->getModel('update')->getUpdates(false); if (!$updates->update_available) { $this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_NOUPDATES'), 'error'); $this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration'); } // Download the package $config = JFactory::getConfig(); $target = $config->get('tmp_path') . '/joomailermailchimpintegration_update.zip'; $result = $this->getModel('update')->downloadPackage($updates->packageUrl, $target); if ($result === false) { $this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_CANTDOWNLOAD'), 'error'); $this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration'); } // Extract the package jimport('joomla.installer.helper'); $result = JInstallerHelper::unpack($target); if ($result === false) { $this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_CANTEXTRACT'), 'error'); $this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration'); } // Package extracted; run the installer $tempdir = $result['dir']; @ob_end_clean(); ?> <html> <head></head> <body> <form action="<?php echo JURI::base() . 'index.php?option=com_installer&view=install'; ?> " method="post" name="frm" id="frm"> <input type="hidden" name="task" value="install.install" /> <input type="hidden" name="installtype" value="folder" /> <input type="hidden" name="install_directory" value="<?php echo htmlspecialchars($tempdir); ?> " /> <input type="hidden" name="<?php echo JSession::getFormToken(); ?> " value="1" /> </form> <script type="text/javascript"> document.frm.submit(); </script> </body> <html><?php exit; }
/** * method to install the component * * @return void * <div id="system-message-container"> <div id="system-message"> <div class="alert alert-message"><a class="close" data-dismiss="alert">×</a> <h4 class="alert-heading">Message</h4> <div> <p>Installing component was successful.</p> </div> </div> </div> </div> */ function install($parent) { // $parent is the class calling this method echo '<div id="system-message-container">'; $msgtext = ""; echo '<div id="system-message"> <div style=" overflow:hidden; margin:8px 0 8px 0; padding:5px;" > <div style=" font-size:12px; margin:0px 0 0px 0; padding:5px; position:relative; float:right;"><div>Powered by Percha.com</div></div> <div style="float:left; margin:0 20px 20px 0;"><img src="http://www.fieldsattach.com/images/logo_fieldsattach_small.png" alt="fieldsattach.com" /></div> <div style=" margin:30px 0 8px 0; padding:5px; font-size:23px; color:#4892AB;">Thanks for install the Fieldsattach component.</div> </div>'; //INSTALL THE PLUGINS ******************************************************************************* $installer = new JInstaller(); //$installer->_overwrite = true; $pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_fieldsattach' . DS . 'extensions' . DS; $pkgs = array('input.zip' => 'Plugin fieldsattachment <strong>Input</strong>', 'file.zip' => 'Plugin fieldsattachment <strong>File</strong>', 'image.zip' => 'Plugin fieldsattachment <strong>image</strong>', 'imagegallery.zip' => 'Plugin fieldsattachment <strong>imagegallery</strong>', 'select.zip' => 'Plugin fieldsattachment <strong>select</strong>', 'textarea.zip' => 'Plugin fieldsattachment <strong>textarea</strong>', 'content_fieldsattachment.zip' => 'Plugin Content FieldsAttachment', 'system_fieldsattachment.zip' => 'Plugin System FieldsAttachment', 'advancedsearch_fieldsattachment.zip' => 'Plugin Advanced Search FieldsAttachment', 'filterarticles.zip' => 'Plugin Advanced FILTER FieldsAttachment'); foreach ($pkgs as $pkg => $pkgname) { $package = JInstallerHelper::unpack($pkg_path . $pkg); if ($installer->install($package['dir'])) { $msgtext .= '<div id="system-message-container"><div class="alert alert-message">' . $pkgname . ' successfully installed.</div></div>'; //ACTIVE IT } else { $msgtext .= '<div id="system-message-container"><div class="alert alert-message">ERROR: Could not install the $pkgname. Please install manually</div></div>'; } //ACTIVE THE PLUGINS ******************************************************************************* $db = JFactory::getDBO(); $sql = "UPDATE #__extensions SET enabled = 1 WHERE element = 'fieldsattachment'"; $db->setQuery($sql); $db->query(); $db = JFactory::getDBO(); $sql = "UPDATE #__extensions SET enabled = 1 WHERE element = 'fieldsattachmentadvanced'"; $db->setQuery($sql); $db->query(); $db = JFactory::getDBO(); $sql = "UPDATE #__extensions SET enabled = 1 WHERE folder = 'fieldsattachment'"; $db->setQuery($sql); $db->query(); //DESACTIVE OLD SEARCH $db = JFactory::getDBO(); $sql = "UPDATE #__extensions SET enabled = 0 WHERE element = 'fieldsattachment' AND folder='search'"; $db->setQuery($sql); $db->query(); JInstallerHelper::cleanupInstall($pkg_path . $pkg, $package['dir']); } //DELETE EXTENSIONS $pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_fieldsattach' . DS . 'extensions' . DS; destroy_dir($pkg_path); $msgtext .= '<div id="system-message-container"><div class="alert alert-message">Clean install directory: ' . $pkg_path . '</div></div>'; echo $msgtext; echo '</div>'; //$parent->getParent()->setRedirectURL('index.php?option=com_helloworld'); }
function com_install() { JAVoiceHelpers::Install_Db(); $messages = array(); // Import required modules jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); jimport('joomla.filesystem.file'); // Get packages $p_dir = JPath::clean(JPATH_SITE . '/components/com_javoice/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); } }
public function applyDump($dump) { jimport("joomla.installer.helper"); jimport("joomla.version"); $version = new JVersion(); if ($version->RELEASE == "1.5") { $helper = new JInstallerHelper(); $sql_statements = $helper->splitSql($dump); } else { //$helper = new JInstallerHelper(); $sql_statements = JInstallerHelper::splitSql($dump); } $db =& JFactory::getDBO(); $count = 0; foreach ($sql_statements as $statement) { if (trim($statement)) { $db->setQuery($statement); $db->query(); $count++; } } return $count; }
private function _getPackageFromDistributives($plugin_distr) { // Make sure that zlib is loaded so that the package can be unpacked if (!extension_loaded('zlib')) { return false; } //Check file exist if (!file_exists($plugin_distr)) { return false; } // Unpack the downloaded package file $package = JInstallerHelper::unpack($plugin_distr); return $package; }
function autoupdate() { $update = $this->parseXMLFile(); $config =& JFactory::getConfig(); $tmp_dest = $config->getValue('config.tmp_path'); if (!is_object($update)) { // parseXMLFile will have set a message hopefully //$this->setState('message', 'XML Parse failed'); return false; } else { $destination = $tmp_dest . DS . 'com_jupdateman_auto.tgz'; $download = downloadFile($update->updaterurl, $destination); if ($download !== true) { $this->setState('message', $download->error_message); return false; } else { $package = JInstallerHelper::unpack($destination); if (!$package) { $this->setState('message', 'Unable to find install package'); return false; } $installer =& JInstaller::getInstance(); // Install the package if (!$installer->install($package['dir'])) { // There was an error installing the package $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error')); $result = false; } else { // Package installed sucessfully $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success')); $result = true; } // Grab the application $mainframe =& JFactory::getApplication(); // Set some model state values $mainframe->enqueueMessage($msg); $this->setState('name', $installer->get('name')); $this->setState('result', $result); $this->setState('message', $installer->message); $this->setState('extension.message', $installer->get('extension.message')); // Cleanup the install files if (!is_file($package['packagefile'])) { $config =& JFactory::getConfig(); $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); return $result; } } }
function postflight($type, $parent) { $url = "http://www.jhackguard.com/downloads/com_jhackguard.zip"; // Download the package at the URL given $p_file = JInstallerHelper::downloadPackage($url); // Was the package downloaded? if (!$p_file) { JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL')); return false; } $config = JFactory::getConfig(); $tmp_dest = $config->get('tmp_path'); // Unpack the downloaded package file $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true); // Was the package unpacked? if (!$package || !$package['type']) { if (in_array($installType, array('upload', 'url'))) { JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); } $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE')); return false; } // Get an installer instance $installer = new JInstaller(); // Install the package if (!$installer->install($package['dir'])) { // There was an error installing the package $msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))); $result = false; } else { // Package installed sucessfully $msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))); $result = true; } // Set some model state values $app = JFactory::getApplication(); $app->enqueueMessage($msg); $app->setUserState('com_installer.message', $installer->message); $app->setUserState('com_installer.extension_message', $installer->get('extension_message')); $app->setUserState('com_installer.redirect_url', $installer->get('redirect_url')); // Cleanup the install files if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); $app->enqueueMessage("The default installation of jHackGuard has no filters included. Please download the latest filters by going to the '<b>Filter Maintenance</b>' page in the component menu.", "error"); }
public function process($limitstart = 0) { require_once JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php'; JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_installer/models'); // Path to the pf 4 package $pkg = JPATH_ADMINISTRATOR . '/components/com_pfmigrator/_install/pkg_projectfork_4.1.0.zip'; $dest = JFactory::getConfig()->get('tmp_path') . '/pkg_projectfork_4.1.0.zip'; // Check if the package exists if (!file_exists($pkg)) { $this->success = false; $this->log[] = JText::_('COM_PFMIGRATOR_PKG_NOT_FOUND'); return false; } // Copy package to tmp dir if (!JFile::copy($pkg, $dest)) { $this->success = false; $this->log[] = JText::_('COM_PFMIGRATOR_PKG_COPY_FAILED'); return false; } // Unpack the package file $package = JInstallerHelper::unpack($dest); if (!$package) { if (JFile::exists($dest)) { JFile::delete($dest); } $this->success = false; $this->log[] = JText::_('COM_PFMIGRATOR_PKG_EXTRACT_FAILED'); return false; } $installer = JInstaller::getInstance(); // Install the package if (!$installer->install($package['dir'])) { if (JFile::exists($dest)) { JFile::delete($dest); } $this->success = false; $this->log[] = JText::_('COM_PFMIGRATOR_PKG_INSTALL_FAILED') . ' ' . $installer->message . ' ' . $installer->get('extension_message'); return false; } // Cleanup the install files if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); $this->log[] = JText::_('COM_PFMIGRATOR_PKG_INSTALL_SUCCESS'); return true; }
/** * Perform installation of SQL queries * * @since 5.0 * @access public * @param string * @return */ public function execute() { // Get the temporary path from the server. $tmpPath = $this->input->get('path', '', 'default'); // There should be a queries.zip archive in the archive. $tmpQueriesPath = $tmpPath . '/queries.zip'; // Extract the queries $path = $tmpPath . '/queries'; // If on development mode, skip this if ($this->isDevelopment()) { return $this->output($this->getResultObj('COM_EASYBLOG_INSTALLATION_DEVELOPER_MODE', true)); } // Check if this folder exists. if (JFolder::exists($path)) { JFolder::delete($path); } // Extract the archive now $state = JArchive::extract($tmpQueriesPath, $path); if (!$state) { $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_UNABLE_EXTRACT_QUERIES', false); return $this->output(); } // Get the list of files in the folder. $queryFiles = JFolder::files($path, '.', true, true); // When there are no queries file, we should just display a proper warning instead of exit if (!$queryFiles) { $this->setInfo('COM_EASYBLOG_INSTALLATION_ERROR_EMPTY_QUERIES_FOLDER', false); return $this->output(); } $db = JFactory::getDBO(); $total = 0; foreach ($queryFiles as $file) { // Get the contents of the file $contents = JFile::read($file); $queries = JInstallerHelper::splitSql($contents); foreach ($queries as $query) { $query = trim($query); if (!empty($query)) { $db->setQuery($query); $state = $db->execute(); } } $total += 1; } $this->setInfo(JText::sprintf('COM_EASYBLOG_INSTALLATION_SQL_EXECUTED_SUCCESS', $total), true); return $this->output(); }
function _installPackage() { if ($this->_packageExtract) { $jinstaller = JInstaller::getInstance(); if (!$jinstaller->install($this->_packageExtract['dir'])) { $this->_msgError = JText::_('INSTALLER_PACKAGE_UNSUCCESSFULLY_INSTALLED'); $this->_error = true; return false; } if (!is_file($this->_packageExtract['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $this->_packageExtract['packagefile']; } JInstallerHelper::cleanupInstall($this->_packageExtract['packagefile'], $this->_packageExtract['extractdir']); } return false; }
function com_install() { $db =& JFactory::getDBO(); // install the plugin jimport('joomla.installer.installer'); /* // Get the path to the package to install $p_dir = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_sef'.DS.'plugin'; // Detect the package type $type = JInstallerHelper::detectType($p_dir); $package = array(); $package['packagefile'] = null; $package['extractdir'] = null; $package['dir'] = $p_dir; $package['type'] = $type; */ // Get the path to the package to install $p_filename = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sef' . DS . 'plugin' . DS . 'sef_advance.tgz'; // Unpack and verify $package = JInstallerHelper::unpack($p_filename); // Get an installer instance //$installer =& JInstaller::getInstance(); $installer = new JInstaller(); // Install the package if (!$installer->install($package['dir'])) { $msg = 'Error installing the plugin<br />Please install the SEF Advance plugin manually.'; } else { $msg = 'SEF Advance system plugin installed'; $query = "UPDATE #__plugins " . "SET published=1, ordering=-200 " . "WHERE element='sef_advance'"; $db->setQuery($query); if ($db->query()) { $msg .= ' and published'; } } // Cleanup JInstallerHelper::cleanupInstall($p_filename, $package['dir']); echo $msg; echo '<br />'; $query = "UPDATE #__components " . "SET name = '. SEF Advance .', admin_menu_alt = '. SEF Advance .' " . "WHERE admin_menu_link = 'option=com_sef' AND name = 'SEF Advance'"; $db->setQuery($query); $db->query(); echo '<a href="index.php?option=com_sef">Proceed to SEF Advance control panel</a><br />'; return true; }
function installPlugin($maintain = false, $filename = '') { if (!$filename) { return false; } $package = $this->_unPackageFromTempFolder($filename); if (!$package) { $this->setState('message', 'Unable to find install package'); return false; } $objJSNPlugins = JSNISFactory::getObj('classes.jsn_is_plugins'); $pluginModel = JModel::getInstance('plugins', 'imageshowmodel'); $listJSNPlugins = $pluginModel->getFullData(); $countPlugin = count($listJSNPlugins); global $mainframe; $plugins = array(); if ($countPlugin) { for ($i = 0; $i < $countPlugin; $i++) { $item = $listJSNPlugins[$i]; $plugins[$item->element] = $objJSNPlugins->getXmlFile($item); } } $installer = JSNISInstaller::getInstance(); if (!$installer->install($package['dir'])) { $result = false; } else { $msg = JText::_('INSTALLER_THEME_PACKAGE_SUCCESSFULLY_INSTALLED'); $result = true; } if ($result && count($plugins) && !$maintain) { $this->upgradeThemeDB($plugins, $installer); } $mainframe->enqueueMessage(@$msg); $this->setState('name', $installer->get('name')); $this->setState('result', $result); $this->setState('message', $installer->message); $this->setState('extension.message', $installer->get('extension.message')); if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . DS . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); return $result; }
public function install($package = null) { $app = JFactory::getApplication(); if (!$package) { $package = $this->getPackage(); } // Was the package unpacked? if (!$package) { $this->setState('message', 'WF_INSTALLER_NO_PACKAGE'); return false; } // Get an installer instance $installer = WFInstaller::getInstance(); // Install the package if (!$installer->install($package['dir'])) { $result = false; $app->enqueueMessage(WFText::sprintf('WF_INSTALLER_INSTALL_ERROR'), 'error'); } else { $result = true; $app->enqueueMessage(WFText::sprintf('WF_INSTALLER_INSTALL_SUCCESS')); } $this->_result[] = array('name' => $installer->get('name'), 'type' => $package['type'], 'version' => $installer->get('version'), 'result' => $result); $this->setState('install.result', $this->_result); $this->setState('name', WFText::_($installer->get('name'))); $this->setState('message', WFText::_($installer->get('message'))); $this->setState('extension.message', $installer->get('extension.message')); $this->setState('result', $result); // Cleanup the install files if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } if (is_file($package['packagefile'])) { JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); } return $result; }
function update($parent) { $manifest = $parent->get('manifest'); $parent2 = $parent->getParent(); $source = $parent2->getPath('source'); $this->_installPlugins($manifest, $source, true); // If a version prior to 0.5 has been installed, the database // tables will not have the UUID fields set, so the tables must // be rebuit $hasUUID = false; $db = JFactory::getDbo(); $blogFields = $db->getTableColumns('#__' . $this->component_base . '_blogs'); foreach ($blogFields['#__' . $this->component_base . '_blogs'] as $fieldname => $fieldtype) { if ($fieldname == 'blog_uuid') { $hasUUID = true; break; } } if (!$hasUUID) { // All the database tables need to be rebuilt at this // point $sql = file_get_contents(dirname(__FILE__) . DS . 'admin' . DS . $manifest->install->sql->file); jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($sql); if (count($queries) > 0) { foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); $db->execute(); } } } echo '<p>' . JText::sprintf('COM_WORDBRIDGE_UPDATED_DB') . '123</p>'; } echo '<p>' . JText::sprintf('COM_WORDBRIDGE_UPDATED_TO_VER', htmlspecialchars($manifest->version->data())) . '</p>'; }
/** * Custom install method * * @return int The extension id * * @since 3.1 */ public function install() { // Get the extension manifest object $this->manifest = $this->parent->getManifest(); /* * --------------------------------------------------------------------------------------------- * Manifest Document Setup Section * --------------------------------------------------------------------------------------------- */ // Set the extensions name $filter = JFilterInput::getInstance(); $name = (string) $this->manifest->packagename; $name = $filter->clean($name, 'cmd'); $this->set('name', $name); $element = 'pkg_' . $filter->clean($this->manifest->packagename, 'cmd'); $this->set('element', $element); // Get the component description $description = (string) $this->manifest->description; if ($description) { $this->parent->set('message', JText::_($description)); } else { $this->parent->set('message', ''); } // Set the installation path $files = $this->manifest->files; $group = (string) $this->manifest->packagename; if (!empty($group)) { $this->parent->setPath('extension_root', JPATH_MANIFESTS . '/packages/' . implode(DIRECTORY_SEPARATOR, explode('/', $group))); } else { $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_PACK', JText::_('JLIB_INSTALLER_' . strtoupper($this->route)))); return false; } /* * If the package manifest already exists, then we will assume that the package is already * installed. */ if (file_exists(JPATH_MANIFESTS . '/packages/' . basename($this->parent->getPath('manifest')))) { // Look for an update function or update tag $updateElement = $this->manifest->update; // If $this->upgrade has already been set, or an update property exists in the manifest, update the extensions if ($this->parent->isUpgrade() || $updateElement) { // Use the update route for all packaged extensions $this->route = 'update'; } } /** * --------------------------------------------------------------------------------------------- * Installer Trigger Loading * --------------------------------------------------------------------------------------------- */ // If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet) $this->scriptElement = $this->manifest->scriptfile; $manifestScript = (string) $this->manifest->scriptfile; if ($manifestScript) { $manifestScriptFile = $this->parent->getPath('source') . '/' . $manifestScript; if (is_file($manifestScriptFile)) { // Load the file include_once $manifestScriptFile; } // Set the class name $classname = $element . 'InstallerScript'; if (class_exists($classname)) { // Create a new instance $this->parent->manifestClass = new $classname($this); // And set this so we can copy it later $this->set('manifest_script', $manifestScript); } } // Run preflight if possible (since we know we're not an update) ob_start(); ob_implicit_flush(false); if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) { if ($this->parent->manifestClass->preflight($this->route, $this) === false) { // Preflight failed, rollback changes $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_PACKAGE_INSTALL_CUSTOM_INSTALL_FAILURE')); return false; } } // Create msg object; first use here $msg = ob_get_contents(); ob_end_clean(); /* * --------------------------------------------------------------------------------------------- * Filesystem Processing Section * --------------------------------------------------------------------------------------------- */ if ($folder = $files->attributes()->folder) { $source = $this->parent->getPath('source') . '/' . $folder; } else { $source = $this->parent->getPath('source'); } // Install all necessary files if (count($this->manifest->files->children())) { $i = 0; foreach ($this->manifest->files->children() as $child) { $file = $source . '/' . $child; if (is_dir($file)) { // If it's actually a directory then fill it up $package = array(); $package['dir'] = $file; $package['type'] = JInstallerHelper::detectType($file); } else { // If it's an archive $package = JInstallerHelper::unpack($file); } $tmpInstaller = new JInstaller(); $installResult = $tmpInstaller->{$this->route}($package['dir']); if (!$installResult) { $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_ERROR_EXTENSION', JText::_('JLIB_INSTALLER_' . strtoupper($this->route)), basename($file))); return false; } else { $results[$i] = array('name' => $tmpInstaller->manifest->name, 'result' => $installResult); } $i++; } } else { $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_FILES', JText::_('JLIB_INSTALLER_' . strtoupper($this->route)))); return false; } // Parse optional tags $this->parent->parseLanguages($this->manifest->languages); /* * --------------------------------------------------------------------------------------------- * Extension Registration * --------------------------------------------------------------------------------------------- */ $row = JTable::getInstance('extension'); $eid = $row->find(array('element' => strtolower($this->get('element')), 'type' => 'package')); if ($eid) { $row->load($eid); } else { $row->name = $this->get('name'); $row->type = 'package'; $row->element = $this->get('element'); // There is no folder for modules $row->folder = ''; $row->enabled = 1; $row->protected = 0; $row->access = 1; $row->client_id = 0; // Custom data $row->custom_data = ''; $row->params = $this->parent->getParams(); } // Update the manifest cache for the entry $row->manifest_cache = $this->parent->generateManifestCache(); if (!$row->store()) { // Install failed, roll back changes $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_ROLLBACK', $row->getError())); return false; } /* * --------------------------------------------------------------------------------------------- * Finalization and Cleanup Section * --------------------------------------------------------------------------------------------- */ // Run the custom method based on the route ob_start(); ob_implicit_flush(false); if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, $this->route)) { if ($this->parent->manifestClass->{$this->route}($this) === false) { // Install failed, rollback changes $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_CUSTOM_INSTALL_FAILURE')); return false; } } // Append messages $msg .= ob_get_contents(); ob_end_clean(); // Lastly, we will copy the manifest file to its appropriate place. $manifest = array(); $manifest['src'] = $this->parent->getPath('manifest'); $manifest['dest'] = JPATH_MANIFESTS . '/packages/' . basename($this->parent->getPath('manifest')); if (!$this->parent->copyFiles(array($manifest), true)) { // Install failed, rollback changes $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_COPY_SETUP', JText::_('JLIB_INSTALLER_ABORT_PACK_INSTALL_NO_FILES'))); return false; } // If there is a manifest script, let's copy it. if ($this->get('manifest_script')) { // First, we have to create a folder for the script if one isn't present if (!file_exists($this->parent->getPath('extension_root'))) { JFolder::create($this->parent->getPath('extension_root')); } $path['src'] = $this->parent->getPath('source') . '/' . $this->get('manifest_script'); $path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->get('manifest_script'); if (!file_exists($path['dest']) || $this->parent->isOverwrite()) { if (!$this->parent->copyFiles(array($path))) { // Install failed, rollback changes $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_PACKAGE_INSTALL_MANIFEST')); return false; } } } // And now we run the postflight ob_start(); ob_implicit_flush(false); if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'postflight')) { $this->parent->manifestClass->postflight($this->route, $this, $results); } // Append messages $msg .= ob_get_contents(); ob_end_clean(); if ($msg != '') { $this->parent->set('extension_message', $msg); } return $row->extension_id; }
/** * Get the install package or folder * @return Array $package */ private function getPackage() { $app = JFactory::getApplication(); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.archive'); // set standard method $upload = true; $package = null; // Get the uploaded file information $file = JRequest::getVar('install', null, 'files', 'array'); // get the file path information $path = JRequest::getString('install_input'); if (!(bool) ini_get('file_uploads') || !is_array($file)) { $upload = false; // no path either! if (!$path) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_NO_FILE')); return false; } } // Install failed if (!is_uploaded_file($file['tmp_name']) || !$file['tmp_name'] || !$file['name'] || $file['error']) { $upload = false; // no path either! if (!$path) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_NO_FILE')); return false; } } // uploaded file if ($upload) { // check extension if (!preg_match('/\\.(zip|tar|gz)$/i', $file['name'])) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_INVALID_FILE')); return false; } $dest = JPath::clean($app->getCfg('tmp_path') . '/' . $file['name']); $src = $file['tmp_name']; $safeFileOptions = array('php_ext_content_extensions' => array('rar', 'tgz', 'bz2', 'tbz', 'jpa')); // upload file if (!JFile::upload($src, $dest, false, false, $safeFileOptions)) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_UPLOAD_FAILED')); return false; } if (!is_file($dest)) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_UPLOAD_FAILED')); return false; } // path to file } else { $dest = JPath::clean($path); } // set install method JRequest::setVar('install_method', 'install'); // Unpack the package file if (preg_match('/\\.(zip|tar|gz)$/i', $dest)) { // Make sure that zlib is loaded so that the package can be unpacked if (!extension_loaded('zlib')) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_WARNINSTALLZLIB')); return false; } $package = JPath::clean(dirname($dest) . '/' . uniqid('install_')); if (!JArchive::extract($dest, $package)) { JInstallerHelper::cleanupInstall($dest, $package); JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_EXTRACT_ERROR')); return false; } if (JFolder::exists($package)) { $type = self::detectType($package); if ($type === false) { JInstallerHelper::cleanupInstall($dest, $package); JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_MANIFEST_INVALID')); return false; } } return array('manifest' => null, 'packagefile' => $dest, 'extractdir' => $package, 'dir' => $package, 'type' => $type); // might be a directory } else { if (!is_dir($dest)) { JError::raiseWarning('SOME_ERROR_CODE', WFText::_('WF_INSTALLER_INVALID_SRC')); return false; } // Detect the package type $type = self::detectType($dest); if ($type === false) { JInstallerHelper::cleanupInstall($dest, $package); JError::raiseWarning(1, JText::_('WF_INSTALLER_MANIFEST_INVALID')); return false; } return array('manifest' => null, 'packagefile' => null, 'extractdir' => null, 'dir' => $dest, 'type' => $type); } }
/** * Install extension update * @return String JSON string */ public function install() { jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); jimport('joomla.filesystem.file'); $app = JFactory::getApplication(); $result = array('error' => WFText::_('WF_UPDATES_INSTALL_ERROR')); // get vars $file = JRequest::getCmd('file'); $hash = JRequest::getVar('hash', '', 'POST', 'alnum'); $method = JRequest::getWord('installer'); $type = JRequest::getWord('type'); // check for vars if ($file && $hash && $method) { $path = $app->getCfg('tmp_path') . '/' . $file; // check if file exists if (JFile::exists($path)) { // check hash if ($hash == md5(md5_file($path))) { $package = self::unpack($path); if ($package) { // Install a JCE Add-on if ($method == 'jce') { wfimport('admin.classes.installer'); $installer = WFInstaller::getInstance(); // install if ($installer->install($package['dir'])) { // installer message $result = array('error' => '', 'text' => WFText::_($installer->get('message'), $installer->get('message'))); } // Install a Joomla! Extension } else { jimport('joomla.installer.installer'); // get new Installer instance $installer = JInstaller::getInstance(); if ($installer->install($package['dir'])) { // installer message $result = array('error' => '', 'text' => WFText::_($installer->get('message'), $installer->get('message'))); } } // Cleanup the install files JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); } else { $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_EXTRACT_FAIL')); JFile::delete($path); } } else { $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_VERIFICATION_FAIL')); } } else { $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_MISSING_OR_INVALID')); } } return json_encode($result); }