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