Перехват "лишнего" вывода от вызываемых подпроцессов, чтоб не засорять лог.
[weathermon.git] / web / graphs.php
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
5   <meta name="GENERATOR" content="Mozilla/4.72 (X11; U; Linux 2.2.12-20smp i686) [Netscape]">    
6   <title>WeatherMon (Последние 24 часа)</title>                      
7   <link rel="icon" href="favicon.png" />
8   <style type="text/css">
9      a:visited { text-decoration: none; color:darkblue; }
10      a:link { text-decoration: none; color:blue; }
11      a:hover { text-decoration: underline; color:navy; }
12   </style>
13 </head>
14 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">         
15 <?php
16
17 include('config_local.php');
18
19 $client_ip = $_SERVER["REMOTE_ADDR"];
20   
21 if ((strpos($client_ip, "192.168.") === 0) || (strpos($client_ip, "10.8.") === 0)
22    || (strpos($client_ip, "2a02:578:5002:8174:") === 0)
23    || (strpos($client_ip, "2a02:578:5002:196::2") === 0)) {
24               
25    $local_net = True;
26                   
27 } else {
28                     
29    $local_net = False;
30                
31 }
32                          
33
34 if (! ($db = new PDO("mysql:host=$mysql_host;port=$mysql_port;dbname=$mysql_schema",$mysql_user,$mysql_pwd,array( PDO::ATTR_PERSISTENT => false)))) {
35   die($err);
36   }  
37
38 $db -> exec('SET CHARACTER SET utf8');
39
40 if (!$local_net) {
41
42   $filter = ' and s.is_public=1';
43
44 } else {
45
46   $filter = '';
47
48 }  
49
50 $q = $db -> prepare(
51   'select 
52     distinct v.sensor_id,s.s_description,p.id as param_id,p.st_description 
53   from 
54     sensor_values v,st_parameters p,sensors s 
55   where 
56     v.timestamp>adddate(now(), -1) 
57     and v.sensor_id=s.id 
58     and s.st_id=p.st_id
59     and p.id>=0'.$filter.'
60   order by s_description,st_description'
61   );
62 $q -> execute();
63
64 while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
65
66   echo '<h3 align="center">'.$row['s_description'].'/'.$row['st_description'].'</h3>';
67 ?>
68 <center><img src="image.php?sensor=<?php echo $row['sensor_id']; ?>&param=<?php echo $row['param_id']?>&type=last24"></center>
69 <?php  
70
71 }                                                            
72   
73 ?>
74 <a href="archive.php">Архивные данные</a>
75 <br>
76 <a href="setup.php">Настройки</a>
77 </body>
78