X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/e7a2d1b901dbeb947e0ad605a53badc845e23ebc..82c945cbf3ea97175cd2fba31f8ba92b9aade8ba:/web/send.php?ds=sidebyside diff --git a/web/send.php b/web/send.php index 7a69838..86286ef 100644 --- a/web/send.php +++ b/web/send.php @@ -1,42 +1,60 @@ $valid_ip_end || $valid_ip_start > $client_ip) { + $client_ip = $_SERVER["REMOTE_ADDR"]; + + if ((strpos($client_ip, "192.168.") === 0) || (strpos($client_ip, "10.8.") === 0) || (strpos($client_ip, "2001:470:6f:9d5:") === 0)) { + + + $local_net = True; + + } else { + + $local_net = False; + + } + + + + if (! $local_net) { header('HTTP/1.1 403 Forbidden'); echo "IP not in allowed range"; exit; } + $stype = $_REQUEST['stype']; $sid = $_REQUEST['sid']; $param = $_REQUEST['param']; $value = $_REQUEST['value']; + if (isset($_REQUEST['time'])) { + + $timestamp = "'".$_REQUEST['time']."'"; + + } else { + + $timestamp = 'NULL'; + + } + + + $connection = new mysqli($mysql_host, $mysql_user, $mysql_pwd, $mysql_schema, $mysql_port); if ($connection->connect_errno) { header('HTTP/1.1 500 Internal Server Error'); exit; } - $str = "CALL meteo.submit_value('".$stype."','".$sid."','".$param."',".$value.",NULL)"; - if (!$connection->query($str)) { - header('HTTP/1.1 500 Internal Server Error'); - exit; - } else { - $connection->commit(); -?> - - - - Meteo logger - - -OK Logged - - -query($str)) { + header('HTTP/1.1 500 Internal Server Error'); + echo "$str\n"; + echo "Call Failed\n"; + exit; + } else { + $connection->commit(); + echo "OK Logged"; } -?>