Source for file default.php

Documentation is available at default.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_joomlaupdate
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. jimport('joomla.filesystem.folder');
  13. jimport('joomla.filesystem.file');
  14.  
  15. /**
  16.  * Joomla! update overview Model
  17.  *
  18.  * @package     Joomla.Administrator
  19.  * @subpackage  com_joomlaupdate
  20.  * @author      nikosdion <nicholas@dionysopoulos.me>
  21.  * @since       2.5.4
  22.  */
  23. {
  24.     /**
  25.      * Detects if the Joomla! update site currently in use matches the one
  26.      * configured in this component. If they don't match, it changes it.
  27.      *
  28.      * @return  void 
  29.      *
  30.      * @since    2.5.4
  31.      */
  32.     public function applyUpdateSite()
  33.     {
  34.         // Determine the intended update URL
  35.         $params JComponentHelper::getParams('com_joomlaupdate');
  36.         switch ($params->get('updatesource''nochange'))
  37.         {
  38.             // "Long Term Support (LTS) branch - Recommended"
  39.             case 'lts':
  40.                 $updateURL 'http://update.joomla.org/core/list.xml';
  41.                 break;
  42.  
  43.             // "Short term support (STS) branch"
  44.             case 'sts':
  45.                 $updateURL 'http://update.joomla.org/core/sts/list_sts.xml';
  46.                 break;
  47.  
  48.             // "Testing"
  49.             case 'testing':
  50.                 $updateURL 'http://update.joomla.org/core/test/list_test.xml';
  51.                 break;
  52.  
  53.             // "Custom" if custom URL empty no changes
  54.             case 'custom':
  55.                 if ($params->get('customurl'''!= '')
  56.                 {
  57.                     $updateURL $params->get('customurl''');
  58.                 }
  59.                 else
  60.                 {
  61.                     return JError::raiseWarning(403JText::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_CUSTOM_ERROR'));
  62.                 }
  63.                 break;
  64.  
  65.             // "Do not change"
  66.             case 'nochange':
  67.             default:
  68.                 return;
  69.                 break;
  70.         }
  71.  
  72.         $db $this->getDbo();
  73.         $query $db->getQuery(true)
  74.             ->select($db->quoteName('us''.*')
  75.             ->from($db->quoteName('#__update_sites_extensions'' AS ' $db->quoteName('map'))
  76.             ->join(
  77.                 'INNER'$db->quoteName('#__update_sites'' AS ' $db->quoteName('us')
  78.                 . ' ON (' 'us.update_site_id = map.update_site_id)'
  79.             )
  80.             ->where('map.extension_id = ' $db->quote(700));
  81.         $db->setQuery($query);
  82.         $update_site $db->loadObject();
  83.  
  84.         if ($update_site->location != $updateURL)
  85.         {
  86.             // Modify the database record
  87.             $update_site->last_check_timestamp 0;
  88.             $update_site->location $updateURL;
  89.             $db->updateObject('#__update_sites'$update_site'update_site_id');
  90.  
  91.             // Remove cached updates
  92.             $query->clear()
  93.                 ->delete($db->quoteName('#__updates'))
  94.                 ->where($db->quoteName('extension_id'' = ' $db->quote('700'));
  95.             $db->setQuery($query);
  96.             $db->execute();
  97.         }
  98.     }
  99.  
  100.     /**
  101.      * Makes sure that the Joomla! update cache is up-to-date
  102.      *
  103.      * @param   boolean  $force  Force reload, ignoring the cache timeout
  104.      *
  105.      * @return  void 
  106.      *
  107.      * @since    2.5.4
  108.      */
  109.     public function refreshUpdates($force false)
  110.     {
  111.         if ($force)
  112.         {
  113.             $cache_timeout 0;
  114.         }
  115.         else
  116.         {
  117.             $update_params JComponentHelper::getParams('com_installer');
  118.             $cache_timeout $update_params->get('cachetimeout'6'int');
  119.             $cache_timeout 3600 $cache_timeout;
  120.         }
  121.         $updater JUpdater::getInstance();
  122.         $updater->findUpdates(700$cache_timeout);
  123.     }
  124.  
  125.     /**
  126.      * Returns an array with the Joomla! update information
  127.      *
  128.      * @return  array 
  129.      *
  130.      * @since   2.5.4
  131.      */
  132.     public function getUpdateInformation()
  133.     {
  134.         // Initialise the return array
  135.         $ret array(
  136.             'installed' => JVERSION,
  137.             'latest' => null,
  138.             'object' => null
  139.         );
  140.  
  141.         // Fetch the update information from the database
  142.         $db $this->getDbo();
  143.         $query $db->getQuery(true)
  144.             ->select('*')
  145.             ->from($db->quoteName('#__updates'))
  146.             ->where($db->quoteName('extension_id'' = ' $db->quote(700));
  147.         $db->setQuery($query);
  148.         $updateObject $db->loadObject();
  149.  
  150.         if (is_null($updateObject))
  151.         {
  152.             $ret['latest'JVERSION;
  153.             return $ret;
  154.         }
  155.         else
  156.         {
  157.             $ret['latest'$updateObject->version;
  158.         }
  159.  
  160.         // Fetch the full udpate details from the update details URL
  161.         jimport('joomla.updater.update');
  162.         $update new JUpdate;
  163.         $update->loadFromXML($updateObject->detailsurl);
  164.  
  165.         // Pass the update object
  166.         if ($ret['latest'== JVERSION)
  167.         {
  168.             $ret['object'null;
  169.         }
  170.         else
  171.         {
  172.             $ret['object'$update;
  173.         }
  174.  
  175.         return $ret;
  176.     }
  177.  
  178.     /**
  179.      * Returns an array with the configured FTP options
  180.      *
  181.      * @return  array 
  182.      *
  183.      * @since   2.5.4
  184.      */
  185.     public function getFTPOptions()
  186.     {
  187.         $config JFactory::getConfig();
  188.         return array(
  189.             'host' => $config->get('ftp_host'),
  190.             'port' => $config->get('ftp_port'),
  191.             'username' => $config->get('ftp_user'),
  192.             'password' => $config->get('ftp_pass'),
  193.             'directory' => $config->get('ftp_root'),
  194.             'enabled' => $config->get('ftp_enable'),
  195.         );
  196.     }
  197.  
  198.     /**
  199.      * Removes all of the updates from the table and enable all update streams.
  200.      *
  201.      * @return  boolean  Result of operation
  202.      *
  203.      * @since   3.0
  204.      */
  205.     public function purge()
  206.     {
  207.         $db JFactory::getDbo();
  208.  
  209.         // Modify the database record
  210.         $update_site new stdClass;
  211.         $update_site->last_check_timestamp 0;
  212.         $update_site->enabled 1;
  213.         $update_site->update_site_id 1;
  214.         $db->updateObject('#__update_sites'$update_site'update_site_id');
  215.  
  216.         $query $db->getQuery(true)
  217.             ->delete($db->quoteName('#__updates'))
  218.             ->where($db->quoteName('update_site_id'' = ' $db->quote('1'));
  219.         $db->setQuery($query);
  220.  
  221.         if ($db->execute())
  222.         {
  223.             $this->_message JText::_('JLIB_INSTALLER_PURGED_UPDATES');
  224.             return true;
  225.         }
  226.         else
  227.         {
  228.             $this->_message JText::_('JLIB_INSTALLER_FAILED_TO_PURGE_UPDATES');
  229.             return false;
  230.         }
  231.     }
  232.  
  233.     /**
  234.      * Downloads the update package to the site
  235.      *
  236.      * @return  bool|stringFalse on failure, basename of the file in any other case
  237.      *
  238.      * @since   2.5.4
  239.      */
  240.     public function download()
  241.     {
  242.         $updateInfo $this->getUpdateInformation();
  243.         $packageURL $updateInfo['object']->downloadurl->_data;
  244.         $basename basename($packageURL);
  245.  
  246.         // Find the path to the temp directory and the local package
  247.         $config JFactory::getConfig();
  248.         $tempdir $config->get('tmp_path');
  249.         $target $tempdir '/' $basename;
  250.  
  251.         // Do we have a cached file?
  252.         $exists JFile::exists($target);
  253.  
  254.         if (!$exists)
  255.         {
  256.             // Not there, let's fetch it
  257.             return $this->downloadPackage($packageURL$target);
  258.         }
  259.         else
  260.         {
  261.             // Is it a 0-byte file? If so, re-download please.
  262.             $filesize @filesize($target);
  263.             if (empty($filesize))
  264.             {
  265.                 return $this->downloadPackage($packageURL$target);
  266.             }
  267.  
  268.             // Yes, it's there, skip downloading
  269.             return $basename;
  270.         }
  271.     }
  272.  
  273.     /**
  274.      * Downloads a package file to a specific directory
  275.      *
  276.      * @param   string  $url     The URL to download from
  277.      * @param   string  $target  The directory to store the file
  278.      *
  279.      * @return  boolean True on success
  280.      *
  281.      * @since   2.5.4
  282.      */
  283.     protected function downloadPackage($url$target)
  284.     {
  285.         JLoader::import('helpers.download'JPATH_COMPONENT_ADMINISTRATOR);
  286.         JLog::add(JText::sprintf('COM_JOOMLAUPDATE_UPDATE_LOG_URL'$packageURL)JLog::INFO'Update');
  287.         $result AdmintoolsHelperDownload::download($url$target);
  288.  
  289.         if (!$result)
  290.         {
  291.             return false;
  292.         }
  293.         else
  294.         {
  295.             return basename($target);
  296.         }
  297.     }
  298.  
  299.     /**
  300.      * @since  2.5.4
  301.      */
  302.     public function createRestorationFile($basename null)
  303.     {
  304.         // Get a password
  305.         $password JUserHelper::genRandomPassword(32);
  306.         $app JFactory::getApplication();
  307.         $app->setUserState('com_joomlaupdate.password'$password);
  308.  
  309.         // Do we have to use FTP?
  310.         $method $app->input->get('method''direct');
  311.  
  312.         // Get the absolute path to site's root
  313.         $siteroot JPATH_SITE;
  314.  
  315.         // If the package name is not specified, get it from the update info
  316.         if (empty($basename))
  317.         {
  318.             $updateInfo $this->getUpdateInformation();
  319.             $packageURL $updateInfo['object']->downloadurl->_data;
  320.             $basename basename($packageURL);
  321.         }
  322.  
  323.         // Get the package name
  324.         $config JFactory::getConfig();
  325.         $tempdir $config->get('tmp_path');
  326.         $file $tempdir '/' $basename;
  327.  
  328.         $filesize @filesize($file);
  329.         $app->setUserState('com_joomlaupdate.password'$password);
  330.         $app->setUserState('com_joomlaupdate.filesize'$filesize);
  331.  
  332.         $data "<?php\ndefined('_AKEEBA_RESTORATION') or die('Restricted access');\n";
  333.         $data .= '$restoration_setup = array(' "\n";
  334.         $data .= <<<ENDDATA
  335.     'kickstart.security.password' => '$password',
  336.     'kickstart.tuning.max_exec_time' => '5',
  337.     'kickstart.tuning.run_time_bias' => '75',
  338.     'kickstart.tuning.min_exec_time' => '0',
  339.     'kickstart.procengine' => '$method',
  340.     'kickstart.setup.sourcefile' => '$file',
  341.     'kickstart.setup.destdir' => '$siteroot',
  342.     'kickstart.setup.restoreperms' => '0',
  343.     'kickstart.setup.filetype' => 'zip',
  344.     'kickstart.setup.dryrun' => '0'
  345. ENDDATA;
  346.  
  347.         if ($method == 'ftp')
  348.         {
  349.             // Fetch the FTP parameters from the request. Note: The password should be
  350.             // allowed as raw mode, otherwise something like !@<sdf34>43H% would be
  351.             // sanitised to !@43H% which is just plain wrong.
  352.             $ftp_host $app->input->get('ftp_host''');
  353.             $ftp_port $app->input->get('ftp_port''21');
  354.             $ftp_user $app->input->get('ftp_user''');
  355.             $ftp_pass $app->input->get('ftp_pass''''default''none'2);
  356.             $ftp_root $app->input->get('ftp_root''');
  357.  
  358.             // Is the tempdir really writable?
  359.             $writable @is_writeable($tempdir);
  360.             if ($writable)
  361.             {
  362.                 // Let's be REALLY sure
  363.                 $fp @fopen($tempdir '/test.txt''w');
  364.                 if ($fp === false)
  365.                 {
  366.                     $writable false;
  367.                 }
  368.                 else
  369.                 {
  370.                     fclose($fp);
  371.                     unlink($tempdir '/test.txt');
  372.                 }
  373.             }
  374.  
  375.             // If the tempdir is not writable, create a new writable subdirectory
  376.             if (!$writable)
  377.             {
  378.                 $FTPOptions JClientHelper::getCredentials('ftp');
  379.                 $ftp JClientFtp::getInstance($FTPOptions['host']$FTPOptions['port']null$FTPOptions['user']$FTPOptions['pass']);
  380.                 $dest JPath::clean(str_replace(JPATH_ROOT$FTPOptions['root']$tempdir '/admintools')'/');
  381.                 if (!@mkdir($tempdir '/admintools'))
  382.                 {
  383.                     $ftp->mkdir($dest);
  384.                 }
  385.                 if (!@chmod($tempdir '/admintools'511))
  386.                 {
  387.                     $ftp->chmod($dest511);
  388.                 }
  389.  
  390.                 $tempdir .= '/admintools';
  391.             }
  392.  
  393.             // Just in case the temp-directory was off-root, try using the default tmp directory
  394.             $writable @is_writeable($tempdir);
  395.             if (!$writable)
  396.             {
  397.                 $tempdir JPATH_ROOT '/tmp';
  398.  
  399.                 // Does the JPATH_ROOT/tmp directory exist?
  400.                 if (!is_dir($tempdir))
  401.                 {
  402.  
  403.                     JFolder::create($tempdir511);
  404.                     JFile::write($tempdir '/.htaccess'"order deny, allow\ndeny from all\nallow from none\n");
  405.                 }
  406.  
  407.                 // If it exists and it is unwritable, try creating a writable admintools subdirectory
  408.                 if (!is_writable($tempdir))
  409.                 {
  410.                     $FTPOptions JClientHelper::getCredentials('ftp');
  411.                     $ftp JClientFtp::getInstance($FTPOptions['host']$FTPOptions['port']null$FTPOptions['user']$FTPOptions['pass']);
  412.                     $dest JPath::clean(str_replace(JPATH_ROOT$FTPOptions['root']$tempdir '/admintools')'/');
  413.                     if (!@mkdir($tempdir '/admintools'))
  414.                     {
  415.                         $ftp->mkdir($dest);
  416.                     }
  417.                     if (!@chmod($tempdir '/admintools'511))
  418.                     {
  419.                         $ftp->chmod($dest511);
  420.                     }
  421.  
  422.                     $tempdir .= '/admintools';
  423.                 }
  424.             }
  425.  
  426.             // If we still have no writable directory, we'll try /tmp and the system's temp-directory
  427.             $writable @is_writeable($tempdir);
  428.  
  429.             if (!$writable)
  430.             {
  431.                 if (@is_dir('/tmp'&& @is_writable('/tmp'))
  432.                 {
  433.                     $tempdir '/tmp';
  434.                 }
  435.                 else
  436.                 {
  437.                     // Try to find the system temp path
  438.                     $tmpfile @tempnam("dummy""");
  439.                     $systemp @dirname($tmpfile);
  440.                     @unlink($tmpfile);
  441.  
  442.                     if (!empty($systemp))
  443.                     {
  444.                         if (@is_dir($systemp&& @is_writable($systemp))
  445.                         {
  446.                             $tempdir $systemp;
  447.                         }
  448.                     }
  449.                 }
  450.             }
  451.  
  452.             $data .= <<<ENDDATA
  453.     ,
  454.     'kickstart.ftp.ssl' => '0',
  455.     'kickstart.ftp.passive' => '1',
  456.     'kickstart.ftp.host' => '$ftp_host',
  457.     'kickstart.ftp.port' => '$ftp_port',
  458.     'kickstart.ftp.user' => '$ftp_user',
  459.     'kickstart.ftp.pass' => '$ftp_pass',
  460.     'kickstart.ftp.dir' => '$ftp_root',
  461.     'kickstart.ftp.tempdir' => '$tempdir'
  462. ENDDATA;
  463.         }
  464.  
  465.         $data .= ');';
  466.  
  467.         // Remove the old file, if it's there...
  468.         $configpath JPATH_COMPONENT_ADMINISTRATOR '/restoration.php';
  469.         if (JFile::exists($configpath))
  470.         {
  471.             JFile::delete($configpath);
  472.         }
  473.  
  474.         // Write new file. First try with JFile.
  475.         $result JFile::write($configpath$data);
  476.         // In case JFile used FTP but direct access could help
  477.         if (!$result)
  478.         {
  479.             if (function_exists('file_put_contents'))
  480.             {
  481.                 $result @file_put_contents($configpath$data);
  482.                 if ($result !== false)
  483.                 {
  484.                     $result true;
  485.                 }
  486.             }
  487.             else
  488.             {
  489.                 $fp @fopen($configpath'wt');
  490.  
  491.                 if ($fp !== false)
  492.                 {
  493.                     $result @fwrite($fp$data);
  494.                     if ($result !== false)
  495.                     {
  496.                         $result true;
  497.                     }
  498.                     @fclose($fp);
  499.                 }
  500.             }
  501.         }
  502.         return $result;
  503.     }
  504.  
  505.     /**
  506.      * Runs the schema update SQL files, the PHP update script and updates the
  507.      * manifest cache and #__extensions entry. Essentially, it is identical to
  508.      * JInstallerFile::install() without the file copy.
  509.      *
  510.      * @return  boolean True on success
  511.      *
  512.      * @since   2.5.4
  513.      */
  514.     public function finaliseUpgrade()
  515.     {
  516.         $installer JInstaller::getInstance();
  517.  
  518.         $installer->setPath('source'JPATH_ROOT);
  519.         $installer->setPath('extension_root'JPATH_ROOT);
  520.  
  521.         if (!$installer->setupInstall())
  522.         {
  523.             $installer->abort(JText::_('JLIB_INSTALLER_ABORT_DETECTMANIFEST'));
  524.  
  525.             return false;
  526.         }
  527.  
  528.         $installer->extension JTable::getInstance('extension');
  529.         $installer->extension->load(700);
  530.         $installer->setAdapter($installer->extension->type);
  531.  
  532.         $manifest $installer->getManifest();
  533.  
  534.         $manifestPath JPath::clean($installer->getPath('manifest'));
  535.         $element preg_replace('/\.xml/'''basename($manifestPath));
  536.  
  537.         // Run the script file
  538.         $manifestScript = (string) $manifest->scriptfile;
  539.  
  540.         if ($manifestScript)
  541.         {
  542.             $manifestScriptFile JPATH_ROOT '/' $manifestScript;
  543.  
  544.             if (is_file($manifestScriptFile))
  545.             {
  546.                 // load the file
  547.                 include_once $manifestScriptFile;
  548.             }
  549.  
  550.             $classname 'JoomlaInstallerScript';
  551.  
  552.             if (class_exists($classname))
  553.             {
  554.                 $manifestClass new $classname($this);
  555.             }
  556.         }
  557.  
  558.         ob_start();
  559.         ob_implicit_flush(false);
  560.         if ($manifestClass && method_exists($manifestClass'preflight'))
  561.         {
  562.             if ($manifestClass->preflight('update'$this=== false)
  563.             {
  564.                 $installer->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_CUSTOM_INSTALL_FAILURE'));
  565.  
  566.                 return false;
  567.             }
  568.         }
  569.  
  570.         $msg ob_get_contents()// create msg object; first use here
  571.         ob_end_clean();
  572.  
  573.         // Get a database connector object
  574.         $db JFactory::getDbo();
  575.  
  576.         // Check to see if a file extension by the same name is already installed
  577.         // If it is, then update the table because if the files aren't there
  578.         // we can assume that it was (badly) uninstalled
  579.         // If it isn't, add an entry to extensions
  580.         $query $db->getQuery(true)
  581.             ->select($db->quoteName('extension_id'))
  582.             ->from($db->quoteName('#__extensions'))
  583.             ->where($db->quoteName('type'' = ' $db->quote('file'))
  584.             ->where($db->quoteName('element'' = ' $db->quote('joomla'));
  585.         $db->setQuery($query);
  586.         try
  587.         {
  588.             $db->execute();
  589.         }
  590.         catch (RuntimeException $e)
  591.         {
  592.             // Install failed, roll back changes
  593.             $installer->abort(
  594.                 JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK'JText::_('JLIB_INSTALLER_UPDATE')$db->stderr(true))
  595.             );
  596.             return false;
  597.         }
  598.         $id $db->loadResult();
  599.         $row JTable::getInstance('extension');
  600.  
  601.         if ($id)
  602.         {
  603.             // Load the entry and update the manifest_cache
  604.             $row->load($id);
  605.             // Update name
  606.             $row->set('name''files_joomla');
  607.             // Update manifest
  608.             $row->manifest_cache $installer->generateManifestCache();
  609.             if (!$row->store())
  610.             {
  611.                 // Install failed, roll back changes
  612.                 $installer->abort(
  613.                     JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK'JText::_('JLIB_INSTALLER_UPDATE')$db->stderr(true))
  614.                 );
  615.                 return false;
  616.             }
  617.         }
  618.         else
  619.         {
  620.             // Add an entry to the extension table with a whole heap of defaults
  621.             $row->set('name''files_joomla');
  622.             $row->set('type''file');
  623.             $row->set('element''joomla');
  624.             // There is no folder for files so leave it blank
  625.             $row->set('folder''');
  626.             $row->set('enabled'1);
  627.             $row->set('protected'0);
  628.             $row->set('access'0);
  629.             $row->set('client_id'0);
  630.             $row->set('params''');
  631.             $row->set('system_data''');
  632.             $row->set('manifest_cache'$installer->generateManifestCache());
  633.  
  634.             if (!$row->store())
  635.             {
  636.                 // Install failed, roll back changes
  637.                 $installer->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_ROLLBACK'$db->stderr(true)));
  638.                 return false;
  639.             }
  640.  
  641.             // Set the insert id
  642.             $row->set('extension_id'$db->insertid());
  643.  
  644.             // Since we have created a module item, we add it to the installation step stack
  645.             // so that if we have to rollback the changes we can undo it.
  646.             $installer->pushStep(array('type' => 'extension''extension_id' => $row->extension_id));
  647.         }
  648.  
  649.         /*
  650.          * Let's run the queries for the file
  651.          */
  652.         if ($manifest->update)
  653.         {
  654.             $result $installer->parseSchemaUpdates($manifest->update->schemas$row->extension_id);
  655.             if ($result === false)
  656.             {
  657.                 // Install failed, rollback changes
  658.                 $installer->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_UPDATE_SQL_ERROR'$db->stderr(true)));
  659.                 return false;
  660.             }
  661.         }
  662.  
  663.         // Start Joomla! 1.6
  664.         ob_start();
  665.         ob_implicit_flush(false);
  666.  
  667.         if ($manifestClass && method_exists($manifestClass'update'))
  668.         {
  669.             if ($manifestClass->update($installer=== false)
  670.             {
  671.                 // Install failed, rollback changes
  672.                 $installer->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_CUSTOM_INSTALL_FAILURE'));
  673.  
  674.                 return false;
  675.             }
  676.         }
  677.  
  678.         $msg .= ob_get_contents()// append messages
  679.         ob_end_clean();
  680.  
  681.         // Lastly, we will copy the manifest file to its appropriate place.
  682.         $manifest array();
  683.         $manifest['src'$installer->getPath('manifest');
  684.         $manifest['dest'JPATH_MANIFESTS '/files/' basename($installer->getPath('manifest'));
  685.         if (!$installer->copyFiles(array($manifest)true))
  686.         {
  687.             // Install failed, rollback changes
  688.             $installer->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_COPY_SETUP'));
  689.             return false;
  690.         }
  691.  
  692.         // Clobber any possible pending updates
  693.         $update JTable::getInstance('update');
  694.         $uid $update->find(
  695.             array('element' => $element'type' => 'file''client_id' => '0''folder' => '')
  696.         );
  697.  
  698.         if ($uid)
  699.         {
  700.             $update->delete($uid);
  701.         }
  702.  
  703.         // And now we run the postflight
  704.         ob_start();
  705.         ob_implicit_flush(false);
  706.  
  707.         if ($manifestClass && method_exists($manifestClass'postflight'))
  708.         {
  709.             $manifestClass->postflight('update'$this);
  710.         }
  711.  
  712.         $msg .= ob_get_contents()// append messages
  713.         ob_end_clean();
  714.  
  715.         if ($msg != '')
  716.         {
  717.             $installer->set('extension_message'$msg);
  718.         }
  719.  
  720.         // Refresh versionable assets cache
  721.         JFactory::getApplication()->flushAssets();
  722.  
  723.         return true;
  724.     }
  725.  
  726.     /**
  727.      * Removes the extracted package file
  728.      *
  729.      * @return  void 
  730.      *
  731.      * @since   2.5.4
  732.      */
  733.     public function cleanUp()
  734.     {
  735.         // Remove the update package
  736.         $config JFactory::getConfig();
  737.         $tempdir $config->get('tmp_path');
  738.  
  739.         $file JFactory::getApplication()->getUserState('com_joomlaupdate.file'null);
  740.         $target $tempdir '/' $file;
  741.         if (!@unlink($target))
  742.         {
  743.             JFile::delete($target);
  744.         }
  745.  
  746.         // Remove the restoration.php file
  747.         $target JPATH_COMPONENT_ADMINISTRATOR '/restoration.php';
  748.         if (!@unlink($target))
  749.         {
  750.             JFile::delete($target);
  751.         }
  752.  
  753.         // Remove joomla.xml from the site's root
  754.         $target JPATH_ROOT '/joomla.xml';
  755.         if (!@unlink($target))
  756.         {
  757.             JFile::delete($target);
  758.         }
  759.  
  760.         // Unset the update filename from the session
  761.         JFactory::getApplication()->setUserState('com_joomlaupdate.file'null);
  762.     }
  763. }

Documentation generated on Tue, 19 Nov 2013 14:59:57 +0100 by phpDocumentor 1.4.3