Хранилища Subversion ant

Редакция

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

Редакция 202 Редакция 203
1
<?php
1
<?php
2
2
3
/**
3
/**
4
 * Project:     Ant: sources.list generator
4
 * Project:     Ant: sources.list generator
5
 * File:        core.php
5
 * File:        core.php
6
 *
6
 *
7
 * This library is free software; you can redistribute it and/or
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
11
 *
12
 * This library is distributed in the hope that it will be useful,
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
15
 * Lesser General Public License for more details.
16
 *
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 *
20
 *
21
 */
21
 */
22
22
23
23
24
class Core {
24
class Core {
25
25
26
        function getRepList($distro,$version,$dblink) {
26
        function getRepList($distro,$version,$dblink) {
27
                // Fetch settings
27
                // Fetch settings
28
                $query =& $dblink->query("SELECT * FROM settings");
28
                $query =& $dblink->query("SELECT * FROM settings");
29
                $settings = array();
29
                $settings = array();
30
                while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
30
                while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
31
                    $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
31
                    $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
32
                };
32
                };
33
                // Fetch info about distribution
33
                // Fetch info about distribution
34
                $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'");
34
                $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'");
35
                $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
35
                $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
36
                // Fetch repos
36
                // Fetch repos
37
                $repos=array_values($_GET);
37
                $repos=$_GET["r"];
38
                $porigid = -1; // Previous origin id
38
                $porigid = -1; // Previous origin id
-
 
39
               
39
                for ($i=3;$i<count($repos);$i++){
40
                for($i=0;$i<count($repos);$i++) {
40
                    $id=(int)$repos[$i];
41
                    $id=$_GET["r"][$i];
41
                    // Fetch info about origin and scheme
42
                    // Fetch info about origin and scheme
42
                    $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);
43
                    $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);
43
                    $sql->fetchInto($resinfo, DB_FETCHMODE_ASSOC);
44
                    $sql->fetchInto($resinfo, DB_FETCHMODE_ASSOC);
44
                    $repscheme = stripslashes($resinfo["scheme"]);
45
                    $repscheme = stripslashes($resinfo["scheme"]);
45
                    // Fetch info about sections
46
                    // Fetch info about sections
46
                    $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$resinfo[rep_id]'");
47
                    $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$resinfo[rep_id]'");
47
                    $sections = "";
48
                    $sections = "";
48
                    while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
49
                    while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
49
                        $sections .= stripslashes($section["sectname"])." ";
50
                        $sections .= stripslashes($section["sectname"])." ";
50
                    }
51
                    }
51
                    // Conversion scheme
52
                    // Conversion scheme
52
                    $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
53
                    $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
53
                    $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
54
                    $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
54
                    $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
55
                    $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
55
                    $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
56
                    $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
56
                    $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
57
                    $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
57
                    $repscheme = str_replace("{SECT}",$sections,$repscheme);
58
                    $repscheme = str_replace("{SECT}",$sections,$repscheme);
58
                    $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
59
                    $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
59
                    // Comment if another origin
60
                    // Comment if another origin
60
                    if($porigid != $resinfo["orig_id"]) {
61
                    if($porigid != $resinfo["orig_id"]) {
61
                        $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
62
                        $result .= "### ".$resinfo["origin"]." ( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
62
                    }
63
                    }
63
                    $porigid = $resinfo["orig_id"];
64
                    $porigid = $resinfo["orig_id"];
64
                    // Result
65
                    // Result
65
                    $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
66
                    $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
66
                }
67
                }
67
                return $result;
68
                return $result;
68
        }
69
        }
69
       
70
       
70
        function getInfo($message,$dblink){
71
        function getInfo($message,$dblink){
71
                $answer = array();
72
                $answer = array();
72
73
73
                if (preg_match("/linux/i",$message)) {
74
                if (preg_match("/linux/i",$message)) {
74
                        $dist_id = 0;
75
                        $dist_id = 0;
75
                        $dist_info = "";
76
                        $dist_info = "";
76
                        $vers_id = 0;
77
                        $vers_id = 0;
77
                        $vers_info = "";
78
                        $vers_info = "";
78
                        $qd =& $dblink->query("SELECT * FROM distribution");
79
                        $qd =& $dblink->query("SELECT * FROM distribution");
79
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
80
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
80
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
81
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
81
                                        $dist_id = $res["dist_id"];
82
                                        $dist_id = $res["dist_id"];
82
                                        $dist_info = stripslashes($res["distname"]);
83
                                        $dist_info = stripslashes($res["distname"]);
83
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
84
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
84
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
85
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
85
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
86
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
86
                                                        $vers_id = $rev["version_id"];
87
                                                        $vers_id = $rev["version_id"];
87
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
88
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
88
                                                }
89
                                                }
89
                                        }
90
                                        }
90
                                }
91
                                }
91
                        }
92
                        }
92
                        $answer[] = "Linux";
93
                        $answer[] = "Linux";
93
                        $answer[] = "Судя по всему у Вас операционная система ";
94
                        $answer[] = "Судя по всему у Вас операционная система ";
94
                        if ($dist_id!=0) {
95
                        if ($dist_id!=0) {
95
                                $answer[] = $dist_id;
96
                                $answer[] = $dist_id;
96
                                $answer[] = $dist_info;
97
                                $answer[] = $dist_info;
97
                        }
98
                        }
98
                        if ($vers_id!=0) {
99
                        if ($vers_id!=0) {
99
                                $answer[] = $vers_id;
100
                                $answer[] = $vers_id;
100
                                $answer[] = $vers_info;
101
                                $answer[] = $vers_info;
101
                        }
102
                        }
102
103
103
                } else {
104
                } else {
104
                        $answer[] = "unknown";
105
                        $answer[] = "unknown";
105
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
106
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
106
                }
107
                }
107
108
108
                return $answer;
109
                return $answer;
109
        }
110
        }
110
111
111
        function getInterfacesList($current,$dblink) {
112
        function getInterfacesList($current,$dblink) {
112
                $url  = parse_url($current);
113
                $url  = parse_url($current);
113
                $path = array();
114
                $path = array();
114
                $path = split("/",$url["path"]);
115
                $path = split("/",$url["path"]);
115
                $currentIF = str_replace(".php","",$path[count($path)-1]);
116
                $currentIF = str_replace(".php","",$path[count($path)-1]);
116
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
117
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
117
                $iflist = "<a href='./'>Интерфейсы</a>: ";
118
                $iflist = "<a href='./'>Интерфейсы</a>: ";
118
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
119
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
119
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
120
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
120
                }
121
                }
121
                $iflist = substr($iflist, 0, strlen($iflist)-2);
122
                $iflist = substr($iflist, 0, strlen($iflist)-2);
122
                return $iflist;
123
                return $iflist;
123
        }
124
        }
124
125
125
        function getCSSList($dblink) {
126
        function getCSSList($dblink) {
126
                $req =& $dblink->query("SELECT * FROM distribution");
127
                $req =& $dblink->query("SELECT * FROM distribution");
127
                if ($req->numRows()>0) {
128
                if ($req->numRows()>0) {
128
                        $css = "<style type=\"text/css\">\n";
129
                        $css = "<style type=\"text/css\">\n";
129
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
130
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
130
                                if ($dist["distlogo"]) {
131
                                if ($dist["distlogo"]) {
131
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
132
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
132
                                        $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";
133
                                        $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";
133
                                } else {
134
                                } else {
134
                                        $css .= "";
135
                                        $css .= "";
135
                                }
136
                                }
136
                        }
137
                        }
137
                        $css .= "</style>";
138
                        $css .= "</style>";
138
                } else {
139
                } else {
139
                        $css = "";
140
                        $css = "";
140
                }
141
                }
141
                return $css;
142
                return $css;
142
        }
143
        }
143
144
144
        function getSetting($setting, $dblink) {
145
        function getSetting($setting, $dblink) {
145
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
146
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
146
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
147
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
147
                return stripslashes($sett["optvalue"]);
148
                return stripslashes($sett["optvalue"]);
148
        }
149
        }
149
150
150
        function getUUID($param) {
151
        function getUUID($param) {
151
                $param_s = md5($param);
152
                $param_s = md5($param);
152
                $time_low = bin2hex(substr($param_s,0, 4));
153
                $time_low = bin2hex(substr($param_s,0, 4));
153
                $time_mid = bin2hex(substr($param_s,4, 2));
154
                $time_mid = bin2hex(substr($param_s,4, 2));
154
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
155
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
155
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
156
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
156
                $node = bin2hex(substr($param_s,10, 6));
157
                $node = bin2hex(substr($param_s,10, 6));
157
158
158
                $time_hi_and_version = hexdec($time_hi_and_version);
159
                $time_hi_and_version = hexdec($time_hi_and_version);
159
                $time_hi_and_version = $time_hi_and_version >> 4;
160
                $time_hi_and_version = $time_hi_and_version >> 4;
160
                $time_hi_and_version = $time_hi_and_version | 0x4000;
161
                $time_hi_and_version = $time_hi_and_version | 0x4000;
161
       
162
       
162
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
163
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
163
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
164
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
164
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
165
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
165
       
166
       
166
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
167
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
167
        }
168
        }
168
169
169
170
170
    function getAddsRepList($distro,$version,$dblink) {
171
    function getAddsRepList($distro,$version,$dblink) {
171
        $query =& $dblink->query("SELECT * FROM settings");
172
        $query =& $dblink->query("SELECT * FROM settings");
172
        $settings = array();
173
        $settings = array();
173
        while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
174
        while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
174
            $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
175
            $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
175
        };
176
        };
176
        $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'");
177
        $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'");
177
        $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
-
 
178
        $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");
178
        $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
179
        $result.='<input type="hidden" name="d" value="'.$_GET['d'].'">
179
        $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");
180
                  <input type="hidden" name="v" value="'.$_GET['v'].'">';
180
        $result.="<input type='hidden' name='d' value='".$_GET["d"]."'><input type='hidden' name='v' value='".$_GET["v"]."'>";
181
        $tmp=0;
181
        $tmp=0;
182
        while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
182
        while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
183
             $tmp++;
183
             $tmp++;
184
             if ($resinfo['rtype_id']!=3){$ch='checked';}else{$ch='';}
184
             if ($resinfo["rtype_id"]!=3){$ch="checked";} else{$ch="";} // Default reps hack, replace in future
185
             $result.='<input type="checkbox" name="'.$tmp.'" '.$ch.' value="'.$resinfo['rep_id'].'">'.$resinfo['repname'].' <em>('.$resinfo['repdescribe'].')</em><br>';
185
             $result.="<input type='checkbox' name='r[]' ".$ch." value='".$resinfo["rep_id"]."'>".$resinfo["repname"]." <em>(".$resinfo["repdescribe"].")</em><br>";
186
        }
186
        }
187
        return $result;
187
        return $result;
188
    }
188
    }
189
}    
189
}
190
?>
190
?>
191
 
191