From: Roman Bazalevsky Date: Tue, 19 May 2015 14:00:09 +0000 (+0300) Subject: Web updated X-Git-Url: https://git.rvb.name/weathermon.git/commitdiff_plain/6f6f38ad845e089ef732873cfcf8e321d8cc1e38?ds=sidebyside Web updated --- diff --git a/web/archive.php b/web/archive.php index c403863..1b21599 100644 --- a/web/archive.php +++ b/web/archive.php @@ -23,7 +23,7 @@ } 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; } @@ -33,6 +33,21 @@ include('config_local.php'); include('calendar.php'); include('units.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; + + } + + $year = $_REQUEST['year']; $month = $_REQUEST['month']; $day = $_REQUEST['day']; @@ -58,7 +73,7 @@ if (! $year) { fetch(PDO::FETCH_ASSOC)) { ?> - Данные за год
+ Данные за год prepare ( 'select s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name, @@ -128,7 +155,7 @@ if (! $year) { v.parameter=p.id and p.st_unit=u.id and v.day>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and - v.day prepare( 'select date_format(day,\'%d\') as day from - sensors_ranges + sensors_ranges r,sensors s where + s.id=r.sensor and day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and - day prepare ( 'select @@ -221,7 +271,7 @@ if (! $year) { v.parameter=p.id and p.st_unit=u.id and v.day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and - v.day prepare( 'select distinct v.sensor as sensor_id,s.s_description,p.id as param_id,p.st_description @@ -270,7 +331,7 @@ if (! $year) { where v.day=str_to_date(\''.$year.'-'.$month.'-'.$day.'\',\'%Y-%m-%d\') and v.sensor=s.id - and v.parameter=p.id' + and v.parameter=p.id'.$filter ); $q -> execute(); diff --git a/web/config_local.php b/web/config_local.php index 00afede..9ec56a8 100644 --- a/web/config_local.php +++ b/web/config_local.php @@ -1,14 +1,14 @@ \ No newline at end of file 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 @@ @@ -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(); diff --git a/web/image.php b/web/image.php index 16fbafb..bf511f2 100644 --- a/web/image.php +++ b/web/image.php @@ -200,16 +200,21 @@ if ($type and $param) { $g->xaxis->SetPos("min"); # $g->xaxis->scale->SetTimeAlign( HOURADJ_1 ); - // We use a scatterplot to illustrate the original - // contro points. - $splot = new ScatterPlot($ydata,$xdata); - $g->Add($splot); - - // - $splot->mark->SetFillColor($dot_color); - $splot->mark->SetColor($dot_color); - $splot->mark->SetType(MARK_FILLEDCIRCLE); - $splot->mark->SetSize(2); + + if ($type!="last24small") { + + // We use a scatterplot to illustrate the original + // contro points. + $splot = new ScatterPlot($ydata,$xdata); + $g->Add($splot); + + // + $splot->mark->SetFillColor($dot_color); + $splot->mark->SetColor($dot_color); + $splot->mark->SetType(MARK_FILLEDCIRCLE); + $splot->mark->SetSize(2); + + } $fplot = new LinePlot($f_ydata,$xdata); $g->Add($fplot); diff --git a/web/image_minmax.php b/web/image_minmax.php index dfa66d2..183942b 100644 --- a/web/image_minmax.php +++ b/web/image_minmax.php @@ -84,16 +84,17 @@ if ($type and $param) { $next_year = $year; $next_month = $month+1; - if ($month==13) { + if ($month==12) { $next_year++; $next_month=1; - + } $curr = date("Ym"); + $ym=sprintf('%04d%02d',$next_year,$next_month); - if ($curr>$next_year.$next_month) { + if ($curr>$ym) { $cachefilename='meteo.month.'.$sensor.'.'.$param.'.'.$to_unit.'.'.$year.'-'.$month.'.'.$img_format; diff --git a/web/index.php b/web/index.php index 37251e6..92a8e8e 100644 --- a/web/index.php +++ b/web/index.php @@ -9,7 +9,7 @@