Хранилища Subversion ant

Редакция

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

Редакция 138 Редакция 190
1
<?php
1
<?php
2
2
3
class Core {
3
class Core {
4
4
5
        function getRepList($distro,$version,$dblink) {
5
        function getRepList($distro,$version,$dblink) {
6
                $query =& $dblink->query("SELECT * FROM settings");
6
                $query =& $dblink->query("SELECT * FROM settings");
7
                $settings = array();
7
                $settings = array();
8
                while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
8
                while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
9
                        $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
9
                        $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
10
                };
10
                };
11
                $query =& $dblink->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id JOIN dtype p ON d.disttype=p.type_id WHERE v.dist_id='$distro' AND v.version_id='$version'");
11
                $query =& $dblink->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id JOIN dtype p ON d.disttype=p.type_id WHERE v.dist_id='$distro' AND v.version_id='$version'");
12
                $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
12
                $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
13
                $query =& $dblink->query("SELECT * FROM repository r JOIN ver2rep v ON r.rep_id=v.rep_id JOIN version v2 ON v.ver_id=v2.version_id JOIN scheme s ON s.scheme_id=r.scheme_id JOIN root r2 ON r2.root_id=r.root_id WHERE v.ver_id='$version' ORDER BY r.rtype_id, r.scheme_id ASC");
13
                $query =& $dblink->query("SELECT * FROM repository r JOIN ver2rep v ON r.rep_id=v.rep_id JOIN origin o ON o.orig_id=r.orig_id JOIN version v2 ON v.ver_id=v2.version_id JOIN scheme s ON s.scheme_id=r.scheme_id JOIN root r2 ON r2.root_id=r.root_id WHERE v.ver_id='$version' ORDER BY r.rtype_id, r.scheme_id ASC");
-
 
14
                $pre=-1;
14
                while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
15
                while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
15
                        $repscheme = stripslashes($resinfo["scheme"]);
16
                        $repscheme = stripslashes($resinfo["scheme"]);
16
           
17
17
                        $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
18
                        $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
18
r.rep_id='$resinfo[rep_id]'");
19
r.rep_id='$resinfo[rep_id]'");
19
                        $sections = "";
20
                        $sections = "";
20
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
21
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
21
                                $sections .= stripslashes($section["sectname"])." ";
22
                                $sections .= stripslashes($section["sectname"])." ";
22
                        }
23
                        }
23
24
24
                        $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
25
                        $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
25
                        $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
26
                        $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
26
                        $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
27
                        $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
27
                        $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
28
                        $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
28
                        $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
29
                        $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
29
                        $repscheme = str_replace("{SECT}",$sections,$repscheme);
30
                        $repscheme = str_replace("{SECT}",$sections,$repscheme);
30
                        $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
31
                        $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
31
           
32
                       
-
 
33
                        if($pre != $resinfo["orig_id"]) {
-
 
34
                            $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
-
 
35
                        }
-
 
36
                        $pre = $resinfo["orig_id"];
-
 
37
                       
32
                        $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
38
                        $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
33
                }
39
                }
34
                return $result;
40
                return $result;
35
        }
41
        }
36
       
42
       
37
        function getInfo($message,$dblink){
43
        function getInfo($message,$dblink){
38
                $answer = array();
44
                $answer = array();
39
45
40
                if (preg_match("/linux/i",$message)) {
46
                if (preg_match("/linux/i",$message)) {
41
                        $dist_id = 0;
47
                        $dist_id = 0;
42
                        $dist_info = "";
48
                        $dist_info = "";
43
                        $vers_id = 0;
49
                        $vers_id = 0;
44
                        $vers_info = "";
50
                        $vers_info = "";
45
                        $qd =& $dblink->query("SELECT * FROM distribution");
51
                        $qd =& $dblink->query("SELECT * FROM distribution");
46
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
52
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
47
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
53
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
48
                                        $dist_id = $res["dist_id"];
54
                                        $dist_id = $res["dist_id"];
49
                                        $dist_info = stripslashes($res["distname"]);
55
                                        $dist_info = stripslashes($res["distname"]);
50
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
56
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
51
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
57
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
52
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
58
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
53
                                                        $vers_id = $rev["version_id"];
59
                                                        $vers_id = $rev["version_id"];
54
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
60
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
55
                                                }
61
                                                }
56
                                        }
62
                                        }
57
                                }
63
                                }
58
                        }
64
                        }
59
                        $answer[] = "Linux";
65
                        $answer[] = "Linux";
60
                        $answer[] = "Судя по всему у Вас операционная система ";
66
                        $answer[] = "Судя по всему у Вас операционная система ";
61
                        if ($dist_id!=0) {
67
                        if ($dist_id!=0) {
62
                                $answer[] = $dist_id;
68
                                $answer[] = $dist_id;
63
                                $answer[] = $dist_info;
69
                                $answer[] = $dist_info;
64
                        }
70
                        }
65
                        if ($vers_id!=0) {
71
                        if ($vers_id!=0) {
66
                                $answer[] = $vers_id;
72
                                $answer[] = $vers_id;
67
                                $answer[] = $vers_info;
73
                                $answer[] = $vers_info;
68
                        }
74
                        }
69
75
70
                } else {
76
                } else {
71
                        $answer[] = "unknown";
77
                        $answer[] = "unknown";
72
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
78
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
73
                }
79
                }
74
80
75
                return $answer;
81
                return $answer;
76
        }
82
        }
77
83
78
        function getInterfacesList($current,$dblink) {
84
        function getInterfacesList($current,$dblink) {
79
                $url  = parse_url($current);
85
                $url  = parse_url($current);
80
                $path = array();
86
                $path = array();
81
                $path = split("/",$url["path"]);
87
                $path = split("/",$url["path"]);
82
                $currentIF = str_replace(".php","",$path[count($path)-1]);
88
                $currentIF = str_replace(".php","",$path[count($path)-1]);
83
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
89
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
84
                $iflist = "<a href='./'>Интерфейсы</a>: ";
90
                $iflist = "<a href='./'>Интерфейсы</a>: ";
85
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
91
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
86
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
92
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
87
                }
93
                }
88
                $iflist = substr($iflist, 0, strlen($iflist)-2);
94
                $iflist = substr($iflist, 0, strlen($iflist)-2);
89
                return $iflist;
95
                return $iflist;
90
        }
96
        }
91
97
92
        function getCSSList($dblink) {
98
        function getCSSList($dblink) {
93
                $req =& $dblink->query("SELECT * FROM distribution");
99
                $req =& $dblink->query("SELECT * FROM distribution");
94
                if ($req->numRows()>0) {
100
                if ($req->numRows()>0) {
95
                        $css = "<style type=\"text/css\">\n";
101
                        $css = "<style type=\"text/css\">\n";
96
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
102
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
97
                                if ($dist["distlogo"]) {
103
                                if ($dist["distlogo"]) {
98
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
104
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
99
                                        $css .= ".".stripslashes($dist["distua"])."-em { display: inline; padding-left: 30px; background: transparent url(./img/logo/".stripslashes($dist["distua"])."-em.png) top left no-repeat; }\n";
105
                                        $css .= ".".stripslashes($dist["distua"])."-em { display: inline; padding-left: 30px; background: transparent url(./img/logo/".stripslashes($dist["distua"])."-em.png) top left no-repeat; }\n";
100
                                } else {
106
                                } else {
101
                                        $css .= "";
107
                                        $css .= "";
102
                                }
108
                                }
103
                        }
109
                        }
104
                        $css .= "</style>";
110
                        $css .= "</style>";
105
                } else {
111
                } else {
106
                        $css = "";
112
                        $css = "";
107
                }
113
                }
108
                return $css;
114
                return $css;
109
        }
115
        }
110
116
111
        function getSetting($setting, $dblink) {
117
        function getSetting($setting, $dblink) {
112
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
118
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
113
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
119
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
114
                return stripslashes($sett["optvalue"]);
120
                return stripslashes($sett["optvalue"]);
115
        }
121
        }
116
122
117
        function getUUID($param) {
123
        function getUUID($param) {
118
                $param_s = md5($param);
124
                $param_s = md5($param);
119
                $time_low = bin2hex(substr($param_s,0, 4));
125
                $time_low = bin2hex(substr($param_s,0, 4));
120
                $time_mid = bin2hex(substr($param_s,4, 2));
126
                $time_mid = bin2hex(substr($param_s,4, 2));
121
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
127
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
122
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
128
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
123
                $node = bin2hex(substr($param_s,10, 6));
129
                $node = bin2hex(substr($param_s,10, 6));
124
130
125
                $time_hi_and_version = hexdec($time_hi_and_version);
131
                $time_hi_and_version = hexdec($time_hi_and_version);
126
                $time_hi_and_version = $time_hi_and_version >> 4;
132
                $time_hi_and_version = $time_hi_and_version >> 4;
127
                $time_hi_and_version = $time_hi_and_version | 0x4000;
133
                $time_hi_and_version = $time_hi_and_version | 0x4000;
128
       
134
       
129
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
135
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
130
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
136
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
131
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
137
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
132
       
138
       
133
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
139
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
134
        }
140
        }
135
}
141
}
136
142
137
?>
143
?>
138
 
144