From: Roman Bazalevsky Date: Thu, 29 Nov 2018 18:00:14 +0000 (+0300) Subject: Веб переделан/ X-Git-Url: https://git.rvb.name/weathermon.git/commitdiff_plain/d5653b977ce2b9d0ef6e6c07b3a9b64c1462e601?ds=sidebyside Веб переделан/ --- diff --git a/web/archive.php b/web/archive.php deleted file mode 100644 index 1b21599..0000000 --- a/web/archive.php +++ /dev/null @@ -1,351 +0,0 @@ - - - - - - WeatherMon (архив) - - - - - false)))) { - die($err); - } - -$db -> exec('SET CHARACTER SET utf8'); - -if (! $year) { - - $q = $db -> prepare( - 'select - date_format(day,\'%Y\') as year - from - calendar - group by year - order by year'); - $q -> execute(); -?> -

Архив метеоданных

- fetch(PDO::FETCH_ASSOC)) { -?> - Данные за год - prepare( - 'select - date_format(day,\'%m\') as month, - date_format(day,\'%d\') as day - from - calendar - where - day>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and - day execute(); -?> -

год

- fetchAll(PDO::FETCH_ASSOC); - $months = []; - foreach ($data as $row) { - $days [$year.$row['month'].$row['day']] = '&month='.$row['month'].'&day='.$row['day']; - $months[$row['month']]=1; - } - $m = 1; - echo ''; - for ($i=1; $i<=3; $i++) { - echo ''; - for ($j=1; $j<=4; $j++) { - echo ''; - $m++; - } - echo ''; - } - echo '
'; - $month=sprintf('%02d',$m); - $month_name = strftime('%B',mktime(0,0,0,$month,1,$year)); - if (!empty($months[$month])) { - echo '

'.$month_name.'

'; - } else { - echo '

'.$month_name.'

'; - } - calendar($year,$month,$days,'?year='.$year.'%s',0); - echo '
'; - - $next_year = $year+1; - - if (!$local_net) { - - $filter = ' and s.is_public=1'; - - } else { - - $filter = ''; - - } - - - - $q = $db -> prepare ( - 'select - s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name, - count(distinct day) cnt, - round(min(v.min),1) min_value, - round(max(v.max),1) max_value, - u.name_short unit - from - sensors_ranges v,sensors s,st_parameters p,units u - where - v.sensor=s.id and - 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 execute(); - $sensors = $q -> fetchAll(PDO::FETCH_ASSOC); - - foreach ($sensors as $sensor) { - - $units = get_unit($db,$sensor['param']); - $from_unit = $units['from']; - $to_unit = $units['to']; - $param_unit = $units['name']; - - $min_val = convert_unit($db,$sensor['min_value'],$from_unit,$to_unit); - $max_val = convert_unit($db,$sensor['max_value'],$from_unit,$to_unit); - - echo '

'.$sensor['param_name'].'('.$sensor['sensor_name'].')

'; - echo ''; - echo ''; - echo '
'; - echo 'Минимальное значение за год '.$min_val.' '.$param_unit.'
'; - echo 'Максимальное значение за год '.$max_val.' '.$param_unit.'
'; - echo '
'; - - if ($sensor['cnt']>1) { - - echo '
'; - - } - - } - - - } else { - - if (!$day) { - - $next_year = $year; - $next_month = $month+1; - - if ($next_month == 13) { - $next_month = 1; - $next_year = $next_year+1; - } - - $next_month = sprintf('%02d',$next_month); - $next_year = sprintf('%04d',$next_year); - $month = sprintf('%02d',$month); - $year = sprintf('%04d',$year); - - if (!$local_net) { - - $filter = ' and s.is_public=1'; - - } else { - - $filter = ''; - - } - - - $q = $db -> prepare( - 'select - date_format(day,\'%d\') as day - from - sensors_ranges r,sensors s - where - s.id=r.sensor and - day>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and - day execute(); - - $data = $q -> fetchAll(PDO::FETCH_ASSOC); - - $month_name = strftime('%B %Y',mktime(0,0,0,$month,1,$year)); - -?> -

- prepare ( - 'select - s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name, - count(distinct day) cnt, - round(min(v.min),1) min_value, - round(max(v.max),1) max_value, - u.name_short unit - from - sensors_ranges v,sensors s,st_parameters p,units u - where - v.sensor=s.id and - 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 execute(); - $sensors = $q -> fetchAll(PDO::FETCH_ASSOC); - - foreach ($sensors as $sensor) { - - $units = get_unit($db,$sensor['param']); - $from_unit = $units['from']; - $to_unit = $units['to']; - $param_unit = $units['name']; - - $min_val = convert_unit($db,$sensor['min_value'],$from_unit,$to_unit); - $max_val = convert_unit($db,$sensor['max_value'],$from_unit,$to_unit); - - echo '

'.$sensor['param_name'].'('.$sensor['sensor_name'].')

'; - echo ''; - echo ''; - echo '
'; - echo 'Минимальное значение за месяц '.$min_val.' '.$param_unit.'
'; - echo 'Максимальное значение за месяц '.$max_val.' '.$param_unit.'
'; - echo '
'; - - if ($sensor['cnt']>1) { - - echo '
'; - - } - - } - - } else { - - $month = sprintf('%02d',$month); - $year = sprintf('%04d',$year); - $day = sprintf('%02d',$day); - - if (!$local_net) { - - $filter = ' and s.is_public=1'; - - } else { - - $filter = ''; - - } - - - $q = $db -> prepare( - 'select - distinct v.sensor as sensor_id,s.s_description,p.id as param_id,p.st_description - from - sensors_ranges v,st_parameters p,sensors s - where - v.day=str_to_date(\''.$year.'-'.$month.'-'.$day.'\',\'%Y-%m-%d\') - and v.sensor=s.id - and v.parameter=p.id'.$filter - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - - echo '

'.$row['s_description'].'/'.$row['st_description'].'

'; -?> -
- - - \ No newline at end of file diff --git a/web/calendar.php b/web/calendar.php deleted file mode 100644 index 6dbef05..0000000 --- a/web/calendar.php +++ /dev/null @@ -1,87 +0,0 @@ - $dayofmonth) break; - - } - - if($day_count > $dayofmonth) break; - - } - - echo ''; - - for($i = 0; $i < count($week); $i++) { - - echo ''; - - for($j = 0; $j < 7; $j++) { - - if(!empty($week[$i][$j])) { - $str = $week[$i][$j]; - $fstr=''.$str.''; - if (!empty($days[$year.$month.sprintf('%02d',$str)])) { - $href=sprintf($ref_template,$days[$year.$month.sprintf('%02d',$str)]); - if($j == 5 || $j == 6) { - echo ''; - } else { - echo ''; - } - } else { - if($j == 5 || $j == 6) { - echo ''; - } else { - echo ''; - } - } - } - - else echo ''; - - } - - echo ''; - - } - - echo '
'.$fstr.''.$fstr.''.$fstr.''.$fstr.' 
'; - -} - -?> \ No newline at end of file diff --git a/web/favicon.png b/web/favicon.png deleted file mode 100644 index a8081d8..0000000 Binary files a/web/favicon.png and /dev/null differ diff --git a/web/favicon.svg b/web/favicon.svg deleted file mode 100644 index 7d502ad..0000000 --- a/web/favicon.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - diff --git a/web/graphs.php b/web/graphs.php deleted file mode 100644 index 850d9d7..0000000 --- a/web/graphs.php +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - WeatherMon (Последние 24 часа) - - - - - 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 - from - sensor_values v,st_parameters p,sensors s - where - v.timestamp>adddate(now(), -1) - and v.sensor_id=s.id - and s.st_id=p.st_id - and p.id>=0'.$filter.' - order by s_description,st_description' - ); -$q -> execute(); - -while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - - echo '

'.$row['s_description'].'/'.$row['st_description'].'

'; -?> -
- -Архивные данные -
-Настройки - - \ No newline at end of file diff --git a/web/image.php b/web/image.php deleted file mode 100644 index 9b6ca84..0000000 --- a/web/image.php +++ /dev/null @@ -1,248 +0,0 @@ - false)))) { - - die('Не могу подключиться к БД'); - -} - -$supported = imagetypes(); -if( $supported & IMG_PNG ) $img_format="png"; -elseif( $supported & IMG_GIF ) $img_format="gif"; -elseif( $supported & IMG_JPG ) $img_format="jpeg"; -elseif( $supported & IMG_WBMP ) $img_format="wbmp"; -elseif( $supported & IMG_XPM ) $img_format="xpm"; - -$cachefilename = NULL; - -$db -> exec('SET CHARACTER SET utf8'); - -$type = $_REQUEST['type']; -$sensor=$_REQUEST['sensor']; -$param=$_REQUEST['param']; - -if ($type and $param) { - - $sensor = intval($sensor); - $param = intval($param); - - $q = $db -> prepare( - 'select s_description from sensors where id='.$sensor - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $sensor_name = $row['s_description']; - } - - $q = $db -> prepare( - 'select st.st_dot_color,st.st_line_color,st.st_description,u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id' - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $param_name = $row['st_description']; - $from_unit = $row['id']; - $unit_group = $row['unit_group']; - $dot_color = $row['st_dot_color']; - $line_color = $row['st_line_color']; - } - - if (!empty($_COOKIE['unit_'.$unit_group])) { - $to_unit=intval($_COOKIE['unit_'.$unit_group]); - } else { - $to_unit=$from_unit; - } - - $q = $db -> prepare( - 'select u.name_short,u.prec from units u where u.id='.$to_unit - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $param_unit = $row['name_short']; - $precision = $row['prec']; - } - - $xdata = array(); - $ydata = array(); - - if ($type == 'last24') { - - $q = $db -> prepare( - 'select unix_timestamp(timestamp) as x,unitconv(value,'.$from_unit.','.$to_unit.') as y from sensor_values where timestamp>adddate(now(), -1) and sensor_id='.$sensor.' and parameter_id='.$param.' order by timestamp' - ); - - $bottomheight = 130; - $topheight = 40; - $sizex = 1000; - $sizey = 800; - $scale = True; - - } elseif ($type == 'last24small') { - - $q = $db -> prepare( - 'select unix_timestamp(timestamp) as x,unitconv(value,'.$from_unit.','.$to_unit.') as y from sensor_values where timestamp>adddate(now(), -1) and sensor_id='.$sensor.' and parameter_id='.$param.' order by timestamp' - ); - - $bottomheight = 20; - $topheight = 20; - $sizex = 400; - $sizey = 300; - $scale = False; - - } elseif ($type == 'range') { - - $curr = intval(date('YmdHis')); - - $from = intval($_REQUEST['fromdate']); - $to = intval($_REQUEST['todate']); - - if ($curr>$to) { - - $cachefilename='meteo.'.$sensor.'.'.$param.'.'.$to_unit.'.'.$from.'-'.$to.'.'.$img_format; - - } - - $q = $db -> prepare( - 'select unix_timestamp(timestamp) as x,unitconv(value,'.$from_unit.','.$to_unit.') as y from sensor_values where timestamp>=str_to_date("'.$from.'","%Y%m%d%H%i%s") and timestamp<=str_to_date("'.$to.'","%Y%m%d%H%i%s") and sensor_id='.$sensor.' and parameter_id='.$param.' order by timestamp' - ); - - $bottomheight = 60; - $topheight = 40; - $sizex = 1000; - $sizey = 800; - $scale = True; - - } - - $g = new Graph($sizex,$sizey); - - if ($cachefilename) { - if ($g->cache->IsValid($cachefilename)) { - - $g->cache->StreamImgFile($g->img,$cachefilename); - return; - - } else { - - $timeout = 8640000; - $g->SetupCache($cachefilename,$timeout); - - } - } - - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - - $xdata[] = $row['x']; - $ydata[] = $row['y']; - - } - - - for ($i = 0; $i < count($xdata); ++$i) { - - $total_weight=0; - $sum=0; - $maxdelta = 1800; - - for ($j = $i; $j < count($xdata); ++$j) { - - $delta = abs($xdata[$i]-$xdata[$j]); - if ($delta > $maxdelta) { break; } - - $weight = 1-$delta/$maxdelta; - $total_weight += $weight; - $sum += $weight*$ydata[$j]; - - } - - for ($j = $i-1; $j >=0 ; --$j) { - - $delta = abs($xdata[$i]-$xdata[$j]); - if ($delta > $maxdelta) { break; } - - $weight = 1-$delta/$maxdelta; - $total_weight += $weight; - $sum += $weight*$ydata[$j]; - - } - - $new_val = $sum/$total_weight; - $f_ydata[$i] = $new_val; - - } - - // Create the graph - $g->graph_theme = null; - - $g->img->SetAntiAliasing(); - - // We need a datlin scale since we provide both - // x and y coordinates for the data points, but x is unix timestamp. - $g->SetScale('datlin'); - if ($scale) { - $g->xaxis->SetLabelAngle(90); - } else { - $g->xaxis->HideLabels(True); - } - $g->xaxis->SetPos("min"); - $g->yaxis->SetLabelFormat("%0.".$precision."f"); -# $g->xaxis->scale->SetTimeAlign( HOURADJ_1 ); - - - 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); - $fplot->SetColor($line_color); - $fplot->SetWeight(2); - - $g->SetMargin(50,30,$topheight,$bottomheight); - if ($scale) { - $g->title->Set($sensor_name.'/'.$param_name.', '.$param_unit); - $g->title->SetFont(FF_DV_SANSSERIF,FS_BOLD,12); - } - $g->SetMarginColor('lightgray'); - - $g->xgrid->Show(); - $g->xgrid->SetLineStyle('dotted'); - $g->ygrid->Show(); - $g->ygrid->SetLineStyle('dotted'); - - // Add the plots to the graph and stroke - $g->Stroke(); - -} else { - - header("Content-Type: text/html; charset=UTF-8"); - die('Сенсор не выбран!'); - -} - -?> \ No newline at end of file diff --git a/web/image_minmax.php b/web/image_minmax.php deleted file mode 100644 index edc1708..0000000 --- a/web/image_minmax.php +++ /dev/null @@ -1,246 +0,0 @@ - false)))) { - - die('Не могу подключиться к БД'); - -} - -$supported = imagetypes(); -if( $supported & IMG_PNG ) $img_format="png"; -elseif( $supported & IMG_GIF ) $img_format="gif"; -elseif( $supported & IMG_JPG ) $img_format="jpeg"; -elseif( $supported & IMG_WBMP ) $img_format="wbmp"; -elseif( $supported & IMG_XPM ) $img_format="xpm"; - -$cachefilename = NULL; - -$db -> exec('SET CHARACTER SET utf8'); - -$type = $_REQUEST['type']; -$sensor=$_REQUEST['sensor']; -$param=$_REQUEST['param']; -$year=$_REQUEST['year']; -$month=$_REQUEST['month']; - -if ($type and $param) { - - $sensor = intval($sensor); - $param = intval($param); - - $q = $db -> prepare( - 'select s_description from sensors where id='.$sensor - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $sensor_name = $row['s_description']; - } - - $q = $db -> prepare( - 'select st.st_fill_color_top,st.st_fill_color_bottom,st.st_description,u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id' - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $param_name = $row['st_description']; - $from_unit = $row['id']; - $unit_group = $row['unit_group']; - $fill_color_top=$row['st_fill_color_top']; - $fill_color_bottom=$row['st_fill_color_bottom']; - } - - if (!empty($_COOKIE['unit_'.$unit_group])) { - $to_unit=intval($_COOKIE['unit_'.$unit_group]); - } else { - $to_unit=$from_unit; - } - - $q = $db -> prepare( - 'select u.name_short from units u where u.id='.$to_unit - ); - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $param_unit = $row['name_short']; - } - - $xdata = array(); - $ydata = array(); - - if ($type == 'month') { - - $next_year = $year; - $next_month = $month+1; - - if ($month==12) { - - $next_year++; - $next_month=1; - - } - - $curr = date("Ym"); - $ym=sprintf('%04d%02d',$next_year,$next_month); - - if ($curr>$ym) { - - $cachefilename='meteo.month.'.$sensor.'.'.$param.'.'.$to_unit.'.'.$year.'-'.$month.'.'.$img_format; - - } - - $datestr=sprintf("%04d%02d01",$year,$month); - $nextdatestr=sprintf("%04d%02d01",$next_year,$next_month); - - $q = $db -> prepare( - ' - select - x, - unitconv(min(min),'.$from_unit.','.$to_unit.') min_value, - unitconv(max(max),'.$from_unit.','.$to_unit.') max_value - from ( - select - unix_timestamp(day) x, - min, - max - from - sensors_ranges - where - day>=STR_TO_DATE(\''.$datestr.'\',\'%Y%m%d\') - and day$next_year) { - - $cachefilename='meteo.year.'.$sensor.'.'.$param.'.'.$year.'.'.$img_format; - - } - - $datestr=sprintf("%04d0101",$year); - $nextdatestr=sprintf("%04d0101",$next_year); - - $q = $db -> prepare( - ' - select - x, - unitconv(min(min),'.$from_unit.','.$to_unit.') min_value, - unitconv(max(max),'.$from_unit.','.$to_unit.') max_value - from ( - select - unix_timestamp( - DATE_SUB(day, INTERVAL DAYOFWEEK(day)-1 DAY) - ) x, - min, - max - from - sensors_ranges - where - day>=STR_TO_DATE(\''.$datestr.'\',\'%Y%m%d\') - and daycache->IsValid($cachefilename)) { - - $g->cache->StreamImgFile($g->img,$cachefilename); - return; - - } else { - - $timeout = 8640000; - $g->SetupCache($cachefilename,$timeout); - - } - } - - - $q -> execute(); - - while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - - $xdata[] = $row['x']; - $mindata[] = $row['min_value']; - $maxdata[] = $row['max_value']; - - } - - // Create the graph - $g->graph_theme = null; - - //$g->img->SetAntiAliasing(); - - // We need a linlin scale since we provide both - // x and y coordinates for the data points. - $g->SetScale('datlin'); - $g->xaxis->SetLabelAngle(90); - $g->xaxis->SetPos("min"); - $g->xaxis->scale->SetTimeAlign( MINADJ_1 ); - - // We use a scatterplot to illustrate the original - // contro points. - - $bplot = new LinePlot($maxdata,$xdata); - $g->Add($bplot); - $bplot->SetColor($fill_color_top); - $bplot->SetFillGradient($fill_color_top.'@0.2',$fill_color_bottom.'@0.9',100,TRUE); - $bplot->SetFillFromYMin(TRUE); - $bplot->SetWeight(4); - - $aplot = new LinePlot($mindata,$xdata); - $g->Add($aplot); - $aplot->SetColor($fill_color_bottom); - $aplot->SetFillGradient($fill_color_bottom.'@0.2','white@0.9',100,TRUE); - $aplot->SetFillFromYMin(TRUE); - $aplot->SetWeight(4); - - $g->SetMargin(60,60,60,130); - $g->title->Set($sensor_name.'/'.$param_name.', '.$param_unit); - $g->title->SetFont(FF_DV_SANSSERIF,FS_BOLD,12); - $g->subtitle->Set('(минимальные и максимальные значения за период)'); - $g->subtitle->SetColor('darkred'); - $g->SetMarginColor('silver'); - - $g->xgrid->Show(); - $g->xgrid->SetLineStyle('dotted'); - $g->ygrid->Show(); - $g->ygrid->SetLineStyle('dotted'); - - // Add the plots to the graph and stroke - $g->Stroke(); - -} else { - - header("Content-Type: text/html; charset=UTF-8"); - die('Сенсор не выбран!'); - -} - -?> \ No newline at end of file diff --git a/web/index.php b/web/index.php deleted file mode 100644 index 92a8e8e..0000000 --- a/web/index.php +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - WeatherMon (Последние 24 часа) - - - - -
- 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 - from - sensor_values v,st_parameters p,sensors s - where - v.timestamp>adddate(now(), -1) - and v.sensor_id=s.id - and v.parameter_id=p.id - and s.st_id=p.st_id - and p.id>=0'.$filter.' - order by s_description,st_description' - ); -$q -> execute(); - -while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - - echo '
'; - echo '
'.$row['s_description'].'/'.$row['st_description'].'
'; - -$ql = $db -> prepare( - ' - SELECT unix_timestamp(timestamp) timestamp,DATE_FORMAT(timestamp,"%H:%i") printable,value - FROM - meteo.sensor_values - WHERE - sensor_id='.$row['sensor_id'].' and parameter_id='.$row['param_id'].' and timestamp>addtime(now(), -3600) - ORDER BY - timestamp desc - ' - ); - -$ql -> execute(); - -$printable_ts = "?"; -$val = "?"; - -if ($rowl = $ql -> fetch(PDO::FETCH_ASSOC)) { - - $timestamp = $rowl['timestamp']; - $printable_ts = $rowl['printable']; - $value = $rowl['value']; - - $units = get_unit($db,$row['param_id']); - $from_unit = $units['from']; - $to_unit = $units['to']; - $param_unit = $units['name']; - - $val = convert_unit($db,$value,$from_unit,$to_unit); - -} - -if ($printable_ts != '?') { - echo '
'.$printable_ts.'
'; - echo '
'.$val.' '.$param_unit.'
'; -} -?> -
-"; - -} - -?> -
- - - \ No newline at end of file diff --git a/web/setup.php b/web/setup.php deleted file mode 100644 index e591264..0000000 --- a/web/setup.php +++ /dev/null @@ -1,114 +0,0 @@ - false)))) { - - die('Не могу подключиться к БД'); - -} - -$db -> exec('SET CHARACTER SET utf8'); - -$selected = []; - -if ($_REQUEST['action']=='submit') { - - foreach($_REQUEST as $key=>$value) { - - if (strpos($key,'unit_')===0) { - - $group_id=intval(substr($key,5)); - $unit_id=$value; - setcookie('unit_'.$group_id,$unit_id,time()+86400*365*10); - $selected[$group_id]=$unit_id; - - } - - } - -?> - - - - - - WeatherMon (Настройки) - - - -

Сохранено...

- -$value) { - - if (strpos($key,'unit_')===0) { - - $group_id=intval(substr($key,5)); - $unit_id=$value; - setcookie('unit_'.$group_id,$unit_id); - $selected[$group_id]=$unit_id; - - } - - } - -?> - - - - - - WeatherMon (Настройки) - - - - - prepare( - 'select id,name,(select count(*) from units where unit_group=g.id) cnt from unit_groups g' -); -$q -> execute(); - -echo '
'; -while ($row = $q -> fetch(PDO::FETCH_ASSOC)) { - $group_id = $row['id']; - $group_name = $row['name']; - $group_cnt = $row['cnt']; - - echo '

'.$group_name.'

'; - - $q_p = $db -> prepare( - 'select id,name from units where unit_group='.$group_id - ); - - $q_p->execute(); - - echo '
'; -} -echo ''; -echo '

'; -echo '
'; - -} - -?> - - \ No newline at end of file diff --git a/web/units.php b/web/units.php deleted file mode 100644 index 16ad227..0000000 --- a/web/units.php +++ /dev/null @@ -1,61 +0,0 @@ - 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 ($from==$to) { - - $val = $value; - - } else { - - $qv = $db -> prepare( - 'select round(unitconv('.$value.','.$from.','.$to.'),2) res' - ); - $qv -> execute(); - - while ($row = $qv -> fetch(PDO::FETCH_ASSOC)) { - $val = $row['res']; - } - - } - - return $val; - -} - -?> \ No newline at end of file