forked from smogon/pokemon-showdown-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
39 lines (30 loc) · 1.05 KB
/
action.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
<?php
/*
License: GPLv2 or later
<http://www.gnu.org/licenses/gpl-2.0.html>
*/
error_reporting(E_ALL);
include_once __DIR__ . '/config/config.inc.php';
if (@$_GET['act'] === 'dlteam') {
header("Content-Type: text/plain; charset=utf-8");
if (substr(@$_SERVER['HTTP_REFERER'], 0, 32) !== 'https://' . $psconfig['routes']['client']) {
// since this is only to support Chrome on HTTPS, we can get away with a very specific referer check
die("access denied");
}
echo base64_decode(@$_GET['team']);
die();
}
if (preg_match('/^http\\:\\/\\/[a-z0-9]+\\.psim\\.us\\//', $_SERVER['HTTP_REFERER'] ?? '')) {
header("Access-Control-Allow-Origin: *");
} else if ($_POST['sid'] ?? null) {
header("Access-Control-Allow-Origin: *");
}
// header("X-Debug: " . @$_SERVER['HTTP_REFERER']);
require_once __DIR__ . '/lib/ntbb-session.lib.php';
include_once __DIR__ . '/config/servers.inc.php';
include_once __DIR__ . '/lib/dispatcher.lib.php';
$dispatcher = new ActionDispatcher(array(
new DefaultActionHandler(),
new LadderActionHandler()
));
$dispatcher->executeActions();