/** * MyBB 1.8 * Copyright 2014 MyBB Group, All Rights Reserved * * Website: http://www.mybb.com * License: http://www.mybb.com/about/license * */ function task_usercleanup($task) { global $db, $lang, $cache, $plugins; // Expire any old warnings require_once MYBB_ROOT . 'inc/datahandlers/warnings.php'; $warningshandler = new WarningsHandler('update'); $warningshandler->expire_warnings(); // Expire any post moderation or suspension limits $query = $db->simple_select("users", "uid, moderationtime, suspensiontime", "(moderationtime!=0 AND moderationtime<" . TIME_NOW . ") OR (suspensiontime!=0 AND suspensiontime<" . TIME_NOW . ")"); while ($user = $db->fetch_array($query)) { $updated_user = array(); if ($user['moderationtime'] != 0 && $user['moderationtime'] < TIME_NOW) { $updated_user['moderateposts'] = 0; $updated_user['moderationtime'] = 0; } if ($user['suspensiontime'] != 0 && $user['suspensiontime'] < TIME_NOW) { $updated_user['suspendposting'] = 0; $updated_user['suspensiontime'] = 0; } $db->update_query("users", $updated_user, "uid='{$user['uid']}'"); } // Expire any suspended signatures $query = $db->simple_select("users", "uid, suspendsigtime", "suspendsignature != 0 AND suspendsigtime < '" . TIME_NOW . "'"); while ($user = $db->fetch_array($query)) { if ($user['suspendsigtime'] != 0 && $user['suspendsigtime'] < TIME_NOW) { $updated_user = array("suspendsignature" => 0, "suspendsigtime" => 0); $db->update_query("users", $updated_user, "uid='" . $user['uid'] . "'"); } } // Expire bans $query = $db->simple_select("banned", "*", "lifted!=0 AND lifted<" . TIME_NOW); while ($ban = $db->fetch_array($query)) { $updated_user = array("usergroup" => $ban['oldgroup'], "additionalgroups" => $ban['oldadditionalgroups'], "displaygroup" => $ban['olddisplaygroup']); $db->update_query("users", $updated_user, "uid='{$ban['uid']}'"); $db->delete_query("banned", "uid='{$ban['uid']}'"); } $cache->update_moderators(); if (is_object($plugins)) { $plugins->run_hooks('task_usercleanup', $task); } add_task_log($task, $lang->task_usercleanup_ran); }
$latest_warnings = ''; if ($mybb->settings['enablewarningsystem'] != 0 && $mybb->settings['canviewownwarning'] != 0) { if ($mybb->settings['maxwarningpoints'] < 1) { $mybb->settings['maxwarningpoints'] = 10; } $warning_level = round($mybb->user['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100); if ($warning_level > 100) { $warning_level = 100; } if ($mybb->user['warningpoints'] > $mybb->settings['maxwarningpoints']) { $mybb->user['warningpoints'] = $mybb->settings['maxwarningpoints']; } if ($warning_level > 0) { require_once MYBB_ROOT . 'inc/datahandlers/warnings.php'; $warningshandler = new WarningsHandler('update'); $warningshandler->expire_warnings(); $lang->current_warning_level = $lang->sprintf($lang->current_warning_level, $warning_level, $mybb->user['warningpoints'], $mybb->settings['maxwarningpoints']); $warnings = ''; // Fetch latest warnings $query = $db->query("\n\t\t\t\tSELECT w.*, t.title AS type_title, u.username, p.subject AS post_subject\n\t\t\t\tFROM " . TABLE_PREFIX . "warnings w\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "warningtypes t ON (t.tid=w.tid)\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=w.issuedby)\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (p.pid=w.pid)\n\t\t\t\tWHERE w.uid='{$mybb->user['uid']}'\n\t\t\t\tORDER BY w.expired ASC, w.dateline DESC\n\t\t\t\tLIMIT 5\n\t\t\t"); while ($warning = $db->fetch_array($query)) { $post_link = ""; if ($warning['post_subject']) { $warning['post_subject'] = $parser->parse_badwords($warning['post_subject']); $warning['post_subject'] = htmlspecialchars_uni($warning['post_subject']); $warning['postlink'] = get_post_link($warning['pid']); eval("\$post_link .= \"" . $templates->get("usercp_warnings_warning_post") . "\";"); } $issuedby = build_profile_link($warning['username'], $warning['issuedby']); $date_issued = my_date('relative', $warning['dateline']); if ($warning['type_title']) {
/** * Expire old warnings in the database. * * @return bool */ function expire_warnings() { global $warningshandler; if (!is_object($warningshandler)) { require_once MYBB_ROOT . 'inc/datahandlers/warnings.php'; $warningshandler = new WarningsHandler('update'); } return $warningshandler->expire_warnings(); }