Хранилища Subversion www_nix-files

Редакция

Редакция 177 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

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