Редакция 132 | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 132 | Редакция 133 | ||
---|---|---|---|
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 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 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"); |
14 | while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) { |
14 | while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) { |
15 | $repscheme = stripslashes($resinfo["scheme"]); |
15 | $repscheme = stripslashes($resinfo["scheme"]); |
16 | 16 | ||
17 | $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE |
17 | $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE |
18 | r.rep_id='$resinfo[rep_id]'"); |
18 | r.rep_id='$resinfo[rep_id]'"); |
19 | $sections = ""; |
19 | $sections = ""; |
20 | while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) { |
20 | while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) { |
21 | $sections .= stripslashes($section["sectname"])." "; |
21 | $sections .= stripslashes($section["sectname"])." "; |
22 | }
|
22 | }
|
23 | 23 | ||
24 | $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme); |
24 | $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme); |
25 | $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme); |
25 | $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme); |
26 | $repscheme = str_replace("{URL}",$settings["url"],$repscheme); |
26 | $repscheme = str_replace("{URL}",$settings["url"],$repscheme); |
27 | $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme); |
27 | $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme); |
28 | $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme); |
28 | $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme); |
29 | $repscheme = str_replace("{SECT}",$sections,$repscheme); |
29 | $repscheme = str_replace("{SECT}",$sections,$repscheme); |
30 | $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme); |
30 | $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme); |
31 | 31 | ||
32 | $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n"; |
32 | $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n"; |
33 | }
|
33 | }
|
34 | return $result; |
34 | return $result; |
35 | }
|
35 | }
|
36 | 36 | ||
37 | function getInfo($message,$dblink){ |
37 | function getInfo($message,$dblink){ |
38 | $answer = array(); |
38 | $answer = array(); |
39 | 39 | ||
40 | if (preg_match("/linux/i",$message)) { |
40 | if (preg_match("/linux/i",$message)) { |
41 | $dist_id = 0; |
41 | $dist_id = 0; |
42 | $dist_info = ""; |
42 | $dist_info = ""; |
43 | $vers_id = 0; |
43 | $vers_id = 0; |
44 | $vers_info = ""; |
44 | $vers_info = ""; |
45 | $qd =& $dblink->query("SELECT * FROM distribution"); |
45 | $qd =& $dblink->query("SELECT * FROM distribution"); |
46 | while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) { |
46 | while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) { |
47 | if (preg_match("/".stripslashes($res["distua"])."/i",$message)) { |
47 | if (preg_match("/".stripslashes($res["distua"])."/i",$message)) { |
48 | $dist_id = $res["dist_id"]; |
48 | $dist_id = $res["dist_id"]; |
49 | $dist_info = stripslashes($res["distname"]); |
49 | $dist_info = stripslashes($res["distname"]); |
50 | $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'"); |
50 | $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'"); |
51 | while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) { |
51 | while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) { |
52 | if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) { |
52 | if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) { |
53 | $vers_id = $rev["version_id"]; |
53 | $vers_id = $rev["version_id"]; |
54 | $vers_info = stripslashes($rev["version"])." “".stripslashes($rev["vname"])."”"; |
54 | $vers_info = stripslashes($rev["version"])." “".stripslashes($rev["vname"])."”"; |
55 | }
|
55 | }
|
56 | }
|
56 | }
|
57 | }
|
57 | }
|
58 | }
|
58 | }
|
59 | $answer[] = "Linux"; |
59 | $answer[] = "Linux"; |
60 | $answer[] = "Судя по всему у Вас операционная система "; |
60 | $answer[] = "Судя по всему у Вас операционная система "; |
61 | if ($dist_id!=0) { |
61 | if ($dist_id!=0) { |
62 | $answer[] = $dist_id; |
62 | $answer[] = $dist_id; |
63 | $answer[] = $dist_info; |
63 | $answer[] = $dist_info; |
64 | }
|
64 | }
|
65 | if ($vers_id!=0) { |
65 | if ($vers_id!=0) { |
66 | $answer[] = $vers_id; |
66 | $answer[] = $vers_id; |
67 | $answer[] = $vers_info; |
67 | $answer[] = $vers_info; |
68 | }
|
68 | }
|
69 | 69 | ||
70 | } else { |
70 | } else { |
71 | $answer[] = "unknown"; |
71 | $answer[] = "unknown"; |
72 | $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!"; |
72 | $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!"; |
73 | }
|
73 | }
|
74 | 74 | ||
75 | return $answer; |
75 | return $answer; |
76 | }
|
76 | }
|
77 | 77 | ||
78 | function getInterfacesList($current,$dblink) { |
78 | function getInterfacesList($current,$dblink) { |
79 | $url = parse_url($current); |
79 | $url = parse_url($current); |
80 | $path = array(); |
80 | $path = array(); |
81 | $path = split("/",$url["path"]); |
81 | $path = split("/",$url["path"]); |
82 | $currentIF = str_replace(".php","",$path[count($path)-1]); |
82 | $currentIF = str_replace(".php","",$path[count($path)-1]); |
83 | $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'"); |
83 | $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'"); |
84 | $iflist = "<a href='./'>Интерфейсы</a>: "; |
84 | $iflist = "<a href='./'>Интерфейсы</a>: "; |
85 | while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) { |
85 | while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) { |
86 | $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, "; |
86 | $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, "; |
87 | }
|
87 | }
|
88 | $iflist = substr($iflist, 0, strlen($iflist)-2); |
88 | $iflist = substr($iflist, 0, strlen($iflist)-2); |
89 | return $iflist; |
89 | return $iflist; |
90 | }
|
90 | }
|
91 | 91 | ||
92 | function getCSSList($dblink) { |
92 | function getCSSList($dblink) { |
93 | $req =& $dblink->query("SELECT * FROM distribution"); |
93 | $req =& $dblink->query("SELECT * FROM distribution"); |
94 | if ($req->numRows()>0) { |
94 | if ($req->numRows()>0) { |
95 | $css = "<style type=\"text/css\">\n"; |
95 | $css = "<style type=\"text/css\">\n"; |
96 | while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) { |
96 | while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) { |
97 | if ($dist["distlogo"]) { |
97 | if ($dist["distlogo"]) { |
98 | $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n"; |
98 | $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n"; |
99 | $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"; |
99 | $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"; |
100 | } else { |
100 | } else { |
101 | $css .= ""; |
101 | $css .= ""; |
102 | }
|
102 | }
|
103 | }
|
103 | }
|
104 | $css .= "</style>"; |
104 | $css .= "</style>"; |
105 | } else { |
105 | } else { |
106 | $css = ""; |
106 | $css = ""; |
107 | }
|
107 | }
|
108 | return $css; |
108 | return $css; |
109 | }
|
109 | }
|
110 | 110 | ||
111 | function getSettings($setting, $dblink) { |
111 | function getSetting($setting, $dblink) { |
112 | $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'"); |
112 | $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'"); |
113 | $query->fetchInto($sett, DB_FETCHMODE_ASSOC); |
113 | $query->fetchInto($sett, DB_FETCHMODE_ASSOC); |
114 | return stripslashes($sett["optvalue"]); |
114 | return stripslashes($sett["optvalue"]); |
115 | }
|
115 | }
|
116 | }
|
116 | }
|
117 | 117 | ||
118 | ?>
|
118 | ?>
|
119 | 119 |