Редакция 91 | К новейшей редакции | Авторство | Сравнить с предыдущей | Последнее изменение | Открыть журнал | Скачать | RSS
<?php
class Core {
function getRepList($distro,$version,$dblink) {
$query =& $dblink->query("SELECT * FROM settings");
$settings = array();
while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
$settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
};
$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'");
$query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
$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");
while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
$repscheme = stripslashes($resinfo["scheme"]);
$querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE
r.rep_id='$resinfo[rep_id]'");
$sections = "";
while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
$sections .= stripslashes($section["sectname"])." ";
}
$repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
$repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
$repscheme = str_replace("{URL}",$settings["url"],$repscheme);
$repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
$repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
$repscheme = str_replace("{SECT}",$sections,$repscheme);
$repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
$result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
}
return $result;
}
function getInfo($message,$dblink){
$answer = array();
if (preg_match("/linux/i",$message)) {
$dist_id = 0;
$dist_info = "";
$vers_id = 0;
$vers_info = "";
$qd =& $dblink->query("SELECT * FROM distribution");
while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
$dist_id = $res["dist_id"];
$dist_info = stripslashes($res["distname"]);
$qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
$vers_id = $rev["version_id"];
$vers_info = stripslashes($rev["version"])." “".stripslashes($rev["vname"])."”";
}
}
}
}
$answer[] = "Linux";
$answer[] = "Судя по всему у Вас операционная система ";
if ($dist_id!=0) {
$answer[] = $dist_id;
$answer[] = $dist_info;
}
if ($vers_id!=0) {
$answer[] = $vers_id;
$answer[] = $vers_info;
}
} else {
$answer[] = "unknown";
$answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
}
return $answer;
}
function getInterfacesList($current,$dblink) {
$url = parse_url($current);
$path = array();
$path = split("/",$url["path"]);
$currentIF = str_replace(".php","",$path[count($path)-1]);
$req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
$iflist = "<a href='./'>Интерфейсы</a>: ";
while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
$iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
}
$iflist = substr($iflist, 0, strlen($iflist)-2);
return $iflist;
}
function getCSSList($dblink) {
$req =& $dblink->query("SELECT * FROM distribution");
if ($req->numRows()>0) {
$css = "<style type=\"text/css\">\n";
while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
if ($dist["distlogo"]) {
$css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
$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";
} else {
$css .= "";
}
}
$css .= "</style>";
} else {
$css = "";
}
return $css;
}
function getSettings($setting, $dblink) {
$query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
$query->fetchInto($sett, DB_FETCHMODE_ASSOC);
return stripslashes($sett["optvalue"]);
}
}
?>