[ Index ]

PHP Cross Reference of MyBB 1.8.32

title

Body

[close]

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

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  function task_dailycleanup($task)
  12  {
  13      global $mybb, $db, $cache, $lang, $plugins;
  14  
  15      require_once  MYBB_ROOT."inc/functions_user.php";
  16  
  17      $time = array(
  18          'sessionstime' => TIME_NOW-60*60*24,
  19          'threadreadcut' => TIME_NOW-(((int)$mybb->settings['threadreadcut'])*60*60*24),
  20          'privatemessages' => TIME_NOW-(60*60*24*7),
  21          'deleteinvite' => TIME_NOW-(((int)$mybb->settings['deleteinvites'])*60*60*24),
  22          'stoppmtracking' => TIME_NOW-(60*60*24*180)
  23      );
  24  
  25      if(is_object($plugins))
  26      {
  27          $args = array(
  28              'task' => &$task,
  29              'time' => &$time
  30          );
  31          $plugins->run_hooks('task_dailycleanup_start', $args);
  32      }
  33  
  34      // Clear out sessions older than 24h
  35      $db->delete_query("sessions", "time < '".(int)$time['sessionstime']."'");
  36  
  37      // Delete old read topics
  38      if($mybb->settings['threadreadcut'] > 0)
  39      {
  40          $db->delete_query("threadsread", "dateline < '".(int)$time['threadreadcut']."'");
  41          $db->delete_query("forumsread", "dateline < '".(int)$time['threadreadcut']."'");
  42      }
  43  
  44      // Check PMs moved to trash over a week ago & delete them
  45      $query = $db->simple_select("privatemessages", "pmid, uid, folder", "deletetime<='".(int)$time['privatemessages']."' AND folder='4'");
  46      while($pm = $db->fetch_array($query))
  47      {
  48          $user_update[$pm['uid']] = 1;
  49          $pm_update[] = $pm['pmid'];
  50      }
  51  
  52      // Delete old group invites
  53      if($mybb->settings['deleteinvites'] > 0)
  54      {
  55          $db->delete_query("joinrequests", "dateline < '".(int)$time['deleteinvite']."' AND invite='1'");
  56      }
  57  
  58      // Stop tracking read PMs after 6 months
  59      $sql_array = array(
  60          "receipt" => 0
  61      );
  62      $db->update_query("privatemessages", $sql_array, "receipt='2' AND folder!='3' AND status!='0' AND readtime < '".(int)$time['stoppmtracking']."'");
  63  
  64      if(is_object($plugins))
  65      {
  66          $args = array(
  67              'user_update' => &$user_update,
  68              'pm_update' => &$pm_update
  69          );
  70          $plugins->run_hooks('task_dailycleanup_end', $args);
  71      }
  72  
  73      if(!empty($pm_update))
  74      {
  75          $db->delete_query("privatemessages", "pmid IN(".implode(',', $pm_update).")");
  76      }
  77  
  78      if(!empty($user_update))
  79      {
  80          foreach($user_update as $uid => $data)
  81          {
  82              update_pm_count($uid);
  83          }
  84      }
  85  
  86      $cache->update_most_replied_threads();
  87      $cache->update_most_viewed_threads();
  88      $cache->update_birthdays();
  89      $cache->update_forumsdisplay();
  90  
  91      add_task_log($task, $lang->task_dailycleanup_ran);
  92  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref