/
login.php
46 lines (33 loc) · 1002 Bytes
/
login.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
<?php
header("Content-Type: application/json");
ob_start();
require_once 'config.php';
require_once 'functions.php';
require_once 'func_login.php';
db_connect();
$input = json_decode(file_get_contents("php://input"));
$request_id = time();
file_put_contents("log/{$request_id}-request", json_encode($input, JSON_PRETTY_PRINT));
switch ($input->type ?? '') {
case 'cacheinfo':
global $statistics;
echo json_encode($statistics);
break;
case 'eventschedule':
global $schedule;
echo json_encode($schedule);
break;
case 'boostedcreature':
global $boostedcreature;
echo json_encode($boostedcreature);
break;
case 'login':
echo login($input);
break;
default:
return jsonError("Unrecognized event.");
}
$response = ob_get_contents();
ob_end_clean();
file_put_contents("log/{$request_id}-response", print_r($response, true));
die($response);