-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetReplayTimes.php
More file actions
54 lines (45 loc) · 1.3 KB
/
getReplayTimes.php
File metadata and controls
54 lines (45 loc) · 1.3 KB
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
<?php
//load latest,
//figure out time 5 minutes before that
//send client start time for replay, avoid long gaps
require('constants.php');
if (!empty($_GET)) {
$args=$_GET;
} else if (!empty($postData)) {
$postData = file_get_contents("php://input");
$args = json_decode($postData,true); // true: assoc mode
}
$q = "SELECT timeCode FROM frameTable";
$q = $q . " ORDER BY timeCode DESC";
$q = $q . " LIMIT $MAX_REPLAY_TIME";
if (isset($args)) {
//var_dump($args);
$q = 'SELECT timeCode FROM frameTable ';
if (isset($args['endTime']) || isset($args['startTime'])) {
$q = $q . " WHERE ";
if (isset($args['endTime'])) {
$q .= "timeCode <= " . $args['endTime'];
}
if (isset($args['startTime']) && isset($args['endTime'])) {
$q .= " AND ";
}
if (isset($args['startTime'])) {
$q .= "timeCode >= " . $args['startTime'];
}
}
$q = $q." ORDER BY timeCode DESC";
if (!isset($args['startTime']) || !isset($args['endTime'])) {
$q = $q. " LIMIT $MAX_REPLAY_TIME";
}
}
//echo "DOING: $q\n";
$result = $db->query($q);
//var_dump($result);
$frameList = array();
for($i = 0; $i < $result->num_rows; $i++) {
//var_dump($result->fetch_object());
$row = $result->fetch_object();
array_unshift($frameList,$row->timeCode);
}
echo json_encode($frameList);
?>