[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/inc/tasks/ -> usercleanup.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_usercleanup($task)
  12  {
  13      global $db, $lang, $cache, $plugins;
  14  
  15      // Expire any old warnings
  16      require_once  MYBB_ROOT.'inc/datahandlers/warnings.php';
  17      $warningshandler = new WarningsHandler('update');
  18  
  19      $warningshandler->expire_warnings();
  20  
  21      // Expire any post moderation or suspension limits
  22      $query = $db->simple_select("users", "uid, moderationtime, suspensiontime", "(moderationtime!=0 AND moderationtime<".TIME_NOW.") OR (suspensiontime!=0 AND suspensiontime<".TIME_NOW.")");
  23      while($user = $db->fetch_array($query))
  24      {
  25          $updated_user = array();
  26          if($user['moderationtime'] != 0 && $user['moderationtime'] < TIME_NOW)
  27          {
  28              $updated_user['moderateposts'] = 0;
  29              $updated_user['moderationtime'] = 0;
  30          }
  31          if($user['suspensiontime'] != 0 && $user['suspensiontime'] < TIME_NOW)
  32          {
  33              $updated_user['suspendposting'] = 0;
  34              $updated_user['suspensiontime'] = 0;
  35          }
  36          $db->update_query("users", $updated_user, "uid='{$user['uid']}'");
  37      }
  38  
  39      // Expire any suspended signatures
  40      $query = $db->simple_select("users", "uid, suspendsigtime", "suspendsignature != 0 AND suspendsigtime < '".TIME_NOW."'");
  41      while($user = $db->fetch_array($query))
  42      {
  43          if($user['suspendsigtime'] != 0 && $user['suspendsigtime'] < TIME_NOW)
  44          {
  45              $updated_user = array(
  46                  "suspendsignature" => 0,
  47                  "suspendsigtime" => 0,
  48              );
  49              $db->update_query("users", $updated_user, "uid='".$user['uid']."'");
  50          }
  51      }
  52  
  53      // Expire bans
  54      $query = $db->simple_select("banned", "*", "lifted!=0 AND lifted<".TIME_NOW);
  55      while($ban = $db->fetch_array($query))
  56      {
  57          $updated_user = array(
  58              "usergroup" => $ban['oldgroup'],
  59              "additionalgroups" => $db->escape_string($ban['oldadditionalgroups']),
  60              "displaygroup" => $ban['olddisplaygroup']
  61          );
  62          $db->update_query("users", $updated_user, "uid='{$ban['uid']}'");
  63          $db->delete_query("banned", "uid='{$ban['uid']}'");
  64      }
  65  
  66      $cache->update_moderators();
  67  
  68      if(is_object($plugins))
  69      {
  70          $plugins->run_hooks('task_usercleanup', $task);
  71      }
  72  
  73      add_task_log($task, $lang->task_usercleanup_ran);
  74  }


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