-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmetrics.php
32 lines (26 loc) · 990 Bytes
/
metrics.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
<?
include("dao.php");
include("encrypt_decrypt.php");
header('Content-Type: application/json');
if(!isset($_GET['security_code'])) {
exit(json_encode(array('successful' => false, 'message' => "no security code")));
}
if(!validSecurityCode($_GET['security_code'], $gracePeriodSeconds)) {
exit(json_encode(array('successful' => false, 'message' => "invalid security code")));
}
if(!isset($_GET['action'])) {
exit(json_encode(array('successful' => false, 'message' => "no action provided")));
}
$dao = new dao();
switch($_GET['action']) {
case "button":
if(!isset($_GET['id'])) {
exit(json_encode(array('successful' => false, 'message' => "no id provided")));
}
$dao->insertButtonMetrics($_GET['id'], $_SERVER['REMOTE_ADDR']);
exit(json_encode(array('successful' => true, 'message' => "")));
break;
default:
exit(json_encode(array('successful' => false, 'message' => "unknown action: ".$_GET['action'])));
}
?>