Удаление аттач-мода

Продолжаем удаление.
This commit is contained in:
Exile 2014-12-26 21:25:17 +03:00
commit 4fd707ad5e
2 changed files with 424 additions and 425 deletions

View file

@ -257,7 +257,6 @@ define('LOG_DIR', BB_PATH .'/internal_data/log/' );
define('SITEMAP_DIR', BB_PATH .'/internal_data/sitemap/' ); define('SITEMAP_DIR', BB_PATH .'/internal_data/sitemap/' );
define('TRIGGERS_DIR', BB_PATH .'/internal_data/triggers/' ); define('TRIGGERS_DIR', BB_PATH .'/internal_data/triggers/' );
define('AJAX_DIR', BB_ROOT .'/library/ajax/' ); define('AJAX_DIR', BB_ROOT .'/library/ajax/' );
define('ATTACH_DIR', BB_PATH .'/library/attach_mod/' );
define('CFG_DIR', BB_PATH .'/library/config/' ); define('CFG_DIR', BB_PATH .'/library/config/' );
define('INC_DIR', BB_PATH .'/library/includes/' ); define('INC_DIR', BB_PATH .'/library/includes/' );
define('CLASS_DIR', BB_PATH .'/library/includes/classes/'); define('CLASS_DIR', BB_PATH .'/library/includes/classes/');

View file

@ -22,11 +22,11 @@ $seeders = $leechers = '';
$tor_info = array(); $tor_info = array();
$template->assign_vars(array( $template->assign_vars(array(
'SEED_COUNT' => false, 'SEED_COUNT' => false,
'LEECH_COUNT' => false, 'LEECH_COUNT' => false,
'TOR_SPEED_UP' => false, 'TOR_SPEED_UP' => false,
'TOR_SPEED_DOWN' => false, 'TOR_SPEED_DOWN' => false,
'SHOW_RATIO_WARN' => false, 'SHOW_RATIO_WARN' => false,
)); ));
// Define show peers mode (count only || user names with complete % || full details) // Define show peers mode (count only || user names with complete % || full details)
@ -37,23 +37,23 @@ $s_mode = 'count';
if ($cfg_sp_mode == SHOW_PEERS_NAMES) if ($cfg_sp_mode == SHOW_PEERS_NAMES)
{ {
$s_mode = 'names'; $s_mode = 'names';
} }
else if ($cfg_sp_mode == SHOW_PEERS_FULL) else if ($cfg_sp_mode == SHOW_PEERS_FULL)
{ {
$s_mode = 'full'; $s_mode = 'full';
} }
if ($bb_cfg['bt_allow_spmode_change']) if ($bb_cfg['bt_allow_spmode_change'])
{ {
if ($get_sp_mode == 'names') if ($get_sp_mode == 'names')
{ {
$s_mode = 'names'; $s_mode = 'names';
} }
else if ($get_sp_mode == 'full') else if ($get_sp_mode == 'full')
{ {
$s_mode = 'full'; $s_mode = 'full';
} }
} }
$bt_topic_id = $t_data['topic_id']; $bt_topic_id = $t_data['topic_id'];
@ -80,245 +80,245 @@ $description = ($comment) ? $comment : preg_replace("#.torrent$#i", '', $displ
if ($tor_auth_reg || $tor_auth_del) if ($tor_auth_reg || $tor_auth_del)
{ {
$reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : '. $attach_id .', type: \'reg\'}); return false;">'. $lang['BT_REG_ON_TRACKER'] .'</a>'; $reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : '. $attach_id .', type: \'reg\'}); return false;">'. $lang['BT_REG_ON_TRACKER'] .'</a>';
$unreg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : '. $attach_id .', type: \'unreg\'}); return false;">'. $lang['BT_UNREG_FROM_TRACKER'] .'</a>'; $unreg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : '. $attach_id .', type: \'unreg\'}); return false;">'. $lang['BT_UNREG_FROM_TRACKER'] .'</a>';
$tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url; $tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url;
} }
if ($bb_cfg['torrent_name_style']) if ($bb_cfg['torrent_name_style'])
{ {
$display_name = '['.$bb_cfg['server_name'].'].t' . $bt_topic_id . '.torrent'; $display_name = '['.$bb_cfg['server_name'].'].t' . $bt_topic_id . '.torrent';
} }
if (!$tor_reged) if (!$tor_reged)
{ {
$template->assign_block_vars('postrow.attach.tor_not_reged', array( $template->assign_block_vars('postrow.attach.tor_not_reged', array(
'DOWNLOAD_NAME' => $display_name, 'DOWNLOAD_NAME' => $display_name,
'TRACKER_LINK' => $tracker_link, 'TRACKER_LINK' => $tracker_link,
'ATTACH_ID' => $attach_id, 'ATTACH_ID' => $attach_id,
'S_UPLOAD_IMAGE' => $upload_image, 'S_UPLOAD_IMAGE' => $upload_image,
'U_DOWNLOAD_LINK' => $download_link, 'U_DOWNLOAD_LINK' => $download_link,
'FILESIZE' => $tor_file_size, 'FILESIZE' => $tor_file_size,
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count), 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count),
'POSTED_TIME' => $tor_file_time, 'POSTED_TIME' => $tor_file_time,
)); ));
if ($comment) if ($comment)
{ {
$template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment)); $template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment));
} }
} }
else else
{ {
$sql = "SELECT bt.*, u.user_id, u.username, u.user_rank $sql = "SELECT bt.*, u.user_id, u.username, u.user_rank
FROM ". BB_BT_TORRENTS ." bt FROM ". BB_BT_TORRENTS ." bt
LEFT JOIN ". BB_USERS ." u ON(bt.checked_user_id = u.user_id) LEFT JOIN ". BB_USERS ." u ON(bt.checked_user_id = u.user_id)
WHERE bt.attach_id = $attach_id"; WHERE bt.attach_id = $attach_id";
if (!$result = DB()->sql_query($sql)) if (!$result = DB()->sql_query($sql))
{ {
bb_die('Could not obtain torrent information'); bb_die('Could not obtain torrent information');
} }
$tor_info = DB()->sql_fetchrow($result); $tor_info = DB()->sql_fetchrow($result);
DB()->sql_freeresult($result); DB()->sql_freeresult($result);
} }
if ($tor_reged && !$tor_info) if ($tor_reged && !$tor_info)
{ {
DB()->query("UPDATE ". BB_ATTACHMENTS_DESC ." SET tracker_status = 0 WHERE attach_id = $attach_id"); DB()->query("UPDATE ". BB_ATTACHMENTS_DESC ." SET tracker_status = 0 WHERE attach_id = $attach_id");
bb_die('Torrent status fixed'); bb_die('Torrent status fixed');
} }
if ($tor_auth) if ($tor_auth)
{ {
$template->assign_vars(array( $template->assign_vars(array(
'TOR_CONTROLS' => true, 'TOR_CONTROLS' => true,
'TOR_ATTACH_ID' => $attach_id, 'TOR_ATTACH_ID' => $attach_id,
)); ));
if ($t_data['self_moderated'] || $is_auth['auth_mod']) if ($t_data['self_moderated'] || $is_auth['auth_mod'])
{ {
$template->assign_vars(array('AUTH_MOVE' => true)); $template->assign_vars(array('AUTH_MOVE' => true));
} }
} }
if ($tor_reged && $tor_info) if ($tor_reged && $tor_info)
{ {
$tor_size = ($tor_info['size']) ? $tor_info['size'] : 0; $tor_size = ($tor_info['size']) ? $tor_info['size'] : 0;
$tor_id = $tor_info['topic_id']; $tor_id = $tor_info['topic_id'];
$tor_type = $tor_info['tor_type']; $tor_type = $tor_info['tor_type'];
// Magnet link // Magnet link
$passkey = DB()->fetch_row("SELECT auth_key FROM ". BB_BT_USERS ." WHERE user_id = ". (int) $bt_user_id ." LIMIT 1"); $passkey = DB()->fetch_row("SELECT auth_key FROM ". BB_BT_USERS ." WHERE user_id = ". (int) $bt_user_id ." LIMIT 1");
$tor_magnet = create_magnet($tor_info['info_hash'], $passkey['auth_key'], $userdata['session_logged_in']); $tor_magnet = create_magnet($tor_info['info_hash'], $passkey['auth_key'], $userdata['session_logged_in']);
// ratio limits // ratio limits
$min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; $min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor'];
$min_ratio_warn = $bb_cfg['bt_min_ratio_warning']; $min_ratio_warn = $bb_cfg['bt_min_ratio_warning'];
$dl_allowed = true; $dl_allowed = true;
$user_ratio = 0; $user_ratio = 0;
if (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id) if (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id)
{ {
$sql = "SELECT u.*, dl.user_status $sql = "SELECT u.*, dl.user_status
FROM ". BB_BT_USERS ." u FROM ". BB_BT_USERS ." u
LEFT JOIN ". BB_BT_DLSTATUS ." dl ON dl.user_id = $bt_user_id AND dl.topic_id = $bt_topic_id LEFT JOIN ". BB_BT_DLSTATUS ." dl ON dl.user_id = $bt_user_id AND dl.topic_id = $bt_topic_id
WHERE u.user_id = $bt_user_id WHERE u.user_id = $bt_user_id
LIMIT 1"; LIMIT 1";
} }
else else
{ {
$sql = "SELECT user_status $sql = "SELECT user_status
FROM ". BB_BT_DLSTATUS ." FROM ". BB_BT_DLSTATUS ."
WHERE user_id = $bt_user_id WHERE user_id = $bt_user_id
AND topic_id = $bt_topic_id AND topic_id = $bt_topic_id
LIMIT 1"; LIMIT 1";
} }
$bt_userdata = DB()->fetch_row($sql); $bt_userdata = DB()->fetch_row($sql);
$user_status = isset($bt_userdata['user_status']) ? $bt_userdata['user_status'] : null; $user_status = isset($bt_userdata['user_status']) ? $bt_userdata['user_status'] : null;
if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD) if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD)
{ {
if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) if (($user_ratio = get_bt_ratio($bt_userdata)) !== null)
{ {
$dl_allowed = ($user_ratio > $min_ratio_dl); $dl_allowed = ($user_ratio > $min_ratio_dl);
} }
if ((isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) if ((isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO))
{ {
$template->assign_vars(array( $template->assign_vars(array(
'SHOW_RATIO_WARN' => true, 'SHOW_RATIO_WARN' => true,
'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']), 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']),
)); ));
} }
} }
if (!$dl_allowed) if (!$dl_allowed)
{ {
$template->assign_block_vars('postrow.attach.tor_reged', array()); $template->assign_block_vars('postrow.attach.tor_reged', array());
$template->assign_vars(array( $template->assign_vars(array(
'TOR_BLOCKED' => true, 'TOR_BLOCKED' => true,
'TOR_BLOCKED_MSG' => sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu=$bt_user_id&amp;dlc=1"), 'TOR_BLOCKED_MSG' => sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu=$bt_user_id&amp;dlc=1"),
)); ));
} }
else else
{ {
$template->assign_block_vars('postrow.attach.tor_reged', array( $template->assign_block_vars('postrow.attach.tor_reged', array(
'DOWNLOAD_NAME' => $display_name, 'DOWNLOAD_NAME' => $display_name,
'TRACKER_LINK' => $tracker_link, 'TRACKER_LINK' => $tracker_link,
'ATTACH_ID' => $attach_id, 'ATTACH_ID' => $attach_id,
'TOR_SILVER_GOLD' => $tor_type, 'TOR_SILVER_GOLD' => $tor_type,
// torrent status mod // torrent status mod
'TOR_FROZEN' => (!IS_AM) ? (isset($bb_cfg['tor_frozen'][$tor_info['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id'])) ? true : '' : '', 'TOR_FROZEN' => (!IS_AM) ? (isset($bb_cfg['tor_frozen'][$tor_info['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id'])) ? true : '' : '',
'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor_info['tor_status']], 'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor_info['tor_status']],
'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor_info['tor_status']], 'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor_info['tor_status']],
'TOR_STATUS_BY' => ($tor_info['checked_user_id'] && $is_auth['auth_mod']) ? ('<span title="'. bb_date($tor_info['checked_time']) .'"> &middot; '. profile_url($tor_info) .' &middot; <i>'. delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] .'</i></span>') : '', 'TOR_STATUS_BY' => ($tor_info['checked_user_id'] && $is_auth['auth_mod']) ? ('<span title="'. bb_date($tor_info['checked_time']) .'"> &middot; '. profile_url($tor_info) .' &middot; <i>'. delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] .'</i></span>') : '',
'TOR_STATUS_SELECT' => build_select('sel_status', array_flip($lang['TOR_STATUS_NAME']), TOR_APPROVED), 'TOR_STATUS_SELECT' => build_select('sel_status', array_flip($lang['TOR_STATUS_NAME']), TOR_APPROVED),
'TOR_STATUS_REPLY' => $bb_cfg['tor_comment'] && !IS_GUEST && in_array($tor_info['tor_status'], $bb_cfg['tor_reply']) && $userdata['user_id'] == $tor_info['poster_id'] && $t_data['topic_status'] != TOPIC_LOCKED, 'TOR_STATUS_REPLY' => $bb_cfg['tor_comment'] && !IS_GUEST && in_array($tor_info['tor_status'], $bb_cfg['tor_reply']) && $userdata['user_id'] == $tor_info['poster_id'] && $t_data['topic_status'] != TOPIC_LOCKED,
//end torrent status mod //end torrent status mod
'S_UPLOAD_IMAGE' => $upload_image, 'S_UPLOAD_IMAGE' => $upload_image,
'U_DOWNLOAD_LINK' => $download_link, 'U_DOWNLOAD_LINK' => $download_link,
'DL_LINK_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed', 'DL_LINK_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed',
'DL_TITLE_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_status_css[$bt_userdata['user_status']] : 'gen', 'DL_TITLE_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_status_css[$bt_userdata['user_status']] : 'gen',
'FILESIZE' => $tor_file_size, 'FILESIZE' => $tor_file_size,
'MAGNET' => $tor_magnet, 'MAGNET' => $tor_magnet,
'HASH' => strtoupper(bin2hex($tor_info['info_hash'])), 'HASH' => strtoupper(bin2hex($tor_info['info_hash'])),
'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count), 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $download_count),
'REGED_TIME' => bb_date($tor_info['reg_time']), 'REGED_TIME' => bb_date($tor_info['reg_time']),
'REGED_DELTA' => delta_time($tor_info['reg_time']), 'REGED_DELTA' => delta_time($tor_info['reg_time']),
'TORRENT_SIZE' => humn_size($tor_size), 'TORRENT_SIZE' => humn_size($tor_size),
'COMPLETED' => sprintf($lang['DOWNLOAD_NUMBER'], $tor_info['complete_count']), 'COMPLETED' => sprintf($lang['DOWNLOAD_NUMBER'], $tor_info['complete_count']),
)); ));
if ($comment) if ($comment)
{ {
$template->assign_block_vars('postrow.attach.tor_reged.comment', array('COMMENT' => $comment)); $template->assign_block_vars('postrow.attach.tor_reged.comment', array('COMMENT' => $comment));
} }
} }
if ($bb_cfg['show_tor_info_in_dl_list']) if ($bb_cfg['show_tor_info_in_dl_list'])
{ {
$template->assign_vars(array( $template->assign_vars(array(
'SHOW_DL_LIST' => true, 'SHOW_DL_LIST' => true,
'SHOW_DL_LIST_TOR_INFO' => true, 'SHOW_DL_LIST_TOR_INFO' => true,
'TOR_SIZE' => humn_size($tor_size), 'TOR_SIZE' => humn_size($tor_size),
'TOR_LONGEVITY' => delta_time($tor_info['reg_time']), 'TOR_LONGEVITY' => delta_time($tor_info['reg_time']),
'TOR_COMPLETED' => declension($tor_info['complete_count'], 'times'), 'TOR_COMPLETED' => declension($tor_info['complete_count'], 'times'),
)); ));
} }
// Show peers // Show peers
if ($show_peers) if ($show_peers)
{ {
// Sorting order in full mode // Sorting order in full mode
if ($s_mode == 'full') if ($s_mode == 'full')
{ {
$full_mode_order = 'tr.remain'; $full_mode_order = 'tr.remain';
$full_mode_sort_dir = 'ASC'; $full_mode_sort_dir = 'ASC';
if (isset($_REQUEST['psortasc'])) if (isset($_REQUEST['psortasc']))
{ {
$full_mode_sort_dir = 'ASC'; $full_mode_sort_dir = 'ASC';
} }
else if (isset($_REQUEST['psortdesc'])) else if (isset($_REQUEST['psortdesc']))
{ {
$full_mode_sort_dir = 'DESC'; $full_mode_sort_dir = 'DESC';
} }
if (isset($_REQUEST['porder'])) if (isset($_REQUEST['porder']))
{ {
$peer_orders = array( $peer_orders = array(
'name' => 'u.username', 'name' => 'u.username',
'ip' => 'tr.ip', 'ip' => 'tr.ip',
'port' => 'tr.port', 'port' => 'tr.port',
'compl' => 'tr.remain', 'compl' => 'tr.remain',
'cup' => 'tr.uploaded', 'cup' => 'tr.uploaded',
'cdown' => 'tr.downloaded', 'cdown' => 'tr.downloaded',
'sup' => 'tr.speed_up', 'sup' => 'tr.speed_up',
'sdown' => 'tr.speed_down', 'sdown' => 'tr.speed_down',
'time' => 'tr.update_time', 'time' => 'tr.update_time',
); );
foreach ($peer_orders as $get_key => $order_by_value) foreach ($peer_orders as $get_key => $order_by_value)
{ {
if ($_REQUEST['porder'] == $get_key) if ($_REQUEST['porder'] == $get_key)
{ {
$full_mode_order = $order_by_value; $full_mode_order = $order_by_value;
break; break;
} }
} }
} }
} }
// SQL for each mode // SQL for each mode
if ($s_mode == 'count') if ($s_mode == 'count')
{ {
$sql = "SELECT seeders, leechers, speed_up, speed_down $sql = "SELECT seeders, leechers, speed_up, speed_down
FROM ". BB_BT_TRACKER_SNAP ." FROM ". BB_BT_TRACKER_SNAP ."
WHERE topic_id = $tor_id WHERE topic_id = $tor_id
LIMIT 1"; LIMIT 1";
} }
else if ($s_mode == 'names') else if ($s_mode == 'names')
{ {
$sql = "SELECT tr.user_id, tr.ip, tr.port, tr.remain, tr.seeder, u.username, u.user_rank $sql = "SELECT tr.user_id, tr.ip, tr.port, tr.remain, tr.seeder, u.username, u.user_rank
FROM ". BB_BT_TRACKER ." tr, ". BB_USERS ." u FROM ". BB_BT_TRACKER ." tr, ". BB_USERS ." u
WHERE tr.topic_id = $tor_id WHERE tr.topic_id = $tor_id
AND u.user_id = tr.user_id AND u.user_id = tr.user_id
GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder
ORDER BY u.username ORDER BY u.username
LIMIT $show_peers_limit"; LIMIT $show_peers_limit";
} }
else else
{ {
$sql = "SELECT $sql = "SELECT
tr.user_id, tr.ip, tr.port, tr.uploaded, tr.downloaded, tr.remain, tr.user_id, tr.ip, tr.port, tr.uploaded, tr.downloaded, tr.remain,
tr.seeder, tr.releaser, tr.speed_up, tr.speed_down, tr.update_time, tr.seeder, tr.releaser, tr.speed_up, tr.speed_down, tr.update_time,
tr.complete_percent, u.username, u.user_rank tr.complete_percent, u.username, u.user_rank
@ -328,277 +328,277 @@ if ($tor_reged && $tor_info)
GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder GROUP BY tr.ip, tr.user_id, tr.port, tr.seeder
ORDER BY $full_mode_order $full_mode_sort_dir ORDER BY $full_mode_order $full_mode_sort_dir
LIMIT $show_peers_limit"; LIMIT $show_peers_limit";
} }
// Build peers table // Build peers table
if ($peers = DB()->fetch_rowset($sql)) if ($peers = DB()->fetch_rowset($sql))
{ {
$peers_cnt = count($peers); $peers_cnt = count($peers);
$cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = array(); $cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = array();
$cnt['s'] = $tr['s'] = $sp_up['s'] = $sp_down['s'] = $sp_up_tot['s'] = $sp_down_tot['s'] = 0; $cnt['s'] = $tr['s'] = $sp_up['s'] = $sp_down['s'] = $sp_up_tot['s'] = $sp_down_tot['s'] = 0;
$cnt['l'] = $tr['l'] = $sp_up['l'] = $sp_down['l'] = $sp_up_tot['l'] = $sp_down_tot['l'] = 0; $cnt['l'] = $tr['l'] = $sp_up['l'] = $sp_down['l'] = $sp_up_tot['l'] = $sp_down_tot['l'] = 0;
$max_up = $max_down = $max_sp_up = $max_sp_down = array(); $max_up = $max_down = $max_sp_up = $max_sp_down = array();
$max_up['s'] = $max_down['s'] = $max_sp_up['s'] = $max_sp_down['s'] = 0; $max_up['s'] = $max_down['s'] = $max_sp_up['s'] = $max_sp_down['s'] = 0;
$max_up['l'] = $max_down['l'] = $max_sp_up['l'] = $max_sp_down['l'] = 0; $max_up['l'] = $max_down['l'] = $max_sp_up['l'] = $max_sp_down['l'] = 0;
$max_up_id['s'] = $max_down_id['s'] = $max_sp_up_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1); $max_up_id['s'] = $max_down_id['s'] = $max_sp_up_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1);
$max_up_id['l'] = $max_down_id['l'] = $max_sp_up_id['l'] = $max_sp_down_id['l'] = ($peers_cnt + 1); $max_up_id['l'] = $max_down_id['l'] = $max_sp_up_id['l'] = $max_sp_down_id['l'] = ($peers_cnt + 1);
if ($s_mode == 'full') if ($s_mode == 'full')
{ {
foreach ($peers as $pid => $peer) foreach ($peers as $pid => $peer)
{ {
$x = ($peer['seeder']) ? 's' : 'l'; $x = ($peer['seeder']) ? 's' : 'l';
$cnt[$x]++; $cnt[$x]++;
$sp_up_tot[$x] += $peer['speed_up']; $sp_up_tot[$x] += $peer['speed_up'];
$sp_down_tot[$x] += $peer['speed_down']; $sp_down_tot[$x] += $peer['speed_down'];
$guest = ($peer['user_id'] == GUEST_UID || is_null($peer['username'])); $guest = ($peer['user_id'] == GUEST_UID || is_null($peer['username']));
$p_max_up = $peer['uploaded']; $p_max_up = $peer['uploaded'];
$p_max_down = $peer['downloaded']; $p_max_down = $peer['downloaded'];
if ($p_max_up > $max_up[$x]) if ($p_max_up > $max_up[$x])
{ {
$max_up[$x] = $p_max_up; $max_up[$x] = $p_max_up;
$max_up_id[$x] = $pid; $max_up_id[$x] = $pid;
} }
if ($peer['speed_up'] > $max_sp_up[$x]) if ($peer['speed_up'] > $max_sp_up[$x])
{ {
$max_sp_up[$x] = $peer['speed_up']; $max_sp_up[$x] = $peer['speed_up'];
$max_sp_up_id[$x] = $pid; $max_sp_up_id[$x] = $pid;
} }
if ($p_max_down > $max_down[$x]) if ($p_max_down > $max_down[$x])
{ {
$max_down[$x] = $p_max_down; $max_down[$x] = $p_max_down;
$max_down_id[$x] = $pid; $max_down_id[$x] = $pid;
} }
if ($peer['speed_down'] > $max_sp_down[$x]) if ($peer['speed_down'] > $max_sp_down[$x])
{ {
$max_sp_down[$x] = $peer['speed_down']; $max_sp_down[$x] = $peer['speed_down'];
$max_sp_down_id[$x] = $pid; $max_sp_down_id[$x] = $pid;
} }
} }
$max_down_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1); $max_down_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1);
if ($cnt['s'] == 1) if ($cnt['s'] == 1)
{ {
$max_up_id['s'] = $max_sp_up_id['s'] = ($peers_cnt + 1); $max_up_id['s'] = $max_sp_up_id['s'] = ($peers_cnt + 1);
} }
if ($cnt['l'] == 1) if ($cnt['l'] == 1)
{ {
$max_up_id['l'] = $max_down_id['l'] = $max_sp_up_id['l'] = $max_sp_down_id['l'] = ($peers_cnt + 1); $max_up_id['l'] = $max_down_id['l'] = $max_sp_up_id['l'] = $max_sp_down_id['l'] = ($peers_cnt + 1);
} }
} }
if ($s_mode == 'count') if ($s_mode == 'count')
{ {
$tmp = array(); $tmp = array();
$tmp[0]['seeder'] = $tmp[0]['username'] = $tmp[1]['username'] = 0; $tmp[0]['seeder'] = $tmp[0]['username'] = $tmp[1]['username'] = 0;
$tmp[1]['seeder'] = 1; $tmp[1]['seeder'] = 1;
$tmp[0]['username'] = (int) @$peers[0]['leechers']; $tmp[0]['username'] = (int) @$peers[0]['leechers'];
$tmp[1]['username'] = (int) @$peers[0]['seeders']; $tmp[1]['username'] = (int) @$peers[0]['seeders'];
$tor_speed_up = (int) @$peers[0]['speed_up']; $tor_speed_up = (int) @$peers[0]['speed_up'];
$tor_speed_down = (int) @$peers[0]['speed_down']; $tor_speed_down = (int) @$peers[0]['speed_down'];
$peers = $tmp; $peers = $tmp;
$template->assign_vars(array( $template->assign_vars(array(
'TOR_SPEED_UP' => ($tor_speed_up) ? humn_size($tor_speed_up, 0, 'KB') .'/s' : '0 KB/s', 'TOR_SPEED_UP' => ($tor_speed_up) ? humn_size($tor_speed_up, 0, 'KB') .'/s' : '0 KB/s',
'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') .'/s' : '0 KB/s', 'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') .'/s' : '0 KB/s',
)); ));
} }
foreach ($peers as $pid => $peer) foreach ($peers as $pid => $peer)
{ {
$u_prof_href = ($s_mode == 'count') ? '#' : "profile.php?mode=viewprofile&amp;u=". $peer['user_id'] ."#torrent"; $u_prof_href = ($s_mode == 'count') ? '#' : "profile.php?mode=viewprofile&amp;u=". $peer['user_id'] ."#torrent";
// Full details mode // Full details mode
if ($s_mode == 'full') if ($s_mode == 'full')
{ {
$ip = bt_show_ip($peer['ip']); $ip = bt_show_ip($peer['ip']);
$port = bt_show_port($peer['port']); $port = bt_show_port($peer['port']);
// peer max/current up/down // peer max/current up/down
$p_max_up = $peer['uploaded']; $p_max_up = $peer['uploaded'];
$p_max_down = $peer['downloaded']; $p_max_down = $peer['downloaded'];
$p_cur_up = $peer['uploaded']; $p_cur_up = $peer['uploaded'];
$p_cur_down = $peer['downloaded']; $p_cur_down = $peer['downloaded'];
if ($peer['seeder']) if ($peer['seeder'])
{ {
$x = 's'; $x = 's';
$x_row = 'srow'; $x_row = 'srow';
$x_full = 'sfull'; $x_full = 'sfull';
if (!defined('SEEDER_EXIST')) if (!defined('SEEDER_EXIST'))
{ {
define('SEEDER_EXIST', true); define('SEEDER_EXIST', true);
$seed_order_action = "viewtopic.php?". POST_TOPIC_URL ."=$bt_topic_id&amp;spmode=full#seeders"; $seed_order_action = "viewtopic.php?". POST_TOPIC_URL ."=$bt_topic_id&amp;spmode=full#seeders";
$template->assign_block_vars("$x_full", array( $template->assign_block_vars("$x_full", array(
'SEED_ORD_ACT' => $seed_order_action, 'SEED_ORD_ACT' => $seed_order_action,
'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') .'/s' 'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') .'/s'
)); ));
if ($ip) if ($ip)
{ {
$template->assign_block_vars("$x_full.iphead", array()); $template->assign_block_vars("$x_full.iphead", array());
} }
if ($port !== false) if ($port !== false)
{ {
$template->assign_block_vars("$x_full.porthead", array()); $template->assign_block_vars("$x_full.porthead", array());
} }
} }
$compl_perc = ($tor_size) ? round(($p_max_up / $tor_size), 1) : 0; $compl_perc = ($tor_size) ? round(($p_max_up / $tor_size), 1) : 0;
} }
else else
{ {
$x = 'l'; $x = 'l';
$x_row = 'lrow'; $x_row = 'lrow';
$x_full = 'lfull'; $x_full = 'lfull';
if (!defined('LEECHER_EXIST')) if (!defined('LEECHER_EXIST'))
{ {
define('LEECHER_EXIST', true); define('LEECHER_EXIST', true);
$leech_order_action = "viewtopic.php?". POST_TOPIC_URL ."=$bt_topic_id&amp;spmode=full#leechers"; $leech_order_action = "viewtopic.php?". POST_TOPIC_URL ."=$bt_topic_id&amp;spmode=full#leechers";
$template->assign_block_vars("$x_full", array( $template->assign_block_vars("$x_full", array(
'LEECH_ORD_ACT' => $leech_order_action, 'LEECH_ORD_ACT' => $leech_order_action,
'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') .'/s', 'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') .'/s',
'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') .'/s' 'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') .'/s'
)); ));
if ($ip) if ($ip)
{ {
$template->assign_block_vars("$x_full.iphead", array()); $template->assign_block_vars("$x_full.iphead", array());
} }
if ($port !== false) if ($port !== false)
{ {
$template->assign_block_vars("$x_full.porthead", array()); $template->assign_block_vars("$x_full.porthead", array());
} }
} }
$compl_size = ($peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0; $compl_size = ($peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0;
$compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0; $compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0;
} }
$rel_sign = (!$guest && $peer['releaser']) ? '&nbsp;<b><sup>&reg;</sup></b>' : ''; $rel_sign = (!$guest && $peer['releaser']) ? '&nbsp;<b><sup>&reg;</sup></b>' : '';
$name = profile_url($peer). $rel_sign; $name = profile_url($peer). $rel_sign;
$up_tot = ($p_max_up) ? humn_size($p_max_up) : '-'; $up_tot = ($p_max_up) ? humn_size($p_max_up) : '-';
$down_tot = ($p_max_down) ? humn_size($p_max_down) : '-'; $down_tot = ($p_max_down) ? humn_size($p_max_down) : '-';
$up_ratio = ($p_max_down) ? round(($p_max_up / $p_max_down), 2) : ''; $up_ratio = ($p_max_down) ? round(($p_max_up / $p_max_down), 2) : '';
$sp_up = ($peer['speed_up']) ? humn_size($peer['speed_up'], 0, 'KB') .'/s' : '-'; $sp_up = ($peer['speed_up']) ? humn_size($peer['speed_up'], 0, 'KB') .'/s' : '-';
$sp_down = ($peer['speed_down']) ? humn_size($peer['speed_down'], 0, 'KB') .'/s' : '-'; $sp_down = ($peer['speed_down']) ? humn_size($peer['speed_down'], 0, 'KB') .'/s' : '-';
$bgr_class = (!($tr[$x] % 2)) ? $bgr_class_1 : $bgr_class_2; $bgr_class = (!($tr[$x] % 2)) ? $bgr_class_1 : $bgr_class_2;
$row_bgr = ($change_peers_bgr_over) ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : ''; $row_bgr = ($change_peers_bgr_over) ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : '';
$tr[$x]++; $tr[$x]++;
$template->assign_block_vars("$x_full.$x_row", array( $template->assign_block_vars("$x_full.$x_row", array(
'ROW_BGR' => $row_bgr, 'ROW_BGR' => $row_bgr,
'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>", 'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>",
'COMPL_PRC' => $compl_perc, 'COMPL_PRC' => $compl_perc,
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "<b>$up_tot</b>" : $up_tot, 'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "<b>$up_tot</b>" : $up_tot,
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "<b>$down_tot</b>" : $down_tot, 'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "<b>$down_tot</b>" : $down_tot,
'SPEED_UP' => ($max_sp_up_id[$x] == $pid) ? "<b>$sp_up</b>" : $sp_up, 'SPEED_UP' => ($max_sp_up_id[$x] == $pid) ? "<b>$sp_up</b>" : $sp_up,
'SPEED_DOWN' => ($max_sp_down_id[$x] == $pid) ? "<b>$sp_down</b>" : $sp_down, 'SPEED_DOWN' => ($max_sp_down_id[$x] == $pid) ? "<b>$sp_down</b>" : $sp_down,
'UP_TOTAL_RAW' => $peer['uploaded'], 'UP_TOTAL_RAW' => $peer['uploaded'],
'DOWN_TOTAL_RAW' => $peer['downloaded'], 'DOWN_TOTAL_RAW' => $peer['downloaded'],
'SPEED_UP_RAW' => $peer['speed_up'], 'SPEED_UP_RAW' => $peer['speed_up'],
'SPEED_DOWN_RAW' => $peer['speed_down'], 'SPEED_DOWN_RAW' => $peer['speed_down'],
'UPD_EXP_TIME' => ($peer['update_time']) ? $lang['DL_UPD'] . bb_date($peer['update_time'], 'd-M-y H:i') .' &middot; '. delta_time($peer['update_time']) . $lang['TOR_BACK'] : $lang['DL_STOPPED'], 'UPD_EXP_TIME' => ($peer['update_time']) ? $lang['DL_UPD'] . bb_date($peer['update_time'], 'd-M-y H:i') .' &middot; '. delta_time($peer['update_time']) . $lang['TOR_BACK'] : $lang['DL_STOPPED'],
'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : '', 'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : '',
)); ));
if ($ip) if ($ip)
{ {
$template->assign_block_vars("$x_full.$x_row.ip", array('IP' => $ip)); $template->assign_block_vars("$x_full.$x_row.ip", array('IP' => $ip));
} }
if ($port !== false) if ($port !== false)
{ {
$template->assign_block_vars("$x_full.$x_row.port", array('PORT' => $port)); $template->assign_block_vars("$x_full.$x_row.port", array('PORT' => $port));
} }
} }
// Count only & only names modes // Count only & only names modes
else else
{ {
if ($peer['seeder']) if ($peer['seeder'])
{ {
$seeders .= '<nobr><a href="'. $u_prof_href .'" class="seedmed">'. $peer['username'] .'</a>,</nobr> '; $seeders .= '<nobr><a href="'. $u_prof_href .'" class="seedmed">'. $peer['username'] .'</a>,</nobr> ';
$seed_count = $peer['username']; $seed_count = $peer['username'];
} }
else else
{ {
$compl_size = (@$peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0; $compl_size = (@$peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0;
$compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0; $compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0;
$leechers .= '<nobr><a href="'. $u_prof_href .'" class="leechmed">'. $peer['username'] .'</a>'; $leechers .= '<nobr><a href="'. $u_prof_href .'" class="leechmed">'. $peer['username'] .'</a>';
$leechers .= ($s_mode == 'names') ? ' ['. $compl_perc .'%]' : ''; $leechers .= ($s_mode == 'names') ? ' ['. $compl_perc .'%]' : '';
$leechers .= ',</nobr> '; $leechers .= ',</nobr> ';
$leech_count = $peer['username']; $leech_count = $peer['username'];
} }
} }
} }
if ($s_mode != 'full' && $seeders) if ($s_mode != 'full' && $seeders)
{ {
$seeders[strlen($seeders)-9] = ' '; $seeders[strlen($seeders)-9] = ' ';
$template->assign_vars(array( $template->assign_vars(array(
'SEED_LIST' => $seeders, 'SEED_LIST' => $seeders,
'SEED_COUNT' => ($seed_count) ? $seed_count : 0, 'SEED_COUNT' => ($seed_count) ? $seed_count : 0,
)); ));
} }
if ($s_mode != 'full' && $leechers) if ($s_mode != 'full' && $leechers)
{ {
$leechers[strlen($leechers)-9] = ' '; $leechers[strlen($leechers)-9] = ' ';
$template->assign_vars(array( $template->assign_vars(array(
'LEECH_LIST' => $leechers, 'LEECH_LIST' => $leechers,
'LEECH_COUNT' => ($leech_count) ? $leech_count : 0, 'LEECH_COUNT' => ($leech_count) ? $leech_count : 0,
)); ));
} }
} }
unset($peers); unset($peers);
// Show "seeder last seen info" // Show "seeder last seen info"
if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST'))) if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST')))
{ {
$last_seen_time = ($tor_info['seeder_last_seen']) ? delta_time($tor_info['seeder_last_seen']) : $lang['NEVER']; $last_seen_time = ($tor_info['seeder_last_seen']) ? delta_time($tor_info['seeder_last_seen']) : $lang['NEVER'];
$template->assign_vars(array( $template->assign_vars(array(
'SEEDER_LAST_SEEN' => sprintf($lang['SEEDER_LAST_SEEN'], $last_seen_time), 'SEEDER_LAST_SEEN' => sprintf($lang['SEEDER_LAST_SEEN'], $last_seen_time),
)); ));
} }
} }
$template->assign_block_vars('tor_title', array('U_DOWNLOAD_LINK' => $download_link)); $template->assign_block_vars('tor_title', array('U_DOWNLOAD_LINK' => $download_link));
if ($peers_cnt > $max_peers_before_overflow && $s_mode == 'full') if ($peers_cnt > $max_peers_before_overflow && $s_mode == 'full')
{ {
$template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_overflow)); $template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_overflow));
$template->assign_vars(array('PEERS_OVERFLOW' => true)); $template->assign_vars(array('PEERS_OVERFLOW' => true));
} }
else else
{ {
$template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_normal)); $template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_normal));
} }
} }
if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full')
{ {
$template->assign_vars(array( $template->assign_vars(array(
'PEERS_FULL_LINK' => true, 'PEERS_FULL_LINK' => true,
'SPMODE_FULL_HREF' => "viewtopic.php?". POST_TOPIC_URL ."=$bt_topic_id&amp;spmode=full#seeders", 'SPMODE_FULL_HREF' => "viewtopic.php?". POST_TOPIC_URL ."=$bt_topic_id&amp;spmode=full#seeders",
)); ));
} }
$template->assign_vars(array( $template->assign_vars(array(
'SHOW_DL_LIST_LINK' => (($bb_cfg['bt_show_dl_list'] || $bb_cfg['allow_dl_list_names_mode']) && $t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL), 'SHOW_DL_LIST_LINK' => (($bb_cfg['bt_show_dl_list'] || $bb_cfg['allow_dl_list_names_mode']) && $t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL),
'SHOW_TOR_ACT' => ($tor_reged && $show_peers && (!isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) || IS_AM)), 'SHOW_TOR_ACT' => ($tor_reged && $show_peers && (!isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) || IS_AM)),
'S_MODE_COUNT' => ($s_mode == 'count'), 'S_MODE_COUNT' => ($s_mode == 'count'),
'S_MODE_NAMES' => ($s_mode == 'names'), 'S_MODE_NAMES' => ($s_mode == 'names'),
'S_MODE_FULL' => ($s_mode == 'full'), 'S_MODE_FULL' => ($s_mode == 'full'),
'PEER_EXIST' => ($seeders || $leechers || defined('SEEDER_EXIST') || defined('LEECHER_EXIST')), 'PEER_EXIST' => ($seeders || $leechers || defined('SEEDER_EXIST') || defined('LEECHER_EXIST')),
'SEED_EXIST' => ($seeders || defined('SEEDER_EXIST')), 'SEED_EXIST' => ($seeders || defined('SEEDER_EXIST')),
'LEECH_EXIST' => ($leechers || defined('LEECHER_EXIST')), 'LEECH_EXIST' => ($leechers || defined('LEECHER_EXIST')),
'TOR_HELP_LINKS' => $bb_cfg['tor_help_links'], 'TOR_HELP_LINKS' => $bb_cfg['tor_help_links'],
'CALL_SEED' => ($bb_cfg['callseed'] && $tor_reged && !isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)), 'CALL_SEED' => ($bb_cfg['callseed'] && $tor_reged && !isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)),
)); ));