Moved callseed to ajax actions (#877)

This commit is contained in:
Roman Kelesidis 2023-09-02 10:09:58 +07:00 committed by GitHub
commit 9bb409c4ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 14 deletions

View file

@ -7,24 +7,31 @@
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License * @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/ */
define('BB_SCRIPT', 'callseed'); if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
require __DIR__ . '/common.php'; global $bb_cfg, $userdata, $lang;
// Init userdata if (!$bb_cfg['callseed']) {
$user->session_start(array('req_login' => true)); $this->ajax_die($lang['MODULE_OFF']);
}
if (!$topic_id = (int)$this->request['topic_id']) {
$this->ajax_die($lang['INVALID_TOPIC_ID']);
}
if (!$t_data = topic_info($topic_id)) {
$this->ajax_die($lang['INVALID_TOPIC_ID_DB']);
}
$topic_id = (int)request_var('t', 0);
$t_data = topic_info($topic_id);
$forum_id = $t_data['forum_id']; $forum_id = $t_data['forum_id'];
set_die_append_msg($forum_id, $topic_id);
if ($t_data['seeders'] > 2) { if ($t_data['seeders'] > 2) {
bb_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders'])); $this->ajax_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
} elseif ($t_data['call_seed_time'] > (TIMENOW - 86400)) { } elseif ($t_data['call_seed_time'] > (TIMENOW - 86400)) {
$time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days'); $time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
bb_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left)); $this->ajax_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
} }
$ban_user_id = []; $ban_user_id = [];
@ -67,9 +74,6 @@ if ($user_list) {
DB()->query("UPDATE " . BB_BT_TORRENTS . " SET call_seed_time = " . TIMENOW . " WHERE topic_id = $topic_id"); DB()->query("UPDATE " . BB_BT_TORRENTS . " SET call_seed_time = " . TIMENOW . " WHERE topic_id = $topic_id");
meta_refresh(TOPIC_URL . $topic_id);
bb_die($lang['CALLSEED_MSG_OK']);
function topic_info($topic_id) function topic_info($topic_id)
{ {
global $lang; global $lang;
@ -90,3 +94,5 @@ function topic_info($topic_id)
return $torrent; return $torrent;
} }
$this->response['response'] = $lang['CALLSEED_MSG_OK'];

View file

@ -39,6 +39,7 @@ class Ajax
'change_torrent' => ['user'], 'change_torrent' => ['user'],
'change_tor_status' => ['user'], 'change_tor_status' => ['user'],
'manage_group' => ['user'], 'manage_group' => ['user'],
'callseed' => ['user'],
'view_post' => ['guest'], 'view_post' => ['guest'],
'view_torrent' => ['guest'], 'view_torrent' => ['guest'],
@ -470,4 +471,14 @@ class Ajax
{ {
require AJAX_DIR . '/sitemap.php'; require AJAX_DIR . '/sitemap.php';
} }
/**
* Call seed actions
*
* @return void
*/
public function callseed()
{
require AJAX_DIR . '/callseed.php';
}
} }

View file

@ -9,6 +9,17 @@ $(document).ready(function(){
sortList: [[4,1]] sortList: [[4,1]]
}); });
}); });
// callseed
ajax.callseed = function (topic_id) {
ajax.exec({
action: 'callseed',
topic_id: topic_id,
});
};
ajax.callback.callseed = function (data) {
alert(data.response);
};
</script> </script>
<tr> <tr>
@ -238,7 +249,7 @@ $(document).ready(function(){
<!-- IF DL_BUT_CANCEL --><input type="submit" name="dl_set_cancel" value="{L_DLCANCEL}" class="liteoption" /><!-- ENDIF --> <!-- IF DL_BUT_CANCEL --><input type="submit" name="dl_set_cancel" value="{L_DLCANCEL}" class="liteoption" /><!-- ENDIF -->
</form> </form>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF CALL_SEED --><form action="callseed.php?t={TOPIC_ID}" method="post"><input type="submit" value="{L_CALLSEED}" class="liteoption" />&nbsp;</form><!-- ENDIF --> <!-- IF CALL_SEED --><input onclick="ajax.callseed({TOPIC_ID}); return false;" type="button" value="{L_CALLSEED}" class="liteoption"/>&nbsp;<!-- ENDIF -->
&nbsp; &nbsp;
</td> </td>
</tr> </tr>