Esempio n. 1
0
function synch_dl_topics($forum_id, $synch_type)
{
    // disabled in version 0.3.5
    return;
    global $ft_cfg;
    if (!$forum_id) {
        return;
    }
    $topics_sql = array();
    if ($synch_type == 'expire') {
        $dl_topics_limit = 80;
        $dl_expire_time = time() - $ft_cfg['bt_dl_list_expire'] * 60 * 60 * 24;
        $sql = 'SELECT DISTINCT t.topic_id
			FROM ' . TOPICS_TABLE . ' t, ' . BT_USR_DL_STAT_TABLE . " d\n\t\t\tWHERE t.forum_id = {$forum_id}\n\t\t\t\tAND t.topic_dl_type = " . TOPIC_DL_TYPE_DL . '
				AND t.topic_status <> ' . TOPIC_MOVED . '
				AND t.topic_id = d.topic_id
				AND d.user_status IN(' . DL_STATUS_WILL . ',' . DL_STATUS_DOWN . ")\n\t\t\t\tAND d.update_time < {$dl_expire_time}\n\t\t\tORDER BY t.topic_id DESC\n\t\t\tLIMIT {$dl_topics_limit}";
        if (!($result = DB()->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not synchronize topics DL-status', '', __LINE__, __FILE__, $sql);
        }
        if ($rowset = @DB()->sql_fetchrowset($result)) {
            for ($i = 0; $i < count($rowset); $i++) {
                $topics_sql[] = $rowset[$i]['topic_id'];
            }
            if ($topics_sql = implode(',', $topics_sql)) {
                $sql = 'DELETE FROM ' . BT_USR_DL_STAT_TABLE . "\n\t\t\t\t\tWHERE topic_id IN({$topics_sql})\n\t\t\t\t\t\tAND user_status IN(" . DL_STATUS_WILL . ',' . DL_STATUS_DOWN . ")\n\t\t\t\t\t\tAND update_time < {$dl_expire_time}";
                if (!DB()->sql_query($sql)) {
                    message_die(GENERAL_ERROR, "Could not delete expired users from DL-List", '', __LINE__, __FILE__, $sql);
                }
                update_topics_dl_status($topics_sql, 'expire');
            }
        }
    }
    $sql = 'UPDATE ' . FORUMS_TABLE . ' SET
			last_dl_topics_synch = ' . time() . "\n\t\tWHERE forum_id = {$forum_id}";
    if (!DB()->sql_query($sql)) {
        message_die(GENERAL_ERROR, "Could not update last_dl_topics_synch in forums table", '', __LINE__, __FILE__, $sql);
    }
    return;
}
Esempio n. 2
0
         message_die(GENERAL_MESSAGE, $lang['None_selected']);
     }
     $topics = isset($_POST['topic_id_list']) ? $_POST['topic_id_list'] : array($topic_id);
     $topic_id_sql = '';
     for ($i = 0, $cnt = count($topics); $i < $cnt; $i++) {
         $topic_id_sql .= ($topic_id_sql ? ',' : '') . intval($topics[$i]);
     }
     $topic_dl_type = $mode == 'set_download' ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
     $sql = 'UPDATE ' . TOPICS_TABLE . " SET\r\n\t\t\t\ttopic_dl_type = {$topic_dl_type}\r\n\t\t\tWHERE topic_id IN({$topic_id_sql})\r\n\t\t\t\tAND forum_id = {$forum_id}\r\n\t\t\t\tAND topic_moved_id = 0";
     if (!($result = DB()->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
     }
     if ($mode == 'unset_download') {
         require_once FT_ROOT . 'includes/functions_dl_list.php';
         clear_dl_list($topic_id);
         update_topics_dl_status($topic_id, 'DL-List deleted');
     }
     if (!empty($topic_id)) {
         $redirect_page = "viewtopic.php?" . POST_TOPIC_URL . "={$topic_id}&amp;sid=" . $userdata['session_id'];
         $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
     } else {
         $redirect_page = "modcp.php?" . POST_FORUM_URL . "={$forum_id}&amp;sid=" . $userdata['session_id'];
         $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
     }
     $message = $message . '<br \\><br \\>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.php?" . POST_FORUM_URL . "={$forum_id}&amp;sid=" . $userdata['session_id'] . '">', '</a>');
     $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">'));
     $msg = $mode == 'set_download' ? $lang['Topics_Down_Sets'] : $lang['Topics_Down_Unsets'];
     message_die(GENERAL_MESSAGE, $msg . '<br /><br />' . $message);
     break;
     //bt end
 //bt end
         $dl_count[$user['user_status']] = $user['username'];
     } else {
         $upd_time = create_date($title_date_format, $user['update_time'], $ft_cfg['board_timezone']);
         $upd_time_title = $exp_time ? " upd: {$upd_time} \n exp: {$exp_time} " : " {$upd_time} ";
         $u_prof_href = $user['user_id'] == GUEST_UID ? '#' : append_sid("profile.php?mode=viewprofile&amp;u=" . $user['user_id']) . '#torrent';
         $dl_cat[$user['user_status']] .= '<nobr><a class="' . $u_link_class . '" href="' . $u_prof_href . '" title="' . $upd_time_title . '">' . $user['username'] . '</a></nobr>, ';
         $dl_count[$user['user_status']]++;
     }
 }
 if ($expired_users = implode(',', $expired_users)) {
     require_once FT_ROOT . 'includes/functions_dl_list.php';
     $sql = 'DELETE FROM ' . BT_USR_DL_STAT_TABLE . "\n\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\tAND user_id IN({$expired_users})";
     if (!DB()->sql_query($sql)) {
         message_die(GENERAL_ERROR, 'Could not delete expired users from DL-List', '', __LINE__, __FILE__, $sql);
     }
     update_topics_dl_status($topic_id, 'expire');
 }
 foreach ($dl_status_val as $i => $desc) {
     if ($dl_cat[$i] && $count_mode && !$ft_cfg['bt_dl_list_expire']) {
         if ($i == DL_STATUS_CANCEL && !$show_canceled_in_count_mode && !$peers_full_mode) {
             continue;
         }
         $dl_cat[$i][strlen($dl_cat[$i]) - 2] = ' ';
         $template->assign_block_vars('dl_counts.count_row', array('DL_OPTION_NAME' => $lang[$desc . '_2'], 'DL_OPTION_USERS' => $dl_cat[$i]));
     } else {
         if ($dl_cat[$i] && !$count_mode) {
             $dl_users_div_style = $dl_count[$i] > $max_dl_users_before_overflow ? $dl_users_div_style_overflow : $dl_users_div_style_normal;
             $dl_cat[$i][strlen($dl_cat[$i]) - 2] = ' ';
             $dl_cat[$i] = "<span class={$desc}>" . $dl_cat[$i] . '</span>';
             $template->assign_block_vars('dl_users.users_row', array('DL_OPTION_NAME' => $lang[$desc . '_2'], 'DL_OPTION_USERS' => $dl_cat[$i], 'DL_COUNT' => $dl_count[$i], 'DL_USERS_DIV_STYLE' => $dl_users_div_style));
         } else {
Esempio n. 4
0
//
if ($topics && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')) {
    $sql = 'REPLACE INTO ' . BT_USR_DL_STAT_TABLE . ' (topic_id, user_id, user_status, update_time) VALUES ';
    for ($i = 0, $cnt = count($topics_ary); $i < $cnt; $i++) {
        $sql .= "({$topics_ary[$i]}, {$user_id}, {$new_dl_status}, {$current_time})";
        $sql .= $i != $cnt - 1 ? ', ' : '';
    }
    if (!DB()->sql_query($sql)) {
        message_die(GENERAL_ERROR, "Could not insert user_id for DL-List", '', __LINE__, __FILE__, $sql);
    }
    //
    // Update topics DL-status
    //
    if ($new_dl_status == DL_STATUS_WILL) {
        update_topics_dl_status($topics, 'will');
    } else {
        if ($new_dl_status == DL_STATUS_DOWN) {
            update_topics_dl_status($topics, 'down');
        } else {
            if ($new_dl_status == DL_STATUS_COMPLETE) {
                update_topics_dl_status($topics, 'complete');
            } else {
                if ($new_dl_status == DL_STATUS_CANCEL) {
                    update_topics_dl_status($topics, 'cancel');
                }
            }
        }
    }
    redirect(append_sid("{$redirect_type}?{$redirect}", true));
}
redirect(append_sid("index.php", true));