torrentpier/library/ajax/change_torrent.php
Roman Kelesidis 0ca5fe3abe
Minor improvements (#1461)
* Minor improvements

* Update edit_user_profile.php

* Update init_bb.php

* Update init_bb.php

* Update init_bb.php

* Update usercp_register.tpl

* Update admin_ug_auth.php

* Update admin_ug_auth.tpl

* Update tpl_config.php

* Update viewprofile.php

* Update group_membership.php

* Update group_membership.php

* Update viewtopic.tpl

* Update admin_ug_auth.php

* Update functions.php

* Update admin_ug_auth.php

* Update admin_ug_auth.php

* Update admin_ug_auth.php

* Update admin_forums.php

* Update admin_forums.php

* Update posting_tpl.php

* Update viewforum.php

* Update viewforum.tpl

* Update admin_forums.php

* Update admin_ug_auth.php

* Update admin_ug_auth.php

* Update usercp_viewprofile.tpl

* Update register.php

* Update admin_ug_auth.php

* Update admin_ug_auth.php

* Update posts.php

* Update posting_tpl.php

* Update viewforum.php

* Update admin_forums.php

* Update admin_forums.php

* Update admin_forumauth.php

* Update index_map.tpl

* Update index.tpl

* Update index.tpl

* Update group.php

* Update viewtopic.tpl

* Update change_torrent.php

* Update viewtopic.tpl

* Update viewtopic.php

* Update viewtopic.php

* Update admin_log.php

* Update search.php

* Update usercp_register.tpl

* Update CHANGELOG.md
2024-05-04 11:58:21 +07:00

105 lines
3.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* TorrentPier Bull-powered BitTorrent tracker engine
*
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $userdata, $bb_cfg, $lang;
if (!isset($this->request['attach_id'])) {
$this->ajax_die($lang['EMPTY_ATTACH_ID']);
}
if (!isset($this->request['type'])) {
$this->ajax_die('empty type');
}
$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,
t.topic_first_post_id,
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) {
case 'set_gold':
case 'set_silver':
case 'unset_silver_gold':
if ($type == 'set_silver') {
$tor_type = TOR_TYPE_SILVER;
} elseif ($type == 'set_gold') {
$tor_type = TOR_TYPE_GOLD;
} else {
$tor_type = 0;
}
\TorrentPier\Legacy\Torrent::change_tor_type($attach_id, $tor_type);
$title = $lang['CHANGE_TOR_TYPE'];
$url = make_url(TOPIC_URL . $torrent['topic_id']);
break;
case 'reg':
\TorrentPier\Legacy\Torrent::tracker_register($attach_id);
$url = (TOPIC_URL . $torrent['topic_id']);
break;
case 'unreg':
\TorrentPier\Legacy\Torrent::tracker_unregister($attach_id);
$url = (TOPIC_URL . $torrent['topic_id']);
break;
case 'del_torrent':
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_TORRENT']);
}
\TorrentPier\Legacy\Torrent::delete_torrent($attach_id);
$url = make_url(TOPIC_URL . $torrent['topic_id']);
break;
case 'del_torrent_move_topic':
if (empty($this->request['confirmed'])) {
$this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']);
}
\TorrentPier\Legacy\Torrent::delete_torrent($attach_id);
$url = make_url("modcp.php?" . POST_TOPIC_URL . "={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}");
break;
}
$this->response['url'] = $url;
$this->response['title'] = $title;