Хранилища Subversion ant

Редакция

Редакция 138 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
41 alex-w 1
<?php
2
 
3
class Core {
59 alex-w 4
 
5
        function getRepList($distro,$version,$dblink) {
6
                $query =& $dblink->query("SELECT * FROM settings");
7
                $settings = array();
8
                while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
9
                        $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
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'");
12
                $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
190 diffor 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");
14
                $pre=-1;
59 alex-w 15
                while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
16
                        $repscheme = stripslashes($resinfo["scheme"]);
190 diffor 17
 
59 alex-w 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]'");
20
                        $sections = "";
91 alex-w 21
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
59 alex-w 22
                                $sections .= stripslashes($section["sectname"])." ";
23
                        }
24
 
25
                        $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
26
                        $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
27
                        $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
28
                        $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
29
                        $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
30
                        $repscheme = str_replace("{SECT}",$sections,$repscheme);
91 alex-w 31
                        $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
190 diffor 32
 
33
                        if($pre != $resinfo["orig_id"]) {
34
                            $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
35
                        }
36
                        $pre = $resinfo["orig_id"];
37
 
59 alex-w 38
                        $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";
39
                }
40
                return $result;
41
        }
42
 
62 alex-w 43
        function getInfo($message,$dblink){
44
                $answer = array();
45
 
41 alex-w 46
                if (preg_match("/linux/i",$message)) {
62 alex-w 47
                        $dist_id = 0;
48
                        $dist_info = "";
63 alex-w 49
                        $vers_id = 0;
50
                        $vers_info = "";
62 alex-w 51
                        $qd =& $dblink->query("SELECT * FROM distribution");
52
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
53
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
54
                                        $dist_id = $res["dist_id"];
55
                                        $dist_info = stripslashes($res["distname"]);
56
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
57
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
63 alex-w 58
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
59
                                                        $vers_id = $rev["version_id"];
60
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
61
                                                }
62 alex-w 62
                                        }
63
                                }
64
                        }
65
                        $answer[] = "Linux";
66
                        $answer[] = "Судя по всему у Вас операционная система ";
67
                        if ($dist_id!=0) {
68
                                $answer[] = $dist_id;
69
                                $answer[] = $dist_info;
70
                        }
71
                        if ($vers_id!=0) {
72
                                $answer[] = $vers_id;
73
                                $answer[] = $vers_info;
74
                        }
75
 
41 alex-w 76
                } else {
62 alex-w 77
                        $answer[] = "unknown";
78
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
41 alex-w 79
                }
62 alex-w 80
 
42 alex-w 81
                return $answer;
82
        }
70 alex-w 83
 
84
        function getInterfacesList($current,$dblink) {
85
                $url  = parse_url($current);
86
                $path = array();
87
                $path = split("/",$url["path"]);
88
                $currentIF = str_replace(".php","",$path[count($path)-1]);
89
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
74 alex-w 90
                $iflist = "<a href='./'>Интерфейсы</a>: ";
70 alex-w 91
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
92
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
93
                }
94
                $iflist = substr($iflist, 0, strlen($iflist)-2);
95
                return $iflist;
96
        }
79 alex-w 97
 
98
        function getCSSList($dblink) {
99
                $req =& $dblink->query("SELECT * FROM distribution");
100
                if ($req->numRows()>0) {
83 alex-w 101
                        $css = "<style type=\"text/css\">\n";
79 alex-w 102
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
103
                                if ($dist["distlogo"]) {
83 alex-w 104
                                        $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";
79 alex-w 106
                                } else {
107
                                        $css .= "";
108
                                }
109
                        }
83 alex-w 110
                        $css .= "</style>";
79 alex-w 111
                } else {
112
                        $css = "";
113
                }
114
                return $css;
115
        }
132 alex-w 116
 
133 alex-w 117
        function getSetting($setting, $dblink) {
132 alex-w 118
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
119
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
120
                return stripslashes($sett["optvalue"]);
121
        }
138 alex-w 122
 
123
        function getUUID($param) {
124
                $param_s = md5($param);
125
                $time_low = bin2hex(substr($param_s,0, 4));
126
                $time_mid = bin2hex(substr($param_s,4, 2));
127
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
128
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
129
                $node = bin2hex(substr($param_s,10, 6));
130
 
131
                $time_hi_and_version = hexdec($time_hi_and_version);
132
                $time_hi_and_version = $time_hi_and_version >> 4;
133
                $time_hi_and_version = $time_hi_and_version | 0x4000;
134
 
135
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
136
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
137
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
138
 
139
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
140
        }
41 alex-w 141
}
142
 
143
?>