X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/ee2fccf67428124c6ae125e5c35064c6ccae7a7b..769d0bd71b19b467c195838379a379e0e2d69c2b:/web/archive.php?ds=sidebyside diff --git a/web/archive.php b/web/archive.php index 031bce7..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; }
@@ -31,64 +31,22 @@ include('config_local.php'); include('calendar.php'); +include('units.php'); -function get_unit($db,$param) { + $client_ip = $_SERVER["REMOTE_ADDR"]; - $qug = $db -> prepare( - 'select u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id' - ); - $qug -> execute(); - - while ($row = $qug -> fetch(PDO::FETCH_ASSOC)) { - $from_unit = $row['id']; - $unit_group = $row['unit_group']; - } - - if (!empty($_COOKIE['unit_'.$unit_group])) { - $to_unit=intval($_COOKIE['unit_'.$unit_group]); - } else { - $to_unit=$from_unit; - } - - $qu = $db -> prepare( - 'select u.name_short from units u where u.id='.$to_unit - ); - $qu -> execute(); - - while ($row = $qu -> fetch(PDO::FETCH_ASSOC)) { - $param_unit = $row['name_short']; - } - - return Array( - 'from' => $from_unit, - 'to' => $to_unit, - 'name' => $param_unit - ); - -} - -function convert_unit($db,$value,$from,$to) { + 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)) { - if ($from==$to) { - - $val = $value; + $local_net = True; } else { - $qv = $db -> prepare( - 'select round(unitconv('.$value.','.$from.','.$to.'),2) res' - ); - $qv -> execute(); - - while ($row = $qv -> fetch(PDO::FETCH_ASSOC)) { - $val = $row['res']; - } + $local_net = False; } - - return $val; -} $year = $_REQUEST['year']; $month = $_REQUEST['month']; @@ -115,7 +73,7 @@ if (! $year) { fetch(PDO::FETCH_ASSOC)) { ?> - ÐаннÑе за год