Хранилища Subversion ant

Редакция

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