-
Notifications
You must be signed in to change notification settings - Fork 0
/
updater.php
46 lines (45 loc) · 1022 Bytes
/
updater.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
<?php
//
// NOTE: This is a trust=yes web, any query will affect the whole system.
// DONT DO IT MANUALLY. Only thinked to process Arduino queries.
//
// Get the IP of the client connecting
$connecting_as = $_SERVER['REMOTE_ADDR'];
// List of accepted IPs
$accepted = array(
"::1",
"127.0.0.1",
"192.168.1.102",
"10.19.250.20",
"10.19.250.30",
"10.19.250.40",
"10.19.250.50"
);
// Check if it is valid
if(in_array($connecting_as, $accepted))
{
// Check if there are GET requests
if(count($_GET))
{
// Get GET request
$query = $_SERVER['QUERY_STRING'];
// Divide it in small piecessss
$send = explode('&', $query);
// Default command (to update)
$command = "nodejs /opt/websocket/updater.js ";
// Foreach query value
foreach($send as $valor){
// Add it to the command as a parameter
$command .= "$valor ";
}
// Run it in the shell!
exec($command);
}
}
// Non accepted visitors
else
{
// Say we dont want annoying access.
echo "YOU DONT HAVE PERMISSIONS TO ACCESS THIS PAGE.";
}
?>