[ Index ]

PHP Cross Reference of phpBB 3.0 Beta 3

title

Body

[close]

/ -> cron.php (source)

   1  <?php
   2  /** 
   3  *
   4  * @package phpBB3
   5  * @version $Id: cron.php,v 1.14 2006/08/25 15:15:52 acydburn Exp $
   6  * @copyright (c) 2005 phpBB Group 
   7  * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
   8  *
   9  */
  10  
  11  /**
  12  */
  13  define('IN_PHPBB', true);
  14  define('IN_CRON', true);
  15  $phpbb_root_path = './';
  16  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  17  include($phpbb_root_path . 'common.' . $phpEx);
  18  
  19  // Do not update users last page entry
  20  $user->session_begin(false);
  21  $auth->acl($user->data);
  22  
  23  $cron_type = request_var('cron_type', '');
  24  $use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
  25  
  26  // Output transparent gif
  27  header('Cache-Control: no-cache');
  28  header('Content-type: image/gif');
  29  header('Content-length: 43');
  30  
  31  echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
  32  
  33  flush();
  34  
  35  /**
  36  * Run cron-like action
  37  * Real cron-based layer will be introduced in 3.2
  38  */
  39  switch ($cron_type)
  40  {
  41      case 'queue':
  42  
  43          if (time() - $config['queue_interval'] <= $config['last_queue_run'] || !file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))
  44          {
  45              break;
  46          }
  47  
  48          include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
  49          $queue = new queue();
  50  
  51          if ($use_shutdown_function)
  52          {
  53              register_shutdown_function(array(&$queue, 'process'));
  54          }
  55          else
  56          {
  57              $queue->process();
  58          }
  59  
  60      break;
  61  
  62      case 'tidy_cache':
  63  
  64          if (time() - $config['cache_gc'] <= $config['cache_last_gc'] || !method_exists($cache, 'tidy'))
  65          {
  66              break;
  67          }
  68  
  69          if ($use_shutdown_function)
  70          {
  71              register_shutdown_function(array(&$cache, 'tidy'));
  72          }
  73          else
  74          {
  75              $cache->tidy();
  76          }
  77  
  78      break;
  79  
  80      case 'tidy_search':
  81          
  82          // Select the search method
  83          $search_type = basename($config['search_type']);
  84  
  85          if (time() - $config['search_gc'] <= $config['search_last_gc'] || !file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
  86          {
  87              break;
  88          }
  89  
  90          include_once("{$phpbb_root_path}includes/search/$search_type.$phpEx");
  91  
  92          // We do some additional checks in the module to ensure it can actually be utilised
  93          $error = false;
  94          $search = new $search_type($error);
  95  
  96          if ($error)
  97          {
  98              break;
  99          }
 100  
 101          if ($use_shutdown_function)
 102          {
 103              register_shutdown_function(array(&$search, 'tidy'));
 104          }
 105          else
 106          {
 107              $search->tidy();
 108          }
 109  
 110      break;
 111  
 112      case 'tidy_warnings':
 113  
 114          if (time() - $config['warnings_gc'] <= $config['warnings_last_gc'])
 115          {
 116              break;
 117          }
 118  
 119          include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
 120  
 121          if ($use_shutdown_function)
 122          {
 123              register_shutdown_function('tidy_warnings');
 124          }
 125          else
 126          {
 127              tidy_warnings();
 128          }
 129  
 130      break;
 131  
 132      case 'tidy_database':
 133  
 134          if (time() - $config['database_gc'] <= $config['database_last_gc'])
 135          {
 136              break;
 137          }
 138  
 139          include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
 140  
 141          if ($use_shutdown_function)
 142          {
 143              register_shutdown_function('tidy_database');
 144          }
 145          else
 146          {
 147              tidy_database();
 148          }
 149  
 150      break;
 151  
 152      case 'tidy_sessions':
 153  
 154          if (time() - $config['session_gc'] <= $config['session_last_gc'])
 155          {
 156              break;
 157          }
 158  
 159          if ($use_shutdown_function)
 160          {
 161              register_shutdown_function(array(&$user, 'session_gc'));
 162          }
 163          else
 164          {
 165              $user->session_gc();
 166          }
 167  
 168      break;
 169  
 170      case 'prune_forum':
 171  
 172          $forum_id = request_var('f', 0);
 173  
 174          $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
 175              FROM ' . FORUMS_TABLE . "
 176              WHERE forum_id = $forum_id";
 177          $result = $db->sql_query($sql);
 178          $row = $db->sql_fetchrow($result);
 179          $db->sql_freeresult($result);
 180  
 181          if (!$row)
 182          {
 183              break;
 184          }
 185  
 186          // Do the forum Prune thang
 187          if ($row['prune_next'] < time() && $row['enable_prune'])
 188          {
 189              include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
 190  
 191              if ($row['prune_days'])
 192              {
 193                  if ($use_shutdown_function)
 194                  {
 195                      register_shutdown_function('auto_prune', $row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
 196                  }
 197                  else
 198                  {
 199                      auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
 200                  }
 201              }
 202  
 203              if ($row['prune_viewed'])
 204              {
 205                  if ($use_shutdown_function)
 206                  {
 207                      register_shutdown_function('auto_prune', $row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
 208                  }
 209                  else
 210                  {
 211                      auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
 212                  }
 213              }
 214          }
 215  
 216      break;
 217  }
 218  
 219  // Unloading cache and closing db after having done the dirty work.
 220  if ($use_shutdown_function)
 221  {
 222      register_shutdown_function('garbage_collection');
 223  }
 224  else
 225  {
 226      garbage_collection();
 227  }
 228  
 229  exit;
 230  
 231  ?>


Generated: Wed Nov 22 00:35:05 2006 Cross-referenced by PHPXref 0.6