1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
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 (архив)</title>
7 <link rel="icon" href="favicon.png" />
8 <style type="text/css">
12 border:2px solid darkgrey;
24 a:visited { text-decoration: none; color:darkblue; }
25 a:link { text-decoration: none; color:blue; }
26 a:hover { text-decoration: underline; color:navy; }
29 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">
32 include('config_local.php');
33 include('calendar.php');
36 $client_ip = $_SERVER["REMOTE_ADDR"];
38 if ((strpos($client_ip, "192.168.") === 0) || (strpos($client_ip, "10.8.") === 0)
39 || (strpos($client_ip, "2a02:578:5002:8174:") === 0)
40 || (strpos($client_ip, "2a02:578:5002:196::2") === 0)) {
51 $year = $_REQUEST['year'];
52 $month = $_REQUEST['month'];
53 $day = $_REQUEST['day'];
55 if (! ($db = new PDO("mysql:host=$mysql_host;port=$mysql_port;dbname=$mysql_schema",$mysql_user,$mysql_pwd,array( PDO::ATTR_PERSISTENT => false)))) {
59 $db -> exec('SET CHARACTER SET utf8');
65 date_format(day,\'%Y\') as year
72 <h1>Архив метеоданных</h1>
74 while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
76 <a class="year" href="?year=<?php echo $row['year']; ?>">Данные за <?php echo $row['year']; ?> год</a>
85 $year = sprintf('%04d',$year);
86 $next_year = sprintf('%04d',$next_year);
89 date_format(day,\'%m\') as month,
90 date_format(day,\'%d\') as day
94 day>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and
95 day<str_to_date(\''.$next_year.'-01-01\',\'%Y-%m-%d\')
101 <h1 align="center"><?php echo $year; ?> год</h1>
103 $data = $q -> fetchAll(PDO::FETCH_ASSOC);
105 foreach ($data as $row) {
106 $days [$year.$row['month'].$row['day']] = '&month='.$row['month'].'&day='.$row['day'];
107 $months[$row['month']]=1;
110 echo '<table align="center">';
111 for ($i=1; $i<=3; $i++) {
113 for ($j=1; $j<=4; $j++) {
114 echo '<td valign="top">';
115 $month=sprintf('%02d',$m);
116 $month_name = strftime('%B',mktime(0,0,0,$month,1,$year));
117 if (!empty($months[$month])) {
118 echo '<h3 align="center"><a class="month" href="?year='.$year.'&month='.$month.'">'.$month_name.'</a></h3>';
120 echo '<h3 align="center">'.$month_name.'</h3>';
122 calendar($year,$month,$days,'?year='.$year.'%s',0);
130 $next_year = $year+1;
134 $filter = ' and s.is_public=1';
144 $q = $db -> prepare (
146 s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name,
147 count(distinct day) cnt,
148 round(min(v.min),1) min_value,
149 round(max(v.max),1) max_value,
152 sensors_ranges v,sensors s,st_parameters p,units u
157 v.day>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and
158 v.day<str_to_date(\''.$next_year.'-01-01\',\'%Y-%m-%d\''.$filter.')
159 group by s.id,p.id,s.s_description,p.st_description
164 $sensors = $q -> fetchAll(PDO::FETCH_ASSOC);
166 foreach ($sensors as $sensor) {
168 $units = get_unit($db,$sensor['param']);
169 $from_unit = $units['from'];
170 $to_unit = $units['to'];
171 $param_unit = $units['name'];
173 $min_val = convert_unit($db,$sensor['min_value'],$from_unit,$to_unit);
174 $max_val = convert_unit($db,$sensor['max_value'],$from_unit,$to_unit);
176 echo '<h3 align="center">'.$sensor['param_name'].'('.$sensor['sensor_name'].')</h3>';
177 echo '<table align="center">';
179 echo 'Минимальное значение за год <b>'.$min_val.' '.$param_unit.'</b><br>';
180 echo 'Максимальное значение за год <b>'.$max_val.' '.$param_unit.'</b><br>';
184 if ($sensor['cnt']>1) {
186 echo '<center><img src="image_minmax.php?sensor='.$sensor['sensor'].'¶m='.$sensor['param'].
187 '&type=year&year='.$year.'"></center>';
199 $next_month = $month+1;
201 if ($next_month == 13) {
203 $next_year = $next_year+1;
206 $next_month = sprintf('%02d',$next_month);
207 $next_year = sprintf('%04d',$next_year);
208 $month = sprintf('%02d',$month);
209 $year = sprintf('%04d',$year);
213 $filter = ' and s.is_public=1';
224 date_format(day,\'%d\') as day
226 sensors_ranges r,sensors s
229 day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and
230 day<str_to_date(\''.$next_year.'-'.$next_month.'-01\',\'%Y-%m-%d\')'.$filter.'
236 $data = $q -> fetchAll(PDO::FETCH_ASSOC);
238 $month_name = strftime('%B %Y',mktime(0,0,0,$month,1,$year));
241 <h1 align="center"><?php echo 'Данные за '.$month_name; ?></h1>
243 foreach ($data as $row) {
244 $days [$year.$month.$row['day']] = $row['day'];
247 calendar($year,$month,$days,'?year='.$year.'&month='.$month.'&day=%s',3);
251 $filter = ' and s.is_public=1';
260 $q = $db -> prepare (
262 s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name,
263 count(distinct day) cnt,
264 round(min(v.min),1) min_value,
265 round(max(v.max),1) max_value,
268 sensors_ranges v,sensors s,st_parameters p,units u
273 v.day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and
274 v.day<str_to_date(\''.$next_year.'-'.$next_month.'-01\',\'%Y-%m-%d\')'.$filter.'
275 group by s.id,p.id,s.s_description,p.st_description
280 $sensors = $q -> fetchAll(PDO::FETCH_ASSOC);
282 foreach ($sensors as $sensor) {
284 $units = get_unit($db,$sensor['param']);
285 $from_unit = $units['from'];
286 $to_unit = $units['to'];
287 $param_unit = $units['name'];
289 $min_val = convert_unit($db,$sensor['min_value'],$from_unit,$to_unit);
290 $max_val = convert_unit($db,$sensor['max_value'],$from_unit,$to_unit);
292 echo '<h3 align="center">'.$sensor['param_name'].'('.$sensor['sensor_name'].')</h3>';
293 echo '<table align="center">';
295 echo 'Минимальное значение за месяц <b>'.$min_val.' '.$param_unit.'</b><br>';
296 echo 'Максимальное значение за месяц <b>'.$max_val.' '.$param_unit.'</b><br>';
300 if ($sensor['cnt']>1) {
302 echo '<center><img src="image_minmax.php?sensor='.$sensor['sensor'].'¶m='.$sensor['param'].
303 '&type=month&year='.$year.'&month='.$month.'"></center>';
311 $month = sprintf('%02d',$month);
312 $year = sprintf('%04d',$year);
313 $day = sprintf('%02d',$day);
317 $filter = ' and s.is_public=1';
328 distinct v.sensor as sensor_id,s.s_description,p.id as param_id,p.st_description
330 sensors_ranges v,st_parameters p,sensors s
332 v.day=str_to_date(\''.$year.'-'.$month.'-'.$day.'\',\'%Y-%m-%d\')
334 and v.parameter=p.id'.$filter
338 while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
340 echo '<h3 align="center">'.$row['s_description'].'/'.$row['st_description'].'</h3>';
342 <center><img src="image.php?sensor=<?php echo $row['sensor_id']; ?>¶m=<?php echo $row['param_id']?>&type=range&fromdate=<?php echo $year.$month.$day.'000000'; ?>&todate=<?php echo $year.$month.$day.'235959'?>"></center>