/**
  * Check for IPS Report.  Prints XML file if called properly.  No longer used, really.
  *
  * @access	protected
  * @return	void
  * @since	2.0
  * @deprecated	Consider removing this.  We no longer use this.
  */
 protected function _checkIPSReport()
 {
     //-----------------------------------------
     // Note, this is designed to allow IPS validate boards
     // who've purchased copyright removal / registration.
     // The order number is the only thing shown and the
     // order number is unique to the person who paid and
     // is no good to anyone else.
     // Showing the order number poses no risk at all -
     // the information is useless to anyone outside of IPS.
     //-----------------------------------------
     $pass = 0;
     $key = isset($this->request['key']) ? trim($this->request['key']) : '';
     $cust_number = 0;
     $acc_number = 0;
     $cust_number_tmp = '0,0';
     if (isset($this->request['ipsreport']) and $this->request['ipsreport'] or isset($this->request['ipscheck']) and $this->request['ipscheck']) {
         if ($this->settings['ipb_copy_number']) {
             $cust_number_tmp = preg_replace("/^(\\d+?)-(\\d+?)-(\\d+?)-(\\S+?)\$/", "\\2,\\3", $this->settings['ipb_copy_number']);
         } else {
             if ($this->settings['ipb_reg_number']) {
                 $cust_number_tmp = preg_replace("/^(\\d+?)-(\\d+?)-(\\d+?)-(\\d+?)-(\\S+?)\$/", "\\2,\\4", $this->settings['ipb_reg_number']);
             }
         }
         if (md5($key) == '23f2554a507f6d52b8f27934d3d2a88d') {
             $latest_version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(0, 1)));
             if (ipsRegistry::$version == 'v<{%dyn.down.var.human.version%}>') {
                 ipsRegistry::$version = 'v' . $latest_version['upgrade_version_human'];
             }
             if (ipsRegistry::$acpversion == '<{%dyn.down.var.long_version_id%}>') {
                 ipsRegistry::$acpversion = $latest_version['upgrade_version_id'];
             }
             list($cust_number, $acc_number) = explode(',', $cust_number_tmp);
             @header("Content-type: text/xml");
             $out = '<?xml version="1.0" encoding="ISO-8859-1"?' . '>';
             $out .= "\n<ipscheck>\n\t<result>1</result>\n\t<customer_id>{$cust_number}</customer_id>\n\t<account_id>{$acc_number}</account_id>\n\t" . "<version_id>{ipsRegistry::{$acpversion}}</version_id>\n\t<version_string>{ipsRegistry::{$version}}</version_string>\n\t<release_hash><![CDATA[<{%dyn.down.var.md5%}]]>></release_hash>" . "\n</ipscheck>";
             print $out;
             exit;
         } else {
             if (md5($key) == 'd66ab5043c553f1f1fd5fad3ece252e3') {
                 $latest_version = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(0, 1)));
                 if (ipsRegistry::$version == 'v<{%dyn.down.var.human.version%}>') {
                     ipsRegistry::$version = 'v' . $latest_version['upgrade_version_human'];
                 }
                 if (ipsRegistry::$acpversion == '<{%dyn.down.var.long_version_id%}>') {
                     ipsRegistry::$acpversion = $latest_version['upgrade_version_id'];
                 }
                 @header("Content-type: text/plain");
                 print ipsRegistry::$version . ' (ID:' . ipsRegistry::$acpversion . ')';
                 exit;
             } else {
                 @header("Content-type: text/plain");
                 print "<result>0</result>\nYou do not have permission to view this page.";
                 exit;
             }
         }
     }
 }
 /**
  * Check caches
  *
  * @return	@e void
  * @author	MattMecham
  */
 protected function checkCaches()
 {
     //-----------------------------------------
     // Check app cache data
     //-----------------------------------------
     # Apps
     $app_cache = self::$handles['caches']->getCache('app_cache');
     # Modules...
     self::$modules = self::$handles['caches']->getCache('module_cache');
     if (!count($app_cache) or !count(self::$modules)) {
         self::$handles['caches']->rebuildCache('app_cache', 'global');
         self::$handles['caches']->rebuildCache('module_cache', 'global');
         $app_cache = self::$handles['caches']->getCache('app_cache');
         self::$modules = self::$handles['caches']->getCache('module_cache');
     }
     //-----------------------------------------
     // Build app data and APP specific load requests
     //-----------------------------------------
     foreach ($app_cache as $_app_dir => $_app_data) {
         if (!IPS_IS_TASK and IPS_AREA == 'public' && !$_app_data['app_public_title']) {
             continue;
         }
         $_app_data['app_public_title'] = $_app_data['app_public_title'] ? $_app_data['app_public_title'] : $_app_data['app_title'];
         self::$applications[$_app_dir] = $_app_data;
     }
     /* Sort by position */
     uasort(self::$applications, 'ipsRegistry::_appPositionSort');
     # Modules by section...
     foreach (self::$modules as $_app_dir => $_modules) {
         foreach ($_modules as $_data) {
             self::$modules_by_section[$_app_dir][$_data['sys_module_key']] = $_data;
         }
     }
     //-----------------------------------------
     // System vars and group
     //-----------------------------------------
     $systemvars_cache = self::$handles['caches']->getCache('systemvars');
     if (!isset($systemvars_cache) or !isset($systemvars_cache['task_next_run'])) {
         $update = array('task_next_run' => time());
         $update['loadlimit'] = $systemvars_cache['loadlimit'] ? $systemvars_cache['loadlimit'] : 0;
         $update['mail_queue'] = $systemvars_cache['mail_queue'] ? $systemvars_cache['mail_queue'] : 0;
         $update['last_virus_check'] = $systemvars_cache['last_virus_check'] ? $systemvars_cache['last_virus_check'] : 0;
         $update['last_deepscan_check'] = $systemvars_cache['last_deepscan_check'] ? $systemvars_cache['last_deepscan_check'] : 0;
         self::$handles['caches']->setCache('systemvars', $update, array('donow' => 1, 'array' => 1));
     }
     $group_cache = self::$handles['caches']->getCache('group_cache');
     if (!is_array($group_cache) or !count($group_cache)) {
         $this->cache()->rebuildCache('group_cache', 'global');
     }
     //-----------------------------------------
     // User agent caches
     //-----------------------------------------
     $useragent_cache = $this->cache()->getCache('useragents');
     if (!is_array($useragent_cache) or !count($useragent_cache)) {
         $this->cache()->rebuildCache('useragents', 'global');
     }
     //-----------------------------------------
     // Output formats
     //-----------------------------------------
     $outputformats_cache = $this->cache()->getCache('outputformats');
     if (!is_array($outputformats_cache) or !count($outputformats_cache)) {
         $this->cache()->rebuildCache('outputformats', 'global');
     }
     //-----------------------------------------
     // Hooks cache
     //-----------------------------------------
     if ($this->cache()->exists('hooks') !== TRUE) {
         $this->cache()->rebuildCache('hooks', 'global');
     }
     //-----------------------------------------
     // Version numbers
     //-----------------------------------------
     $version_numbers = $this->cache()->getCache('vnums');
     if (!is_array($version_numbers) or !count($version_numbers)) {
         $this->cache()->rebuildCache('vnums', 'global');
         $version_numbers = $this->cache()->getCache('vnums');
     }
     /* Set them */
     if (!defined('IPB_VERSION')) {
         define('IPB_VERSION', $version_numbers['human']);
         ipsRegistry::$version = IPB_VERSION;
     }
     if (!defined('IPB_LONG_VERSION')) {
         define('IPB_LONG_VERSION', $version_numbers['long']);
         ipsRegistry::$acpversion = IPB_LONG_VERSION;
         ipsRegistry::$vn_full = IPB_LONG_VERSION;
     }
     //-----------------------------------------
     // Any to rebuild?
     //-----------------------------------------
     if (count($this->cache()->fetchRebuildList())) {
         foreach ($this->cache()->fetchRebuildList() as $_toRebuild) {
             $this->cache()->rebuildCache($_toRebuild);
         }
     }
 }