[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/inc/tasks/ -> dailycleanup.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  function task_dailycleanup($task)
  13  {
  14      global $mybb, $db, $cache, $lang;
  15      
  16      require_once  MYBB_ROOT."inc/functions_user.php";
  17      
  18      // Clear out sessions older than 24h
  19      $cut = TIME_NOW-60*60*24;
  20      $db->delete_query("sessions", "time < '{$cut}'");
  21  
  22      // Delete old read topics
  23      if($mybb->settings['threadreadcut'] > 0)
  24      {
  25          $cut = TIME_NOW-($mybb->settings['threadreadcut']*60*60*24);
  26          $db->delete_query("threadsread", "dateline < '{$cut}'");
  27          $db->delete_query("forumsread", "dateline < '{$cut}'");
  28      }
  29      
  30      // Check PMs moved to trash over a week ago & delete them
  31      $timecut = TIME_NOW-(60*60*24*7);
  32      $query = $db->simple_select("privatemessages", "pmid, uid, folder", "deletetime<='{$timecut}' AND folder='4'");
  33      while($pm = $db->fetch_array($query))
  34      {
  35          $user_update[$pm['uid']] = $uid;
  36          $pm_update[] = $pm['pmid'];
  37      }
  38      
  39      if(!empty($pm_update))
  40      {
  41          $db->delete_query("privatemessages", "pmid IN(".implode(',', $pm_update).")");
  42      }
  43      
  44      if(!empty($user_update))
  45      {
  46          foreach($user_update as $uid)
  47          {
  48              update_pm_count($uid);
  49          }
  50      }
  51      
  52      $cache->update_most_replied_threads();
  53      $cache->update_most_viewed_threads();
  54      $cache->update_birthdays();
  55      $cache->update_forumsdisplay();
  56      
  57      add_task_log($task, $lang->task_dailycleanup_ran);
  58  }
  59  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1