Skip to content

Commit

Permalink
Восстановление регистрации торрент-файлов на трекере
Browse files Browse the repository at this point in the history
  • Loading branch information
Exileum committed Feb 12, 2016
1 parent ae7f4a3 commit 9df0c8d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 56 deletions.
8 changes: 3 additions & 5 deletions library/includes/functions_torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function tracker_register ($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED

$sql = "
SELECT
t.forum_id, t.post_id, t.poster_id, t.attach_ext_id, t.tracker_status,
t.forum_id, t.topic_poster, t.attach_ext_id, t.tracker_status,
f.allow_reg_tracker
FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f
WHERE t.topic_id = ". intval($topic_id) ."
Expand All @@ -139,22 +139,20 @@ function tracker_register ($topic_id, $mode = '', $tor_status = TOR_NOT_APPROVED
{
return torrent_error_exit('Invalid topic_id');
}
$post_id = $tor['post_id'];
$forum_id = $tor['forum_id'];
$poster_id = $tor['poster_id'];
$poster_id = $tor['topic_poster'];


if ($tor['attach_ext_id'] != 8) return torrent_error_exit($lang['NOT_TORRENT']);
if (!$tor['allow_reg_tracker']) return torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
if ($post_id != $tor['topic_first_post_id']) return torrent_error_exit($lang['ALLOWED_ONLY_1ST_POST_REG']);
if ($tor['tracker_status']) return torrent_error_exit($lang['ALREADY_REG']);

if ($reg_mode != 'mcp_tor_register')
{
torrent_auth_check($forum_id, $poster_id);
}

$filename = get_attach_path($topic_id);
$filename = get_attach_path($topic_id, 8);

if (!file_exists($filename))
{
Expand Down
6 changes: 3 additions & 3 deletions library/includes/viewtopic_torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

if ($tor_reged && !$tor_info)
{
//DB()->query("UPDATE ". BB_TOPICS ." SET tracker_status = 0 WHERE topic_id = $topic_id LIMIT 1");
//bb_die('Torrent status fixed'); //TODO: восстановить
DB()->query("UPDATE ". BB_TOPICS ." SET tracker_status = 0 WHERE topic_id = $topic_id LIMIT 1");
bb_die('Torrent status fixed'); //TODO: локализация
}

if ($tor_reged)
Expand Down Expand Up @@ -513,7 +513,7 @@

$template->assign_vars(array(
'SHOW_DL_LIST_LINK' => (($bb_cfg['bt_show_dl_list'] || $bb_cfg['allow_dl_list_names_mode']) && $t_data['tracker_status']),
'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 && (!isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) || IS_AM)),
'S_MODE_COUNT' => ($s_mode == 'count'),
'S_MODE_FULL' => ($s_mode == 'full'),
'PEER_EXIST' => ($seeders || $leechers || defined('SEEDER_EXIST') || defined('LEECHER_EXIST')),
Expand Down
77 changes: 29 additions & 48 deletions posting.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
$tracking_topics = get_tracks('topic');
$tracking_forums = get_tracks('forum');



set_die_append_msg($forum_id, $topic_id);

// What auth type do we need to check?
Expand Down Expand Up @@ -94,8 +92,7 @@
break;
}

// Here we do various lookups to find topic_id, forum_id, post_id etc.
// Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id
// Various lookups to find topic_id, forum_id, post_id etc
$error_msg = '';
$post_data = array();
switch ($mode)
Expand Down Expand Up @@ -382,7 +379,6 @@
$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];
update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
}
//$attachment_mod['posting']->insert_attachment($post_id);

if (!$error_msg)
{
Expand All @@ -399,7 +395,8 @@

if ($can_attach_file && !empty($_FILES['attach']['name']))
{
$upload = new Upload();
require(INC_DIR .'functions_upload.php');
$upload = new upload_common();

if ($upload->init($bb_cfg['attach'], $_FILES['attach']) AND $upload->store('attach', array('topic_id' => $topic_id)))
{
Expand All @@ -413,12 +410,36 @@
if ($upload->file_ext_id == 8)
{
require_once(INC_DIR .'functions_torrent.php');
tracker_register($topic_id, 'newtopic', TOR_NOT_APPROVED); # --> exit
if ($bb_cfg['premod'])
{
// Получение списка id форумов начиная с parent
$forum_parent = $forum_id;
if ($post_info['forum_parent']) $forum_parent = $post_info['forum_parent'];
$count_rowset = DB()->fetch_rowset("SELECT forum_id FROM ". BB_FORUMS ." WHERE forum_parent = $forum_parent");
$sub_forums = array();
foreach ($count_rowset as $count_row)
{
if ($count_row['forum_id'] != $forum_id) $sub_forums[] = $count_row['forum_id'];
}
$sub_forums[] = $forum_id;
$sub_forums = join(',', $sub_forums);
// Подсчет проверенных релизов в форумах раздела
$count_checked_releases = DB()->fetch_row("SELECT COUNT(*) AS checked_releases FROM ". BB_BT_TORRENTS ." WHERE poster_id = ". $userdata['user_id'] ." AND forum_id IN($sub_forums) AND tor_status IN(". TOR_APPROVED .",". TOR_DOUBTFUL .",". TOR_TMP .") LIMIT 1", 'checked_releases');
if ($count_checked_releases || IS_AM)
{
tracker_register($topic_id, 'newtopic', TOR_NOT_APPROVED);
}
else
{
tracker_register($topic_id, 'newtopic', TOR_PREMOD);
}
}
else tracker_register($topic_id, 'newtopic', TOR_NOT_APPROVED);
}
}
else
{
$return_to_edit_link = '<a href="'. POSTING_URL .'?mode=editpost&amp;p='. $post_id .'">Вернуться к редактированию сообщения</a>';
$return_to_edit_link = '<a href="'. POSTING_URL .'?mode=editpost&amp;p='. $post_id .'">Вернуться к редактированию сообщения</a>'; //TODO: локализация
$return_message = '
<span class="warnColor1">'. join('<br />', $upload->errors) ."</span>
<br /><br />
Expand All @@ -429,46 +450,6 @@
}
}

/*if (defined('TORRENT_ATTACH_ID') && $bb_cfg['bt_newtopic_auto_reg'] && !$error_msg)
{
include(INC_DIR .'functions_torrent.php');
if (!DB()->fetch_row("SELECT attach_id FROM ". BB_BT_TORRENTS ." WHERE attach_id = ". TORRENT_ATTACH_ID))
{
if ($bb_cfg['premod'])
{
// Получение списка id форумов начиная с parent
$forum_parent = $forum_id;
if ($post_info['forum_parent']) $forum_parent = $post_info['forum_parent'];
$count_rowset = DB()->fetch_rowset("SELECT forum_id FROM ". BB_FORUMS ." WHERE forum_parent = $forum_parent");
$sub_forums = array();
foreach ($count_rowset as $count_row)
{
if ($count_row['forum_id'] != $forum_id) $sub_forums[] = $count_row['forum_id'];
}
$sub_forums[] = $forum_id;
$sub_forums = join(',', $sub_forums);
// Подсчет проверенных релизов в форумах раздела
$count_checked_releases = DB()->fetch_row("
SELECT COUNT(*) AS checked_releases
FROM ". BB_BT_TORRENTS ."
WHERE poster_id = ". $userdata['user_id'] ."
AND forum_id IN($sub_forums)
AND tor_status IN(". TOR_APPROVED .",". TOR_DOUBTFUL .",". TOR_TMP .")
LIMIT 1
", 'checked_releases');
if ($count_checked_releases || IS_AM)
{
tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_NOT_APPROVED);
}
else
{
tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_PREMOD);
}
}
else tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_NOT_APPROVED);
}
}*/

// Update atom feed
update_atom('topic', $topic_id);

Expand Down

0 comments on commit 9df0c8d

Please sign in to comment.