This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sensor_edit.php
executable file
·180 lines (146 loc) · 4.47 KB
/
sensor_edit.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
session_start();
require("include/functions.php");
$config_file = 'config.php';
if (file_exists($config_file)) {
require("config.php");
} else {
header("Location: error.php?e=config");
die();
}
require("include/apply_config.php");
$force_loggedin = TRUE;
require("include/check_login.php");
#Sanitize inputs
$SensorID=filter_var($_GET["SensorID"], FILTER_SANITIZE_NUMBER_INT);
if (isset($_GET["u"])){
$u=filter_var($_GET["u"], FILTER_SANITIZE_NUMBER_INT);
}
else{
$u = 0;
}
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>$app_custom_name - Edit Sensor</title>";
require("include/get_css.php");
require("include/get_jqueryui.php");
?>
<script src="js/jquery.validate.js"></script>
<!-- Form validation from http://bassistance.de/jquery-plugins/jquery-plugin-validation/ -->
<script type="text/javascript">
$().ready(function() {
// validate signup form on keyup and submit
$("#AddSensors").validate({
rules: {
Recorder: {
required: true
},
Microphone: {
required: true
}
},
messages: {
Recorder: "Please enter the name/model of the recorder",
Microphone: "Please enter the name/model of the microphone"
}
});
});
</script>
<style type="text/css">
#AddSensors label.error {
margin-left: 10px;
width: auto;
display: inline;
}
</style>
<script type="text/javascript">
$(function() {
$("#sensordel2").dialog({
autoOpen: false,
bgiframe: true,
resizable: false,
draggable: false,
height:140,
modal: true,
overlay: {
backgroundColor: '#000',
opacity: 0.5
},
buttons: {
"Delete sensor": function() {
document.sensordel1.submit();
},
"Cancel": function() {
$( this ).dialog( "close" );
}
}
});
$('form#sensordel1').submit(function(){
$('#sensordel2').dialog('open');
return false;
});
});
</script>
<?php
if ($use_googleanalytics) {
echo $googleanalytics_code;
}
#Execute custom code for head, if set
if (is_file("$absolute_dir/customhead.php")) {
include("customhead.php");
}
?>
</head>
<body>
<!--Blueprint container-->
<div class="container">
<?php
require("include/topbar.php");
?>
<div class="span-24 last">
<hr noshade>
</div>
<div class="span-24 last">
<?php
$query = "SELECT * FROM Sensors WHERE SensorID='$SensorID'";
$result=query_several($query, $connection);
$nrows = mysqli_num_rows($result);
if ($nrows==0) {
echo "<div class=\"error\"><img src=\"images/exclamation.png\"> There was an error. That sensor ID could not be found. Please go back and try again.</div>";
}
else {
$row = mysqli_fetch_array($result);
extract($row);
echo "<h3>Edit sensor to the database</h3>";
if ($u==1) {
echo "<p><div class=\"success\">Sensor data was updated successfully.</div>";
}
echo "<form action=\"include/sensor_edit.php\" method=\"POST\" id=\"AddSensors\">
<input name=\"SensorID\" type=\"hidden\" value=\"$SensorID\">
<p>Sensor ID: $SensorID
<p>Recorder: <input type=\"text\" name=\"Recorder\" maxlength=\"100\" size=\"40\" class=\"fg-button ui-state-default ui-corner-all\" value=\"$Recorder\"><br>
Microphone: <input type=\"text\" name=\"Microphone\" maxlength=\"80\" size=\"40\" class=\"fg-button ui-state-default ui-corner-all\" value=\"$Microphone\"><br>
Notes of the sensor: <input type=\"text\" name=\"Notes\" maxlength=\"255\" size=\"40\" class=\"fg-button ui-state-default ui-corner-all\" value=\"$Notes\"><br>
<input type=submit value=\" Edit sensor \" class=\"fg-button ui-state-default ui-corner-all\"></form>";
#Delete div
echo "<div id=\"sensordel2\" title=\"Delete sensor?\">
<p><span class=\"ui-icon ui-icon-alert\" style=\"float:left; margin:0 7px 20px 0;\"></span>This sensor will be deleted, this action can not be undone! Are you sure?</p></div>";
echo "<form action=\"sensor_del.php\" method=\"GET\" id=\"sensordel1\" name=\"sensordel1\">
<input name=\"SensorID\" type=\"hidden\" value=\"$SensorID\">
<input type=submit value=\" Delete sensor \" class=\"fg-button ui-state-default ui-corner-all\">
</form>";
}
?>
</div>
<div class="span-24 last">
</div>
<div class="span-24 last">
<?php
require("include/bottom.php");
?>
</div>
</div>
</body>
</html>