-
Notifications
You must be signed in to change notification settings - Fork 0
/
givestar.php
77 lines (68 loc) · 1.29 KB
/
givestar.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
require_once("award.inc.php");
require_once("bgg.inc.php");
db_connect();
$user = db_get_user_by_cookie( $_COOKIE['bggcookie'] );
if( !$user )
{
?>
Error authenticating. Try logging in again.
<?php
exit();
}
$recipient = bgg_untaint_username( trim($_POST['recipient']) );
if( strlen($recipient) <= 0 )
{
?>
Error: recipient not specified. Go back and try again.
<?php
exit();
}
# check if the BGG user is the same as the BGG user of the giver
if( strcasecmp($recipient, $user['username']) == 0 )
{
?>
Error: You cannot award to yourself!
<?php
exit();
}
$recipient_profile = bgg_get_profile( $recipient );
if( !$recipient_profile || !$recipient_profile['result'] )
{
if( $recipient_profile['user_not_found'] )
{
?>
Error: Could not find user profile for <?=$recipient?>! Did you mis-spell it?
<?php
}
else
{
?>
Error while checking user profile!
<?php
}
exit();
}
if( $recipient_profile['stars'][4] )
{
?>
The user <?=$recipient?> already has 5 stars!<br/>
How about choosing someone else?
<?php
exit();
}
$result = award_add_to_queue( $user['id'], $recipient );
if( $result )
{
?>
The microbadge has been queued to be awarded. You will get notified when it is.
<?php
}
else
{
?>
Error adding microbagde to the queue: Perhaps you already awarded a star this month?
<?php
exit();
}
?>