コード例 #1
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_hourlycleanup($task)
{
    global $db, $lang, $plugins;
    $time = array('threads' => TIME_NOW, 'searchlog' => TIME_NOW - 60 * 60 * 24, 'captcha' => TIME_NOW - 60 * 60 * 24, 'question' => TIME_NOW - 60 * 60 * 24);
    if (is_object($plugins)) {
        $args = array('task' => &$task, 'time' => &$time);
        $plugins->run_hooks('task_hourlycleanup', $args);
    }
    require_once MYBB_ROOT . "inc/class_moderation.php";
    $moderation = new Moderation();
    // Delete moved threads with time limits
    $query = $db->simple_select('threads', 'tid', "deletetime != '0' AND deletetime < '" . (int) $time['threads'] . "'");
    while ($tid = $db->fetch_field($query, 'tid')) {
        $moderation->delete_thread($tid);
    }
    // Delete old searches
    $db->delete_query("searchlog", "dateline < '" . (int) $time['searchlog'] . "'");
    // Delete old captcha images
    $cut = TIME_NOW - 60 * 60 * 24 * 7;
    $db->delete_query("captcha", "dateline < '" . (int) $time['captcha'] . "'");
    // Delete old registration questions
    $cut = TIME_NOW - 60 * 60 * 24 * 7;
    $db->delete_query("questionsessions", "dateline < '" . (int) $time['question'] . "'");
    add_task_log($task, $lang->task_hourlycleanup_ran);
}
コード例 #2
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_userpruning($task)
{
    global $db, $lang, $mybb, $cache, $plugins;
    if ($mybb->settings['enablepruning'] != 1) {
        return;
    }
    // Are we pruning by posts?
    if ($mybb->settings['enableprunebyposts'] == 1) {
        $in_usergroups = array();
        $users = array();
        $usergroups = $cache->read('usergroups');
        foreach ($usergroups as $gid => $usergroup) {
            // Exclude admin, moderators, super moderators, banned
            if ($usergroup['canmodcp'] == 1 || $usergroup['cancp'] == 1 || $usergroup['issupermod'] == 1 || $usergroup['isbannedgroup'] == 1) {
                continue;
            }
            $in_usergroups[] = $gid;
        }
        // If we're not pruning unactivated users, then remove them from the criteria
        if ($mybb->settings['pruneunactived'] == 0) {
            $key = array_search('5', $in_usergroups);
            unset($in_usergroups[$key]);
        }
        $prunepostcount = (int) $mybb->settings['prunepostcount'];
        $regdate = TIME_NOW - (int) $mybb->settings['dayspruneregistered'] * 24 * 60 * 60;
        $usergroups = $db->escape_string(implode(',', $in_usergroups));
        $query = $db->simple_select('users', 'uid', "regdate<={$regdate} AND postnum<={$prunepostcount} AND usergroup IN({$usergroups})");
        while ($uid = $db->fetch_field($query, 'uid')) {
            $users[$uid] = $uid;
        }
        if ($users && $mybb->settings['prunepostcountall']) {
            $query = $db->simple_select('posts', 'uid, COUNT(pid) as posts', "uid IN ('" . implode("','", $users) . "') AND visible>0", array('group_by' => 'uid'));
            while ($user = $db->fetch_array($query)) {
                if ($user['posts'] >= $prunepostcount) {
                    unset($users[$user['uid']]);
                }
            }
        }
    }
    // Are we pruning unactivated users?
    if ($mybb->settings['pruneunactived'] == 1) {
        $regdate = TIME_NOW - (int) $mybb->settings['dayspruneunactivated'] * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate<={$regdate} AND usergroup='5'");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    if (is_object($plugins)) {
        $args = array('task' => &$task, 'in_usergroups' => &$in_usergroups, 'users' => &$users);
        $plugins->run_hooks('task_userpruning', $args);
    }
    if (!empty($users)) {
        // Set up user handler.
        require_once MYBB_ROOT . 'inc/datahandlers/user.php';
        $userhandler = new UserDataHandler('delete');
        // Delete the prunned users
        $userhandler->delete_user($users, $mybb->settings['prunethreads']);
    }
    add_task_log($task, $lang->task_userpruning_ran);
}
コード例 #3
0
ファイル: logcleanup.php プロジェクト: Nidrax/ppm-1.6
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: logcleanup.php 5297 2010-12-28 22:01:14Z Tomm $
 */
function task_logcleanup($task)
{
    global $mybb, $db, $lang;
    // Clear out old admin logs
    if ($mybb->config['log_pruning']['admin_logs'] > 0) {
        $cut = TIME_NOW - 60 * 60 * 24 * $mybb->config['log_pruning']['admin_logs'];
        $db->delete_query("adminlog", "dateline<'{$cut}'");
    }
    // Clear out old moderator logs
    if ($mybb->config['log_pruning']['mod_logs'] > 0) {
        $cut = TIME_NOW - 60 * 60 * 24 * $mybb->config['log_pruning']['mod_logs'];
        $db->delete_query("moderatorlog", "dateline<'{$cut}'");
    }
    // Clear out old task logs
    if ($mybb->config['log_pruning']['task_logs'] > 0) {
        $cut = TIME_NOW - 60 * 60 * 24 * $mybb->config['log_pruning']['task_logs'];
        $db->delete_query("tasklog", "dateline<'{$cut}'");
    }
    // Clear out old mail error logs
    if ($mybb->config['log_pruning']['mail_logs'] > 0) {
        $cut = TIME_NOW - 60 * 60 * 24 * $mybb->config['log_pruning']['mail_logs'];
        $db->delete_query("mailerrors", "dateline<'{$cut}'");
    }
    // Clear out old user mail logs
    if ($mybb->config['log_pruning']['user_mail_logs'] > 0) {
        $cut = TIME_NOW - 60 * 60 * 24 * $mybb->config['log_pruning']['user_mail_logs'];
        $db->delete_query("maillogs", "dateline<'{$cut}'");
    }
    // Clear out old promotion logs
    if ($mybb->config['log_pruning']['promotion_logs'] > 0) {
        $cut = TIME_NOW - 60 * 60 * 24 * $mybb->config['log_pruning']['promotion_logs'];
        $db->delete_query("promotionlogs", "dateline<'{$cut}'");
    }
    add_task_log($task, $lang->task_logcleanup_ran);
}
コード例 #4
0
/**
 * MyBB 1.4
 * Copyright © 2008 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybboard.net
 * License: http://www.mybboard.net/about/license
 *
 * $Id: usercleanup.php 4304 2009-01-02 01:11:56Z chris $
 */
function task_usercleanup($task)
{
    global $db, $lang, $cache;
    // Expire any old warnings
    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 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();
    add_task_log($task, $lang->task_usercleanup_ran);
}
コード例 #5
0
ファイル: dailycleanup.php プロジェクト: GeorgeLVP/mybb
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id$
 */
function task_dailycleanup($task)
{
    global $mybb, $db, $cache, $lang;
    require_once MYBB_ROOT . "inc/functions_user.php";
    // Clear out sessions older than 24h
    $cut = TIME_NOW - 60 * 60 * 24;
    $db->delete_query("sessions", "time < '{$cut}'");
    // Delete old read topics
    if ($mybb->settings['threadreadcut'] > 0) {
        $cut = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
        $db->delete_query("threadsread", "dateline < '{$cut}'");
        $db->delete_query("forumsread", "dateline < '{$cut}'");
    }
    // Check PMs moved to trash over a week ago & delete them
    $timecut = TIME_NOW - 60 * 60 * 24 * 7;
    $query = $db->simple_select("privatemessages", "pmid, uid, folder", "deletetime<='{$timecut}' AND folder='4'");
    while ($pm = $db->fetch_array($query)) {
        $user_update[$pm['uid']] = $uid;
        $pm_update[] = $pm['pmid'];
    }
    if (!empty($pm_update)) {
        $db->delete_query("privatemessages", "pmid IN(" . implode(',', $pm_update) . ")");
    }
    if (!empty($user_update)) {
        foreach ($user_update as $uid) {
            update_pm_count($uid);
        }
    }
    $cache->update_most_replied_threads();
    $cache->update_most_viewed_threads();
    $cache->update_birthdays();
    $cache->update_forumsdisplay();
    add_task_log($task, $lang->task_dailycleanup_ran);
}
コード例 #6
0
ファイル: backupnewpoints.php プロジェクト: ambsalinas/anima
function task_backupnewpoints($task)
{
    global $mybb, $db, $lang, $cache, $plugins;
    $lang->load("newpoints");
    $plugins->run_hooks("newpoints_task_backup");
    backupnewpoints_backupdb();
    add_task_log($task, $lang->newpoints_task_ran);
}
コード例 #7
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_versioncheck($task)
{
    global $cache, $lang, $mybb;
    $current_version = rawurlencode($mybb->version_code);
    $updated_cache = array('last_check' => TIME_NOW);
    // Check for the latest version
    require_once MYBB_ROOT . 'inc/class_xml.php';
    $contents = fetch_remote_file("http://www.mybb.com/version_check.php");
    if (!$contents) {
        add_task_log($task, $lang->task_versioncheck_ran_errors);
        return false;
    }
    $pos = strpos($contents, "<");
    if ($pos > 1) {
        $contents = substr($contents, $pos);
    }
    $pos = strpos(strrev($contents), ">");
    if ($pos > 1) {
        $contents = substr($contents, 0, -1 * ($pos - 1));
    }
    $parser = new XMLParser($contents);
    $tree = $parser->get_tree();
    $latest_code = (int) $tree['mybb']['version_code']['value'];
    $latest_version = "<strong>" . htmlspecialchars_uni($tree['mybb']['latest_version']['value']) . "</strong> (" . $latest_code . ")";
    if ($latest_code > $mybb->version_code) {
        $latest_version = "<span style=\"color: #C00;\">" . $latest_version . "</span>";
        $version_warn = 1;
        $updated_cache['latest_version'] = $latest_version;
        $updated_cache['latest_version_code'] = $latest_code;
    } else {
        $latest_version = "<span style=\"color: green;\">" . $latest_version . "</span>";
    }
    // Check for the latest news
    require_once MYBB_ROOT . "inc/class_feedparser.php";
    $feed_parser = new FeedParser();
    $feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
    $updated_cache['news'] = array();
    require_once MYBB_ROOT . '/inc/class_parser.php';
    $post_parser = new postParser();
    if ($feed_parser->error == '') {
        foreach ($feed_parser->items as $item) {
            if (isset($updated_cache['news'][2])) {
                break;
            }
            $description = $item['description'];
            $description = $post_parser->parse_message($description, array('allow_html' => true));
            $description = preg_replace('#<img(.*)/>#', '', $description);
            $updated_cache['news'][] = array('title' => htmlspecialchars_uni($item['title']), 'description' => $description, 'link' => htmlspecialchars_uni($item['link']), 'author' => htmlspecialchars_uni($item['author']), 'dateline' => $item['date_timestamp']);
        }
    }
    $cache->update("update_check", $updated_cache);
    add_task_log($task, $lang->task_versioncheck_ran);
}
コード例 #8
0
ファイル: myalerts.php プロジェクト: harrygg/MyAlerts
function task_myalerts($task)
{
    global $db, $lang;
    if (!isset($lang->myalerts)) {
        $lang->load('myalerts');
    }
    if ($db->delete_query('alerts', 'unread = 0')) {
        add_task_log($task, $lang->myalerts_task_cleanup_ran);
    } else {
        add_task_log($task, $lang->myalerts_task_cleanup_error);
    }
}
コード例 #9
0
/**
 * Execute a scheduled task.
 *
 * @param int $tid The task ID. If none specified, the next task due to be ran is executed
 * @return boolean True if successful, false on failure
 */
function run_task($tid = 0)
{
    global $db, $mybb, $cache, $plugins, $task, $lang;
    // Run a specific task
    if ($tid > 0) {
        $query = $db->simple_select("tasks", "*", "tid='{$tid}'");
        $task = $db->fetch_array($query);
    } else {
        $query = $db->simple_select("tasks", "*", "enabled=1 AND nextrun<='" . TIME_NOW . "'", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1));
        $task = $db->fetch_array($query);
    }
    // No task? Return
    if (!$task['tid']) {
        $cache->update_tasks();
        return false;
    }
    // Is this task still running and locked less than 5 minutes ago? Well don't run it now - clearly it isn't broken!
    if ($task['locked'] != 0 && $task['locked'] > TIME_NOW - 300) {
        $cache->update_tasks();
        return false;
    } else {
        $db->update_query("tasks", array("locked" => TIME_NOW), "tid='{$task['tid']}'");
    }
    // The task file does not exist
    if (!file_exists(MYBB_ROOT . "inc/tasks/{$task['file']}.php")) {
        if ($task['logging'] == 1) {
            add_task_log($task, $lang->missing_task);
        }
        // If task file does not exist, disable task and inform the administrator
        $updated_task = array("enabled" => 0, "locked" => 0);
        $db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");
        $subject = $lang->sprintf($lang->email_broken_task_subject, $mybb->settings['bbname']);
        $message = $lang->sprintf($lang->email_broken_task, $mybb->settings['bbname'], $mybb->settings['bburl'], $task['title']);
        my_mail($mybb->settings['adminemail'], $subject, $message, $mybb->settings['adminemail']);
        $cache->update_tasks();
        return false;
    } else {
        // Update the nextrun time now, so if the task causes a fatal error, it doesn't get stuck first in the queue
        $nextrun = fetch_next_run($task);
        $db->update_query("tasks", array("nextrun" => $nextrun), "tid='{$task['tid']}'");
        include_once MYBB_ROOT . "inc/tasks/{$task['file']}.php";
        $function = "task_{$task['file']}";
        if (function_exists($function)) {
            $function($task);
        }
    }
    $updated_task = array("lastrun" => TIME_NOW, "locked" => 0);
    $db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");
    $cache->update_tasks();
    return true;
}
コード例 #10
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_checktables($task)
{
    global $db, $mybb, $lang, $plugins;
    // Sorry SQLite, you don't have a decent way of checking if the table is corrupted or not.
    if ($db->type == "sqlite") {
        return;
    }
    @set_time_limit(0);
    $ok = array("The storage engine for the table doesn't support check", "Table is already up to date", "OK");
    $comma = "";
    $tables_list = "";
    $repaired = "";
    $setting_done = false;
    $tables = $db->list_tables($mybb->config['database']['database'], $mybb->config['database']['table_prefix']);
    foreach ($tables as $key => $table) {
        $tables_list .= "{$comma}{$table} ";
        $comma = ",";
    }
    if ($tables_list) {
        $query = $db->query("CHECK TABLE {$tables_list}CHANGED;");
        while ($table = $db->fetch_array($query)) {
            if (!in_array($table['Msg_text'], $ok)) {
                if ($table['Table'] != $mybb->config['database']['database'] . "." . TABLE_PREFIX . "settings" && $setting_done != true) {
                    $boardclosed = $mybb->settings['boardclosed'];
                    $boardclosed_reason = $mybb->settings['boardclosed_reason'];
                    $db->update_query("settings", array('value' => 1), "name='boardclosed'", 1);
                    $db->update_query("settings", array('value' => $db->escape_string($lang->error_database_repair)), "name='boardclosed_reason'", 1);
                    rebuild_settings();
                    $setting_done = true;
                }
                $db->query("REPAIR TABLE {$table['Table']}");
                $repaired[] = $table['Table'];
            }
        }
        if ($table['Table'] != $mybb->config['database']['table_prefix'] . "." . TABLE_PREFIX . "settings" && $setting_done == true) {
            $db->update_query("settings", array('value' => (int) $boardclosed), "name='boardclosed'", 1);
            $db->update_query("settings", array('value' => $db->escape_string($boardclosed_reason)), "name='boardclosed_reason'", 1);
            rebuild_settings();
        }
    }
    if (is_object($plugins)) {
        $plugins->run_hooks('task_checktables', $task);
    }
    if (!empty($repaired)) {
        add_task_log($task, $lang->sprintf($lang->task_checktables_ran_found, implode(', ', $repaired)));
    } else {
        add_task_log($task, $lang->task_checktables_ran);
    }
}
コード例 #11
0
/**
 * MyBB 1.4
 * Copyright © 2008 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybboard.net
 * License: http://www.mybboard.net/about/license
 *
 * $Id: threadviews.php 4304 2009-01-02 01:11:56Z chris $
 */
function task_threadviews($task)
{
    global $mybb, $db, $lang;
    $threadviews = array();
    if ($mybb->settings['delayedthreadviews'] != 1) {
        return;
    }
    // Update thread views
    $query = $db->query("\n\t\tSELECT tid, COUNT(tid) AS views\n\t\tFROM " . TABLE_PREFIX . "threadviews\n\t\tGROUP BY tid\n\t");
    while ($threadview = $db->fetch_array($query)) {
        $db->write_query("UPDATE " . TABLE_PREFIX . "threads SET views=views+{$threadview['views']} WHERE tid='{$threadview['tid']}' LIMIT 1");
    }
    $db->write_query("TRUNCATE TABLE " . TABLE_PREFIX . "threadviews");
    add_task_log($task, $lang->task_threadviews_ran);
}
コード例 #12
0
ファイル: hourlycleanup.php プロジェクト: slothly/mybb
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id$
 */
function task_hourlycleanup($task)
{
    global $db, $lang;
    $threads = array();
    $posts = array();
    // Delete moved threads with time limits
    $db->delete_query("threads", "deletetime != '0' AND deletetime < '" . TIME_NOW . "'");
    // Delete old searches
    $cut = TIME_NOW - 60 * 60 * 24;
    $db->delete_query("searchlog", "dateline < '{$cut}'");
    // Delete old captcha images
    $cut = TIME_NOW - 60 * 60 * 24;
    $db->delete_query("captcha", "dateline < '{$cut}'");
    add_task_log($task, $lang->task_hourlycleanup_ran);
}
コード例 #13
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_dailycleanup($task)
{
    global $mybb, $db, $cache, $lang, $plugins;
    require_once MYBB_ROOT . "inc/functions_user.php";
    $time = array('sessionstime' => TIME_NOW - 60 * 60 * 24, 'threadreadcut' => TIME_NOW - (int) $mybb->settings['threadreadcut'] * 60 * 60 * 24, 'privatemessages' => TIME_NOW - 60 * 60 * 24 * 7, 'deleteinvite' => TIME_NOW - (int) $mybb->settings['deleteinvites'] * 60 * 60 * 24, 'stoppmtracking' => TIME_NOW - 60 * 60 * 24 * 180);
    if (is_object($plugins)) {
        $args = array('task' => &$task, 'time' => &$time);
        $plugins->run_hooks('task_dailycleanup_start', $args);
    }
    // Clear out sessions older than 24h
    $db->delete_query("sessions", "time < '" . (int) $time['sessionstime'] . "'");
    // Delete old read topics
    if ($mybb->settings['threadreadcut'] > 0) {
        $db->delete_query("threadsread", "dateline < '" . (int) $time['threadreadcut'] . "'");
        $db->delete_query("forumsread", "dateline < '" . (int) $time['threadreadcut'] . "'");
    }
    // Check PMs moved to trash over a week ago & delete them
    $query = $db->simple_select("privatemessages", "pmid, uid, folder", "deletetime<='" . (int) $time['privatemessages'] . "' AND folder='4'");
    while ($pm = $db->fetch_array($query)) {
        $user_update[$pm['uid']] = 1;
        $pm_update[] = $pm['pmid'];
    }
    // Delete old group invites
    if ($mybb->settings['deleteinvites'] > 0) {
        $db->delete_query("joinrequests", "dateline < '" . (int) $time['deleteinvite'] . "' AND invite='1'");
    }
    // Stop tracking read PMs after 6 months
    $sql_array = array("receipt" => 0);
    $db->update_query("privatemessages", $sql_array, "receipt='2' AND folder!='3' AND status!='0' AND readtime < '" . (int) $time['stoppmtracking'] . "'");
    if (is_object($plugins)) {
        $args = array('user_update' => &$user_update, 'pm_update' => &$pm_update);
        $plugins->run_hooks('task_dailycleanup_end', $args);
    }
    if (!empty($pm_update)) {
        $db->delete_query("privatemessages", "pmid IN(" . implode(',', $pm_update) . ")");
    }
    if (!empty($user_update)) {
        foreach ($user_update as $uid) {
            update_pm_count($uid);
        }
    }
    $cache->update_most_replied_threads();
    $cache->update_most_viewed_threads();
    $cache->update_birthdays();
    $cache->update_forumsdisplay();
    add_task_log($task, $lang->task_dailycleanup_ran);
}
コード例 #14
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_threadviews($task)
{
    global $mybb, $db, $lang, $plugins;
    if ($mybb->settings['delayedthreadviews'] != 1) {
        return;
    }
    // Update thread views
    $query = $db->simple_select("threadviews", "tid, COUNT(tid) AS views", "", array('group_by' => 'tid'));
    while ($threadview = $db->fetch_array($query)) {
        $db->update_query("threads", array('views' => "views+{$threadview['views']}"), "tid='{$threadview['tid']}'", 1, true);
    }
    $db->write_query("TRUNCATE TABLE " . TABLE_PREFIX . "threadviews");
    if (is_object($plugins)) {
        $plugins->run_hooks('task_threadviews', $task);
    }
    add_task_log($task, $lang->task_threadviews_ran);
}
コード例 #15
0
/**
 * 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);
}
コード例 #16
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_recachestylesheets($task)
{
    global $mybb, $db, $lang;
    if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) {
        require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php";
    } else {
        if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) {
            require_once MYBB_ROOT . "admin/inc/functions_themes.php";
        }
    }
    $query = $db->simple_select('themestylesheets', '*');
    $num_recached = 0;
    while ($stylesheet = $db->fetch_array($query)) {
        if (cache_stylesheet($stylesheet['tid'], $stylesheet['name'], $stylesheet['stylesheet'])) {
            $db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'", 1);
            ++$num_recached;
        }
    }
    add_task_log($task, $lang->sprintf($lang->task_recachestylesheets_ran, $num_recached));
}
コード例 #17
0
function task_xtaorphan_cleanup(&$task)
{
    global $db, $lang, $plugins, $mybb;
    if (is_object($plugins)) {
        $plugins->run_hooks('xthreads_task_xtacleanup', $task);
    }
    // clean out orphaned xtattachments more than 1 day old
    require_once MYBB_ROOT . 'inc/xthreads/xt_modupdhooks.php';
    $count = xthreads_rm_attach_query('tid=0 AND uploadtime<' . (TIME_NOW - 86400));
    // setting "isdatahandler" to true is destructive!!!
    if (!$lang->task_xtaorphan_run_done) {
        $lang->load('xthreads', true);
    }
    if ($count) {
        add_task_log($task, $lang->sprintf($lang->task_xtaorphan_run_cleaned, $count));
    } else {
        add_task_log($task, $lang->task_xtaorphan_run_done);
    }
    // also perform deferred MD5 hashing
    $query = $db->simple_select('xtattachments', 'aid,indir,attachname,updatetime', 'md5hash IS NULL');
    if (isset($db->db_encoding)) {
        // hack for MyBB >= 1.6.12 to force it to not screw up our binary field
        $old_db_encoding = $db->db_encoding;
        $db->db_encoding = 'binary';
    }
    while ($xta = $db->fetch_array($query)) {
        $file = xthreads_get_attach_path($xta);
        $file_md5 = @md5_file($file, true);
        if (strlen($file_md5) == 32) {
            // perhaps not PHP5
            $file_md5 = pack('H*', $file_md5);
        }
        // we ensure that the attachment hasn't been updated during the hashing process by double-checking the updatetime field
        $db->update_query('xtattachments', array('md5hash' => $db->escape_string($file_md5)), 'aid=' . $xta['aid'] . ' AND updatetime=' . $xta['updatetime']);
    }
    if (isset($old_db_encoding)) {
        $db->db_encoding = $old_db_encoding;
    }
}
コード例 #18
0
ファイル: backupdb.php プロジェクト: mainhan1804/xomvanphong
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_backupdb($task)
{
    global $db, $config, $lang, $plugins;
    static $contents;
    @set_time_limit(0);
    if (!defined('MYBB_ADMIN_DIR')) {
        if (!isset($config['admin_dir'])) {
            $config['admin_dir'] = "admin";
        }
        define('MYBB_ADMIN_DIR', MYBB_ROOT . $config['admin_dir'] . '/');
    }
    // Check if folder is writable, before allowing submission
    if (!is_writable(MYBB_ADMIN_DIR . "/backups")) {
        add_task_log($task, $lang->task_backup_cannot_write_backup);
    } else {
        $db->set_table_prefix('');
        $file = MYBB_ADMIN_DIR . 'backups/backup_' . date("_Ymd_His_") . random_str(16);
        if (function_exists('gzopen')) {
            $fp = gzopen($file . '.incomplete.sql.gz', 'w9');
        } else {
            $fp = fopen($file . '.incomplete.sql', 'w');
        }
        $tables = $db->list_tables($config['database']['database'], $config['database']['table_prefix']);
        $time = date('dS F Y \\a\\t H:i', TIME_NOW);
        $contents = "-- MyBB Database Backup\n-- Generated: {$time}\n-- -------------------------------------\n\n";
        if (is_object($plugins)) {
            $args = array('task' => &$task, 'tables' => &$tables);
            $plugins->run_hooks('task_backupdb', $args);
        }
        foreach ($tables as $table) {
            $field_list = array();
            $fields_array = $db->show_fields_from($table);
            foreach ($fields_array as $field) {
                $field_list[] = $field['Field'];
            }
            $fields = "`" . implode("`,`", $field_list) . "`";
            $structure = $db->show_create_table($table) . ";\n";
            $contents .= $structure;
            clear_overflow($fp, $contents);
            if ($db->engine == 'mysqli') {
                $query = mysqli_query($db->read_link, "SELECT * FROM {$db->table_prefix}{$table}", MYSQLI_USE_RESULT);
            } else {
                $query = $db->simple_select($table);
            }
            while ($row = $db->fetch_array($query)) {
                $insert = "INSERT INTO {$table} ({$fields}) VALUES (";
                $comma = '';
                foreach ($field_list as $field) {
                    if (!isset($row[$field]) || is_null($row[$field])) {
                        $insert .= $comma . "NULL";
                    } else {
                        if ($db->engine == 'mysqli') {
                            $insert .= $comma . "'" . mysqli_real_escape_string($db->read_link, $row[$field]) . "'";
                        } else {
                            $insert .= $comma . "'" . $db->escape_string($row[$field]) . "'";
                        }
                    }
                    $comma = ',';
                }
                $insert .= ");\n";
                $contents .= $insert;
                clear_overflow($fp, $contents);
            }
            $db->free_result($query);
        }
        $db->set_table_prefix(TABLE_PREFIX);
        if (function_exists('gzopen')) {
            gzwrite($fp, $contents);
            gzclose($fp);
            rename($file . '.incomplete.sql.gz', $file . '.sql.gz');
        } else {
            fwrite($fp, $contents);
            fclose($fp);
            rename($file . '.incomplete.sql', $file . '.sql');
        }
        add_task_log($task, $lang->task_backup_ran);
    }
}
コード例 #19
0
/**
 * MyBB 1.4
 * Copyright © 2008 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybboard.net
 * License: http://www.mybboard.net/about/license
 *
 * $Id: promotions.php 4535 2009-11-25 06:23:38Z RyanGordon $
 */
function task_promotions($task)
{
    global $mybb, $db, $lang, $cache;
    // Iterate through all our promotions
    $query = $db->simple_select("promotions", "*", "enabled = '1'");
    while ($promotion = $db->fetch_array($query)) {
        $and = "";
        $sql_where = "";
        // Based on the promotion generate criteria for user selection
        $requirements = explode(',', $promotion['requirements']);
        if (in_array('postcount', $requirements) && intval($promotion['posts']) >= 0 && !empty($promotion['posttype'])) {
            $sql_where .= "{$and}postnum {$promotion['posttype']} '{$promotion['posts']}'";
            $and = " AND ";
        }
        if (in_array('reputation', $requirements) && intval($promotion['reputations']) >= 0 && !empty($promotion['reputationtype'])) {
            $sql_where .= "{$and}reputation {$promotion['reputationtype']} '{$promotion['reputations']}'";
            $and = " AND ";
        }
        if (in_array('timeregistered', $requirements) && intval($promotion['registered']) > 0 && !empty($promotion['registeredtype'])) {
            switch ($promotion['registeredtype']) {
                case "hours":
                    $regdate = $promotion['registered'] * 60 * 60;
                    break;
                case "days":
                    $regdate = $promotion['registered'] * 60 * 60 * 24;
                    break;
                case "weeks":
                    $regdate = $promotion['registered'] * 60 * 60 * 24 * 7;
                case "months":
                    $regdate = $promotion['registered'] * 60 * 60 * 24 * 30;
                    break;
                case "years":
                    $regdate = $promotion['registered'] * 60 * 60 * 24 * 365;
                    break;
                default:
                    $regdate = $promotion['registered'] * 60 * 60 * 24;
            }
            $sql_where .= "{$and}regdate <= '" . (TIME_NOW - $regdate) . "'";
            $and = " AND ";
        }
        if (!empty($promotion['originalusergroup']) && $promotion['originalusergroup'] != '*') {
            $sql_where .= "{$and}usergroup IN ({$promotion['originalusergroup']})";
            $and = " AND ";
        }
        if (!empty($promotion['newusergroup'])) {
            $sql_where .= "{$and}usergroup != '{$promotion['newusergroup']}'";
            $and = " AND ";
        }
        $sql_where .= "{$and}lastactive >= '{$task['lastrun']}'";
        $uid = array();
        $log_inserts = array();
        if ($promotion['usergrouptype'] == "secondary") {
            $usergroup_select = "additionalgroups";
        } else {
            $usergroup_select = "usergroup";
        }
        $query2 = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
        while ($user = $db->fetch_array($query2)) {
            // super admin check?
            if ($usergroup_select == "additionalgroups") {
                $log_inserts[] = array('pid' => $promotion['pid'], 'uid' => $user['uid'], 'oldusergroup' => $user['additionalgroups'], 'newusergroup' => $promotion['newusergroup'], 'dateline' => TIME_NOW, 'type' => "secondary");
            } else {
                $log_inserts[] = array('pid' => $promotion['pid'], 'uid' => $user['uid'], 'oldusergroup' => $user['usergroup'], 'newusergroup' => $promotion['newusergroup'], 'dateline' => TIME_NOW, 'type' => "primary");
            }
            $uids[] = $user['uid'];
            if ($usergroup_select == "additionalgroups") {
                if (join_usergroup($user['uid'], $promotion['newusergroup']) === false) {
                    // Did the user already have the additional usergroup?
                    array_pop($log_inserts);
                    array_pop($uids);
                }
            }
            if (count($uids) % 20 == 0) {
                if ($usergroup_select == "usergroup") {
                    $db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(" . implode(",", $uids) . ")");
                }
                if (!empty($log_inserts)) {
                    $db->insert_query_multiple("promotionlogs", $log_inserts);
                }
                $uids = array();
                $log_inserts = array();
            }
        }
        if (count($uids) > 0) {
            if ($usergroup_select == "usergroup") {
                $db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(" . implode(",", $uids) . ")");
            }
            if (!empty($log_inserts)) {
                $db->insert_query_multiple("promotionlogs", $log_inserts);
            }
            $uids = array();
            $log_inserts = array();
        }
    }
    $cache->update_moderators();
    add_task_log($task, $lang->task_promotions_ran);
}
コード例 #20
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_delayedmoderation($task)
{
    global $db, $lang, $plugins;
    require_once MYBB_ROOT . "inc/class_moderation.php";
    $moderation = new Moderation();
    require_once MYBB_ROOT . "inc/class_custommoderation.php";
    $custommod = new CustomModeration();
    // Iterate through all our delayed moderation actions
    $query = $db->simple_select("delayedmoderation", "*", "delaydateline <= '" . TIME_NOW . "'");
    while ($delayedmoderation = $db->fetch_array($query)) {
        if (is_object($plugins)) {
            $args = array('task' => &$task, 'delayedmoderation' => &$delayedmoderation);
            $plugins->run_hooks('task_delayedmoderation', $args);
        }
        $tids = explode(',', $delayedmoderation['tids']);
        $input = my_unserialize($delayedmoderation['inputs']);
        if (my_strpos($delayedmoderation['type'], "modtool") !== false) {
            list(, $custom_id) = explode('_', $delayedmoderation['type'], 2);
            $custommod->execute($custom_id, $tids);
        } else {
            switch ($delayedmoderation['type']) {
                case "openclosethread":
                    $closed_tids = $open_tids = array();
                    $query2 = $db->simple_select("threads", "tid,closed", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['closed'] == 1) {
                            $closed_tids[] = $thread['tid'];
                        } else {
                            $open_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($closed_tids)) {
                        $moderation->open_threads($closed_tids);
                    }
                    if (!empty($open_tids)) {
                        $moderation->close_threads($open_tids);
                    }
                    break;
                case "deletethread":
                    foreach ($tids as $tid) {
                        $moderation->delete_thread($tid);
                    }
                    break;
                case "move":
                    foreach ($tids as $tid) {
                        $moderation->move_thread($tid, $input['new_forum']);
                    }
                    break;
                case "stick":
                    $unstuck_tids = $stuck_tids = array();
                    $query2 = $db->simple_select("threads", "tid,sticky", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['sticky'] == 1) {
                            $stuck_tids[] = $thread['tid'];
                        } else {
                            $unstuck_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($stuck_tids)) {
                        $moderation->unstick_threads($stuck_tids);
                    }
                    if (!empty($unstuck_tids)) {
                        $moderation->stick_threads($unstuck_tids);
                    }
                    break;
                case "merge":
                    // $delayedmoderation['tids'] should be a single tid
                    if (count($tids) != 1) {
                        continue;
                    }
                    // explode at # sign in a url (indicates a name reference) and reassign to the url
                    $realurl = explode("#", $input['threadurl']);
                    $input['threadurl'] = $realurl[0];
                    // Are we using an SEO URL?
                    if (substr($input['threadurl'], -4) == "html") {
                        // Get thread to merge's tid the SEO way
                        preg_match("#thread-([0-9]+)?#i", $input['threadurl'], $threadmatch);
                        preg_match("#post-([0-9]+)?#i", $input['threadurl'], $postmatch);
                        if ($threadmatch[1]) {
                            $parameters['tid'] = $threadmatch[1];
                        }
                        if ($postmatch[1]) {
                            $parameters['pid'] = $postmatch[1];
                        }
                    } else {
                        // Get thread to merge's tid the normal way
                        $splitloc = explode(".php", $input['threadurl']);
                        $temp = explode("&", my_substr($splitloc[1], 1));
                        if (!empty($temp)) {
                            for ($i = 0; $i < count($temp); $i++) {
                                $temp2 = explode("=", $temp[$i], 2);
                                $parameters[$temp2[0]] = $temp2[1];
                            }
                        } else {
                            $temp2 = explode("=", $splitloc[1], 2);
                            $parameters[$temp2[0]] = $temp2[1];
                        }
                    }
                    if ($parameters['pid'] && !$parameters['tid']) {
                        $post = get_post($parameters['pid']);
                        $mergetid = $post['tid'];
                    } else {
                        if ($parameters['tid']) {
                            $mergetid = $parameters['tid'];
                        }
                    }
                    $mergetid = (int) $mergetid;
                    $mergethread = get_thread($mergetid);
                    if (!$mergethread['tid']) {
                        continue;
                    }
                    if ($mergetid == $delayedmoderation['tids']) {
                        // sanity check
                        continue;
                    }
                    if ($input['subject']) {
                        $subject = $input['subject'];
                    } else {
                        $query = $db->simple_select("threads", "subject", "tid='{$delayedmoderation['tids']}'");
                        $subject = $db->fetch_field($query, "subject");
                    }
                    $moderation->merge_threads($mergetid, $delayedmoderation['tids'], $subject);
                    break;
                case "removeredirects":
                    foreach ($tids as $tid) {
                        $moderation->remove_redirects($tid);
                    }
                    break;
                case "removesubscriptions":
                    $moderation->remove_thread_subscriptions($tids, true);
                    break;
                case "approveunapprovethread":
                    $approved_tids = $unapproved_tids = array();
                    $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['visible'] == 1) {
                            $approved_tids[] = $thread['tid'];
                        } else {
                            $unapproved_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($approved_tids)) {
                        $moderation->unapprove_threads($approved_tids);
                    }
                    if (!empty($unapproved_tids)) {
                        $moderation->approve_threads($unapproved_tids);
                    }
                    break;
                case "softdeleterestorethread":
                    $delete_tids = $restore_tids = array();
                    $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['visible'] == -1) {
                            $restore_tids[] = $thread['tid'];
                        } else {
                            $delete_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($restore_tids)) {
                        $moderation->restore_threads($restore_tids);
                    }
                    if (!empty($delete_tids)) {
                        $moderation->soft_delete_threads($delete_tids);
                    }
                    break;
            }
        }
        $db->delete_query("delayedmoderation", "did='{$delayedmoderation['did']}'");
    }
    add_task_log($task, $lang->task_delayedmoderation_ran);
}
コード例 #21
0
ファイル: massmail.php プロジェクト: benn0034/SHIELDsite2.old
function task_massmail($task)
{
    global $db, $mybb, $lang;
    $query = $db->simple_select("massemails", "*", "senddate <= '" . TIME_NOW . "' AND status IN (1,2)");
    while ($mass_email = $db->fetch_array($query)) {
        if ($mass_email['status'] == 1) {
            $db->update_query("massemails", array('status' => 2), "mid='{$mass_email['mid']}'", 1);
        }
        $sentcount = 0;
        if (!$mass_email['perpage']) {
            $mass_email['perpage'] = 50;
        }
        if (strpos($mass_email['htmlmessage'], '<br />') === false && strpos($mass_email['htmlmessage'], '<br>') === false) {
            $mass_email['htmlmessage'] = nl2br($mass_email['htmlmessage']);
        }
        $mass_email['orig_message'] = $mass_email['message'];
        $mass_email['orig_htmlmessage'] = $mass_email['htmlmessage'];
        // Need to perform the search to fetch the number of users we're emailing
        $member_query = build_mass_mail_query(unserialize($mass_email['conditions']));
        $count_query = $db->simple_select("users u", "COUNT(uid) AS num", $member_query);
        $mass_email['totalcount'] = $db->fetch_field($count_query, "num");
        $query2 = $db->simple_select("users u", "u.uid, u.language, u.pmnotify, u.lastactive, u.username, u.email", $member_query, array('limit_start' => $mass_email['sentcount'], 'limit' => $mass_email['perpage'], 'order_by' => 'u.uid', 'order_dir' => 'asc'));
        while ($user = $db->fetch_array($query2)) {
            $replacement_fields = array("{uid}" => $user['uid'], "{username}" => $user['username'], "{email}" => $user['email'], "{bbname}" => $mybb->settings['bbname'], "{bburl}" => $mybb->settings['bburl'], "[" . $lang->massmail_username . "]" => $user['username'], "[" . $lang->email_addr . "]" => $user['email'], "[" . $lang->board_name . "]" => $mybb->settings['bbname'], "[" . $lang->board_url . "]" => $mybb->settings['bburl']);
            foreach ($replacement_fields as $find => $replace) {
                $mass_email['message'] = str_replace($find, $replace, $mass_email['message']);
                $mass_email['htmlmessage'] = str_replace($find, $replace, $mass_email['htmlmessage']);
            }
            // Private Message
            if ($mass_email['type'] == 1) {
                $pm_handler = new PMDataHandler();
                $pm_handler->admin_override = true;
                $pm = array("subject" => $mass_email['subject'], "message" => $mass_email['message'], "fromid" => $mass_email['uid'], "options" => array("savecopy" => 0));
                $pm['to'] = explode(",", $user['username']);
                $pm_handler->set_data($pm);
                if (!$pm_handler->validate_pm()) {
                    $friendly_errors = implode('\\n', $pm_handler->get_friendly_errors());
                    add_task_log($task, $lang->sprintf($lang->task_massmail_ran_errors, htmlspecialchars_uni($user['username']), $friendly_errors));
                    $friendly_errors = "";
                } else {
                    $pm_handler->insert_pm();
                }
            } else {
                switch ($mass_email['format']) {
                    case 2:
                        $format = "both";
                        $text_message = $mass_email['message'];
                        $mass_email['message'] = $mass_email['htmlmessage'];
                        break;
                    case 1:
                        $format = "html";
                        $text_message = "";
                        $mass_email['message'] = $mass_email['htmlmessage'];
                        break;
                    default:
                        $format = "text";
                        $text_message = "";
                }
                my_mail($user['email'], $mass_email['subject'], $mass_email['message'], "", "", "", false, $format, $text_message);
            }
            ++$sentcount;
            $mass_email['message'] = $mass_email['orig_message'];
            $mass_email['htmlmessage'] = $mass_email['orig_htmlmessage'];
        }
        $update_array = array();
        $update_array['sentcount'] = $mass_email['sentcount'] + $sentcount;
        $update_array['totalcount'] = $mass_email['totalcount'];
        if ($update_array['sentcount'] >= $mass_email['totalcount']) {
            $update_array['status'] = 3;
        }
        $db->update_query("massemails", $update_array, "mid='{$mass_email['mid']}'", 1);
    }
    add_task_log($task, $lang->task_massmail_ran);
}
コード例 #22
0
ファイル: backupdb.php プロジェクト: Nidrax/ppm-1.6
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: backupdb.php 5297 2010-12-28 22:01:14Z Tomm $
 */
function task_backupdb($task)
{
    global $db, $config, $lang;
    static $contents;
    @set_time_limit(0);
    if (!defined('MYBB_ADMIN_DIR')) {
        if (!isset($config['admin_dir'])) {
            $config['admin_dir'] = "admin";
        }
        define('MYBB_ADMIN_DIR', MYBB_ROOT . $config['admin_dir'] . '/');
    }
    // Check if folder is writable, before allowing submission
    if (!is_writable(MYBB_ADMIN_DIR . "/backups")) {
        add_task_log($task, $lang->task_backup_cannot_write_backup);
    } else {
        $db->set_table_prefix('');
        $file = MYBB_ADMIN_DIR . 'backups/backup_' . substr(md5($mybb->user['uid'] . TIME_NOW), 0, 10) . random_str(54);
        if (function_exists('gzopen')) {
            $fp = gzopen($file . '.sql.gz', 'w9');
        } else {
            $fp = fopen($file . '.sql', 'w');
        }
        $tables = $db->list_tables($config['database']['database'], $config['database']['table_prefix']);
        $time = date('dS F Y \\a\\t H:i', TIME_NOW);
        $header = "-- MyBB Database Backup\n-- Generated: {$time}\n-- -------------------------------------\n\n";
        $contents = $header;
        foreach ($tables as $table) {
            $field_list = array();
            $fields_array = $db->show_fields_from($table);
            foreach ($fields_array as $field) {
                $field_list[] = $field['Field'];
            }
            $fields = "`" . implode("`,`", $field_list) . "`";
            $structure = $db->show_create_table($table) . ";\n";
            $contents .= $structure;
            clear_overflow($fp, $contents);
            $query = $db->simple_select($table);
            while ($row = $db->fetch_array($query)) {
                $insert = "INSERT INTO {$table} ({$fields}) VALUES (";
                $comma = '';
                foreach ($field_list as $field) {
                    if (!isset($row[$field]) || is_null($row[$field])) {
                        $insert .= $comma . "NULL";
                    } else {
                        $insert .= $comma . "'" . $db->escape_string($row[$field]) . "'";
                    }
                    $comma = ',';
                }
                $insert .= ");\n";
                $contents .= $insert;
                clear_overflow($fp, $contents);
            }
        }
        $db->set_table_prefix(TABLE_PREFIX);
        if (function_exists('gzopen')) {
            gzwrite($fp, $contents);
            gzclose($fp);
        } else {
            fwrite($fp, $contents);
            fclose($fp);
        }
        add_task_log($task, $lang->task_backup_ran);
    }
}
コード例 #23
0
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: userpruning.php 5297 2010-12-28 22:01:14Z Tomm $
 */
function task_userpruning($task)
{
    global $db, $lang, $mybb, $cache;
    if ($mybb->settings['enablepruning'] != 1) {
        return;
    }
    // Are we pruning by posts?
    if ($mybb->settings['enableprunebyposts'] == 1) {
        $in_usergroups = array();
        $users = array();
        $usergroups = $cache->read("usergroups");
        foreach ($usergroups as $gid => $usergroup) {
            // Exclude admin, moderators, super moderators, banned
            if ($usergroup['canmodcp'] == 1 || $usergroup['cancp'] == 1 || $usergroup['issupermod'] == 1 || $usergroup['isbannedgroup'] == 1) {
                continue;
            }
            $in_usergroups[] = $gid;
        }
        // If we're not pruning unactivated users, then remove them from the criteria
        if ($mybb->settings['pruneunactived'] == 0) {
            $key = array_search('5', $in_usergroups);
            unset($in_usergroups[$key]);
        }
        $regdate = TIME_NOW - intval($mybb->settings['dayspruneregistered']) * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate <= " . intval($regdate) . " AND postnum <= " . intval($mybb->settings['prunepostcount']) . " AND usergroup IN(" . $db->escape_string(implode(',', $in_usergroups)) . ")");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    // Are we pruning unactivated users?
    if ($mybb->settings['pruneunactived'] == 1) {
        $regdate = TIME_NOW - intval($mybb->settings['dayspruneunactivated']) * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate <= " . intval($regdate) . " AND usergroup='5'");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    if (!empty($users)) {
        $uid_list = $db->escape_string(implode(',', $users));
        // Delete the user
        $db->delete_query("userfields", "ufid IN({$uid_list})");
        $db->delete_query("privatemessages", "uid IN({$uid_list})");
        $db->delete_query("events", "uid IN({$uid_list})");
        $db->delete_query("moderators", "id IN({$uid_list}) AND isgroup='0'");
        $db->delete_query("forumsubscriptions", "uid IN({$uid_list})");
        $db->delete_query("threadsubscriptions", "uid IN({$uid_list})");
        $db->delete_query("sessions", "uid IN({$uid_list})");
        $db->delete_query("banned", "uid IN({$uid_list})");
        $db->delete_query("threadratings", "uid IN({$uid_list})");
        $db->delete_query("joinrequests", "uid IN({$uid_list})");
        $db->delete_query("awaitingactivation", "uid IN({$uid_list})");
        $query = $db->delete_query("users", "uid IN({$uid_list})");
        $num_deleted = $db->affected_rows($query);
        // Remove any of the user(s) uploaded avatars
        $query = $db->simple_select("users", "avatar", "uid IN ({$uid_list}) AND avatartype = 'upload'");
        if ($db->num_rows($query)) {
            while ($avatar = $db->fetch_field($query, "avatar")) {
                $avatar = substr($avatar, 2, -20);
                @unlink(MYBB_ROOT . $avatar);
            }
        }
        // Are we removing the posts/threads of a user?
        if ($mybb->settings['prunethreads'] == 1) {
            require_once MYBB_ROOT . "inc/class_moderation.php";
            $moderation = new Moderation();
            // Threads
            $query = $db->simple_select("threads", "tid", "uid IN({$uid_list})");
            while ($thread = $db->fetch_array($query)) {
                $moderation->delete_thread($thread['tid']);
            }
            // Posts
            $query = $db->simple_select("posts", "pid", "uid IN({$uid_list})");
            while ($post = $db->fetch_array($query)) {
                $moderation->delete_post($post['pid']);
            }
        } else {
            // We're just updating the UID
            $db->update_query("posts", array('uid' => 0), "uid IN({$uid_list})");
        }
        // Update forum stats
        update_stats(array('numusers' => '-' . intval($num_deleted)));
        $cache->update_moderators();
        $cache->update_banned();
    }
    add_task_log($task, $lang->task_userpruning_ran);
}
コード例 #24
0
ファイル: mysupport.php プロジェクト: myWebDev/MySupport
/**
 * MySupport 0.4 - Task File

 * Copyright 2010 Matthew Rogowski

 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

 ** http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
**/
function task_mysupport($task)
{
    global $mybb, $db, $lang;
    $lang->load("mysupport");
    $task_log = $lang->task_mysupport_ran;
    // if this is empty or 0 it'll effect all threads
    if ($mybb->settings['mysupporttaskautosolvetime'] > 0) {
        $cut = TIME_NOW - intval($mybb->settings['mysupporttaskautosolvetime']);
        $mysupport_forums = implode(",", array_map("intval", mysupport_forums()));
        // are there any MySupport forums??
        if (!empty($mysupport_forums)) {
            // select all the unsolved threads in MySupport forums where the last post was before the cut-off time, and either the status time is before the cut-off time, or the status of the thread has never been changed
            // this means it's not been posted in, and no MySupport actions have taken place on it, within the cut-off time
            $query = $db->simple_select("threads", "tid", "status != '1' AND fid IN (" . $db->escape_string($mysupport_forums) . ") AND lastpost < '" . intval($cut) . "' AND (statustime < '" . intval($cut) . "' OR statustime = '0')");
            $tids = array();
            while ($thread = $db->fetch_array($query)) {
                $tids[] = $thread['tid'];
            }
            $threads_solved = false;
            // if there are any threads to mark as solved
            if (!empty($tids)) {
                mysupport_change_status($tids, 1, true);
                $threads_solved = true;
            }
        }
        if ($threads_solved) {
            $task_log .= $lang->sprintf($lang->task_mysupport_autosolve_count, count($tids));
        }
    }
    if ($mybb->settings['mysupporttaskbackup'] > 0) {
        $timecut = TIME_NOW - $mybb->settings['mysupporttaskbackup'];
        $query = $db->simple_select("mysupport", "*", "type = 'backup' AND extra > '" . intval($timecut) . "'");
        // no backups have been made within the cut off time
        if ($db->num_rows($query) == 0) {
            if (!defined('MYBB_ADMIN_DIR')) {
                if (!isset($config['admin_dir'])) {
                    $config['admin_dir'] = "admin";
                }
                define('MYBB_ADMIN_DIR', MYBB_ROOT . $config['admin_dir'] . "/");
            }
            if (is_writable(MYBB_ADMIN_DIR . "backups")) {
                $name = substr(md5($mybb->user['uid'] . TIME_NOW), 0, 10) . random_str(54);
                $file = MYBB_ADMIN_DIR . "backups/mysupport_backup_" . $name . ".sql";
                $f = @fopen($file, "w");
                @fwrite($f, "<?php\n");
                @fwrite($f, "/**\n * Backup of MySupport data\n * Generated: " . date("dS F Y \\a\\t H:i", TIME_NOW) . "\n * Only to be imported via the MySupport backup importer.\n**/\n\n");
                require_once MYBB_ROOT . "inc/plugins/mysupport/mysupport.php";
                $mysupport_columns = mysupport_table_columns(2);
                foreach ($mysupport_columns as $table => $columns) {
                    switch ($table) {
                        case "forums":
                            $id_field = "fid";
                            break;
                        case "threads":
                            $id_field = "tid";
                            break;
                        case "users":
                            $id_field = "uid";
                            break;
                        case "usergroups":
                            $id_field = "gid";
                            break;
                    }
                    $columns = implode(", ", array_map($db->escape_string, array_keys($columns)));
                    $query = $db->simple_select($table, $id_field . "," . $columns);
                    $columns = explode(", ", $columns);
                    while ($r = $db->fetch_array($query)) {
                        $set = "";
                        foreach ($columns as $column) {
                            if (!empty($set)) {
                                $set .= ", ";
                            }
                            $set .= "`" . $column . "` = '" . $r[$column] . "'";
                        }
                        $q = "\$queries[] = \"UPDATE " . TABLE_PREFIX . $table . " SET " . $set . " WHERE `" . $id_field . "` = '" . $r[$id_field] . "'\";\n";
                        @fwrite($f, $q);
                    }
                }
                $query = $db->simple_select("mysupport");
                while ($r = $db->fetch_array($query)) {
                    $keys = array();
                    $vals = array();
                    foreach ($r as $key => $val) {
                        $keys[] = "`" . $key . "`";
                        $vals[] = "'" . $val . "'";
                    }
                    $q = "\$queries[] = \"INSERT INTO " . TABLE_PREFIX . "mysupport (" . implode(",", $keys) . ") VALUES (" . implode(",", $vals) . ")\";\n";
                    @fwrite($f, $q);
                }
                @fwrite($f, "?>");
                @fclose($f);
                $insert = array("type" => "backup", "name" => $db->escape_string($name), "extra" => TIME_NOW);
                $db->insert_query("mysupport", $insert);
                // get the latest 3 backups
                $query = $db->simple_select("mysupport", "mid", "type = 'backup'", array("order_by" => "extra", "order_dir" => "DESC", "limit" => 3));
                $backups = array(0);
                while ($backup = $db->fetch_field($query, "mid")) {
                    $backups[] = $backup;
                }
                $backups = implode(",", array_map("intval", $backups));
                // select all the backups that aren't the last 3
                $query = $db->simple_select("mysupport", "mid, name", "type = 'backup' AND mid NOT IN (" . $db->escape_string($backups) . ")");
                while ($backup = $db->fetch_array($query)) {
                    if (file_exists(MYBB_ADMIN_DIR . "backups/mysupport_backup_" . $backup['name'] . ".sql")) {
                        @unlink(MYBB_ADMIN_DIR . "backups/mysupport_backup_" . $backup['name'] . ".sql");
                    }
                    $db->delete_query("mysupport", "mid = '" . intval($backup['mid']) . "'");
                }
                $task_log .= " " . $lang->task_mysupport_backup_ran;
            }
        }
    }
    if (!empty($task_log)) {
        add_task_log($task, $task_log);
    }
    /*
    SELECT `t`.`tid`, `t`.`subject`, `t`.`fid`, `f`.`name`, `t`.`status`, `t`.`statusuid`, `u1`.`username` AS `statusuid_username`, `t`.`statustime`, `t`.`bestanswer`, `t`.`assign`, `u2`.`username` AS `assign_username`, `t`.`assignuid`, `u3`.`username` AS `assignuid_username`, `t`.`priority`, `m`.`name` AS `priority_name`, `t`.`prefix`, `tp`.`prefix` AS `prefix_name`
    FROM `mybb_threads` `t`
    LEFT JOIN `mybb_forums` `f` ON `t`.`fid` = `f`.`fid`
    LEFT JOIN `mybb_threadprefixes` `tp` ON `t`.`prefix` = `tp`.`pid`
    LEFT JOIN `mybb_users` `u1` ON `t`.`statusuid` = `u1`.`uid`
    LEFT JOIN `mybb_users` `u2` ON `t`.`assign` = `u2`.`uid`
    LEFT JOIN `mybb_users` `u3` ON `t`.`assignuid` = `u3`.`uid`
    LEFT JOIN `mybb_mysupport` `m` ON `t`.`priority` = `m`.`mid`
    WHERE CONCAT(',', f.parentlist, ',') LIKE '%,1,%'
    AND `t`.`closed` NOT LIKE 'moved|%'
    ORDER BY `t`.`tid` ASC;
    */
}
コード例 #25
0
 /**
  * Parses a error for processing.
  *
  * @param string The error type (i.e. E_ERROR, E_FATAL)
  * @param string The error message
  * @param string The error file
  * @param integer The error line
  * @return boolean True if parsing was a success, otherwise assume a error
  */
 function error($type, $message, $file = null, $line = 0)
 {
     global $mybb;
     // Error reporting turned off (either globally or by @ before erroring statement)
     if (error_reporting() == 0) {
         return true;
     }
     if (in_array($type, $this->ignore_types)) {
         return true;
     }
     $file = str_replace(MYBB_ROOT, "", $file);
     $this->has_errors = true;
     // For some reason in the installer this setting is set to "<"
     $accepted_error_types = array('both', 'error', 'warning', 'none');
     if (!in_array($mybb->settings['errortypemedium'], $accepted_error_types)) {
         $mybb->settings['errortypemedium'] = "both";
     }
     if (defined("IN_TASK")) {
         global $task;
         require_once MYBB_ROOT . "inc/functions_task.php";
         if ($file) {
             $filestr = " - Line: {$line} - File: {$file}";
         }
         add_task_log($task, "{$this->error_types[$type]} - [{$type}] " . var_export($message, true) . "{$filestr}");
     }
     // Saving error to log file.
     if ($mybb->settings['errorlogmedium'] == "log" || $mybb->settings['errorlogmedium'] == "both") {
         $this->log_error($type, $message, $file, $line);
     }
     // Are we emailing the Admin a copy?
     if ($mybb->settings['errorlogmedium'] == "mail" || $mybb->settings['errorlogmedium'] == "both") {
         $this->email_error($type, $message, $file, $line);
     }
     // SQL Error
     if ($type == MYBB_SQL) {
         $this->output_error($type, $message, $file, $line);
     } else {
         // Do we have a PHP error?
         if (my_strpos(my_strtolower($this->error_types[$type]), 'warning') === false) {
             $this->output_error($type, $message, $file, $line);
         } else {
             if ($mybb->settings['errortypemedium'] == "none" || $mybb->settings['errortypemedium'] == "error") {
                 echo "<div class=\"php_warning\">MyBB Internal: One or more warnings occured. Please contact your administrator for assistance.</div>";
             } else {
                 global $templates;
                 $warning = "<strong>{$this->error_types[$type]}</strong> [{$type}] {$message} - Line: {$line} - File: {$file} PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
                 if (is_object($templates) && method_exists($templates, "get") && !defined("IN_ADMINCP")) {
                     $this->warnings .= $warning;
                     $this->warnings .= $this->generate_backtrace();
                 } else {
                     echo "<div class=\"php_warning\">{$warning}" . $this->generate_backtrace() . "</div>";
                 }
             }
         }
     }
     return true;
 }
コード例 #26
0
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_promotions($task)
{
    global $mybb, $db, $lang, $cache, $plugins;
    $usergroups = $cache->read("usergroups");
    // Iterate through all our promotions
    $query = $db->simple_select("promotions", "*", "enabled = '1'");
    while ($promotion = $db->fetch_array($query)) {
        // Does the destination usergroup even exist?? If it doesn't and it moves a user to it, the user will get PHP errors.
        if (!array_key_exists($promotion['newusergroup'], $usergroups)) {
            // Instead of just skipping this promotion, disable it to stop it even being selected when this task is run.
            $update = array("enabled" => 0);
            $db->update_query("promotions", $update, "pid = '" . (int) $promotion['pid'] . "'");
            continue;
        }
        $and = "";
        $sql_where = "";
        // Based on the promotion generate criteria for user selection
        $requirements = explode(',', $promotion['requirements']);
        if (in_array('postcount', $requirements) && (int) $promotion['posts'] >= 0 && !empty($promotion['posttype'])) {
            $sql_where .= "{$and}postnum {$promotion['posttype']} '{$promotion['posts']}'";
            $and = " AND ";
        }
        if (in_array('threadcount', $requirements) && (int) $promotion['threads'] >= 0 && !empty($promotion['threadtype'])) {
            $sql_where .= "{$and}threadnum {$promotion['threadtype']} '{$promotion['threads']}'";
            $and = " AND ";
        }
        if (in_array('reputation', $requirements) && !empty($promotion['reputationtype'])) {
            $sql_where .= "{$and}reputation {$promotion['reputationtype']} '{$promotion['reputations']}'";
            $and = " AND ";
        }
        if (in_array('referrals', $requirements) && (int) $promotion['referrals'] >= 0 && !empty($promotion['referralstype'])) {
            $sql_where .= "{$and}referrals {$promotion['referralstype']} '{$promotion['referrals']}'";
            $and = " AND ";
        }
        if (in_array('warnings', $requirements) && (int) $promotion['warnings'] >= 0 && !empty($promotion['warningstype'])) {
            $sql_where .= "{$and}warningpoints {$promotion['warningstype']} '{$promotion['warnings']}'";
            $and = " AND ";
        }
        if (in_array('timeregistered', $requirements) && (int) $promotion['registered'] > 0 && !empty($promotion['registeredtype'])) {
            switch ($promotion['registeredtype']) {
                case "hours":
                    $regdate = $promotion['registered'] * 60 * 60;
                    break;
                case "days":
                    $regdate = $promotion['registered'] * 60 * 60 * 24;
                    break;
                case "weeks":
                    $regdate = $promotion['registered'] * 60 * 60 * 24 * 7;
                    break;
                case "months":
                    $regdate = $promotion['registered'] * 60 * 60 * 24 * 30;
                    break;
                case "years":
                    $regdate = $promotion['registered'] * 60 * 60 * 24 * 365;
                    break;
                default:
                    $regdate = $promotion['registered'] * 60 * 60 * 24;
            }
            $sql_where .= "{$and}regdate <= '" . (TIME_NOW - $regdate) . "'";
            $and = " AND ";
        }
        if (in_array('timeonline', $requirements) && (int) $promotion['online'] > 0 && !empty($promotion['onlinetype'])) {
            switch ($promotion['onlinetype']) {
                case "hours":
                    $timeonline = $promotion['online'] * 60 * 60;
                    break;
                case "days":
                    $timeonline = $promotion['online'] * 60 * 60 * 24;
                    break;
                case "weeks":
                    $timeonline = $promotion['online'] * 60 * 60 * 24 * 7;
                    break;
                case "months":
                    $timeonline = $promotion['online'] * 60 * 60 * 24 * 30;
                    break;
                case "years":
                    $timeonline = $promotion['online'] * 60 * 60 * 24 * 365;
                    break;
                default:
                    $timeonline = $promotion['online'] * 60 * 60 * 24;
            }
            $sql_where .= "{$and}timeonline <= '" . (TIME_NOW - $timeonline) . "'";
            $and = " AND ";
        }
        if (!empty($promotion['originalusergroup']) && $promotion['originalusergroup'] != '*') {
            $sql_where .= "{$and}usergroup IN ({$promotion['originalusergroup']})";
            $and = " AND ";
        }
        if (!empty($promotion['newusergroup'])) {
            // Skip users that are already in the new group
            switch ($db->type) {
                case "pgsql":
                case "sqlite":
                    $sql_where .= "{$and}usergroup != '{$promotion['newusergroup']}' AND ','||additionalgroups||',' NOT LIKE '%,{$promotion['newusergroup']},%'";
                    break;
                default:
                    $sql_where .= "{$and}usergroup != '{$promotion['newusergroup']}' AND CONCAT(',', additionalgroups, ',') NOT LIKE '%,{$promotion['newusergroup']},%'";
            }
            $and = " AND ";
        }
        $uid = array();
        $log_inserts = array();
        if ($promotion['usergrouptype'] == "secondary") {
            $usergroup_select = "additionalgroups";
        } else {
            $usergroup_select = "usergroup";
        }
        if (is_object($plugins)) {
            $args = array('task' => &$task, 'promotion' => &$promotion, 'sql_where' => &$sql_where, 'and' => &$and, 'usergroup_select' => &$usergroup_select);
            $plugins->run_hooks('task_promotions', $args);
        }
        $query2 = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
        $uids = array();
        while ($user = $db->fetch_array($query2)) {
            if (is_super_admin($user['uid'])) {
                // Skip super admins
                continue;
            }
            // super admin check?
            if ($usergroup_select == "additionalgroups") {
                $log_inserts[] = array('pid' => $promotion['pid'], 'uid' => $user['uid'], 'oldusergroup' => $user['additionalgroups'], 'newusergroup' => $promotion['newusergroup'], 'dateline' => TIME_NOW, 'type' => "secondary");
            } else {
                $log_inserts[] = array('pid' => $promotion['pid'], 'uid' => $user['uid'], 'oldusergroup' => $user['usergroup'], 'newusergroup' => $promotion['newusergroup'], 'dateline' => TIME_NOW, 'type' => "primary");
            }
            $uids[] = $user['uid'];
            if ($usergroup_select == "additionalgroups") {
                if (join_usergroup($user['uid'], $promotion['newusergroup']) === false) {
                    // Did the user already have the additional usergroup?
                    array_pop($log_inserts);
                    array_pop($uids);
                }
            }
            if (count($uids) % 20 == 0) {
                if ($usergroup_select == "usergroup") {
                    $db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(" . implode(",", $uids) . ")");
                }
                if (!empty($log_inserts)) {
                    $db->insert_query_multiple("promotionlogs", $log_inserts);
                }
                $uids = array();
                $log_inserts = array();
            }
        }
        if (count($uids) > 0) {
            if ($usergroup_select == "usergroup") {
                $db->update_query("users", array('usergroup' => $promotion['newusergroup']), "uid IN(" . implode(",", $uids) . ")");
            }
            if (!empty($log_inserts)) {
                $db->insert_query_multiple("promotionlogs", $log_inserts);
            }
            $uids = array();
            $log_inserts = array();
        }
    }
    $cache->update_moderators();
    add_task_log($task, $lang->task_promotions_ran);
}