mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Vote button code improvements (#1142)
This commit is contained in:
parent
f4e92b44ac
commit
a4be40db9e
3 changed files with 8 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue