X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/6c7c64de24a54d6bea09cb5a179d3a4c630c13ef..43054b4dc0965871a36730c619ee2cde76540a38:/web/graphs.php

diff --git a/web/graphs.php b/web/graphs.php
index dfc7450..850d9d7 100644
--- a/web/graphs.php
+++ b/web/graphs.php
@@ -8,7 +8,7 @@
   <style type="text/css">
      a:visited { text-decoration: none; color:darkblue; }
      a:link { text-decoration: none; color:blue; }
-     a:hover { text-decoration: none; color:navy; }
+     a:hover { text-decoration: underline; color:navy; }
   </style>
 </head>
 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">         
@@ -16,12 +16,37 @@
 
 include('config_local.php');
 
+$client_ip = $_SERVER["REMOTE_ADDR"];
+  
+if ((strpos($client_ip, "192.168.") === 0) || (strpos($client_ip, "10.8.") === 0)
+   || (strpos($client_ip, "2a02:578:5002:8174:") === 0)
+   || (strpos($client_ip, "2a02:578:5002:196::2") === 0)) {
+              
+   $local_net = True;
+                  
+} else {
+                    
+   $local_net = False;
+               
+}
+                         
+
 if (! ($db = new PDO("mysql:host=$mysql_host;port=$mysql_port;dbname=$mysql_schema",$mysql_user,$mysql_pwd,array( PDO::ATTR_PERSISTENT => false)))) {
   die($err);
   }  
 
 $db -> exec('SET CHARACTER SET utf8');
 
+if (!$local_net) {
+
+  $filter = ' and s.is_public=1';
+
+} else {
+
+  $filter = '';
+
+}  
+
 $q = $db -> prepare(
   'select 
     distinct v.sensor_id,s.s_description,p.id as param_id,p.st_description 
@@ -31,7 +56,7 @@ $q = $db -> prepare(
     v.timestamp>adddate(now(), -1) 
     and v.sensor_id=s.id 
     and s.st_id=p.st_id
-    and p.id>=0
+    and p.id>=0'.$filter.'
   order by s_description,st_description'
   );
 $q -> execute();