-
Notifications
You must be signed in to change notification settings - Fork 8
/
fetch.php
executable file
·74 lines (59 loc) · 1.35 KB
/
fetch.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
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
require 'config.php';
$supported = array(
'about' => array(
'tpl' => 'templates/about.tpl',
),
'stats' => array(
'tpl' => 'templates/stats.tpl',
'contr' => 'fetchStats',
),
'gpxfile' => array(
'tpl' => 'templates/gpxfile.tpl',
),
);
if(isset($_REQUEST['content']) && isset($supported[$_REQUEST['content']]))
{
$data = false;
if(!empty($supported[$_REQUEST['content']]['contr']))
{
$controller = $supported[$_REQUEST['content']]['contr'];
if(function_exists($controller))
{
$data = $controller();
}
}
include(__DIR__.'/'.$supported[$_REQUEST['content']]['tpl']);
}
elseif(isset($_REQUEST['get_debug']))
{
$filename = 'cache/result_statistics.json';
if(file_exists($filename))
{
echo file_get_contents($filename);
}
}
function fetchStats()
{
global $dbAccess;
require 'lib/log.php';
$db = new mysqli($dbAccess['host'], $dbAccess['user'], $dbAccess['pass'], $dbAccess['db']);
$log = new log($db);
$data = $log->get();
$min = array();
$max = array();
$midOver = 12;
$dateOf = 6;
$c = 0;
$set = array();
$setDate = false;
$lastDate = false;
foreach ($data as $item)
{
$min[] = array($item['ts'], $item['min']);
$max[] = array($item['ts'], $item['max']);
}
return array($min, $max);
}