Gazelle/sections/user/delete_invite.php

37 lines
801 B
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$InviteKey = db_string($_GET['invite']);
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT InviterID
FROM invites
2013-11-19 08:00:48 +00:00
WHERE InviteKey = '$InviteKey'");
2011-03-28 14:21:28 +00:00
list($UserID) = $DB->next_record();
2013-07-10 00:08:53 +00:00
if (!$DB->has_results() || $UserID != $LoggedUser['ID']) {
2013-04-20 08:01:01 +00:00
error(404);
}
2011-03-28 14:21:28 +00:00
2013-06-09 08:01:21 +00:00
$DB->query("
DELETE FROM invites
WHERE InviteKey = '$InviteKey'");
2011-03-28 14:21:28 +00:00
2013-04-20 08:01:01 +00:00
if (!check_perms('site_send_unlimited_invites')) {
2013-06-09 08:01:21 +00:00
$DB->query("
SELECT Invites
FROM users_main
WHERE ID = $UserID
LIMIT 1");
list($Invites) = $DB->next_record();
2013-04-20 08:01:01 +00:00
if ($Invites < 10) {
2013-06-09 08:01:21 +00:00
$DB->query("
UPDATE users_main
SET Invites = Invites + 1
WHERE ID = '$UserID'");
2013-11-19 08:00:48 +00:00
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('Invites' => '+1'));
$Cache->commit_transaction(0);
}
2011-03-28 14:21:28 +00:00
}
header('Location: user.php?action=invite');
?>