|
@@ -32,8 +32,59 @@
|
32
|
32
|
|
33
|
33
|
}
|
34
|
34
|
|
|
35
|
+ # -------------- End of authentication code --------------------------
|
|
36
|
+
|
35
|
37
|
require('common.php');
|
36
|
38
|
|
|
39
|
+ # -------------- Form handling -----------------
|
|
40
|
+
|
|
41
|
+ function process_activity_add($args) {
|
|
42
|
+ $sql = 'INSERT INTO activities (activity_name, activity_parent) VALUES (\'';
|
|
43
|
+ $sql .= m($args['name']) . '\', ' . ((int) $args['parent']) . ')';
|
|
44
|
+ mysql_query($sql);
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ if (isset($_POST['action'])) {
|
|
48
|
+ $args = array();
|
|
49
|
+ $action = str_replace('.', '_', $_POST['action']) . '_';
|
|
50
|
+ foreach ($_POST as $k => $v) {
|
|
51
|
+ if (substr($k, 0, strlen($action)) == $action) {
|
|
52
|
+ $args[substr($k, strlen($action))] = $v;
|
|
53
|
+ }
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ call_user_func('process_' . str_replace('.', '_', $_POST['action']), $args);
|
|
57
|
+ header('Location: /android/admin.php');
|
|
58
|
+ exit;
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ # ------------------- End of form handling ----------------------
|
|
62
|
+
|
|
63
|
+ $acs = getActivityArray();
|
|
64
|
+
|
|
65
|
+?>
|
|
66
|
+<h1>Activity management</h1>
|
|
67
|
+
|
|
68
|
+<h2>Add an activity</h2>
|
|
69
|
+
|
|
70
|
+<form action="admin.php" method="post">
|
|
71
|
+ <input type="hidden" name="action" value="activity.add">
|
|
72
|
+ <select name="activity.add.parent">
|
|
73
|
+<?PHP
|
|
74
|
+ asort($acs);
|
|
75
|
+
|
|
76
|
+ foreach ($acs as $id => $name) {
|
|
77
|
+ echo ' <option value="', $id, '">', htmlentities($name), '</option>';
|
|
78
|
+ }
|
|
79
|
+?>
|
|
80
|
+ </select> /
|
|
81
|
+ <input type="text" name="activity.add.name">
|
|
82
|
+ <input type="submit" value="Add">
|
|
83
|
+</form>
|
|
84
|
+
|
|
85
|
+<h1>Sample management</h1>
|
|
86
|
+<?PHP
|
|
87
|
+
|
37
|
88
|
$sql = 'SELECT log_id, log_imei, log_version, log_time, log_activity, log_data FROM sensorlogger WHERE log_statuscode = 1';
|
38
|
89
|
$res = mysql_query($sql);
|
39
|
90
|
|