Хранилища Subversion ant

Редакция

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