-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtakeinvite.php
More file actions
37 lines (25 loc) · 922 Bytes
/
Copy pathtakeinvite.php
File metadata and controls
37 lines (25 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?
require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();
function bark($msg) {
stdhead();
stdmsg("Ошибка", $msg);
stdfoot();
die;
}
$id = intval($_GET["id"]);
if ($id == 0) {
$id = $CURUSER["id"];
}
if (get_user_class() <= UC_MODERATOR)
$id = $CURUSER["id"];
$re = sql_query("SELECT invites FROM users WHERE id = $id") or sqlerr(__FILE__,__LINE__);
$tes = mysql_fetch_assoc($re);
if ($tes[invites] <= 0)
bark("У вас больше не осталось приглашений!");
$hash = md5(mt_rand(1, 1000000));
sql_query("INSERT INTO invites (inviter, invite, time_invited) VALUES (" . implode(", ", array_map("sqlesc", array($id, $hash, get_date_time()))) . ")") or sqlerr(__FILE__,__LINE__);
sql_query("UPDATE users SET invites = invites - 1 WHERE id = $id") or sqlerr(__FILE__, __LINE__);
header("Refresh: 0; url=invite.php?id=$id");
?>