3 error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
5 include ('config_local.php');
7 if (! ($db = new PDO("mysql:host=$mysql_host;port=$mysql_port;dbname=$mysql_schema",$mysql_user,$mysql_pwd,array( PDO::ATTR_PERSISTENT => false)))) {
9 die('Не могу подключиться к БД');
13 $db -> exec('SET CHARACTER SET utf8');
17 if ($_REQUEST['action']=='submit') {
19 foreach($_REQUEST as $key=>$value) {
21 if (strpos($key,'unit_')===0) {
23 $group_id=intval(substr($key,5));
25 setcookie('unit_'.$group_id,$unit_id,time()+86400*365*10);
26 $selected[$group_id]=$unit_id;
35 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
36 <meta http-equiv="refresh" content="2; url=index.php">
37 <meta name="GENERATOR" content="Mozilla/4.72 (X11; U; Linux 2.2.12-20smp i686) [Netscape]">
38 <title>WeatherMon (Настройки)</title>
39 <link rel="icon" href="favicon.png" />
41 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">
42 <h1 align="center">Сохранено...</h1>
48 foreach($_COOKIE as $key=>$value) {
50 if (strpos($key,'unit_')===0) {
52 $group_id=intval(substr($key,5));
54 setcookie('unit_'.$group_id,$unit_id);
55 $selected[$group_id]=$unit_id;
62 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
65 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
66 <meta name="GENERATOR" content="Mozilla/4.72 (X11; U; Linux 2.2.12-20smp i686) [Netscape]">
67 <title>WeatherMon (Настройки)</title>
68 <link rel="icon" href="favicon.svg" />
70 <body text="black" bgcolor="silver" link="blue" vlink="#000080" alink="#FF0000">
76 'select id,name,(select count(*) from units where unit_group=g.id) cnt from unit_groups g'
80 echo '<form action="setup.php" method="get">';
81 while ($row = $q -> fetch(PDO::FETCH_ASSOC)) {
82 $group_id = $row['id'];
83 $group_name = $row['name'];
84 $group_cnt = $row['cnt'];
86 echo '<h3 align="center">'.$group_name.'</h3>';
88 $q_p = $db -> prepare(
89 'select id,name from units where unit_group='.$group_id
94 echo '<center><select name="unit_'.$group_id.'" size='.$group_cnt.'>';
95 while ($row_p = $q_p -> fetch(PDO::FETCH_ASSOC)) {
97 if ($selected[$group_id]==$row_p['id']) {
98 echo '<option selected value="'.$row_p['id'].'">'.$row_p['name'].'</option>';
100 echo '<option value="'.$row_p['id'].'">'.$row_p['name'].'</option>';
104 echo '</select></center>';
106 echo '<input type="hidden" name="action" value="submit">';
107 echo '<p><center><input type="submit" value="Сохранить настройки"></center>';