Редакция 174 | Редакция 176 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 174 | Редакция 175 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | require_once dirname(__FILE__)."/lib/init.php"; |
2 | require_once dirname(__FILE__)."/lib/init.php"; |
3 | include "./inc/header.htm"; |
3 | include "./inc/header.htm"; |
4 | 4 | ||
5 | // detect network
|
5 | // detect network
|
6 | $addr=$_SERVER['REMOTE_ADDR']; |
6 | $addr=$_SERVER['REMOTE_ADDR']; |
7 | $snets =& $db->query("SELECT * FROM subnets"); |
7 | $snets =& $db->query("SELECT * FROM subnets"); |
8 | $is_addr_found = false; |
8 | $is_addr_found = false; |
9 | while ($snets->fetchInto($info_snets, DB_FETCHMODE_ASSOC)&&!$is_addr_found) { |
9 | while ($snets->fetchInto($info_snets, DB_FETCHMODE_ASSOC)&&!$is_addr_found) { |
10 | list($ip,$mask) = explode('/',$info_snets['subnet']); |
10 | list($ip,$mask) = explode('/',$info_snets['subnet']); |
11 | $is_addr_found = (ip2long($addr) >> (32 - $mask) == ip2long($ip) >> (32 - $mask)); |
11 | $is_addr_found = (ip2long($addr) >> (32 - $mask) == ip2long($ip) >> (32 - $mask)); |
12 | if($is_addr_found) { |
12 | if($is_addr_found) { |
13 | $curnet =& $db->getOne("SELECT network FROM networks WHERE id=".$info_snets['network_id']); |
13 | $curnet =& $db->getOne("SELECT network FROM networks WHERE id=".$info_snets['network_id']); |
14 | echo "Debug: ваша сеть "+$curnet; |
14 | echo "Debug: ваша сеть ".$curnet; |
15 | }
|
15 | }
|
16 | }
|
16 | }
|
17 | 17 | ||
18 | // table header
|
18 | // table header
|
19 | echo "<table>"; |
19 | echo "<table>"; |
20 | 20 | ||
21 | $netlist = array(); |
21 | $netlist = array(); |
22 | $netcount = 0; |
22 | $netcount = 0; |
23 | 23 | ||
24 | $theader1 = "<tr>\n<th rowspan='2'> </th><th rowspan='2'> </th><th rowspan='2'>Ресурс</th>\n"; // category header |
24 | $theader1 = "<tr>\n<th rowspan='2'> </th><th rowspan='2'> </th><th rowspan='2'>Ресурс</th>\n"; // category header |
25 | $theader2 = "<tr>\n"; // networks header |
25 | $theader2 = "<tr>\n"; // networks header |
26 | 26 | ||
27 | $ncats =& $db->query("SELECT * FROM netcats"); |
27 | $ncats =& $db->query("SELECT * FROM netcats"); |
28 | while ($ncats->fetchInto($info_ncats, DB_FETCHMODE_ASSOC)) { |
28 | while ($ncats->fetchInto($info_ncats, DB_FETCHMODE_ASSOC)) { |
29 | $ccnc = 0; // Count networks of current category |
29 | $ccnc = 0; // Count networks of current category |
30 | $nets =& $db->query("SELECT * FROM networks WHERE netcat_id=".$info_ncats['id']); |
30 | $nets =& $db->query("SELECT * FROM networks WHERE netcat_id=".$info_ncats['id']); |
31 | while ($nets->fetchInto($info_nets, DB_FETCHMODE_ASSOC)) { |
31 | while ($nets->fetchInto($info_nets, DB_FETCHMODE_ASSOC)) { |
32 | // network name & link
|
32 | // network name & link
|
33 | if ($info_nets['link']=="") { $theader2 .= " <th>".$info_nets['network']."</th>\n"; } |
33 | if ($info_nets['link']=="") { $theader2 .= " <th>".$info_nets['network']."</th>\n"; } |
34 | else { $theader2 .= " <th><a href='./networks.php?net=".$info_nets['id']."'>".$info_nets['network']."</a></th>\n"; } |
34 | else { $theader2 .= " <th><a href='./networks.php?net=".$info_nets['id']."'>".$info_nets['network']."</a></th>\n"; } |
35 | // netlist
|
35 | // netlist
|
36 | $netlist[$netcount] = $info_nets['id']; |
36 | $netlist[$netcount] = $info_nets['id']; |
37 | $netcount++; |
37 | $netcount++; |
38 | $ccnc++; |
38 | $ccnc++; |
39 | }
|
39 | }
|
40 | $theader1 .= "<th colspan='".$ccnc."'>".$info_ncats['netcat']."</th>"; |
40 | $theader1 .= "<th colspan='".$ccnc."'>".$info_ncats['netcat']."</th>"; |
41 | }
|
41 | }
|
42 | echo $theader1."\n</tr>\n"; |
42 | echo $theader1."\n</tr>\n"; |
43 | echo $theader2."\n</tr>\n"; |
43 | echo $theader2."\n</tr>\n"; |
44 | 44 | ||
45 | // table body
|
45 | // table body
|
46 | $cats =& $db->query("SELECT * FROM categories"); |
46 | $cats =& $db->query("SELECT * FROM categories"); |
47 | while ($cats->fetchInto($info_cats, DB_FETCHMODE_ASSOC)) { |
47 | while ($cats->fetchInto($info_cats, DB_FETCHMODE_ASSOC)) { |
48 | $res =& $db->query("SELECT * FROM resources WHERE category_id=".$info_cats['id']); |
48 | $res =& $db->query("SELECT * FROM resources WHERE category_id=".$info_cats['id']); |
49 | $first = true; |
49 | $first = true; |
50 | while ($res->fetchInto($info_res, DB_FETCHMODE_ASSOC)) { |
50 | while ($res->fetchInto($info_res, DB_FETCHMODE_ASSOC)) { |
51 | echo "<tr>\n"; |
51 | echo "<tr>\n"; |
52 | 52 | ||
53 | // add rowspan on first resource on category
|
53 | // add rowspan on first resource on category
|
54 | if ($first) { |
54 | if ($first) { |
55 | echo " <td rowspan='".$res->numRows()."'>".$info_cats['category']."</td>\n"; |
55 | echo " <td rowspan='".$res->numRows()."'>".$info_cats['category']."</td>\n"; |
56 | $first = false; |
56 | $first = false; |
57 | }
|
57 | }
|
58 | 58 | ||
59 | // resource picture
|
59 | // resource picture
|
60 | echo " <td><img src='".$info_res['picture']."' alt='".$info_res['resource']."'></td>\n"; |
60 | echo " <td><img src='".$info_res['picture']."' alt='".$info_res['resource']."'></td>\n"; |
61 | 61 | ||
62 | // resource name & link
|
62 | // resource name & link
|
63 | echo " <td><a href='./details.php?res=".$info_res['id']."'>".$info_res['resource']."</a></td>\n"; |
63 | echo " <td><a href='./details.php?res=".$info_res['id']."'>".$info_res['resource']."</a></td>\n"; |
64 | 64 | ||
65 | // resource state by network
|
65 | // resource state by network
|
66 | for ($i=0;$i<$netcount;$i++) { |
66 | for ($i=0;$i<$netcount;$i++) { |
67 | $curstate =& $db->getOne("SELECT state_id FROM res_net_stat WHERE resource_id=".$info_res['id']." AND network_id=".$netlist[$i]); |
67 | $curstate =& $db->getOne("SELECT state_id FROM res_net_stat WHERE resource_id=".$info_res['id']." AND network_id=".$netlist[$i]); |
68 | $curimg = "./img/state/unknown.png"; |
68 | $curimg = "./img/state/unknown.png"; |
69 | if ($curstate == null) { |
69 | if ($curstate == null) { |
70 | echo " <td>—</td>\n"; |
70 | echo " <td>—</td>\n"; |
71 | }
|
71 | }
|
72 | else { |
72 | else { |
73 | // !replace in future!
|
73 | // !replace in future!
|
74 | switch ($curstate) { |
74 | switch ($curstate) { |
75 | case '1': |
75 | case '1': |
76 | $curimg = "./img/state/tick_gold.png"; |
76 | $curimg = "./img/state/tick_gold.png"; |
77 | $curalt = "Основной ресурс"; |
77 | $curalt = "Основной ресурс"; |
78 | break; |
78 | break; |
79 | case '2': |
79 | case '2': |
80 | $curimg = "./img/state/tick_blue.png"; |
80 | $curimg = "./img/state/tick_blue.png"; |
81 | $curalt = "Зеркало"; |
81 | $curalt = "Зеркало"; |
82 | break; |
82 | break; |
83 | case '3': |
83 | case '3': |
84 | $curimg = "./img/state/tick_green.png"; |
84 | $curimg = "./img/state/tick_green.png"; |
85 | $curalt = "Скоростной доступ"; |
85 | $curalt = "Скоростной доступ"; |
86 | break; |
86 | break; |
87 | case '4': |
87 | case '4': |
88 | $curimg = "./img/state/tick_gray.png"; |
88 | $curimg = "./img/state/tick_gray.png"; |
89 | $curalt = "Доступен"; |
89 | $curalt = "Доступен"; |
90 | break; |
90 | break; |
91 | case '5': |
91 | case '5': |
92 | $curimg = "./img/state/snowflake.png"; |
92 | $curimg = "./img/state/snowflake.png"; |
93 | $curalt = "Заморожен"; |
93 | $curalt = "Заморожен"; |
94 | break; |
94 | break; |
95 | }
|
95 | }
|
96 | echo " <td><a href='".$info_res['link_res']."'><img src='".$curimg."' alt='".$curalt."'></a></td>\n"; |
96 | echo " <td><a href='".$info_res['link_res']."'><img src='".$curimg."' alt='".$curalt."'></a></td>\n"; |
97 | }
|
97 | }
|
98 | }
|
98 | }
|
99 | echo "</tr>\n"; |
99 | echo "</tr>\n"; |
100 | }
|
100 | }
|
101 | }
|
101 | }
|
102 | // table footer
|
102 | // table footer
|
103 | echo "</table>"; |
103 | echo "</table>"; |
104 | include "./inc/legend.php"; |
104 | include "./inc/legend.php"; |
105 | 105 | ||
106 | include "./inc/footer.htm"; |
106 | include "./inc/footer.htm"; |
107 | ?>
|
107 | ?>
|
108 | 108 |