forked from edrabbit/biologger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
count.php
64 lines (57 loc) · 1.73 KB
/
count.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
<?php
include_once('fxns.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="iwebkit/css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="iwebkit/javascript/functions.js" type="text/javascript"></script>
<title>Biologger</title>
</head>
<body>
<div id="topbar">
<div id="leftnav"><a href="index.php" />Home</a></div>
</div>
<?
#Open a file and pull in all the options
$activities = load_activities(ACTIVITIES_FILE);
$onetouches = load_activities(ONE_TOUCHES_FILE);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$activity = $_POST["activity"];
} else {
$activity = $_GET["activity"];
}
# make sure activity is in lists of valid activities
if (!(in_array($activity, $activities)) && !(in_array($activity, $onetouches)) ) {
print "Invalid activity";
die();
}
if (is_one_touch($activity)) {
$event = 'activity="'.$activity.'"';
} else {
# make sure count is an intval
if (intval($_POST['count'])) {
$count = intval($_POST['count']);
} else {
print "Invalid count<br />";
die();
}
$event = 'activity="'.$activity.'", amount='.$count;
}
$datetime = utcnow();
$timestamped_event = $datetime." ".$event."\n";
if (log_to_file(ACTIVITIES_LOG_FILE, $timestamped_event)) {
?>
<br /><br /><br /><br />
<div align="center">LOGGED!</div>
<?
print $timestamped_event;
} else {
print "FAILED TO LOG!";
}
?>
</body>
</html>