case 'release_add_list':
$attach_id = (int) $this->request['attach_id'];
$html = '<br>
<table cellspacing="0" cellpadding="0" class="attach bordered med"><tbody>
<tr class="row3 tCenter">
<td width="25%">'.sprintf($lang['SEED_BONUS_ME'], $userdata['user_points']).'</td>
<td width="25%">'.$lang['TOR_BONUS_NUMBER'].': <input id="bonus" type="number" style="width: 70px;" /> <input onclick="return ajax.tor_bonus(\'releaser_bonus_add\'); return false;" type="button" value="OK" /></td>
</tr>
</tbody></table>';
$this->response['html'] = $html;
break;
case 'releaser_bonus_add':
$attach_id = (int) $this->request['attach_id'];
$bonus = (string) $this->request['bonus'];
if (!($bonus == '' || $bonus <= 0))
{
$user_id = $userdata['user_id'];
$sql = DB()->fetch_rowset("
SELECT
tor.poster_id, tor.topic_id, u.user_id, t.topic_title
FROM ". BB_BT_TORRENTS ." tor
INNER JOIN ". BB_USERS ." u ON(u.user_id = tor.poster_id)
INNER JOIN ". BB_TOPICS ." t ON(t.topic_id = tor.topic_id)
WHERE tor.attach_id = $attach_id
AND tor.poster_id = u.user_id
LIMIT 1
");
foreach($sql as $row)
{
$poster_id = $row['poster_id'];
if ($bonus > $userdata['user_points']) $this->ajax_die($lang['ERRORS_NO_BONUS_USER']);
if ($bonus < $userdata['user_points'])
{
$username = '[url='. make_url(PROFILE_URL . $userdata['user_id']) .'][b]'. $userdata['username'] .'[/b][/url]';
$subject = sprintf($lang['POINTS_SUBJECT'], $row['topic_title']);
$message = sprintf($lang['POINTS_MESSAGE'], $username, $bonus);
send_pm($poster_id, $subject, $message, BOT_UID);
DB()->query("UPDATE bb_users SET user_points = user_points - $bonus WHERE user_id = $user_id LIMIT 1");
DB()->query("UPDATE bb_users SET user_points = user_points + $bonus WHERE user_id = $poster_id LIMIT 1");
$title = $lang['RELEASER_BONUS'];
$url = (TOPIC_URL . $row['topic_id']);
cache_rm_user_sessions ($user_id);
}
}
} else $this->ajax_die($lang['ERRORS_TOR_TYPE_TEXT']);
$this->response['url'] = $url;
$this->response['title'] = $title;
break;