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