Хранилища Subversion ant

Редакция

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

Редакция 193 Редакция 194
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
                if ($_GET['mainreps']!='no'){
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 =& $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);
13
                $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 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' AND r.rtype_id!=3 ORDER BY r.rtype_id, r.scheme_id ASC");
14
                $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' AND r.rtype_id!=3 ORDER BY r.rtype_id, r.scheme_id ASC");
14
                $pre=-1;
15
                $pre=-1;
15
                while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
16
                while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
16
                        $repscheme = stripslashes($resinfo["scheme"]);
17
                        $repscheme = stripslashes($resinfo["scheme"]);
17
18
18
                        $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
19
                        $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
19
r.rep_id='$resinfo[rep_id]'");
20
r.rep_id='$resinfo[rep_id]'");
20
                        $sections = "";
21
                        $sections = "";
21
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
22
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
22
                                $sections .= stripslashes($section["sectname"])." ";
23
                                $sections .= stripslashes($section["sectname"])." ";
23
                        }
24
                        }
24
25
25
                        $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
26
                        $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
26
                        $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
27
                        $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
27
                        $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
28
                        $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
28
                        $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
29
                        $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
29
                        $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
30
                        $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
30
                        $repscheme = str_replace("{SECT}",$sections,$repscheme);
31
                        $repscheme = str_replace("{SECT}",$sections,$repscheme);
31
                        $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
32
                        $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
32
                       
33
                       
33
                        if($pre != $resinfo["orig_id"]) {
34
                        if($pre != $resinfo["orig_id"]) {
34
                            $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
35
                            $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
35
                        }
36
                        }
36
                        $pre = $resinfo["orig_id"];
37
                        $pre = $resinfo["orig_id"];
37
                       
38
                       
38
                        $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
39
                        $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
39
                }
40
                }
40
41
        }
41
            if (count($_GET)>3){
42
            if (count($_GET)>3){
42
                $addsreps=array_values($_GET);
43
                $addsreps=array_values($_GET);
-
 
44
                if ($_GET['mainreps']=='no'){$offs=1;}else{$offs=0;} //пока такой костыль
43
                for ($i=3;$i<count($addsreps);$i++){
45
                for ($i=3;$i<count($addsreps)-$offs;$i++){
44
$pre=-1;
46
$pre=-1;
45
                   $id=(int)$addsreps[$i];
47
                   $id=(int)$addsreps[$i];
46
                    $sql =& $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 r.rep_id='.$id);
48
                    $sql =& $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 r.rep_id='.$id);
47
                    $sql->fetchInto($resinfo, DB_FETCHMODE_ASSOC);
49
                    $sql->fetchInto($resinfo, DB_FETCHMODE_ASSOC);
48
           
50
           
49
                    $repscheme = stripslashes($resinfo["scheme"]);
51
                    $repscheme = stripslashes($resinfo["scheme"]);
50
                    $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
52
                    $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
51
r.rep_id='$resinfo[rep_id]'");
53
r.rep_id='$resinfo[rep_id]'");
52
                    $sections = "";
54
                    $sections = "";
53
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
55
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
54
                                $sections .= stripslashes($section["sectname"])." ";
56
                                $sections .= stripslashes($section["sectname"])." ";
55
                        }
57
                        }
56
                    $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
58
                    $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
57
                    $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
59
                    $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
58
                    $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
60
                    $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
59
                    $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
61
                    $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
60
                    $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
62
                    $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
61
                    $repscheme = str_replace("{SECT}",$sections,$repscheme);
63
                    $repscheme = str_replace("{SECT}",$sections,$repscheme);
62
                    $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
64
                    $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
63
                    if($pre != $resinfo["orig_id"]) {
65
                    if($pre != $resinfo["orig_id"]) {
64
                        $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
66
                        $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
65
                    }
67
                    }
66
                    $pre = $resinfo["orig_id"];
68
                    $pre = $resinfo["orig_id"];
67
                    $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";                    
69
                    $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";                    
68
                }
70
                }
69
            }
71
            }
70
72
71
                return $result;
73
                return $result;
72
        }
74
        }
73
       
75
       
74
        function getInfo($message,$dblink){
76
        function getInfo($message,$dblink){
75
                $answer = array();
77
                $answer = array();
76
78
77
                if (preg_match("/linux/i",$message)) {
79
                if (preg_match("/linux/i",$message)) {
78
                        $dist_id = 0;
80
                        $dist_id = 0;
79
                        $dist_info = "";
81
                        $dist_info = "";
80
                        $vers_id = 0;
82
                        $vers_id = 0;
81
                        $vers_info = "";
83
                        $vers_info = "";
82
                        $qd =& $dblink->query("SELECT * FROM distribution");
84
                        $qd =& $dblink->query("SELECT * FROM distribution");
83
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
85
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
84
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
86
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
85
                                        $dist_id = $res["dist_id"];
87
                                        $dist_id = $res["dist_id"];
86
                                        $dist_info = stripslashes($res["distname"]);
88
                                        $dist_info = stripslashes($res["distname"]);
87
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
89
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
88
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
90
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
89
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
91
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
90
                                                        $vers_id = $rev["version_id"];
92
                                                        $vers_id = $rev["version_id"];
91
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
93
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
92
                                                }
94
                                                }
93
                                        }
95
                                        }
94
                                }
96
                                }
95
                        }
97
                        }
96
                        $answer[] = "Linux";
98
                        $answer[] = "Linux";
97
                        $answer[] = "Судя по всему у Вас операционная система ";
99
                        $answer[] = "Судя по всему у Вас операционная система ";
98
                        if ($dist_id!=0) {
100
                        if ($dist_id!=0) {
99
                                $answer[] = $dist_id;
101
                                $answer[] = $dist_id;
100
                                $answer[] = $dist_info;
102
                                $answer[] = $dist_info;
101
                        }
103
                        }
102
                        if ($vers_id!=0) {
104
                        if ($vers_id!=0) {
103
                                $answer[] = $vers_id;
105
                                $answer[] = $vers_id;
104
                                $answer[] = $vers_info;
106
                                $answer[] = $vers_info;
105
                        }
107
                        }
106
108
107
                } else {
109
                } else {
108
                        $answer[] = "unknown";
110
                        $answer[] = "unknown";
109
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
111
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
110
                }
112
                }
111
113
112
                return $answer;
114
                return $answer;
113
        }
115
        }
114
116
115
        function getInterfacesList($current,$dblink) {
117
        function getInterfacesList($current,$dblink) {
116
                $url  = parse_url($current);
118
                $url  = parse_url($current);
117
                $path = array();
119
                $path = array();
118
                $path = split("/",$url["path"]);
120
                $path = split("/",$url["path"]);
119
                $currentIF = str_replace(".php","",$path[count($path)-1]);
121
                $currentIF = str_replace(".php","",$path[count($path)-1]);
120
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
122
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
121
                $iflist = "<a href='./'>Интерфейсы</a>: ";
123
                $iflist = "<a href='./'>Интерфейсы</a>: ";
122
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
124
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
123
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
125
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
124
                }
126
                }
125
                $iflist = substr($iflist, 0, strlen($iflist)-2);
127
                $iflist = substr($iflist, 0, strlen($iflist)-2);
126
                return $iflist;
128
                return $iflist;
127
        }
129
        }
128
130
129
        function getCSSList($dblink) {
131
        function getCSSList($dblink) {
130
                $req =& $dblink->query("SELECT * FROM distribution");
132
                $req =& $dblink->query("SELECT * FROM distribution");
131
                if ($req->numRows()>0) {
133
                if ($req->numRows()>0) {
132
                        $css = "<style type=\"text/css\">\n";
134
                        $css = "<style type=\"text/css\">\n";
133
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
135
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
134
                                if ($dist["distlogo"]) {
136
                                if ($dist["distlogo"]) {
135
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
137
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
136
                                        $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";
138
                                        $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";
137
                                } else {
139
                                } else {
138
                                        $css .= "";
140
                                        $css .= "";
139
                                }
141
                                }
140
                        }
142
                        }
141
                        $css .= "</style>";
143
                        $css .= "</style>";
142
                } else {
144
                } else {
143
                        $css = "";
145
                        $css = "";
144
                }
146
                }
145
                return $css;
147
                return $css;
146
        }
148
        }
147
149
148
        function getSetting($setting, $dblink) {
150
        function getSetting($setting, $dblink) {
149
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
151
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
150
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
152
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
151
                return stripslashes($sett["optvalue"]);
153
                return stripslashes($sett["optvalue"]);
152
        }
154
        }
153
155
154
        function getUUID($param) {
156
        function getUUID($param) {
155
                $param_s = md5($param);
157
                $param_s = md5($param);
156
                $time_low = bin2hex(substr($param_s,0, 4));
158
                $time_low = bin2hex(substr($param_s,0, 4));
157
                $time_mid = bin2hex(substr($param_s,4, 2));
159
                $time_mid = bin2hex(substr($param_s,4, 2));
158
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
160
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
159
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
161
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
160
                $node = bin2hex(substr($param_s,10, 6));
162
                $node = bin2hex(substr($param_s,10, 6));
161
163
162
                $time_hi_and_version = hexdec($time_hi_and_version);
164
                $time_hi_and_version = hexdec($time_hi_and_version);
163
                $time_hi_and_version = $time_hi_and_version >> 4;
165
                $time_hi_and_version = $time_hi_and_version >> 4;
164
                $time_hi_and_version = $time_hi_and_version | 0x4000;
166
                $time_hi_and_version = $time_hi_and_version | 0x4000;
165
       
167
       
166
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
168
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
167
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
169
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
168
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
170
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
169
       
171
       
170
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
172
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
171
        }
173
        }
172
174
173
175
174
    function getAddsRepList($distro,$version,$dblink) {
176
    function getAddsRepList($distro,$version,$dblink) {
175
        $query =& $dblink->query("SELECT * FROM settings");
177
        $query =& $dblink->query("SELECT * FROM settings");
176
        $settings = array();
178
        $settings = array();
177
        while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
179
        while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
178
            $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
180
            $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
179
        };
181
        };
180
        $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'");
182
        $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'");
181
        $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
183
        $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
182
        $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' AND r.rtype_id=3 ORDER BY r.rtype_id, r.scheme_id ASC");
184
        $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' AND r.rtype_id=3 ORDER BY r.rtype_id, r.scheme_id ASC");
183
        $result.='<input type="hidden" name="d" value="'.$_GET['d'].'">
185
        $result.='<input type="hidden" name="d" value="'.$_GET['d'].'">
184
                  <input type="hidden" name="v" value="'.$_GET['v'].'">';
186
                  <input type="hidden" name="v" value="'.$_GET['v'].'">';
185
        $tmp=0;
187
        $tmp=0;
186
        while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
188
        while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
187
             $tmp++;
189
             $tmp++;
188
             $result.='<input type="checkbox" name="'.$tmp.'"  value="'.$resinfo['rep_id'].'">'.$resinfo['repname'].' <em>('.$resinfo['repdescribe'].')</em><br>';
190
             $result.='<input type="checkbox" name="'.$tmp.'"  value="'.$resinfo['rep_id'].'">'.$resinfo['repname'].' <em>('.$resinfo['repdescribe'].')</em><br>';
189
        }
191
        }
190
        return $result;
192
        return $result;
191
    }
193
    }
192
}    
194
}    
193
?>
195
?>
194
 
196