-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.php
executable file
·146 lines (130 loc) · 4.13 KB
/
configuration.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
// DOWNLOAD
$config = simplexml_load_file("/home/pi/openstriato/openstriato.xml");
$values = array();
if($_POST['action'] == 'update') {
if(isset($config)) {
foreach ($config->action as $id => $action) {
$uidtmp = $action['uid'];
if ($_POST["note$uidtmp"] == "") {
$notetmp = "no note";
} else {
$notetmp = $_POST["note$uidtmp"];
}
if ($_POST["$uidtmp"] == "") {
$actiontmp = "no action";
} else {
$actiontmp = $_POST["$uidtmp"];
}
if ($action != $actiontmp) {
$cmd = "/usr/bin/sudo /usr/bin/python2.7 /home/pi/openstriato/openstriato.py -m \"$actiontmp\" -u $uidtmp";
$handle = popen($cmd, "r");
array_push($values, fgets($handle));
$config->action[$id] = $actiontmp;
}
if ($action['note'] != $notetmp) {
$cmd = "/usr/bin/sudo /usr/bin/python2.7 /home/pi/openstriato/openstriato.py -n \"$notetmp\" -u $uidtmp";
$handle = popen($cmd, "r");
array_push($values, fgets($handle));
$config->action[$id]['note'] = $notetmp;
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>OPENSTRIATO</title>
<meta name="description" content="">
<meta name="author" content="Samuel Salas">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<style>
body {
padding-top: 60px; }
</style>
</head>
<body>
<div class="container">
<?php
include('menu.php');
showMenu(1); // See Menu.php to check the menu number
?>
<?php
if (count($values) > 0) {
$displayformupdate = "none";
$displayformrefresh = "block";
echo "<div class=\"alert alert-success\">\n
Modifications uploaded successfully <br />\n
<ul>\n";
foreach($values as $value){
echo "<li />$value\n";
}
echo "</ul>\n
</div>\n";
} else {
$displayformupdate = "block";
$displayformrefresh = "none";
}
?>
<?php
echo "<form id=\"updatexml\" action=\"configuration.php\" method=\"post\" style=\"display: $displayformupdate\">"
?>
<table class="table">
<thead>
<tr>
<th>UID</th>
<th>NOTE</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php // SHOW IMAGE / NAME / DOWNLOAD
if (isset($config)) {
foreach ($config->action as $action) {
echo "<tr>\n";
echo "<td>";
echo $action["uid"];
echo "</td>\n";
echo "<td>";
echo "<div class=\"input-group\">";
echo "<span class=\"input-group-addon\" id=\"basic-addon\">#</span>";
echo "<input class=\"form-control\" placeholder=\"Note\" aria-describedby=\"basic-addon1\" name=\"note".$action["uid"]."\" value=\"".$action["note"]."\" />";
echo "</div>";
echo "</td>\n";
echo "<td>";
echo "<div class=\"input-group\">";
echo "<span class=\"input-group-addon\" id=\"basic-addon\">@</span>";
echo "<input class=\"form-control\" placeholder=\"Action\" aria-describedby=\"basic-addon1\" name=\"".$action["uid"]."\" value=\"$action\" />";
echo "</div>";
echo "</td>\n";
echo "</tr>\n";
}
}
?>
</tbody>
</table>
<input type="hidden" name="action" value="update" />
<button id="validateReboot" type="submit" class="btn btn-primary">Update</button>
</form>
<?php
echo "<form id=\"refreshxml\" action=\"configuration.php\" method=\"post\" style=\"display: $displayformrefresh\">"
?>
<input type="hidden" name="action" value="refresh" />
<button id="validateReboot" type="submit" class="btn btn-primary">OK</button>
</form>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>