Хранилища Subversion ant

Редакция

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

Редакция Автор № строки Строка
41 alex-w 1
<?php
2
 
198 alex-w 3
/**
4
 * Project:     Ant: sources.list generator
5
 * File:        core.php
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 *
21
 */
22
 
23
 
41 alex-w 24
class Core {
59 alex-w 25
 
26
        function getRepList($distro,$version,$dblink) {
201 diffor 27
                // Fetch settings
59 alex-w 28
                $query =& $dblink->query("SELECT * FROM settings");
29
                $settings = array();
30
                while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
31
                        $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
32
                };
201 diffor 33
                // Fetch information about distribution
34
                $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'");
35
                $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
36
                // Fetch repos
37
                $repos=array_values($_GET);
196 sivan 38
                for ($i=3;$i<count($repos);$i++){
39
$pre=-1; //wtf?
40
                   $id=(int)$repos[$i];
201 diffor 41
                    $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);
192 sivan 42
                    $sql->fetchInto($resinfo, DB_FETCHMODE_ASSOC);
43
 
44
                    $repscheme = stripslashes($resinfo["scheme"]);
201 diffor 45
                    $querysect =& $dblink->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$resinfo[rep_id]'");
192 sivan 46
                    $sections = "";
47
                        while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) {
48
                                $sections .= stripslashes($section["sectname"])." ";
49
                        }
50
                    $repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme);
51
                    $repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme);
52
                    $repscheme = str_replace("{URL}",$settings["url"],$repscheme);
53
                    $repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme);
54
                    $repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme);
55
                    $repscheme = str_replace("{SECT}",$sections,$repscheme);
56
                    $repscheme = str_replace("{ROOT}",stripslashes($resinfo["root_folder"]),$repscheme);
57
                    if($pre != $resinfo["orig_id"]) {
58
                        $result .= "### ".$resinfo["origin"]."( ".$resinfo["desk"]." ) - ".$resinfo["homeurl"]." ###\n";
59
                    }
60
                    $pre = $resinfo["orig_id"];
61
                    $result .= "# ".stripslashes($resinfo["repdescribe"])."\n".$repscheme."\n\n";                    
62
                }
196 sivan 63
                return $result;
59 alex-w 64
        }
65
 
62 alex-w 66
        function getInfo($message,$dblink){
67
                $answer = array();
68
 
41 alex-w 69
                if (preg_match("/linux/i",$message)) {
62 alex-w 70
                        $dist_id = 0;
71
                        $dist_info = "";
63 alex-w 72
                        $vers_id = 0;
73
                        $vers_info = "";
62 alex-w 74
                        $qd =& $dblink->query("SELECT * FROM distribution");
75
                        while ($qd->fetchInto($res, DB_FETCHMODE_ASSOC)) {
76
                                if (preg_match("/".stripslashes($res["distua"])."/i",$message)) {
77
                                        $dist_id = $res["dist_id"];
78
                                        $dist_info = stripslashes($res["distname"]);
79
                                        $qv =& $dblink->query("SELECT * FROM version WHERE dist_id='$dist_id'");
80
                                        while($qv->fetchInto($rev, DB_FETCHMODE_ASSOC)) {
63 alex-w 81
                                                if (preg_match("/".stripslashes($rev["vcodename"])."/i",$message)) {
82
                                                        $vers_id = $rev["version_id"];
83
                                                        $vers_info = stripslashes($rev["version"])." &#8220;".stripslashes($rev["vname"])."&#8221;";
84
                                                }
62 alex-w 85
                                        }
86
                                }
87
                        }
88
                        $answer[] = "Linux";
89
                        $answer[] = "Судя по всему у Вас операционная система ";
90
                        if ($dist_id!=0) {
91
                                $answer[] = $dist_id;
92
                                $answer[] = $dist_info;
93
                        }
94
                        if ($vers_id!=0) {
95
                                $answer[] = $vers_id;
96
                                $answer[] = $vers_info;
97
                        }
98
 
41 alex-w 99
                } else {
62 alex-w 100
                        $answer[] = "unknown";
101
                        $answer[] = "Ресурс рассчитан явно не на Вашу операционную систему!";
41 alex-w 102
                }
62 alex-w 103
 
42 alex-w 104
                return $answer;
105
        }
70 alex-w 106
 
107
        function getInterfacesList($current,$dblink) {
108
                $url  = parse_url($current);
109
                $path = array();
110
                $path = split("/",$url["path"]);
111
                $currentIF = str_replace(".php","",$path[count($path)-1]);
112
                $req =& $dblink->query("SELECT * FROM interfaces WHERE interface NOT LIKE '$currentIF'");
74 alex-w 113
                $iflist = "<a href='./'>Интерфейсы</a>: ";
70 alex-w 114
                while ($req->fetchInto($if, DB_FETCHMODE_ASSOC)) {
115
                        $iflist .= "<a href='./".stripslashes($if["interface"]).".php'>".strtolower(stripslashes($if["interfaceinfo"]))."</a>, ";
116
                }
117
                $iflist = substr($iflist, 0, strlen($iflist)-2);
118
                return $iflist;
119
        }
79 alex-w 120
 
121
        function getCSSList($dblink) {
122
                $req =& $dblink->query("SELECT * FROM distribution");
123
                if ($req->numRows()>0) {
83 alex-w 124
                        $css = "<style type=\"text/css\">\n";
79 alex-w 125
                        while ($req->fetchInto($dist, DB_FETCHMODE_ASSOC)) {
126
                                if ($dist["distlogo"]) {
83 alex-w 127
                                        $css .= ".".stripslashes($dist["distua"])." { display: inline; padding-left: 15px; background: transparent url(./img/logo/".stripslashes($dist["distua"]).".png) top left no-repeat; }\n";
128
                                        $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 129
                                } else {
130
                                        $css .= "";
131
                                }
132
                        }
83 alex-w 133
                        $css .= "</style>";
79 alex-w 134
                } else {
135
                        $css = "";
136
                }
137
                return $css;
138
        }
132 alex-w 139
 
133 alex-w 140
        function getSetting($setting, $dblink) {
132 alex-w 141
                $query =& $dblink->query("SELECT * FROM settings WHERE opt LIKE '".$setting."'");
142
                $query->fetchInto($sett, DB_FETCHMODE_ASSOC);
143
                return stripslashes($sett["optvalue"]);
144
        }
138 alex-w 145
 
146
        function getUUID($param) {
147
                $param_s = md5($param);
148
                $time_low = bin2hex(substr($param_s,0, 4));
149
                $time_mid = bin2hex(substr($param_s,4, 2));
150
                $time_hi_and_version = bin2hex(substr($param_s,6, 2));
151
                $clock_seq_hi_and_reserved = bin2hex(substr($param_s,8, 2));
152
                $node = bin2hex(substr($param_s,10, 6));
153
 
154
                $time_hi_and_version = hexdec($time_hi_and_version);
155
                $time_hi_and_version = $time_hi_and_version >> 4;
156
                $time_hi_and_version = $time_hi_and_version | 0x4000;
157
 
158
                $clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
159
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
160
                $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
161
 
162
                return sprintf('%08s-%04s-%04x-%04x-%012s',$time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
163
        }
41 alex-w 164
 
192 sivan 165
 
166
    function getAddsRepList($distro,$version,$dblink) {
167
        $query =& $dblink->query("SELECT * FROM settings");
168
        $settings = array();
169
        while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) {
170
            $settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]);
171
        };
172
        $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'");
173
        $query->fetchInto($infodist, DB_FETCHMODE_ASSOC);
196 sivan 174
        $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");
193 sivan 175
        $result.='<input type="hidden" name="d" value="'.$_GET['d'].'">
176
                  <input type="hidden" name="v" value="'.$_GET['v'].'">';
192 sivan 177
        $tmp=0;
178
        while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) {
179
             $tmp++;
196 sivan 180
             if ($resinfo['rtype_id']!=3){$ch='checked';}else{$ch='';}
181
             $result.='<input type="checkbox" name="'.$tmp.'" '.$ch.' value="'.$resinfo['rep_id'].'">'.$resinfo['repname'].' <em>('.$resinfo['repdescribe'].')</em><br>';
192 sivan 182
        }
183
        return $result;
184
    }
185
}    
41 alex-w 186
?>