示例#1
0
function delete_permissions($group_id = null, $user_id = null, $cat_id = null)
{
    $group_id = get_id_csv($group_id);
    $user_id = get_id_csv($user_id);
    $cat_id = get_id_csv($cat_id);
    $forums_join_sql = $cat_id ? "\n\t\tINNER JOIN " . BB_FORUMS . " f ON(a.forum_id = f.forum_id AND f.cat_id IN({$cat_id}))\n\t" : '';
    if ($group_id) {
        DB()->query("DELETE a FROM " . BB_AUTH_ACCESS . " a {$forums_join_sql} WHERE a.group_id IN({$group_id})");
    }
    if ($user_id) {
        DB()->query("DELETE a FROM " . BB_AUTH_ACCESS_SNAP . " a {$forums_join_sql} WHERE a.user_id IN({$user_id})");
    }
}
示例#2
0
function validate_topics($forum_id, &$req_topics, &$topic_titles)
{
    $valid_topics = $valid_titles = array();
    if ($topic_csv = get_id_csv($req_topics)) {
        $sql = "SELECT topic_id, topic_title FROM " . BB_TOPICS . " WHERE topic_id IN({$topic_csv}) AND forum_id = {$forum_id}";
        foreach (DB()->fetch_rowset($sql) as $row) {
            $valid_topics[] = $row['topic_id'];
            $valid_titles[] = $row['topic_title'];
        }
    }
    $req_topics = $valid_topics;
    $topic_titles = $valid_titles;
}
示例#3
0
function delete_user_sessions($user_id)
{
    cache_rm_user_sessions($user_id);
    $user_id = get_id_csv($user_id);
    DB()->query("DELETE FROM " . SESSIONS_TABLE . " WHERE session_user_id IN({$user_id})");
}
示例#4
0
function get_usernames_for_log($user_id)
{
    $users_log_msg = array();
    if ($user_csv = get_id_csv($user_id)) {
        $sql = "SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN({$user_csv})";
        foreach (DB()->fetch_rowset($sql) as $row) {
            $users_log_msg[] = "<b>{$row['username']}</b> [{$row['user_id']}]";
        }
    }
    return join(', ', $users_log_msg);
}
示例#5
0
function get_username($user_id)
{
    if (empty($user_id)) {
        return is_array($user_id) ? array() : false;
    }
    if (is_array($user_id)) {
        $usernames = array();
        foreach (DB()->fetch_rowset("SELECT user_id, username FROM " . USERS_TABLE . " WHERE user_id IN(" . get_id_csv($user_id) . ")") as $row) {
            $usernames[$row['user_id']] = $row['username'];
        }
        return $usernames;
    } else {
        $row = DB()->fetch_row("SELECT username FROM " . USERS_TABLE . " WHERE user_id = {$user_id} LIMIT 1");
        return $row['username'];
    }
}
示例#6
0
function get_poll_data_items_js($topic_id)
{
    if (!($topic_id_csv = get_id_csv($topic_id))) {
        return is_array($topic_id) ? array() : false;
    }
    $items = array();
    if (!($poll_data = CACHE('bb_poll_data')->get("poll_{$topic_id}"))) {
        $poll_data = DB()->fetch_rowset("\n\t\t\tSELECT topic_id, vote_id, vote_text, vote_result\n\t\t\tFROM " . BB_POLL_VOTES . "\n\t\t\tWHERE topic_id IN({$topic_id_csv})\n\t\t\tORDER BY topic_id, vote_id\n\t\t");
        CACHE('bb_poll_data')->set("poll_{$topic_id}", $poll_data);
    }
    foreach ($poll_data as $row) {
        $opt_text_for_js = htmlCHR($row['vote_text']);
        $opt_result_for_js = (int) $row['vote_result'];
        $items[$row['topic_id']][$row['vote_id']] = array($opt_text_for_js, $opt_result_for_js);
    }
    foreach ($items as $k => $v) {
        $items[$k] = Zend\Json\Json::encode($v);
    }
    return is_array($topic_id) ? $items : $items[$topic_id];
}
示例#7
0
    $tor_min_seeders = 0;
    // "<="
    $tor_min_leechers = 2;
    // ">="
    $tor_min_completed = 10;
    // ">="
    $tor_seed_last_seen_days = 3;
    // "<="
    $tor_downloaded_days_ago = 60;
    // ">="
    $user_last_seen_online = 15;
    // minutes
    $users_limit = 3000;
    $dl_status_ary = array(DL_STATUS_COMPLETE);
    define('NEW_BB_BT_TORHELP', 'new_torhelp');
    define('OLD_BB_BT_TORHELP', 'old_torhelp');
    DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TORHELP . ", " . OLD_BB_BT_TORHELP);
    DB()->query("CREATE TABLE " . NEW_BB_BT_TORHELP . " LIKE " . BB_BT_TORHELP);
    // Select users
    $sql = "\n\t\tSELECT DISTINCT session_user_id AS uid\n\t\tFROM " . BB_SESSIONS . "\n\t\tWHERE session_time > (UNIX_TIMESTAMP() - {$user_last_seen_online}*60)\n\t\t  AND session_user_id != " . GUEST_UID . "\n\t\tORDER BY session_time DESC\n\t\tLIMIT {$users_limit}\n\t";
    $online_users_ary = array();
    foreach (DB()->fetch_rowset($sql) as $row) {
        $online_users_ary[] = $row['uid'];
    }
    if ($online_users_csv = join(',', $online_users_ary)) {
        DB()->query("\n\t\t\tINSERT INTO " . NEW_BB_BT_TORHELP . " (user_id, topic_id_csv)\n\t\t\tSELECT\n\t\t\t  dl.user_id, GROUP_CONCAT(dl.topic_id)\n\t\t\tFROM       " . BB_BT_TRACKER_SNAP . " trsn\n\t\t\tINNER JOIN " . BB_BT_TORRENTS . " tor ON (tor.topic_id = trsn.topic_id)\n\t\t\tINNER JOIN " . BB_BT_DLSTATUS . " dl  ON (dl.topic_id = tor.topic_id)\n\t\t\tWHERE\n\t\t\t      trsn.seeders          <=  {$tor_min_seeders}\n\t\t\t  AND trsn.leechers         >=  {$tor_min_leechers}\n\t\t\t  AND tor.forum_id          !=  " . (int) $bb_cfg['trash_forum_id'] . "\n\t\t\t  AND tor.complete_count    >=  {$tor_min_completed}\n\t\t\t  AND tor.seeder_last_seen  <=  (UNIX_TIMESTAMP() - {$tor_seed_last_seen_days}*86400)\n\t\t\t  AND dl.user_id            IN({$online_users_csv})\n\t\t\t  AND dl.user_status        IN(" . get_id_csv($dl_status_ary) . ")\n\t\t\t  AND dl.last_modified_dlstatus > DATE_SUB(NOW(), INTERVAL {$tor_downloaded_days_ago} DAY)\n\t\t\tGROUP BY dl.user_id\n\t\t\tLIMIT 10000\n\t\t");
    }
    DB()->query("\n\t\tRENAME TABLE\n\t\t" . BB_BT_TORHELP . " TO " . OLD_BB_BT_TORHELP . ",\n\t\t" . NEW_BB_BT_TORHELP . " TO " . BB_BT_TORHELP . "\n\t");
    DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TORHELP . ", " . OLD_BB_BT_TORHELP);
}
DB()->expect_slow_query(10);
示例#8
0
define('BB_ROOT', './');
require BB_ROOT . 'common.php';
require INC_DIR . 'bbcode.php';
require CLASS_DIR . 'utf8.php';
require CLASS_DIR . 'correct.php';
require CLASS_DIR . 'reflection.php';
$page_cfg['load_tpl_vars'] = array('post_buttons', 'post_icons', 'topic_icons');
$user->session_start(array('req_login' => $bb_cfg['disable_search_for_guest']));
set_die_append_msg();
if (isset($_POST['del_my_post'])) {
    $template->assign_var('BB_DIE_APPEND_MSG', '
		<a href="#" onclick="window.close(); window.opener.focus();">' . $lang['GOTO_MY_MESSAGE'] . '</a>
		<br /><br />
		<a href="index.php">' . $lang['INDEX_RETURN'] . '</a>
	');
    if (empty($_POST['topic_id_list']) or !($topic_csv = get_id_csv($_POST['topic_id_list']))) {
        bb_die($lang['NONE_SELECTED']);
    }
    DB()->query("UPDATE " . BB_POSTS . " SET user_post = 0 WHERE poster_id = {$user->id} AND topic_id IN({$topic_csv})");
    if (DB()->affected_rows()) {
        //bb_die('Выбранные темы ['. count($_POST['topic_id_list']) .' шт.] удалены из списка "Мои сообщения"');
        bb_die($lang['DEL_MY_MESSAGE']);
    } else {
        bb_die($lang['NO_TOPICS_MY_MESSAGE']);
    }
} else {
    if (isset($_POST['add_my_post'])) {
        $template->assign_var('BB_DIE_APPEND_MSG', '
		<a href="#" onclick="window.close(); window.opener.focus();">' . $lang['GOTO_MY_MESSAGE'] . '</a>
		<br /><br />
		<a href="index.php">' . $lang['INDEX_RETURN'] . '</a>