-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
executable file
·191 lines (159 loc) · 5.11 KB
/
index.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
181
182
183
184
185
186
187
188
189
190
191
<?php
/*
*IoT LoRa Gateway Controller
*Copyright (C) 2018-2019 Nebra LTD. T/a Pi Supply
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include('inc/header.php');
/*
* Lets load most of the information required to fill this page's details out
*
*/
if($configurationFile['gateway-info']['initial-setup'] == 0) {
//Send to first time setup
header("Location: firstTimeSetup.php");
}
if($loggedIn == 0) {
//Send to login page
header("Location: login.php");
}
//Lets check for external internet connectivity by doing a http request to three servers
$internetCheck1 = file_get_contents('https://1.1.1.1');
$internetStatus = 0;
if($internetCheck1 == FALSE) {
$internetStatus++;
}
$cpuTemp = shell_exec("cat /sys/class/thermal/thermal_zone0/temp");
$cpuTemp = $cpuTemp/1000;
$totalRam = shell_exec("free -m | awk '/Mem/{print $3}'");
$freeRam = shell_exec("free -m | awk '/Mem/{print $2}'");
//var_dump($totalRam);
//var_dump($freeRam);
?>
<?php
if($nebra) {echo('<h1>IoT Smart LoRa Gateway</h1>');}
else {echo('<h1>IoT LoRa Gateway Status Page</h1>');}
?>
<h2>Gateway Name: <?php echo($configurationFile['gateway-info']['gatway-friendly-name']);?></h2>
<h3><?php echo($configurationFile['gateway-info']['gatway-description']);?></h3>
<div class="ui divided grid stackable">
<div class="<?php if($configurationFile['gateway-info']['gateway-type'] == 1) { echo('three');} else {echo('two');} ?> column row">
<div class="column wide">
<?php
//Change the alert box's colour based on the status.
if($internetStatus == 0) {
echo("<div class=\"ui positive message segment\">");
}
else{
echo("<div class=\"ui error message segment\">");
}
?>
<h3>Internet Connectivity <i class="globe icon"></i></h3>
<?php
//Change the text based on the status.
if($internetStatus == 0) {
echo("All good!");
}
elseif($internetStatus == 1) {
echo("There might be an issue of this gateway connecting to the internet, please check and reload.");
}
?>
</div>
</div>
<div class="column wide">
<?php
//Change the alert box's colour based on the status.
if($configurationFile['packet-forwarder-1']['enabled'] == true) {
echo("<div class=\"ui positive message segment\">");
}
else {
echo("<div class=\"ui teal message segment\">");
}
?>
<h3>Packet Forwarder 1<i class="microchip icon"></i></h3>
The packet forwarder container is <?php if($packetForwarder==0){echo("not ");}?>running.
</div>
</div>
<div class="column wide">
<?php
//Change the alert box's colour based on the status.
if($configurationFile['packet-forwarder-2']['enabled'] == true) {
echo("<div class=\"ui positive message segment\">");
}
else {
echo("<div class=\"ui teal message segment\">");
}
?>
<h3>Packet Forwarder 2 <i class="microchip icon"></i></h3>
The packet forwarder container is <?php if($packetForwarder==0){echo("not ");}?>running.
</div>
</div>
</div>
</div>
<div class="ui divided grid stackable">
<?php
if($configurationFile['gateway-info']['gateway-type'] == 0) {
echo ('
<div class="row">
<div class="column">
<div class="ui positive message">
<strong>Configured Server:</strong> '.$configurationFile['packet-forwarder-1']['router'].'
</div>
</div>
</div>
');
}
else {
if($configurationFile['packet-forwarder-1']['enabled'] == true) {
echo ('
<div class="row">
<div class="column">
<div class="ui positive message">
<strong>Packet Forwarder 1 Server:</strong> '.$configurationFile['packet-forwarder-1']['router'].'
</div>
</div>
</div>
');
}
if($configurationFile['packet-forwarder-2']['enabled'] == true) {
echo ('
<div class="row">
<div class="column">
<div class="ui positive message">
<strong>Packet Forwarder 2 Server:</strong> '.$configurationFile['packet-forwarder-2']['router'].'
</div>
</div>
</div>
');
}
}
?>
<div class="row">
<div class="column">
<div class="ui info message">
<strong>CPU Temperature:</strong>
<div class="ui teal progress" id="progressBar" data-percent="<?php echo($cpuTemp); ?>">
<div class="bar"></div>
<div class="label"><?php echo($cpuTemp); ?> Degrees C</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('#progressBar').progress();
</script>
<?php
include('inc/footer.php');
?>