[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/cli/ -> update_cron.php (source)

   1  <?php
   2  /**
   3   * @package        Joomla.Cli
   4   *
   5   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   6   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   7   */
   8  
   9  // Make sure we're being called from the command line, not a web interface
  10  if (array_key_exists('REQUEST_METHOD', $_SERVER)) die();
  11  
  12  /**
  13   * This is a CRON script which should be called from the command-line, not the
  14   * web. For example something like:
  15   * /usr/bin/php /path/to/site/cli/update_cron.php
  16   */
  17  
  18  // Set flag that this is a parent file.
  19  define('_JEXEC', 1);
  20  define('DS', DIRECTORY_SEPARATOR);
  21  
  22  error_reporting(E_ALL | E_NOTICE);
  23  ini_set('display_errors', 1);
  24  
  25  // Load system defines
  26  if (file_exists(dirname(dirname(__FILE__)) . '/defines.php'))
  27  {
  28      require_once dirname(dirname(__FILE__)) . '/defines.php';
  29  }
  30  
  31  if (!defined('_JDEFINES'))
  32  {
  33      define('JPATH_BASE', dirname(dirname(__FILE__)));
  34      require_once  JPATH_BASE . '/includes/defines.php';
  35  }
  36  
  37  require_once JPATH_LIBRARIES . '/import.php';
  38  require_once JPATH_LIBRARIES . '/cms.php';
  39  
  40  // Force library to be in JError legacy mode
  41  JError::$legacy = true;
  42  
  43  // Load the configuration
  44  require_once JPATH_CONFIGURATION . '/configuration.php';
  45  
  46  /**
  47   * This script will fetch the update information for all extensions and store
  48   * them in the database, speeding up your administrator.
  49   *
  50   * @package  Joomla.CLI
  51   * @since    2.5
  52   */
  53  class Updatecron extends JApplicationCli
  54  {
  55      /**
  56       * Entry point for the script
  57       *
  58       * @return  void
  59       *
  60       * @since   2.5
  61       */
  62  	public function execute()
  63      {
  64          // Purge all old records
  65          $db = JFactory::getDBO();
  66  
  67          // Get the update cache time
  68          jimport('joomla.application.component.helper');
  69          $component = JComponentHelper::getComponent('com_installer');
  70  
  71          $params = $component->params;
  72          $cache_timeout = $params->get('cachetimeout', 6, 'int');
  73          $cache_timeout = 3600 * $cache_timeout;
  74  
  75          // Find all updates
  76          $this->out('Fetching updates...');
  77          $updater = JUpdater::getInstance();
  78          $results = $updater->findUpdates(0, $cache_timeout);
  79          $this->out('Finished fetching updates');
  80      }
  81  }
  82  
  83  JApplicationCli::getInstance('Updatecron')->execute();


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1