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