forked from OpenRA/OpenRAMasterServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_stats.php
31 lines (27 loc) · 872 Bytes
/
map_stats.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
<?php
date_default_timezone_set('UTC');
if(!isset($_REQUEST['hash']))
die('hash argument is required.');
header('Content-Type: application/javascript');
header('Access-Control-Allow-Origin: *');
try
{
$db = new PDO('sqlite:db/openra.db');
$query = $db->prepare('SELECT played_counter FROM map_stats WHERE map = :map');
$query->bindValue(':map', $_REQUEST['hash'], PDO::PARAM_STR);
$query->execute();
$result = $query->fetchAll();
$json_result_array = array();
foreach ($result as $row)
{
$json_result_array['map'] = $_REQUEST['hash'];
$json_result_array['played'] = $row['played_counter'];
}
print(json_encode($json_result_array));
$db = null;
}
catch (PDOException $e)
{
echo $e->getMessage();
}
?>