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