예제 #1
0
 function upgrade()
 {
     $model = new UpdaterModel();
     $this->manifest = $model->getManifest();
     $this->forceinstall = $model->getFlagForceInstall();
     $this->forceinstall = true;
     // We're not checking today/.
     if (!$this->forceinstall) {
         $file_errors = checkFiles();
         $errors = count($file_errors);
         if ($errors > 0) {
             $this->setRedirect('index.php?option=com_updater&task=display', "We have detected {$errors} files that are not writeable in your Jooml! install - check 'Diagnostics' for details. Joomla! Upgrade may fail and will not continue.  \n        To get rid of this message and continue, fix your website permissions or\n        enable 'Force Install' in the parameters menu.", 'error');
             return;
         }
     }
     $url = $model->retrievedownloadlink('joomla.jupgrade');
     $p_file = isJInstallerHelper::downloadPackage($url);
     $config =& JFactory::getConfig();
     $tmp_dest = $config->getValue('config.tmp_path');
     // Alternate: extract then copy
     $success = isJInstallerHelper::extract("{$tmp_dest}/{$p_file}", "/", true);
     // Direct extract *should* work better
     //$success = isJInstallerHelper::archive_extract("$tmp_dest/$p_file", JPATH_ROOT); // Direct extraction
     if ($success) {
         $this->setRedirect('index.php?option=com_updater&task=display', 'Joomla! Upgrade Success');
     } else {
         $this->setRedirect('index.php?option=com_updater&task=display', 'Joomla! Upgrade Failed <i>Please Check Your Sites Permissions!</i>', 'error');
     }
 }
예제 #2
0
 /**
  * Custom install method
  *
  * @access    public
  * @return    boolean    True on success
  * @since    1.5
  */
 function install()
 {
     global $installresults;
     $installresults = array();
     $out = array();
     // Get the extension manifest object
     $manifest =& $this->parent->getManifest();
     $this->manifest =& $manifest->document;
     $manifestpath = $this->parent->getPath('manifest');
     $sigpath = str_replace('.xml', '.sig', $manifestpath);
     $mf = new JEXPackageManifest($manifestpath);
     switch ($mf->verify) {
         case 'good':
             $msg = "Package {$mf->name} verified with openssl. Installing.";
             break;
         case 'unknown':
         case 'error':
             $msg = "Package {$mg->name} could not be checked. To verify, please install openssl. Installing.";
             break;
         case 'bad':
             $this->parent->abort(JText::_('Package') . ' ' . JText::_('Install') . ' Failed: ' . JText::_('Signature mismatch.'));
     }
     $installresults['verify'] = $mf->verify;
     $installresults['check'] = $msg;
     $out[] = "<div class='msg'>{$msg}</div>";
     # TODO verify signature
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Set the extensions name
     $name = $mf->name;
     $name = JFilterInput::clean($name, 'cmd');
     $this->set('name', $name);
     $description = $mf->description;
     /**
      * Load the local installer class
      */
     // If there is an install file, lets load it.
     $installScriptElement =& $this->manifest->getElementByPath('installfile');
     $installClass = $name . 'PkgInstallHooks';
     if (is_a($installScriptElement, 'JSimpleXMLElement')) {
         if (!class_exists($installClass, false)) {
             include_once $this->parent->getPath('source') . DS . $installScriptElement->data();
             call_user_func(array($installClass, 'onLoad'));
         }
     }
     if (class_exists($installClass)) {
         call_user_func(array($installClass, 'beforeInstall'));
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     $element =& $this->manifest->getElementByPath('files');
     if (is_a($element, 'JSimpleXMLElement') && count($element->children())) {
         if ($folder = $element->attributes('folder')) {
             $source = $this->parent->getPath('source') . DS . $folder;
         } else {
             $source = $this->parent->getPath('source');
         }
         foreach ($mf->filelist as $oFile) {
             /** @var JEXExtension */
             $oFile = $oFile;
             $file = $source . DS . $oFile->filename;
             $dest = $oFile->dest;
             $md5 = md5(file_get_contents($file));
             if ($md5 != $oFile->md5) {
                 $out[] = "<div class='msg'>Skipping File: " . basename($file) . " signature does not match.</div>";
                 continue;
             }
             if ($dest) {
                 isJInstallerHelper::extract($file, $dest, true);
                 $out[] = "<div class='msg'>Installed: " . basename($file) . " ({$md5})</div><br>\n";
                 continue;
                 // we're done with the tarball
             }
             $package = isJInstallerHelper::unpack($file);
             if (!$package) {
                 $out = "<div class='msg'>Can't extract package: " . basename($file) . ". file skipped.";
                 continue;
             }
             // Use core installer
             $installer =& JInstaller::getInstance();
             $success = $installer->install($package['dir']);
             $msg = "<div class='msg'>Installed: " . basename(basename($file)) . " Signature good: ({$md5})</div><br>\n";
             if ($installer->message) {
                 $msg .= $installer->message;
             }
             $out[] = $msg;
             if (!is_file($package['packagefile'])) {
                 $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
             }
             JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
             // End core Installer
             if (!$success) {
                 $out[] = JText::_('Package') . ' ' . JText::_($install_type) . ': ' . JText::_('There was an error installing an extension:') . basename($file);
             }
             $out[] = "<hr>\n";
         }
         // foreach
     } else {
         // Do Nothing - nothing to install
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Finalization and Cleanup Section
      * ---------------------------------------------------------------------------------------------
      */
     if (class_exists($installClass)) {
         call_user_func(array($installClass, 'afterInstall'));
     }
     // Lastly, we will copy the manifest file to its appropriate place.
     @copy($manifestpath, EXPACKAGE_MANIFEST_PATH . '/' . basename($manifestpath));
     @copy($sigpath, EXPACKAGE_MANIFEST_PATH . '/' . basename($sigpath));
     $msg = '';
     foreach ($out as $txt) {
         $msg .= "<p class='out'>{$txt}</p>\n";
     }
     $this->parent->message = $msg;
     $installresults['out'] = $out;
     $installresults['msg'] = $out;
     return true;
 }