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