Хранилища Subversion ant

Редакция

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

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