Vote button code improvements (#1142)

This commit is contained in:
Roman Kelesidis 2023-11-21 00:57:48 +07:00 committed by GitHub
commit a4be40db9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View file

@ -14,7 +14,7 @@ if (!defined('IN_AJAX')) {
global $bb_cfg, $lang, $userdata;
if (!$bb_cfg['tor_thank']) {
$this->ajax_die($lang['DISABLED']);
$this->ajax_die($lang['MODULE_OFF']);
}
$mode = (string)$this->request['mode'];
@ -22,14 +22,14 @@ $topic_id = (int)$this->request['topic_id'];
switch ($mode) {
case 'add':
if (DB()->fetch_row('SELECT * FROM ' . BB_THX . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id'])) {
$this->ajax_die($lang['LIKE_ALREADY']);
}
if (DB()->fetch_row('SELECT poster_id FROM ' . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND poster_id = " . $userdata['user_id'])) {
$this->ajax_die($lang['LIKE_OWN_POST']);
}
if (DB()->fetch_row('SELECT topic_id FROM ' . BB_THX . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id'])) {
$this->ajax_die($lang['LIKE_ALREADY']);
}
$columns = 'topic_id, user_id, time';
$values = "$topic_id, {$userdata['user_id']}, " . TIMENOW;
DB()->query('INSERT IGNORE INTO ' . BB_THX . " ($columns) VALUES ($values)");
@ -51,3 +51,5 @@ switch ($mode) {
default:
$this->ajax_die('Invalid mode');
}
$this->response['mode'] = $mode;