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']);
     }
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * install plugin
  */
 function install()
 {
     require_once dirname(__FILE__) . DS . "adapter" . DS . "fabrikplugin.php";
     $package = $this->_getPackageFromUpload();
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', JText::_('UNABLE TO INSTALL PACKAGE FILE'));
         return false;
     }
     $installer =& JInstaller::getInstance();
     $this->setState('action', 'install');
     $adaptor = new JInstallerFabrikPlugin($installer);
     //test fro php 4.x??? seems to work
     $adaptor->parent->setPath('source', $package['dir']);
     //end test
     $installer->setAdapter("fabrikplugin", $adaptor);
     // 	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;
     }
     // 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 install($package = null)
 {
     $mainframe = 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 = JInstaller::getInstance();
     // Set Adapter
     $type = $package['type'];
     $adapter = $this->getAdapter($type);
     $installer->setAdapter($type, $adapter);
     // Install the package
     if (!$installer->install($package['dir'])) {
         $result = false;
     } else {
         $result = true;
     }
     $this->_result[] = array('name' => $installer->get('name'), 'type' => $type, 'version' => $installer->get('version'), 'result' => $result, 'message' => $installer->get('message'), 'extension.message' => $installer->get('extension.message'));
     $this->setState('install.result', $this->_result);
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config = JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     if (is_file($package['packagefile'])) {
         JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     }
     return $result;
 }
示例#5
0
 function install()
 {
     $app = JFactory::getApplication();
     $this->setState('action', 'install');
     switch ($app->input->get('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $this->setState('message', 'No Install Type Found');
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', 'Unable to find install package');
         return false;
     }
     // Get a database connector
     //$db = & JFactory::getDBO();
     // Get an installer instance
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'installer.php';
     $installer =& JCKInstaller::getInstance();
     // 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->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->get('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
示例#6
0
 /**
 * 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');
 }
示例#7
0
 public static function installExtension($url, $label)
 {
     // Include Joomla! libraries
     jimport('joomla.installer.installer');
     jimport('joomla.installer.helper');
     // System variables
     $app = JFactory::getApplication();
     // Download the package-file
     $package_file = self::downloadPackage($url);
     // Simple check for the result
     if ($package_file == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_EMPTY', $url));
         return false;
     }
     // Check if the downloaded file exists
     $tmp_path = JFactory::getApplication()->getCfg('tmp_path');
     $package_path = $tmp_path . '/' . $package_file;
     if (!is_file($package_path)) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_NOT_EXIST', $package_path));
         return false;
     }
     // Check if the file is readable
     if (!is_readable($package_path)) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_FILE_NOT_READABLE', $package_path));
         return false;
     }
     // Now we assume this is an archive, so let's unpack it
     $package = JInstallerHelper::unpack($package_path);
     if ($package == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_DOWNLOAD_NO_ARCHIVE', $extension['name']));
         return false;
     }
     // Call the actual installer to install the package
     $installer = JInstaller::getInstance();
     if ($installer->install($package['dir']) == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_EXTENSION_FAIL', $extension['name']));
         return false;
     }
     // Get the name of downloaded package
     if (!is_file($package['packagefile'])) {
         $package['packagefile'] = JFactory::getApplication()->getCfg('tmp_path') . '/' . $package['packagefile'];
     }
     // Clean up the installation
     @JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('LIB_YIREO_HELPER_INSTALL_EXTENSION_SUCCESS', $label));
     // Clean the Joomla! plugins cache
     $options = array('defaultgroup' => 'com_plugins', 'cachebase' => JPATH_ADMINISTRATOR . '/cache');
     $cache = JCache::getInstance('callback', $options);
     $cache->clean();
     return true;
 }
 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;
         }
     }
 }
示例#9
0
 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");
 }
示例#10
0
 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;
 }
示例#11
0
 function upload()
 {
     // Initialise variables.
     $app = JFactory::getApplication('administrator');
     $this->setState('action', 'upload');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             JError::raiseWarning(100, JText::_('NO_UPLOAD_TYPE_FOUND'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         JError::raiseWarning(100, JText::_('UNABLE_TO_FIND_INSTALL_PACKAGE'));
         return false;
     }
     // Get an ja extension uploader instance
     $uploader = jaExtUploader::getInstance();
     $result = $uploader->upload($package['dir']);
     if (!$result) {
         // There was an error uploading the package
         $msg = JText::sprintf('THERE_WAS_AN_ERROR_UPLOADING_THE_PACKAGE_S', $package['type']);
         JError::raiseWarning(100, $msg);
         //$result = false;
     } else {
         // Package uploaded sucessfully
         $msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', $package['type']);
         //$result = true;
     }
     // Cleanup the install files
     if (!JFile::exists($package['packagefile'])) {
         $config = JFactory::getConfig();
         $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
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 _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;
 }
示例#14
0
 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;
 }
示例#15
0
 public function install($plugin_distr)
 {
     $package = $this->_getPackageFromDistributives($plugin_distr);
     if (!$package) {
         return false;
     }
     // Get an installer instance
     $installer = new JInstaller();
     //$installer = JInstaller::getInstance();
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $result = false;
     } else {
         // Package installed sucessfully
         $result = true;
     }
     // Clear install
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
示例#16
0
 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;
 }
示例#17
0
 function install()
 {
     global $mainframe;
     switch (JRequest::getWord('installtype')) {
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         default:
             $this->setState('message', 'No Install Type Found');
             return false;
             break;
     }
     if (!$package) {
         $this->setState('message', 'Unable to find install package');
         return false;
     }
     $installer =& JSNISInstaller::getInstance();
     if (!$installer->install($package['dir'])) {
         //$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
         $result = false;
     } else {
         //$msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
         $msg = JText::_('Theme package successfully installed');
         $result = true;
     }
     $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->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
示例#18
0
 function upload()
 {
     global $mainframe;
     $this->setState('action', 'upload');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             JError::raiseWarning(100, JText::_('No Upload Type Found'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         JError::raiseWarning(100, JText::_('Unable to find install package'));
         return false;
     }
     // Get an ja extension uploader instance
     $uploader =& jaExtUploader::getInstance();
     $result = $uploader->upload($package['dir']);
     // 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;
 }
示例#19
0
 /**
  * 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);
     }
 }
示例#20
0
 /**
  * Install languages in the system.
  *
  * @param   array  $lids  array of language ids selected in the list
  *
  * @return  bool
  *
  * @since   2.5.7
  */
 public function install($lids)
 {
     $app = JFactory::getApplication();
     // Loop through every selected language
     foreach ($lids as $id) {
         $installer = new JInstaller();
         // Loads the update database object that represents the language.
         $language = JTable::getInstance('update');
         $language->load($id);
         // Get the url to the XML manifest file of the selected language.
         $remote_manifest = $this->_getLanguageManifest($id);
         if (!$remote_manifest) {
             // Could not find the url, the information in the update server may be corrupt.
             $message = JText::sprintf('COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_MANIFEST', $language->name);
             $message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER');
             $app->enqueueMessage($message);
             continue;
         }
         // Based on the language XML manifest get the url of the package to download.
         $package_url = $this->_getPackageUrl($remote_manifest);
         if (!$package_url) {
             // Could not find the url , maybe the url is wrong in the update server, or there is not internet access
             $message = JText::sprintf('COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_PACKAGE', $language->name);
             $message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER');
             $app->enqueueMessage($message);
             continue;
         }
         // Download the package to the tmp folder.
         $package = $this->_downloadPackage($package_url);
         // Install the package
         if (!$installer->install($package['dir'])) {
             // There was an error installing the package.
             $message = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', $language->name);
             $message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER');
             $app->enqueueMessage($message);
             continue;
         }
         // Package installed successfully.
         $app->enqueueMessage(JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', $language->name));
         // Cleanup the install files in tmp folder.
         if (!is_file($package['packagefile'])) {
             $config = JFactory::getConfig();
             $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
         }
         JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
         // Delete the installed language from the list.
         $language->delete($id);
     }
 }
示例#21
0
 /**
  * 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);
 }
示例#22
0
 /**
  * Download and install
  */
 function install()
 {
     $config =& JFactory::getConfig();
     $mainframe =& JFactory::getApplication();
     // Get the URL of the package to install
     $url = JRequest::getString('url');
     if (!is_string($url)) {
         JError::raiseWarning(101, JText::_('NNEM_ERROR_NO_VALID_URL') . ' (101)');
         return;
     }
     $parts = explode('/', $url);
     $target = $config->getValue('config.tmp_path') . DS . $parts[count($parts) - 1];
     jimport('joomla.filesystem.file');
     if (!function_exists('curl_version') && !ini_get('allow_url_fopen')) {
         JError::raiseWarning(106, JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE' . ' (106)'));
         return;
     } else {
         if (function_exists('curl_version')) {
             /* USE CURL */
             $ch = curl_init();
             $options = array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30);
             $params =& JComponentHelper::getParams('com_nonumbermanager');
             if ($params->get('use_proxy') && $params->get('proxy_host')) {
                 $options[CURLOPT_PROXY] = $params->get('proxy_host') . ($params->get('proxy_port') ? ':' . $params->get('proxy_port') : '');
                 $options[CURLOPT_PROXYUSERPWD] = $params->get('proxy_login') . ':' . $params->get('proxy_password');
             }
             curl_setopt_array($ch, $options);
             $content = curl_exec($ch);
             curl_close($ch);
         } else {
             /* USE FOPEN */
             if (FALSE === ($handle = @fopen($url, 'r'))) {
                 // load the com_installer language file
                 $lang =& JFactory::getLanguage();
                 $lang->load('com_installer', JPATH_ADMINISTRATOR);
                 JError::raiseWarning(103, JText::_('SERVER_CONNECT_FAILED') . ' (103)');
                 return;
             }
             $content = '';
             while (!feof($handle)) {
                 $content .= fread($handle, 4096);
                 if ($content == false) {
                     JError::raiseWarning(104, 'NNEM_ERROR_FAILED_READING_FILE' . ' (104)');
                     return false;
                 }
             }
             fclose($handle);
         }
     }
     if (empty($content)) {
         JError::raiseWarning(105, JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE' . ' (105)'));
         return;
     }
     // Write buffer to file
     JFile::write($target, $content);
     jimport('joomla.installer.installer');
     JPlugin::loadLanguage('com_installer', JPATH_ADMINISTRATOR);
     jimport('joomla.installer.helper');
     // Unpack the package
     $package = JInstallerHelper::unpack($target);
     // Get an installer instance
     $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'));
     } else {
         // Package installed successfully
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
     }
     $mainframe->enqueueMessage($msg);
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return;
 }
示例#23
0
 /**
  * Method that installs in Joomla! the selected languages in the Languages View of the installer.
  *
  * @param   array  $lids  List of the update_id value of the languages to install
  *
  * @return  boolean True if successful
  */
 public function install($lids)
 {
     /* @var InstallationApplicationWeb $app */
     $app = JFactory::getApplication();
     $installer = JInstaller::getInstance();
     // Loop through every selected language
     foreach ($lids as $id) {
         // Loads the update database object that represents the language
         $language = JTable::getInstance('update');
         $language->load($id);
         // Get the url to the XML manifest file of the selected language
         $remote_manifest = $this->getLanguageManifest($id);
         if (!$remote_manifest) {
             // Could not find the url, the information in the update server may be corrupt
             $message = JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_INSTALL_LANGUAGE', $language->name);
             $message .= ' ' . JText::_('INSTL_DEFAULTLANGUAGE_TRY_LATER');
             $app->enqueueMessage($message);
             continue;
         }
         // Based on the language XML manifest get the url of the package to download
         $package_url = $this->getPackageUrl($remote_manifest);
         if (!$package_url) {
             // Could not find the url , maybe the url is wrong in the update server, or there is not internet access
             $message = JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_INSTALL_LANGUAGE', $language->name);
             $message .= ' ' . JText::_('INSTL_DEFAULTLANGUAGE_TRY_LATER');
             $app->enqueueMessage($message);
             continue;
         }
         // Download the package to the tmp folder
         $package = $this->downloadPackage($package_url);
         // Install the package
         if (!$installer->install($package['dir'])) {
             // There was an error installing the package
             $message = JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_INSTALL_LANGUAGE', $language->name);
             $message .= ' ' . JText::_('INSTL_DEFAULTLANGUAGE_TRY_LATER');
             $app->enqueueMessage($message);
             continue;
         }
         // Cleanup the install files in tmp folder
         if (!is_file($package['packagefile'])) {
             $config = JFactory::getConfig();
             $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
         }
         JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
         // Delete the installed language from the list
         $language->delete($id);
     }
     return true;
 }
示例#24
0
 /**
  * Method to upgrade a specific extension
  *
  * @package MageBridge
  * @access public
  * @param string $exension_name
  * @return bool
  */
 private function update($extension_name = null)
 {
     // Do not continue if the extension name is empty
     if ($extension_name == null) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_NO_EXTENSION'));
         return false;
     }
     // Fetch a list of available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     foreach ($packages as $package) {
         if ($package['name'] == $extension_name) {
             $extension = $package;
             break;
         }
     }
     // Do not continue if the extension does not appear from the list
     if ($extension == null) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_UNKNOWN_EXTENSION'));
         return false;
     }
     // Premature check for the component-directory to be writable
     if ($extension['type'] == 'component' && JFactory::getConfig()->get('ftp_enable') == 0) {
         if (is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components/' . $extension['name'])) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DIR_NOT_WRITABLE', JPATH_ADMINISTRATOR . '/components/' . $extension['name']));
             return false;
         } else {
             if (!is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components')) {
                 JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DIR_NOT_WRITABLE', JPATH_ADMINISTRATOR . '/components'));
                 return false;
             }
         }
     }
     // Construct the update URL
     $extension_uri = $extension['name'];
     $extension_uri .= '_j25';
     $extension_uri .= '.' . MagebridgeModelConfig::load('update_format');
     $extension_url = $this->getUrl($extension_uri);
     // Either use fopen() or CURL
     if (ini_get('allow_url_fopen') == 1 && MagebridgeModelConfig::load('update_method') == 'joomla') {
         $package_file = JInstallerHelper::downloadPackage($extension_url, $extension_uri);
     } else {
         $package_file = MageBridgeUpdateHelper::downloadPackage($extension_url, $extension_uri);
     }
     // Simple check for the result
     if ($package_file == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DOWNLOAD_FAILED', $extension_uri));
         return false;
     }
     // Check if the downloaded file exists
     $tmp_path = JFactory::getConfig()->get('tmp_path');
     $package_path = $tmp_path . '/' . $package_file;
     if (!is_file($package_path)) {
         JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NOT_EXISTS', $package_path));
         return false;
     }
     // Check if the file is readable
     if (!is_readable($package_path)) {
         JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NOT_READABLE', $package_path));
         return false;
     }
     // Check if the downloaded file is abnormally small (so it might just contain a simple warning-text)
     if (filesize($package_path) < 128) {
         $contents = @file_get_contents($package_path);
         if (empty($contents)) {
             JError::raiseWarning('MB', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_EMPTY'));
             return false;
         } else {
             if (preg_match('/^Restricted/', $contents)) {
                 JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_NO_ACCESS'));
                 return false;
             }
         }
         JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NO_ARCHIVE', $package_path));
         return false;
     }
     // Now we assume this is an archive, so let's unpack it
     $package = JInstallerHelper::unpack($package_path);
     if ($package == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_GONE', $extension['name']));
         return false;
     }
     // Quick workaround to prevent Koowa proxying the database
     if (class_exists('KInput')) {
         KInput::set('option', 'com_installer', 'get');
     }
     // Call the actual installer to install the package
     $installer = JInstaller::getInstance();
     if ($installer->install($package['dir']) == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FAILED', $extension['name']));
         return false;
     }
     // Get the name of downloaded package
     if (!is_file($package['packagefile'])) {
         $package['packagefile'] = JFactory::getConfig()->get('tmp_path') . '/' . $package['packagefile'];
     }
     // Clean up the installation
     @JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     // Post install procedure
     if (isset($extension['post_install_query'])) {
         $query = trim($extension['post_install_query']);
         if (!empty($query)) {
             $db = JFactory::getDBO();
             $db->setQuery($query);
             try {
                 $db->execute();
             } catch (Exception $e) {
                 JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_POSTQUERY_FAILED', $db->getErrorMsg()));
                 return false;
             }
             if ($db->getErrorMsg()) {
                 JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_POSTQUERY_FAILED', $db->getErrorMsg()));
                 return false;
             }
         }
     }
     return true;
 }
示例#25
0
 /**
  * Install an extension from either folder, url or upload.
  *
  * @return  boolean result of install
  *
  * @since   1.5
  */
 public function install()
 {
     $this->setState('action', 'install');
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $app = JFactory::getApplication();
     switch ($app->input->getWord('installtype')) {
         case 'folder':
             // Remember the 'Install from Directory' path.
             $app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory');
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
         return false;
     }
     // Get an installer instance
     $installer = JInstaller::getInstance();
     // 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);
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $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']);
     return $result;
 }
示例#26
0
 /**
  * Install extension update
  * @return String JSON string
  */
 function install()
 {
     jimport('joomla.installer.installer');
     jimport('joomla.installer.helper');
     jimport('joomla.filesystem.file');
     $config = JFactory::getConfig();
     $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) {
         $tmp = $config->getValue('config.tmp_path');
         $path = $tmp . DS . $file;
         // check if file exists
         if (JFile::exists($path)) {
             // check hash
             if ($hash == md5(md5_file($path))) {
                 if ($extract = JInstallerHelper::unpack($path)) {
                     // get new Installer instance
                     $installer = JInstaller::getInstance();
                     // set installer adapter
                     if ($method == 'jce') {
                         // create jce plugin adapter
                         $model = JModel::getInstance('installer', 'WFModel');
                         $installer->setAdapter($extract['type'], $model->getAdapter($extract['type']));
                     }
                     // install
                     if ($installer->install($extract['extractdir'])) {
                         // get destination path
                         $path = $installer->getPath('extension_root');
                         // get manifest
                         $manifest = basename($installer->getPath('manifest'));
                         // delete update manifest if any eg: _iframes_155_156.xml
                         if ($type == 'patch' && preg_match('/^_[0-9a-z_\\.-]+\\.xml$/', $manifest)) {
                             if (JFile::exists($path . DS . $manifest)) {
                                 @JFile::delete($path . DS . $manifest);
                             }
                         }
                         // installer message
                         $result = array('error' => '', 'text' => WFText::_($installer->get('message'), $installer->get('message')));
                     }
                     // cleanup package and extract dir
                     JInstallerHelper::cleanupInstall($extract['packagefile'], $extract['extractdir']);
                 } else {
                     $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_EXTRACT_FAIL'));
                 }
             } 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);
 }
示例#27
0
 /**
  * Handles the actual update installation.
  *
  * @param   JUpdate  $update  An update definition
  *
  * @return  boolean   Result of install
  *
  * @since   1.6
  */
 private function install($update)
 {
     $app = JFactory::getApplication();
     if (isset($update->get('downloadurl')->_data)) {
         $url = $update->downloadurl->_data;
         $extra_query = $update->get('extra_query');
         if ($extra_query) {
             if (strpos($url, '?') === false) {
                 $url .= '?';
             } else {
                 $url .= '&amp;';
             }
             $url .= $extra_query;
         }
     } else {
         JError::raiseWarning('', JText::_('COM_INSTALLER_INVALID_EXTENSION_UPDATE'));
         return false;
     }
     $p_file = JInstallerHelper::downloadPackage($url);
     // Was the package downloaded?
     if (!$p_file) {
         JError::raiseWarning('', JText::sprintf('COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED', $url));
         return false;
     }
     $config = JFactory::getConfig();
     $tmp_dest = $config->get('tmp_path');
     // Unpack the downloaded package file
     $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
     // Get an installer instance
     $installer = JInstaller::getInstance();
     $update->set('type', $package['type']);
     // Install the package
     if (!$installer->update($package['dir'])) {
         // There was an error updating the package
         $msg = JText::sprintf('COM_INSTALLER_MSG_UPDATE_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
         $result = false;
     } else {
         // Package updated successfully
         $msg = JText::sprintf('COM_INSTALLER_MSG_UPDATE_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
         $result = true;
     }
     // Quick change
     $this->type = $package['type'];
     // Set some model state values
     $app->enqueueMessage($msg);
     // TODO: Reconfigure this code when you have more battery life left
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $app->setUserState('com_installer.message', $installer->message);
     $app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
     // 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']);
     return $result;
 }
示例#28
0
 /**
  * Action to handle install extension request.
  *
  * @param   string  $id  Identified name of the extension to be installed.
  *
  * @return  void
  */
 public function installExtensionAction($id = null)
 {
     JSNTplHelper::isDisabledFunction('set_time_limit') or set_time_limit(0);
     // Get necessary variables
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $tmpPath = $config->get('tmp_path');
     if (empty($id)) {
         $id = $this->request->getString('id');
     }
     // Disable debug system
     $config->set('debug', 0);
     // Path to sample data file
     $xmlFiles = glob("{$tmpPath}/{$this->template['name']}_sampledata/*.xml");
     if (empty($xmlFiles)) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_SAMPLE_DATA_PACKAGE'));
     }
     // Load XML document
     $xml = simplexml_load_file(current($xmlFiles));
     $extensions = $xml->xpath("//extension[@identifiedname=\"{$id}\"]");
     if (!empty($extensions)) {
         $extension = current($extensions);
         $name = (string) $extension['name'];
         $type = (string) $extension['type'];
         switch ($type) {
             case 'component':
                 $name = 'com_' . $name;
                 break;
             case 'module':
                 $name = 'mod_' . $name;
                 break;
         }
         $this->_cleanExtensionAssets($name);
         // Install JSN Extension Framework first if not already installed
         if ($type == 'component') {
             // Get details about JSN Extension Framework
             $extfw = $xml->xpath('//extension[@identifiedname="ext_framework"]');
             if (!empty($extfw)) {
                 $extfw = current($extfw);
                 if ($this->_getExtensionState((string) $extfw['name'], (string) $extfw['version']) != 'installed') {
                     // Install JSN Extension Framework
                     try {
                         $this->installExtensionAction('ext_framework');
                     } catch (Exception $e) {
                         throw $e;
                     }
                 }
             }
         }
     }
     // Download package from lightcart
     try {
         $packageFile = JSNTplApiLightcart::downloadPackage($id, 'FREE', null, null, "{$tmpPath}/{$this->template['name']}_sampledata/");
     } catch (Exception $e) {
         throw $e;
     }
     if (!is_file($packageFile)) {
         throw new Exception("Package file not found: {$packageFile}");
     }
     // Load extension installation library
     jimport('joomla.installer.helper');
     // Rebuild menu structure
     $this->_rebuildMenus();
     // Extract downloaded package
     $unpackedInfo = JInstallerHelper::unpack($packageFile);
     $installer = JInstaller::getInstance();
     if (empty($unpackedInfo) or !isset($unpackedInfo['dir'])) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_EXTENSION_PACKAGE_FILE'));
     }
     // Install extracted package
     $installResult = $installer->install($unpackedInfo['dir']);
     if ($installResult === false) {
         foreach (JError::getErrors() as $error) {
             throw $error;
         }
     }
     // Clean up temporary data
     JInstallerHelper::cleanupInstall($packageFile, $unpackedInfo['dir']);
     $this->_activeExtension(array('type' => $type, 'name' => $name));
     // Rebuild menu structure
     $this->_rebuildMenus();
 }
示例#29
0
文件: jsn_ajax.php 项目: Rikisha/proj
 function installExtension()
 {
     $sdHelperInstance = new JSNSampleDataHelper();
     $packageName = JRequest::getVar('package', '', 'GET');
     $packagePath = JPATH_ROOT . DS . 'tmp' . DS . $packageName;
     if (JFile::exists($packagePath)) {
         jimport('joomla.installer.helper');
         $installer = JInstaller::getInstance();
         $tmpExtPackage = JPATH_ROOT . DS . 'tmp' . DS . $packageName;
         $unpack = JInstallerHelper::unpack($packagePath);
         $installResult = $installer->install($unpack['dir']);
         JInstallerHelper::cleanupInstall($packagePath, $unpack['dir']);
         echo json_encode(array('result' => $installResult));
     } else {
         $mes = JText::sprintf('JSN_SAMPLE_DATA_EXT_PACKAGE_NOT_FOUND', $packageName);
         echo json_encode(array('result' => false, 'message' => $mes));
     }
     exit;
 }
示例#30
0
 function preflight()
 {
     // try downloading and installing gantry
     if (file_exists(JPATH_SITE . '/administrator/components/com_gantry/gantry.php')) {
         return;
     }
     jimport('joomla.filesystem.file');
     JClientHelper::setCredentialsFromRequest('ftp');
     $config = JFactory::getConfig();
     $dlfile = 'http://crosstec.de/gantry.zip';
     $dlerror = true;
     $p_file = 'gantry.zip';
     $delete = $config->get('tmp_path') . '/' . $p_file;
     if (JFile::exists($delete)) {
         JFile::delete($delete);
     }
     // Download the package at the URL given
     // trying curl first
     if (function_exists('curl_init')) {
         $fp = @fopen($config->get('tmp_path') . '/' . $p_file, 'w');
         if ($fp !== false) {
             $ch = curl_init($dlfile);
             curl_setopt($ch, CURLOPT_FILE, $fp);
             $data = curl_exec($ch);
             curl_close($ch);
             fclose($fp);
             if (file_exists($config->get('tmp_path') . '/' . $p_file)) {
                 $dlerror = false;
             }
         }
     }
     // trying fsockopen next
     if ($dlerror) {
         $host = "crosstec.de";
         $target = "gantry.zip";
         $port = 80;
         $timeout = 120;
         $protocol = "HTTP/1.0";
         $fd = @fsockopen($host, $port, $errnum, $errstr, $timeout);
         if (!is_resource($fd)) {
         } else {
             $br = "\r\n";
             $headers = "GET " . $target . " " . $protocol . $br;
             $headers .= "Accept: image/jpeg" . $br;
             $headers .= "Accept-Language: en-us" . $br;
             $headers .= "Host: " . $host . $br;
             $headers .= "Connection: Keep-Alive" . $br;
             $headers .= "User-Agent: Socket-PHP-browser 1.0" . $br;
             $headers .= "Referer: http://www.somesite.com" . $br;
             $headers .= "X-Something: Hello from John" . $br . $br;
             @fputs($fd, $headers);
             $contents = "";
             while (!feof($fd)) {
                 $contents .= fgets($fd, 2048);
             }
         }
         @fclose($fd);
         if (isset($contents) && $contents) {
             JFile::write($config->get('tmp_path') . '/' . $p_file, $contents);
             $dlerror = false;
         }
     }
     // no curl, no fsockopen, last try
     if ($dlerror) {
         $p_file = JInstallerHelper::downloadPackage($dlfile);
     }
     // Was the package downloaded?
     if ($p_file) {
         $tmp_dest = $config->get('tmp_path');
         // Unpack the downloaded package file
         $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
         if ($package) {
             $installer = new JInstaller();
             // Install the package
             $installer->install($package['dir']);
             // 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']);
         }
     }
     if (!file_exists(JPATH_SITE . '/administrator/components/com_gantry/gantry.php')) {
         echo '<div style="background-color: red; background-color: rgba(255,0,0,0.3); border-radius: 8px;font-size: 18px;margin: 20px;padding: 20px;">
                 Note: Please download and install the Gantry Framework extension <a href="http://crosstec.de/gantry.zip">from here</a> in order to complete the installation. The template won\'t work properly until this extension has been installed.
              </div>';
     }
 }