Rev 14 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | daniel-mar | 1 | <?php |
2 | |||
14 | daniel-mar | 3 | if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgeführt werden.'); |
3 | daniel-mar | 4 | |
5 | ////////////////////////////////////////////////////////////////////////////// |
||
6 | // CODIERUNGSFUNKTIONEN // |
||
7 | ////////////////////////////////////////////////////////////////////////////// |
||
8 | |||
9 | function transamp_replace_spitze_klammern($inp) |
||
10 | { |
||
11 | $inp = str_replace('&', '&', $inp); |
||
12 | //$inp = str_replace('"', '"', $inp); |
||
13 | $inp = str_replace('<', '<', $inp); |
||
14 | $inp = str_replace('>', '>', $inp); |
||
15 | |||
16 | return $inp; |
||
17 | } |
||
18 | |||
19 | function undo_transamp_replace_spitze_klammern($inp) |
||
20 | { |
||
21 | $inp = str_replace('&', '&', $inp); |
||
22 | //$inp = str_replace('"', '"', $inp); |
||
23 | $inp = str_replace('<', '<', $inp); |
||
24 | $inp = str_replace('>', '>', $inp); |
||
25 | |||
26 | return $inp; |
||
27 | } |
||
28 | |||
29 | function ausfuehrbarer_html_code($inp) |
||
30 | { |
||
31 | // Wenn der Benutzer z.B. ä im HTML-Formular eingegeben hat, würde hier aufgrund von Unicode quatsch rauskommen |
||
32 | $inp = my_htmlentities($inp); |
||
33 | |||
34 | $inp = undo_transamp_replace_spitze_klammern($inp); |
||
35 | |||
36 | $trans = get_html_translation_table(HTML_ENTITIES); |
||
37 | foreach ($trans as $m1 => $m2) |
||
38 | { |
||
39 | if (($m2 != '<') && ($m2 != '>')) |
||
40 | $inp = str_replace(str_replace('&', '&', $m2), $m2, $inp); |
||
41 | } |
||
42 | unset($m1); |
||
43 | unset($m2); |
||
44 | |||
45 | // Erweiterte Zeichensatztabelle, die auch da Euro-Zeichen enthält |
||
46 | // Entnommen von http://www.php.net/manual/de/function.get-html-translation-table.php#73410 |
||
47 | $trans2 = array('''=>''', '−'=>'-', 'ˆ'=>'^', '˜'=>'~', 'Š'=>'Š', '‹'=>'‹', 'Œ'=>'Œ', '‘'=>'‘', '’'=>'’', '“'=>'“', '”'=>'”', '•'=>'•', '–'=>'–', '—'=>'—', '˜'=>'˜', '™'=>'™', 'š'=>'š', '›'=>'›', 'œ'=>'œ', 'Ÿ'=>'Ÿ', 'ÿ'=>'ÿ', 'Œ'=>'Œ', 'œ'=>'œ', 'Š'=>'Š', 'š'=>'š', 'Ÿ'=>'Ÿ', 'ƒ'=>'ƒ', 'ˆ'=>'ˆ', '˜'=>'˜', 'Α'=>'Α', 'Β'=>'Β', 'Γ'=>'Γ', 'Δ'=>'Δ', 'Ε'=>'Ε', 'Ζ'=>'Ζ', 'Η'=>'Η', 'Θ'=>'Θ', 'Ι'=>'Ι', 'Κ'=>'Κ', 'Λ'=>'Λ', 'Μ'=>'Μ', 'Ν'=>'Ν', 'Ξ'=>'Ξ', 'Ο'=>'Ο', 'Π'=>'Π', 'Ρ'=>'Ρ', 'Σ'=>'Σ', 'Τ'=>'Τ', 'Υ'=>'Υ', 'Φ'=>'Φ', 'Χ'=>'Χ', 'Ψ'=>'Ψ', 'Ω'=>'Ω', 'α'=>'α', 'β'=>'β', 'γ'=>'γ', 'δ'=>'δ', 'ε'=>'ε', 'ζ'=>'ζ', 'η'=>'η', 'θ'=>'θ', 'ι'=>'ι', 'κ'=>'κ', 'λ'=>'λ', 'μ'=>'μ', 'ν'=>'ν', 'ξ'=>'ξ', 'ο'=>'ο', 'π'=>'π', 'ρ'=>'ρ', 'ς'=>'ς', 'σ'=>'σ', 'τ'=>'τ', 'υ'=>'υ', 'φ'=>'φ', 'χ'=>'χ', 'ψ'=>'ψ', 'ω'=>'ω', 'ϑ'=>'ϑ', 'ϒ'=>'ϒ', 'ϖ'=>'ϖ', ' '=>' ', ' '=>' ', ' '=>' ', '‌'=>'‌', '‍'=>'‍', '‎'=>'‎', '‏'=>'‏', '–'=>'–', '—'=>'—', '‘'=>'‘', '’'=>'’', '‚'=>'‚', '“'=>'“', '”'=>'”', '„'=>'„', '†'=>'†', '‡'=>'‡', '•'=>'•', '…'=>'…', '‰'=>'‰', '′'=>'′', '″'=>'″', '‹'=>'‹', '›'=>'›', '‾'=>'‾', '⁄'=>'⁄', '€'=>'€', 'ℑ'=>'ℑ', '℘'=>'℘', 'ℜ'=>'ℜ', '™'=>'™', 'ℵ'=>'ℵ', '←'=>'←', '↑'=>'↑', '→'=>'→', '↓'=>'↓', '↔'=>'↔', '↵'=>'↵', '⇐'=>'⇐', '⇑'=>'⇑', '⇒'=>'⇒', '⇓'=>'⇓', '⇔'=>'⇔', '∀'=>'∀', '∂'=>'∂', '∃'=>'∃', '∅'=>'∅', '∇'=>'∇', '∈'=>'∈', '∉'=>'∉', '∋'=>'∋', '∏'=>'∏', '∑'=>'∑', '−'=>'−', '∗'=>'∗', '√'=>'√', '∝'=>'∝', '∞'=>'∞', '∠'=>'∠', '∧'=>'∧', '∨'=>'∨', '∩'=>'∩', '∪'=>'∪', '∫'=>'∫', '∴'=>'∴', '∼'=>'∼', '≅'=>'≅', '≈'=>'≈', '≠'=>'≠', '≡'=>'≡', '≤'=>'≤', '≥'=>'≥', '⊂'=>'⊂', '⊃'=>'⊃', '⊄'=>'⊄', '⊆'=>'⊆', '⊇'=>'⊇', '⊕'=>'⊕', '⊗'=>'⊗', '⊥'=>'⊥', '⋅'=>'⋅', '⌈'=>'⌈', '⌉'=>'⌉', '⌊'=>'⌊', '⌋'=>'⌋', '⟨'=>'〈', '⟩'=>'〉', '◊'=>'◊', '♠'=>'♠', '♣'=>'♣', '♥'=>'♥', '♦'=>'♦'); |
||
48 | $trans2 = array_flip($trans2); |
||
49 | foreach ($trans2 as $m1 => $m2) |
||
50 | { |
||
51 | // Funktioniert chr() bei den 8... Einträgen? Finde Eurozeichen nicht bei chr(8364)! |
||
52 | $m1 = chr(substr($m1, 2, strlen($m1)-3)); |
||
53 | |||
54 | if (($m2 != '<') && ($m2 != '>')) |
||
55 | $inp = str_replace(str_replace('&', '&', $m2), $m2, $inp); |
||
56 | } |
||
57 | unset($m1); |
||
58 | unset($m2); |
||
59 | |||
60 | return undo_transamp_replace_spitze_klammern($inp); |
||
61 | } |
||
62 | |||
63 | ////////////////////////////////////////////////////////////////////////////// |
||
64 | // VERSCHLÜSSELUNGSFUNKTIONEN FÜR SESSIONS U.A. // |
||
65 | ////////////////////////////////////////////////////////////////////////////// |
||
66 | |||
67 | function special_hash($string) |
||
68 | { |
||
69 | $iterations = 10; |
||
70 | |||
71 | $last = $string; |
||
72 | $out = ''; |
||
73 | for ($i=0; $i<$iterations; $i++) |
||
74 | { |
||
75 | $last = md5($last); |
||
76 | $out .= $last; |
||
77 | } |
||
78 | |||
79 | $garbarge_count = 0; |
||
80 | for ($i=0; $i<strlen($last); $i++) |
||
81 | { |
||
82 | if (($last[$i] == '0') || ($last[$i] == '1') || ($last[$i] == '2') || ($last[$i] == '3') || |
||
83 | ($last[$i] == '4') || ($last[$i] == '5') || ($last[$i] == '6') || ($last[$i] == '7') || |
||
84 | ($last[$i] == '8') || ($last[$i] == '9')) |
||
85 | { |
||
86 | $garbarge_count = $garbarge_count + $last[$i]; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | for ($i=0; $i<=$garbarge_count; $i++) |
||
91 | { |
||
92 | $out = $last[0].$out.$last[1]; |
||
93 | } |
||
94 | |||
95 | if (strlen($out) > 1024) $out = substr($out, 0, 1024); |
||
96 | |||
97 | return $out; |
||
98 | } |
||
99 | |||
100 | function get_rnd_iv($iv_len) |
||
101 | { |
||
102 | $iv = ''; |
||
103 | while ($iv_len-- > 0) { |
||
104 | $iv .= chr(mt_rand() & 0xff); |
||
105 | } |
||
106 | return $iv; |
||
107 | } |
||
108 | |||
109 | function md5_encrypt($plain_text, $password, $iv_len = 16) |
||
110 | { |
||
111 | $plain_text .= "\x13"; |
||
112 | $n = strlen($plain_text); |
||
113 | if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16)); |
||
114 | $i = 0; |
||
115 | $enc_text = get_rnd_iv($iv_len); |
||
116 | $iv = substr($password ^ $enc_text, 0, 512); |
||
117 | while ($i < $n) { |
||
118 | $block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv)); |
||
119 | $enc_text .= $block; |
||
120 | $iv = substr($block . $iv, 0, 512) ^ $password; |
||
121 | $i += 16; |
||
122 | } |
||
123 | return base64_encode($enc_text); |
||
124 | } |
||
125 | |||
126 | function md5_decrypt($enc_text, $password, $iv_len = 16) |
||
127 | { |
||
128 | $enc_text = base64_decode($enc_text); |
||
129 | $n = strlen($enc_text); |
||
130 | $i = $iv_len; |
||
131 | $plain_text = ''; |
||
132 | $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512); |
||
133 | while ($i < $n) { |
||
134 | $block = substr($enc_text, $i, 16); |
||
135 | $plain_text .= $block ^ pack('H*', md5($iv)); |
||
136 | $iv = substr($block . $iv, 0, 512) ^ $password; |
||
137 | $i += 16; |
||
138 | } |
||
139 | return preg_replace('/\\x13\\x00*$/', '', $plain_text); |
||
140 | } |
||
141 | |||
142 | function ib_encrypt($message, $key) |
||
143 | { |
||
144 | return md5_encrypt($message, $key); |
||
145 | } |
||
146 | |||
147 | function ib_decrypt($message, $key) |
||
148 | { |
||
149 | return md5_decrypt($message, $key); |
||
150 | } |
||
151 | |||
152 | ////////////////////////////////////////////////////////////////////////////// |
||
153 | // NÜTZLICHE FUNKTIONEN // |
||
154 | ////////////////////////////////////////////////////////////////////////////// |
||
155 | |||
156 | function dirname_with_pathdelimiter($directory) |
||
157 | { |
||
158 | $tmp = dirname($directory); |
||
159 | $tmp = str_replace('\\', '/', $tmp); |
||
160 | if (substr($tmp, strlen($tmp)-1, 1) != '/') $tmp .= '/'; |
||
161 | return $tmp; |
||
162 | } |
||
163 | |||
164 | function string2hex($str) |
||
165 | { |
||
166 | if (trim($str) != "") |
||
167 | { |
||
168 | $hex = ""; |
||
169 | $length = strlen($str); |
||
170 | for ($i=0; $i<$length; $i++) |
||
171 | { |
||
172 | $hex .= str_pad(dechex(ord($str[$i])), 2, 0, STR_PAD_LEFT); |
||
173 | } |
||
174 | return $hex; |
||
175 | } |
||
176 | } |
||
177 | |||
178 | function hex2string($hex) |
||
179 | { |
||
180 | $string = ''; |
||
181 | |||
182 | $hex = str_replace(array("\n","\r"," "), "", $hex); |
||
183 | |||
184 | for ($ix=0; $ix < strlen($hex); $ix=$ix+2) |
||
185 | { |
||
186 | $ord = hexdec(substr($hex, $ix, 2)); |
||
187 | $string .= chr($ord); |
||
188 | } |
||
189 | |||
190 | return $string; |
||
191 | } |
||
192 | |||
193 | // http://lists.phpbar.de/pipermail/php/Week-of-Mon-20040322/007749.html |
||
194 | |||
195 | function fetchip() |
||
196 | { |
||
197 | $client_ip = (isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : ''; |
||
198 | $x_forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; |
||
199 | $remote_addr = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : ''; |
||
200 | |||
201 | if (!empty($client_ip)) |
||
202 | { |
||
203 | $ip_expl = explode('.',$client_ip); |
||
204 | $referer = explode('.',$remote_addr); |
||
205 | if($referer[0] != $ip_expl[0]) |
||
206 | { |
||
207 | $ip=array_reverse($ip_expl); |
||
208 | $return=implode('.',$ip); |
||
209 | } |
||
210 | else |
||
211 | { |
||
212 | $return = $client_ip; |
||
213 | } |
||
214 | } |
||
215 | else if (!empty($x_forwarded_for)) |
||
216 | { |
||
217 | if(strstr($x_forwarded_for,',')) |
||
218 | { |
||
219 | $ip_expl = explode(',',$x_forwarded_for); |
||
220 | $return = end($ip_expl); |
||
221 | } |
||
222 | else |
||
223 | { |
||
224 | $return = $x_forwarded_for; |
||
225 | } |
||
226 | } |
||
227 | else |
||
228 | { |
||
229 | $return = $remote_addr; |
||
230 | } |
||
231 | unset ($client_ip, $x_forwarded_for, $remote_addr, $ip_expl); |
||
232 | return $return; |
||
233 | } |
||
234 | |||
235 | // http://de.php.net/manual/de/function.fsockopen.php#73581 |
||
236 | // http://de.php.net/manual/de/function.fsockopen.php#75175 |
||
237 | |||
238 | function decode_header ( $str ) |
||
239 | { |
||
240 | $part = preg_split ( "/\r?\n/", $str, -1, PREG_SPLIT_NO_EMPTY ); |
||
241 | $out = array (); |
||
242 | |||
243 | for ( $h = 0; $h < sizeof ( $part ); $h++ ) |
||
244 | { |
||
245 | if ( $h != 0 ) |
||
246 | { |
||
247 | $pos = strpos ( $part[$h], ':' ); |
||
248 | $k = strtolower ( str_replace ( ' ', '', substr ( $part[$h], 0, $pos ) ) ); |
||
249 | $v = trim ( substr ( $part[$h], ( $pos + 1 ) ) ); |
||
250 | } |
||
251 | else |
||
252 | { |
||
253 | $k = 'status'; |
||
254 | $v = explode ( ' ', $part[$h] ); |
||
255 | $v = $v[1]; |
||
256 | } |
||
257 | |||
258 | if ($k == '') break; // Zusatz von Personal WebBase |
||
259 | |||
260 | if ( $k == 'set-cookie' ) |
||
261 | { |
||
262 | $out['cookies'][] = $v; |
||
263 | } |
||
264 | else if ( $k == 'content-type' ) |
||
265 | { |
||
266 | if ( ( $cs = strpos ( $v, ';' ) ) !== false ) |
||
267 | { |
||
268 | $out[$k] = substr ( $v, 0, $cs ); |
||
269 | } |
||
270 | else |
||
271 | { |
||
272 | $out[$k] = $v; |
||
273 | } |
||
274 | } |
||
275 | else |
||
276 | { |
||
277 | $out[$k] = $v; |
||
278 | } |
||
279 | } |
||
280 | |||
281 | return $out; |
||
282 | } |
||
283 | |||
284 | function decode_body ( $info, $str, $eol = "\r\n" ) |
||
285 | { |
||
286 | $tmp = $str; |
||
287 | $add = strlen ( $eol ); |
||
288 | $str = ''; |
||
289 | if ( isset ( $info['transfer-encoding'] ) && $info['transfer-encoding'] == 'chunked' ) |
||
290 | { |
||
291 | do |
||
292 | { |
||
293 | $tmp = ltrim ( $tmp ); |
||
294 | $pos = strpos ( $tmp, $eol ); |
||
295 | $len = hexdec ( substr ( $tmp, 0, $pos ) ); |
||
296 | if ( isset ( $info['content-encoding'] ) ) |
||
297 | { |
||
298 | $str .= gzinflate ( substr ( $tmp, ( $pos + $add + 10 ), $len ) ); |
||
299 | } |
||
300 | else |
||
301 | { |
||
302 | $str .= substr ( $tmp, ( $pos + $add ), $len ); |
||
303 | } |
||
304 | |||
305 | $tmp = substr ( $tmp, ( $len + $pos + $add ) ); |
||
306 | $check = trim ( $tmp ); |
||
307 | } |
||
308 | while ( ! empty ( $check ) ); |
||
309 | } |
||
310 | else if ( isset ( $info['content-encoding'] ) ) |
||
311 | { |
||
312 | $str = gzinflate ( substr ( $tmp, 10 ) ); |
||
313 | } |
||
314 | else { |
||
315 | $str = $tmp; |
||
316 | } |
||
317 | return $str; |
||
318 | } |
||
319 | |||
320 | function url_protokoll_vorhanden($url) |
||
321 | { |
||
322 | $ary = explode('://', $url); |
||
323 | return ((strpos($ary[0], '/') === false) && (isset($ary[1]))); |
||
324 | } |
||
325 | |||
326 | function my_get_contents($url, $show_errors = false, $ignore_status_code = false, $time_out = 10, $umleitung_limit = 50, $umleitung_count = 0) |
||
327 | { |
||
328 | if (!url_protokoll_vorhanden($url)) $url = 'http://'.$url; |
||
329 | |||
330 | if (!inetconn_ok()) |
||
331 | { |
||
332 | if ($show_errors) |
||
333 | { |
||
334 | echo '<b>Fehler:</b> my_get_contents('.$url.'): Es existiert keine Internetverbindung.<br>'; |
||
335 | } |
||
336 | return false; |
||
337 | } |
||
338 | |||
339 | // Jetzt reichts abba... |
||
340 | if ($umleitung_count > $umleitung_limit) |
||
341 | { |
||
342 | if ($show_errors) |
||
343 | { |
||
344 | echo '<b>Fehler:</b> my_get_contents('.$url.'): Umleitungslimit von 50 erreicht.<br>'; |
||
345 | } |
||
346 | return false; |
||
347 | } |
||
348 | |||
349 | // URL splitten |
||
350 | $ary = explode('://', $url); |
||
351 | $cry = explode('/', $ary[1]); |
||
352 | $bry = explode(':', $cry[0]); |
||
353 | |||
354 | // Host festlegen |
||
355 | $ssl = ''; |
||
356 | $host = $bry[0]; |
||
357 | |||
358 | // Port festlegen und ggf. SSL-Präfix setzen |
||
359 | if (isset($bry[1])) |
||
360 | { |
||
361 | $port = $bry[1]; |
||
362 | } |
||
363 | else |
||
364 | { |
||
365 | if ($ary[0] == 'ftp') |
||
366 | { |
||
367 | $port = 21; |
||
368 | } |
||
369 | if ($ary[0] == 'http') |
||
370 | { |
||
371 | $port = 80; |
||
372 | } |
||
373 | else if ($ary[0] == 'https') |
||
374 | { |
||
375 | $ssl = 'ssl://'; |
||
376 | $port = 443; |
||
377 | } |
||
378 | else |
||
379 | { |
||
380 | $port = 80; // Problem |
||
381 | } |
||
382 | } |
||
383 | |||
384 | // Request-String festlegen |
||
385 | $req = ''; |
||
386 | for ($i=1; isset($cry[$i]); $i++) |
||
387 | { |
||
388 | $req .= '/'.$cry[$i]; |
||
389 | } |
||
390 | if ($req == '') $req = '/'; |
||
391 | |||
392 | // User-Agent = Personal WebBase |
||
393 | $revision = '???'; |
||
394 | if (file_exists('includes/rev.inc.php')) include('includes/rev.inc.php'); |
||
395 | $uagent = 'ViaThinkSoft-Personal WebBase/'.$revision; |
||
396 | |||
397 | // Anfrage starten |
||
398 | $fp = @fsockopen($ssl.$host, $port, $errno, $errstr, $time_out); |
||
399 | if (!$fp) |
||
400 | { |
||
401 | if ($show_errors) |
||
402 | { |
||
403 | echo '<b>Fehler:</b> my_get_contents('.$url.'): Fehler beim öffnen des Sockets - '.$errstr.' ('.$errno.')<br>'; |
||
404 | } |
||
405 | return false; |
||
406 | } |
||
407 | else |
||
408 | { |
||
409 | $tmp = ''; |
||
410 | @fputs ($fp, "GET $req HTTP/1.1\r\nHost: $host\r\nConnection: close\r\nUser-Agent: $uagent\r\n\r\n"); |
||
411 | while (!@feof($fp)) |
||
412 | { |
||
413 | $tmp .= @fgets($fp,128); |
||
414 | } |
||
415 | @fclose($fp); |
||
416 | |||
417 | $info = decode_header($tmp); |
||
418 | |||
419 | // Fehler? |
||
420 | if ((!$ignore_status_code) && (isset($info['status'])) && ($info['status'] >= 400)) |
||
421 | { |
||
422 | if ($show_errors) |
||
423 | { |
||
424 | echo '<b>Fehler:</b> my_get_contents('.$url.'): HTTP-Status-Code '.$info['status'].'<br>'; |
||
425 | } |
||
426 | return false; |
||
427 | } |
||
428 | |||
429 | // Umleitung vorhanden? |
||
430 | if ((isset($info['location'])) && ($info['location'] != '')) |
||
431 | { |
||
432 | if (strpos($info['location'], '://') !== false) |
||
433 | { |
||
434 | // 1. Fall: http://www.example.com/test.php |
||
435 | |||
436 | return my_get_contents($info['location'], $show_errors, $ignore_status_code, $time_out, $umleitung_limit, $umleitung_count+1); |
||
437 | } |
||
438 | else if (substr($info['location'], 0, 2) == './') |
||
439 | { |
||
440 | // 2. Fall: ./test.php |
||
441 | |||
442 | if (substr($req, strlen($req)-1, 1) != '/') |
||
443 | { |
||
444 | // Entweder ein Verzeichnis ohne / am Ende oder eine Datei |
||
445 | // Letztes Element muss abgeschnitten werden |
||
446 | $x = ''; |
||
447 | $gry = explode('/', $req); |
||
448 | for ($j=1; isset($gry[$j+1]); $j++) |
||
449 | { |
||
450 | $x .= '/'.$gry[$j]; |
||
451 | } |
||
452 | $x .= '/'; |
||
453 | } |
||
454 | else |
||
455 | { |
||
456 | $x = $req; |
||
457 | } |
||
458 | $x .= substr($info['location'], 2, strlen($info['location'])-2); |
||
459 | |||
460 | return my_get_contents($ary[0].'://'.$host.$x, $show_errors, $ignore_status_code, $time_out, $umleitung_limit, $umleitung_count+1); |
||
461 | } |
||
462 | else if (substr($info['location'], 0, 1) == '/') |
||
463 | { |
||
464 | // 3. Fall: /test.php |
||
465 | |||
466 | $x = $info['location']; |
||
467 | |||
468 | return my_get_contents($ary[0].'://'.$host.$x, $show_errors, $ignore_status_code, $time_out, $umleitung_limit, $umleitung_count+1); |
||
469 | } |
||
470 | else |
||
471 | { |
||
472 | // 4. Fall: test.php (= ./test.php) |
||
473 | |||
474 | $x = $req; |
||
475 | if (substr($req, strlen($req)-1, 1) != '/') |
||
476 | { |
||
477 | // Entweder ein Verzeichnis ohne / am Ende oder eine Datei |
||
478 | // Letztes Element muss abgeschnitten werden |
||
479 | $x = ''; |
||
480 | $gry = explode('/', $req); |
||
481 | for ($j=1; isset($gry[$j+1]); $j++) |
||
482 | { |
||
483 | $x .= '/'.$gry[$j]; |
||
484 | } |
||
485 | $x .= '/'; |
||
486 | } |
||
487 | else |
||
488 | { |
||
489 | $x = $req; |
||
490 | } |
||
491 | $x .= $info['location']; |
||
492 | |||
493 | return my_get_contents($ary[0].'://'.$host.$x, $show_errors, $ignore_status_code, $time_out, $umleitung_limit, $umleitung_count+1); |
||
494 | } |
||
495 | } |
||
496 | |||
497 | // Content filtern |
||
498 | $con = explode("\r\n\r\n", $tmp); |
||
499 | $tmp = ''; |
||
500 | for ($i=1; isset($con[$i]); $i++) |
||
501 | { |
||
8 | daniel-mar | 502 | $tmp .= $con[$i]; |
3 | daniel-mar | 503 | if (isset($con[$i+1])) $tmp .= "\r\n\r\n"; |
504 | } |
||
505 | |||
506 | return decode_body ( $info, $tmp ); |
||
507 | } |
||
508 | } |
||
509 | |||
510 | function my_htmlentities($inp, $charset = 'iso-8859-1') |
||
511 | { |
||
512 | // http://www.php.net/manual/de/function.htmlspecialchars.php |
||
513 | // PHP-Version wird nicht kontrolliert... |
||
514 | $cs = 'utf-8'; |
||
515 | |||
516 | if (strtolower($charset) == 'iso-8859-1') $cs = 'ISO-8859-1'; |
||
517 | if (strtolower($charset) == 'iso8859-1') $cs = 'ISO-8859-1'; |
||
518 | if (strtolower($charset) == 'iso-8859-15') $cs = 'ISO-8859-15'; |
||
519 | if (strtolower($charset) == 'iso8859-15') $cs = 'ISO-8859-15'; |
||
520 | if (strtolower($charset) == 'utf-8') $cs = 'UTF-8'; |
||
521 | if (strtolower($charset) == 'cp866') $cs = 'cp866'; |
||
522 | if (strtolower($charset) == 'ibm866') $cs = 'cp866'; |
||
523 | if (strtolower($charset) == '866') $cs = 'cp866'; |
||
524 | if (strtolower($charset) == 'cp1251') $cs = 'cp1251'; |
||
525 | if (strtolower($charset) == 'windows-1251') $cs = 'cp1251'; |
||
526 | if (strtolower($charset) == 'win-1251') $cs = 'cp1251'; |
||
527 | if (strtolower($charset) == '1251') $cs = 'cp1251'; |
||
528 | if (strtolower($charset) == 'cp1252') $cs = 'cp1252'; |
||
529 | if (strtolower($charset) == 'windows-1252') $cs = 'cp1252'; |
||
530 | if (strtolower($charset) == '1252') $cs = 'cp1252'; |
||
531 | if (strtolower($charset) == 'koi8-r') $cs = 'KOI8-R'; |
||
532 | if (strtolower($charset) == 'koi8-ru') $cs = 'KOI8-R'; |
||
533 | if (strtolower($charset) == 'koi8r') $cs = 'KOI8-R'; |
||
534 | if (strtolower($charset) == 'big5') $cs = 'BIG5'; |
||
535 | if (strtolower($charset) == '950') $cs = 'BIG5'; |
||
536 | if (strtolower($charset) == 'gb2312') $cs = 'GB2312'; |
||
537 | if (strtolower($charset) == '936') $cs = 'GB2312'; |
||
538 | if (strtolower($charset) == 'big5-hkscs') $cs = 'BIG5-HKSCS'; |
||
539 | if (strtolower($charset) == 'shift_jis') $cs = 'Shift_JIS'; |
||
540 | if (strtolower($charset) == 'sjis') $cs = 'Shift_JIS'; |
||
541 | if (strtolower($charset) == '932') $cs = 'Shift_JIS'; |
||
542 | if (strtolower($charset) == 'euc-jp') $cs = 'EUC-JP'; |
||
543 | if (strtolower($charset) == 'eucjp') $cs = 'EUC-JP'; |
||
544 | |||
545 | return @htmlentities($inp, ENT_NOQUOTES, $cs); |
||
546 | } |
||
547 | |||
548 | function check_email($email_adresse) |
||
549 | { |
||
550 | return preg_match("/^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$/",$email_adresse); |
||
551 | } |
||
552 | |||
553 | function return_bytes($val) |
||
554 | { |
||
555 | $val = trim($val); |
||
556 | if (is_numeric($val)) return $val; |
||
557 | $last = strtolower($val[strlen($val)-1]); |
||
558 | $val = substr($val,0,strlen($val)-1); |
||
559 | switch($last) |
||
560 | { |
||
561 | case 'g': |
||
562 | $val *= 1024; |
||
563 | /* ... falls through ... */ |
||
564 | case 'm': |
||
565 | $val *= 1024; |
||
566 | /* ... falls through ... */ |
||
567 | case 'k': |
||
568 | $val *= 1024; |
||
569 | /* ... falls through ... */ |
||
570 | } |
||
571 | return $val; |
||
572 | } |
||
573 | |||
574 | function zufall($size) |
||
575 | { |
||
576 | $result = ""; |
||
577 | |||
578 | srand((double)microtime()*1000000); |
||
579 | |||
580 | for($i=0; $i < $size; $i++) |
||
581 | { |
||
582 | $num = rand(48,120); |
||
583 | while (($num >= 58 && $num <= 64) || ($num >= 91 && $num <= 96)) |
||
584 | $num = rand(48,120); |
||
585 | |||
586 | $result .= chr($num); |
||
587 | } |
||
588 | return $result; |
||
589 | } |
||
590 | |||
591 | function runden($inp, $nachkommastellen = 0) |
||
592 | { |
||
593 | return number_format($inp, $nachkommastellen, ",", "."); |
||
594 | } |
||
595 | |||
8 | daniel-mar | 596 | // PHP-AntiSpam-Funktion "secure_email", Version 3.0 |
597 | // von Daniel Marschall [www.daniel-marschall.de] |
||
598 | |||
599 | function secure_email($email, $linktext, $crypt_linktext) |
||
600 | { |
||
601 | if (!function_exists('alas_js_crypt')) |
||
602 | { |
||
603 | function alas_js_crypt($text) |
||
604 | { |
||
605 | $tmp = ''; |
||
606 | for ($i=0; $i<strlen($text); $i++) |
||
607 | { |
||
608 | $tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
||
609 | } |
||
610 | return $tmp; |
||
611 | } |
||
612 | } |
||
613 | |||
614 | if (!function_exists('alas_js_write')) |
||
615 | { |
||
616 | function alas_js_write($text) |
||
617 | { |
||
618 | $text = str_replace('\\', '\\\\', $text); |
||
619 | $text = str_replace('"', '\"', $text); |
||
620 | return 'document.write("'.$text.'");'; |
||
621 | } |
||
622 | } |
||
623 | |||
624 | $aus = ''; |
||
625 | if ($email != '') |
||
626 | { |
||
627 | $aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
||
628 | $aus .= alas_js_write('<a href="'); |
||
629 | $aus .= alas_js_crypt('mailto:'.$email); |
||
630 | $aus .= alas_js_write('">'); |
||
631 | $aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext); |
||
632 | $aus .= alas_js_write('</a>').'// --></script>'; |
||
633 | } |
||
634 | return $aus; |
||
3 | daniel-mar | 635 | } |
636 | |||
637 | function de_convertmysqldatetime($datum, $zeige_sekunden = false) |
||
638 | { |
||
639 | if (($datum == '') || ($datum == '0000-00-00 00:00:00')) |
||
640 | { |
||
641 | return 'Unbekannt'; |
||
642 | } |
||
643 | else |
||
644 | { |
||
645 | |||
646 | $date = explode(" ", $datum); |
||
647 | $ddatum = explode("-", $date[0]); |
||
648 | if (isset($date[1])) |
||
649 | { |
||
650 | $date = explode(":", $date[1]); |
||
651 | } |
||
652 | else |
||
653 | { |
||
654 | $date[0] = ''; |
||
655 | $date[1] = ''; |
||
656 | $date[2] = ''; |
||
657 | } |
||
658 | |||
659 | |||
660 | if ($ddatum[1] == '01') $mon = 'Januar'; |
||
661 | if ($ddatum[1] == '02') $mon = 'Februar'; |
||
662 | if ($ddatum[1] == '03') $mon = 'März'; |
||
663 | if ($ddatum[1] == '04') $mon = 'April'; |
||
664 | if ($ddatum[1] == '05') $mon = 'Mai'; |
||
665 | if ($ddatum[1] == '06') $mon = 'Juni'; |
||
666 | if ($ddatum[1] == '07') $mon = 'Juli'; |
||
667 | if ($ddatum[1] == '08') $mon = 'August'; |
||
668 | if ($ddatum[1] == '09') $mon = 'September'; |
||
669 | if ($ddatum[1] == '10') $mon = 'Oktober'; |
||
670 | if ($ddatum[1] == '11') $mon = 'November'; |
||
671 | if ($ddatum[1] == '12') $mon = 'Dezember'; |
||
672 | $tag = sprintf("%d",$ddatum[2]); |
||
673 | $datum = $tag.". ".$mon." ".$ddatum[0]; |
||
674 | |||
675 | if (($date[0] != '') && ($date[1] != '')) |
||
676 | { |
||
677 | if ($zeige_sekunden) $zus = ':'.$date[2]; else $zus = ''; |
||
678 | return $datum.', '.$date[0].':'.$date[1].$zus.' Uhr'; |
||
679 | } |
||
680 | else |
||
681 | return $datum; |
||
682 | } |
||
683 | } |
||
684 | |||
685 | function zwischen_url($url, $von, $bis, $flankierungen_miteinbeziehen = true) |
||
686 | { |
||
687 | return zwischen_str(my_get_contents($url), $von, $bis, $flankierungen_miteinbeziehen); |
||
688 | } |
||
689 | |||
690 | function zwischen_str($str, $von, $bis, $flankierungen_miteinbeziehen = true) |
||
691 | { |
||
692 | $ausgabe = $str; |
||
693 | |||
694 | if ($von != '') |
||
695 | { |
||
696 | $pos = strpos($ausgabe, $von); |
||
697 | if ($pos !== false) |
||
698 | { |
||
699 | $ausgabe = substr($ausgabe, $pos, strlen($ausgabe)-$pos); |
||
700 | if (!$flankierungen_miteinbeziehen) |
||
701 | $ausgabe = substr($ausgabe, strlen($von), strlen($ausgabe)-strlen($von)-1); // -1 ? |
||
702 | } |
||
703 | } |
||
704 | |||
705 | if ($bis != '') |
||
706 | { |
||
707 | $pos = strpos($ausgabe, $bis); |
||
708 | if ($pos !== false) |
||
709 | { |
||
710 | $ausgabe = substr($ausgabe, 0, $pos+strlen($bis)); |
||
711 | if (!$flankierungen_miteinbeziehen) |
||
712 | $ausgabe = substr($ausgabe, 0, strlen($ausgabe)-strlen($bis)); |
||
713 | } |
||
714 | } |
||
715 | |||
716 | return $ausgabe; |
||
717 | } |
||
718 | |||
719 | ////////////////////////////////////////////////////////////////////////////// |
||
720 | // GFX/LISTE/OOP-FUNKTIONEN // |
||
721 | ////////////////////////////////////////////////////////////////////////////// |
||
722 | |||
723 | function oop_link_to_modul($modul, $seite = 'inhalt', $titelzeile_modul = '') |
||
724 | { |
||
725 | $titel = $modul; |
||
726 | |||
727 | $modulueberschrift = ''; |
||
728 | $modulsekpos = ''; |
||
729 | $modulpos = ''; |
||
730 | $modulrechte = ''; |
||
731 | $autor = ''; |
||
732 | $version = ''; |
||
733 | $menuevisible = ''; |
||
734 | $license = ''; |
||
735 | $deaktiviere_zugangspruefung = 0; |
||
736 | |||
737 | if ($titelzeile_modul == '') $titelzeile_modul = $modul; |
||
738 | |||
8 | daniel-mar | 739 | if (file_exists('modules/'.wb_dir_escape($titelzeile_modul).'/var.inc.php')) |
3 | daniel-mar | 740 | { |
8 | daniel-mar | 741 | include('modules/'.wb_dir_escape($titelzeile_modul).'/var.inc.php'); |
3 | daniel-mar | 742 | $titel = $modulueberschrift; |
743 | } |
||
744 | |||
8 | daniel-mar | 745 | if (file_exists('modules/'.wb_dir_escape($titelzeile_modul).'/images/menu/32.png')) |
746 | $g = 'modules/'.wb_dir_escape($titelzeile_modul).'/images/menu/32.png'; |
||
747 | else if (file_exists('modules/'.wb_dir_escape($titelzeile_modul).'/images/menu/32.gif')) |
||
748 | $g = 'modules/'.wb_dir_escape($titelzeile_modul).'/images/menu/32.gif'; |
||
3 | daniel-mar | 749 | else |
750 | $g = 'design/spacer.gif'; |
||
751 | |||
752 | return "javascript:oop('".$modul."', '".$seite."', '".my_htmlentities($titel)."', '".$g."');"; |
||
753 | } |
||
754 | |||
755 | function liste_items($modul, $table, $append, $dir = 0) |
||
756 | { |
||
757 | global $benutzer; |
||
758 | |||
759 | if (!isset($erg)) $erg = array(); |
||
760 | |||
761 | $i = 0; |
||
762 | $res = db_query("SELECT * FROM `$table` WHERE `folder` = '".db_escape($dir)."' AND `user` = '".$benutzer['id']."' $append"); |
||
763 | while ($row = db_fetch($res)) |
||
764 | { |
||
765 | $i++; |
||
766 | $erg[$i] = $row; |
||
767 | } |
||
768 | |||
769 | return $erg; |
||
770 | } |
||
771 | |||
772 | function liste_items_filter($modul, $table, $append) |
||
773 | { |
||
774 | $i = 0; |
||
775 | |||
776 | $res = db_query("SELECT * FROM `$table` $append"); |
||
777 | while ($row = db_fetch($res)) |
||
778 | { |
||
779 | $i++; |
||
780 | $erg[$i] = $row; |
||
781 | } |
||
782 | |||
783 | return $erg; |
||
784 | } |
||
785 | |||
15 | daniel-mar | 786 | function wb_draw_table_begin() |
3 | daniel-mar | 787 | { |
788 | echo '<div align="center"><table cellspacing="0" cellpadding="2" border="0" width="90%">'; |
||
789 | } |
||
790 | |||
15 | daniel-mar | 791 | function wb_draw_table_end() |
3 | daniel-mar | 792 | { |
793 | echo '</table></div><br>'; |
||
794 | } |
||
795 | |||
15 | daniel-mar | 796 | function wb_draw_table_content() |
3 | daniel-mar | 797 | { |
798 | echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">'; |
||
799 | $j = 0; |
||
800 | for ($i=0; $i < @func_num_args(); $i=$i+2) |
||
801 | { |
||
802 | $j++; |
||
803 | if (@func_get_arg($i) != '') |
||
804 | $w = 'width="'.@func_get_arg($i).'" '; |
||
805 | else |
||
806 | $w = ''; |
||
807 | echo '<td valign="top" align="left" '.$w.'>'.@func_get_arg($i+1).'</td>'; |
||
808 | } |
||
809 | if ($j == 0) |
||
810 | echo '<td valign="top" align="left" width="100%"> </td>'; |
||
811 | echo '</tr>'."\n"; |
||
812 | } |
||
813 | |||
814 | function gfx_tablespancontent($highlight, $span, $text) |
||
815 | { |
||
816 | if ($highlight == 1) $hfarb = '4'; |
||
817 | if ($highlight == 0) $hfarb = '5'; |
||
818 | if ($highlight == 2) $hfarb = '6'; |
||
819 | echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">'; |
||
820 | echo '<td valign="top" align="left" colspan="'.$span.'">'.$text.'</td>'; |
||
821 | echo '</tr>'; |
||
822 | |||
823 | } |
||
824 | |||
825 | function gfx_zeichneitems_filter($modul, $table, $append) |
||
826 | { |
||
827 | global $ordnereinzug, $mysql_zugangsdaten; |
||
828 | |||
829 | $einzug = 0; |
||
830 | $ary = liste_items_filter($modul, $table, $append); |
||
831 | $durchlauf = 0; |
||
832 | for ($i=1; isset($ary[$i]['id']); $i++) |
||
833 | { |
||
834 | $durchlauf++; |
||
835 | |||
8 | daniel-mar | 836 | if (file_exists('modules/'.wb_dir_escape($modul).'/menueeintrag.inc.php')) |
837 | include('modules/'.wb_dir_escape($modul).'/menueeintrag.inc.php'); |
||
3 | daniel-mar | 838 | |
839 | echo "\n"; |
||
840 | } |
||
841 | |||
842 | return $durchlauf; |
||
843 | } |
||
844 | |||
845 | function gfx_zeichneitems($modul, $table, $append, $folder = 0, $einzug = 0) |
||
846 | { |
||
847 | global $ordnereinzug, $mysql_zugangsdaten; |
||
848 | |||
849 | $ary = liste_items($modul, $table, $append, $folder); |
||
850 | $durchlauf = 0; |
||
851 | for ($i=1; isset($ary[$i]['id']); $i++) |
||
852 | { |
||
853 | $durchlauf++; |
||
854 | |||
8 | daniel-mar | 855 | if (file_exists('modules/'.wb_dir_escape($modul).'/menueeintrag.inc.php')) |
856 | include('modules/'.wb_dir_escape($modul).'/menueeintrag.inc.php'); |
||
3 | daniel-mar | 857 | } |
858 | |||
859 | return $durchlauf; |
||
860 | } |
||
861 | |||
862 | function gfx_zeichnemenuepunkt($modul, $seite, $titel, $klein, $gross) |
||
863 | { |
||
864 | if (file_exists($gross)) |
||
865 | $g = $gross; |
||
866 | else |
||
867 | $g = 'design/spacer.gif'; |
||
868 | |||
869 | if (file_exists($klein)) |
||
870 | $k = $klein; |
||
871 | else |
||
872 | $k = 'design/spacer.gif'; |
||
873 | |||
874 | return '<tr class="row_nav" onmouseover="this.className=\'row_nav_act\';" onmouseout="this.className=\'row_nav\';"> |
||
875 | <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="design/spacer.gif" height="1" width="3" alt=""></td> |
||
876 | <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="'.$k.'" height="16" width="16" alt=""></td> |
||
877 | <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="design/spacer.gif" height="1" width="5" alt=""></td> |
||
878 | <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left" width="100%"><a href="javascript:oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" class="menu_blk">'.$titel.'</a></td> |
||
879 | <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="design/spacer.gif" alt="" width="1" height="1"></td> |
||
880 | </tr>'."\n"; |
||
881 | } |
||
882 | |||
883 | function gfx_zeichnemenueplatzhalter() |
||
884 | { |
||
885 | return '<tr> |
||
886 | <td colspan="5"><img src="design/spacer.gif" alt="" width="1" height="14"></td> |
||
887 | </tr>'; |
||
888 | } |
||
889 | |||
8 | daniel-mar | 890 | function wb_dir_escape($s) { |
891 | $s = str_replace('..', '__', $s); |
||
892 | $s = str_replace('~', '_', $s); |
||
893 | $s = str_replace('/', '_', $s); |
||
894 | $s = str_replace('\\', '_', $s); |
||
895 | $s = str_replace(chr(0), '_', $s); |
||
896 | return $s; |
||
897 | } |