2023-03-11 12:04:29 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!defined('IN_AJAX')) die(basename(__FILE__));
|
|
|
|
|
2024-12-02 14:18:36 +03:00
|
|
|
global $userdata, $bb_cfg, $lang, $log_action;
|
2023-03-11 12:04:29 +03:00
|
|
|
|
|
|
|
if (!isset($this->request['attach_id']))
|
|
|
|
{
|
|
|
|
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
|
|
|
|
}
|
|
|
|
if (!isset($this->request['type']))
|
|
|
|
{
|
2023-08-24 10:07:42 +03:00
|
|
|
$this->ajax_die('empty type');
|
2023-03-11 12:04:29 +03:00
|
|
|
}
|
|
|
|
$attach_id = (int) $this->request['attach_id'];
|
|
|
|
$type = (string) $this->request['type'];
|
|
|
|
|
|
|
|
$torrent = DB()->fetch_row("
|
|
|
|
SELECT
|
|
|
|
a.post_id, d.physical_filename, d.extension, d.tracker_status,
|
2024-12-02 14:18:36 +03:00
|
|
|
t.topic_first_post_id, t.topic_title,
|
2023-03-11 12:04:29 +03:00
|
|
|
p.poster_id, p.topic_id, p.forum_id,
|
|
|
|
f.allow_reg_tracker
|
|
|
|
FROM
|
|
|
|
". BB_ATTACHMENTS ." a,
|
|
|
|
". BB_ATTACHMENTS_DESC ." d,
|
|
|
|
". BB_POSTS ." p,
|
|
|
|
". BB_TOPICS ." t,
|
|
|
|
". BB_FORUMS ." f
|
|
|
|
WHERE
|
|
|
|
a.attach_id = $attach_id
|
|
|
|
AND d.attach_id = $attach_id
|
|
|
|
AND p.post_id = a.post_id
|
|
|
|
AND t.topic_id = p.topic_id
|
|
|
|
AND f.forum_id = p.forum_id
|
|
|
|
LIMIT 1
|
|
|
|
");
|
|
|
|
|
|
|
|
if (!$torrent) $this->ajax_die($lang['INVALID_ATTACH_ID']);
|
|
|
|
|
|
|
|
if ($torrent['poster_id'] == $userdata['user_id'] && !IS_AM)
|
|
|
|
{
|
|
|
|
if ($type == 'del_torrent' || $type == 'reg' || $type == 'unreg')
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->ajax_die($lang['ONLY_FOR_MOD']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (!IS_AM)
|
|
|
|
{
|
|
|
|
$this->ajax_die($lang['ONLY_FOR_MOD']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = $url = '';
|
|
|
|
switch ($type)
|
|
|
|
{
|
2023-03-11 14:16:19 +03:00
|
|
|
case 'set_gold':
|
|
|
|
case 'set_silver':
|
|
|
|
case 'unset_silver_gold':
|
2023-03-11 12:04:29 +03:00
|
|
|
if ($type == 'set_silver')
|
|
|
|
{
|
|
|
|
$tor_type = TOR_TYPE_SILVER;
|
2024-12-02 14:18:36 +03:00
|
|
|
$tor_type_lang = $lang['SILVER'];
|
2023-03-11 12:04:29 +03:00
|
|
|
}
|
|
|
|
elseif ($type == 'set_gold')
|
|
|
|
{
|
|
|
|
$tor_type = TOR_TYPE_GOLD;
|
2024-12-02 14:18:36 +03:00
|
|
|
$tor_type_lang = $lang['GOLD'];
|
2023-03-11 12:04:29 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tor_type = 0;
|
2024-12-02 14:18:36 +03:00
|
|
|
$tor_type_lang = "{$lang['UNSET_GOLD_TORRENT']} / {$lang['UNSET_SILVER_TORRENT']}";
|
2023-03-11 12:04:29 +03:00
|
|
|
}
|
|
|
|
change_tor_type($attach_id, $tor_type);
|
2024-12-02 14:18:36 +03:00
|
|
|
// Log action
|
|
|
|
$log_action->mod('mod_topic_change_tor_type', array(
|
2024-12-02 18:55:05 +03:00
|
|
|
'forum_id' => $torrent['forum_id'],
|
|
|
|
'topic_id' => $torrent['topic_id'],
|
2024-12-02 14:18:36 +03:00
|
|
|
'topic_title' => $torrent['topic_title'],
|
2024-12-02 18:55:05 +03:00
|
|
|
'log_msg' => sprintf($lang['TOR_TYPE_LOG_ACTION'], $tor_type_lang),
|
2024-12-02 14:18:36 +03:00
|
|
|
));
|
2023-03-11 12:04:29 +03:00
|
|
|
$title = $lang['CHANGE_TOR_TYPE'];
|
|
|
|
$url = make_url(TOPIC_URL . $torrent['topic_id']);
|
|
|
|
break;
|
|
|
|
|
2023-03-11 14:16:19 +03:00
|
|
|
case 'reg':
|
2023-03-11 12:04:29 +03:00
|
|
|
tracker_register($attach_id);
|
|
|
|
$url = (TOPIC_URL . $torrent['topic_id']);
|
|
|
|
break;
|
|
|
|
|
2023-03-11 14:16:19 +03:00
|
|
|
case 'unreg':
|
2023-03-11 12:04:29 +03:00
|
|
|
tracker_unregister($attach_id);
|
|
|
|
$url = (TOPIC_URL . $torrent['topic_id']);
|
|
|
|
break;
|
|
|
|
|
2023-03-11 14:16:19 +03:00
|
|
|
case 'del_torrent':
|
2023-03-11 12:04:29 +03:00
|
|
|
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEL_TORRENT']);
|
|
|
|
delete_torrent($attach_id);
|
|
|
|
$url = make_url(TOPIC_URL . $torrent['topic_id']);
|
|
|
|
break;
|
|
|
|
|
2023-03-11 14:16:19 +03:00
|
|
|
case 'del_torrent_move_topic':
|
2023-03-11 12:04:29 +03:00
|
|
|
if (empty($this->request['confirmed'])) $this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
|
|
|
|
delete_torrent($attach_id);
|
|
|
|
$url = make_url("modcp.php?t={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->response['url'] = $url;
|
2024-12-02 14:18:36 +03:00
|
|
|
$this->response['title'] = $title;
|