forked from jacob-grahn/platform-racing-2-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_campaign.php
40 lines (34 loc) · 1.1 KB
/
set_campaign.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
<?php
require_once GEN_HTTP_FNS;
require_once HTTP_FNS . '/output_fns.php';
require_once HTTP_FNS . '/pages/admin/set_campaign_fns.php';
require_once QUERIES_DIR . '/admin_actions.php';
require_once QUERIES_DIR . '/campaigns.php';
$action = default_post('action', 'lookup');
$message = htmlspecialchars(default_get('message', ''));
$campaign_id = 6; // 1 = Original, 2 = Speed, 3 = Luna, 4 = Timeline, 5 = Legendary, 6 = Custom
try {
// rate limiting
rate_limit('set-campaign-'.$ip, 60, 10);
rate_limit('set-campaign-'.$ip, 10, 2);
// connect
$pdo = pdo_connect();
// make sure you're an admin
$admin = check_moderator($pdo, null, true, 3);
// lookup
if ($action === 'lookup') {
output_form($pdo, $message, $campaign_id);
} // update
elseif ($action === 'update') {
update($pdo, $admin, $campaign_id);
} // this should never happen
else {
throw new Exception("Invalid action specified.");
}
} catch (Exception $e) {
output_header('Error');
$error = $e->getMessage();
echo "Error: $error";
} finally {
output_footer();
}