Subversion Repositories personal-webbase

Rev

Rev 1 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 daniel-mar 1
<?php
2
 
3
if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgef&uuml;hrt werden.');
4
 
5
//////////////////////////////////////////////////////////////////////////////
6
// CODIERUNGSFUNKTIONEN                                                     //
7
//////////////////////////////////////////////////////////////////////////////
8
 
9
function encode_critical_html_characters($inp)
10
{
11
        $inp = str_replace('&', '&amp;', $inp);
12
        //$inp = str_replace('"', '&quot;', $inp);
13
        $inp = str_replace('<', '&lt;', $inp);
14
        $inp = str_replace('>', '&gt;', $inp);
15
 
16
        return $inp;
17
}
18
 
19
function decode_critical_html_characters($inp)
20
{
21
        $inp = str_replace('&amp;', '&', $inp);
22
        //$inp = str_replace('&quot;', '"', $inp);
23
        $inp = str_replace('&lt;', '<', $inp);
24
        $inp = str_replace('&gt;', '>', $inp);
25
 
26
        return $inp;
27
}
28
 
29
function executable_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 = htmlentities($inp, ENT_COMPAT, 'UTF-8');
33
 
34
        $inp = decode_critical_html_characters($inp);
35
 
36
        $trans = get_html_translation_table(HTML_ENTITIES);
37
        foreach ($trans as $m1 => $m2)
38
        {
39
                if (($m2 != '&lt;') && ($m2 != '&gt;'))
40
                {
41
                        $inp = str_replace(str_replace('&', '&amp;', $m2), $m2, $inp);
42
                }
43
        }
44
        unset($m1);
45
        unset($m2);
46
 
47
        // Erweiterte Zeichensatztabelle, die auch da Euro-Zeichen enthält
48
        // Entnommen von http://www.php.net/manual/de/function.get-html-translation-table.php#73410
49
        $trans2 = array('&apos;'=>'&#39;', '&minus;'=>'&#45;', '&circ;'=>'&#94;', '&tilde;'=>'&#126;', '&Scaron;'=>'&#138;', '&lsaquo;'=>'&#139;', '&OElig;'=>'&#140;', '&lsquo;'=>'&#145;', '&rsquo;'=>'&#146;', '&ldquo;'=>'&#147;', '&rdquo;'=>'&#148;', '&bull;'=>'&#149;', '&ndash;'=>'&#150;', '&mdash;'=>'&#151;', '&tilde;'=>'&#152;', '&trade;'=>'&#153;', '&scaron;'=>'&#154;', '&rsaquo;'=>'&#155;', '&oelig;'=>'&#156;', '&Yuml;'=>'&#159;', '&yuml;'=>'&#255;', '&OElig;'=>'&#338;', '&oelig;'=>'&#339;', '&Scaron;'=>'&#352;', '&scaron;'=>'&#353;', '&Yuml;'=>'&#376;', '&fnof;'=>'&#402;', '&circ;'=>'&#710;', '&tilde;'=>'&#732;', '&Alpha;'=>'&#913;', '&Beta;'=>'&#914;', '&Gamma;'=>'&#915;', '&Delta;'=>'&#916;', '&Epsilon;'=>'&#917;', '&Zeta;'=>'&#918;', '&Eta;'=>'&#919;', '&Theta;'=>'&#920;', '&Iota;'=>'&#921;', '&Kappa;'=>'&#922;', '&Lambda;'=>'&#923;', '&Mu;'=>'&#924;', '&Nu;'=>'&#925;', '&Xi;'=>'&#926;', '&Omicron;'=>'&#927;', '&Pi;'=>'&#928;', '&Rho;'=>'&#929;', '&Sigma;'=>'&#931;', '&Tau;'=>'&#932;', '&Upsilon;'=>'&#933;', '&Phi;'=>'&#934;', '&Chi;'=>'&#935;', '&Psi;'=>'&#936;', '&Omega;'=>'&#937;', '&alpha;'=>'&#945;', '&beta;'=>'&#946;', '&gamma;'=>'&#947;', '&delta;'=>'&#948;', '&epsilon;'=>'&#949;', '&zeta;'=>'&#950;', '&eta;'=>'&#951;', '&theta;'=>'&#952;', '&iota;'=>'&#953;', '&kappa;'=>'&#954;', '&lambda;'=>'&#955;', '&mu;'=>'&#956;', '&nu;'=>'&#957;', '&xi;'=>'&#958;', '&omicron;'=>'&#959;', '&pi;'=>'&#960;', '&rho;'=>'&#961;', '&sigmaf;'=>'&#962;', '&sigma;'=>'&#963;', '&tau;'=>'&#964;', '&upsilon;'=>'&#965;', '&phi;'=>'&#966;', '&chi;'=>'&#967;', '&psi;'=>'&#968;', '&omega;'=>'&#969;', '&thetasym;'=>'&#977;', '&upsih;'=>'&#978;', '&piv;'=>'&#982;', '&ensp;'=>'&#8194;', '&emsp;'=>'&#8195;', '&thinsp;'=>'&#8201;', '&zwnj;'=>'&#8204;', '&zwj;'=>'&#8205;', '&lrm;'=>'&#8206;', '&rlm;'=>'&#8207;', '&ndash;'=>'&#8211;', '&mdash;'=>'&#8212;', '&lsquo;'=>'&#8216;', '&rsquo;'=>'&#8217;', '&sbquo;'=>'&#8218;', '&ldquo;'=>'&#8220;', '&rdquo;'=>'&#8221;', '&bdquo;'=>'&#8222;', '&dagger;'=>'&#8224;', '&Dagger;'=>'&#8225;', '&bull;'=>'&#8226;', '&hellip;'=>'&#8230;', '&permil;'=>'&#8240;', '&prime;'=>'&#8242;', '&Prime;'=>'&#8243;', '&lsaquo;'=>'&#8249;', '&rsaquo;'=>'&#8250;', '&oline;'=>'&#8254;', '&frasl;'=>'&#8260;', '&euro;'=>'&#8364;', '&image;'=>'&#8465;', '&weierp;'=>'&#8472;', '&real;'=>'&#8476;', '&trade;'=>'&#8482;', '&alefsym;'=>'&#8501;', '&larr;'=>'&#8592;', '&uarr;'=>'&#8593;', '&rarr;'=>'&#8594;', '&darr;'=>'&#8595;', '&harr;'=>'&#8596;', '&crarr;'=>'&#8629;', '&lArr;'=>'&#8656;', '&uArr;'=>'&#8657;', '&rArr;'=>'&#8658;', '&dArr;'=>'&#8659;', '&hArr;'=>'&#8660;', '&forall;'=>'&#8704;', '&part;'=>'&#8706;', '&exist;'=>'&#8707;', '&empty;'=>'&#8709;', '&nabla;'=>'&#8711;', '&isin;'=>'&#8712;', '&notin;'=>'&#8713;', '&ni;'=>'&#8715;', '&prod;'=>'&#8719;', '&sum;'=>'&#8721;', '&minus;'=>'&#8722;', '&lowast;'=>'&#8727;', '&radic;'=>'&#8730;', '&prop;'=>'&#8733;', '&infin;'=>'&#8734;', '&ang;'=>'&#8736;', '&and;'=>'&#8743;', '&or;'=>'&#8744;', '&cap;'=>'&#8745;', '&cup;'=>'&#8746;', '&int;'=>'&#8747;', '&there4;'=>'&#8756;', '&sim;'=>'&#8764;', '&cong;'=>'&#8773;', '&asymp;'=>'&#8776;', '&ne;'=>'&#8800;', '&equiv;'=>'&#8801;', '&le;'=>'&#8804;', '&ge;'=>'&#8805;', '&sub;'=>'&#8834;', '&sup;'=>'&#8835;', '&nsub;'=>'&#8836;', '&sube;'=>'&#8838;', '&supe;'=>'&#8839;', '&oplus;'=>'&#8853;', '&otimes;'=>'&#8855;', '&perp;'=>'&#8869;', '&sdot;'=>'&#8901;', '&lceil;'=>'&#8968;', '&rceil;'=>'&#8969;', '&lfloor;'=>'&#8970;', '&rfloor;'=>'&#8971;', '&lang;'=>'&#9001;', '&rang;'=>'&#9002;', '&loz;'=>'&#9674;', '&spades;'=>'&#9824;', '&clubs;'=>'&#9827;', '&hearts;'=>'&#9829;', '&diams;'=>'&#9830;');
50
        $trans2 = array_flip($trans2);
51
        foreach ($trans2 as $m1 => $m2)
52
        {
53
                // Funktioniert chr() bei den 8... Einträgen? Finde Eurozeichen nicht bei chr(8364)!
54
                $m1 = chr(substr($m1, 2, strlen($m1)-3));
55
 
56
                if (($m2 != '&lt;') && ($m2 != '&gt;'))
57
                        $inp = str_replace(str_replace('&', '&amp;', $m2), $m2, $inp);
58
        }
59
        unset($m1);
60
        unset($m2);
61
 
62
        return decode_critical_html_characters($inp);
63
}
64
 
65
//////////////////////////////////////////////////////////////////////////////
66
// VERSCHLÜSSELUNGSFUNKTIONEN FÜR SESSIONS U.A.                             //
67
//////////////////////////////////////////////////////////////////////////////
68
 
69
function special_hash($string)
70
{
71
        $iterations = 10;
72
 
73
        $last = $string;
74
        $out = '';
75
        for ($i=0; $i<$iterations; $i++)
76
        {
77
                $last = md5($last);
78
                $out .= $last;
79
        }
80
 
81
        $garbarge_count = 0;
82
        for ($i=0; $i<strlen($last); $i++)
83
        {
84
                if (($last[$i] == '0') || ($last[$i] == '1') || ($last[$i] == '2') || ($last[$i] == '3') ||
85
                                ($last[$i] == '4') || ($last[$i] == '5') || ($last[$i] == '6') || ($last[$i] == '7') ||
86
                                ($last[$i] == '8') || ($last[$i] == '9'))
87
                {
88
                        $garbarge_count = $garbarge_count + $last[$i];
89
                }
90
        }
91
 
92
        for ($i=0; $i<=$garbarge_count; $i++)
93
        {
94
                $out = $last[0].$out.$last[1];
95
        }
96
 
97
        if (strlen($out) > 1024) $out = substr($out, 0, 1024);
98
 
99
        return $out;
100
}
101
 
102
function get_rnd_iv($iv_len)
103
{
104
        $iv = '';
105
        while ($iv_len-- > 0) {
106
                $iv .= chr(mt_rand() & 0xff);
107
        }
108
        return $iv;
109
}
110
 
111
function md5_encrypt($plain_text, $password, $iv_len = 16)
112
{
113
        $plain_text .= "\x13";
114
        $n = strlen($plain_text);
115
        if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
116
        $i = 0;
117
        $enc_text = get_rnd_iv($iv_len);
118
        $iv = substr($password ^ $enc_text, 0, 512);
119
        while ($i < $n) {
120
                $block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
121
                $enc_text .= $block;
122
                $iv = substr($block . $iv, 0, 512) ^ $password;
123
                $i += 16;
124
        }
125
        return base64_encode($enc_text);
126
}
127
 
128
function md5_decrypt($enc_text, $password, $iv_len = 16)
129
{
130
        $enc_text = base64_decode($enc_text);
131
        $n = strlen($enc_text);
132
        $i = $iv_len;
133
        $plain_text = '';
134
        $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512);
135
        while ($i < $n) {
136
                $block = substr($enc_text, $i, 16);
137
                $plain_text .= $block ^ pack('H*', md5($iv));
138
                $iv = substr($block . $iv, 0, 512) ^ $password;
139
                $i += 16;
140
        }
141
        return preg_replace('/\\x13\\x00*$/', '', $plain_text);
142
}
143
 
144
function wb_encrypt($message, $key)
145
{
146
        return md5_encrypt($message, $key);
147
}
148
 
149
function wb_decrypt($message, $key)
150
{
151
        return md5_decrypt($message, $key);
152
}
153
 
154
//////////////////////////////////////////////////////////////////////////////
155
// NÜTZLICHE FUNKTIONEN                                                     //
156
//////////////////////////////////////////////////////////////////////////////
157
 
158
function WBUserAgent() {
159
        global $WBConfig;
160
        return 'ViaThinkSoft Personal WebBase '.$WBConfig->getRevision().' (PHP/'.phpversion().')';
161
}
162
 
163
// Anmerkung: Subdomains sind nicht gültig.
164
 
165
// @param $name Name des Cookies
166
// @value $value Wert des Cookies
167
// @param $time 0 für "Ende der Sitzung" oder Sekundenanzahl als Gültigkeit
168
function wbSetCookie($name, $value, $time) {
169
        global $WBConfig;
170
        if ($time != 0) $time += time();
171
        setCookie($name, $value, $time, RELATIVE_DIR, /* $_SERVER['HTTP_HOST'] */ '', $WBConfig->getForceSSLFlag());
172
}
173
 
174
// @param $name
175
// @param $wb_rel_path Path relative to the WebBase directory (for third-party systems!)
176
function wbUnsetCookie($name, $wb_rel_path = '') {
177
        global $WBConfig;
178
        setCookie($name, '', -1, RELATIVE_DIR.$wb_rel_path, /* $_SERVER['HTTP_HOST'] */ '', $WBConfig->getForceSSLFlag());
179
}
180
 
181
// TODO (Prüfen)
182
// Das Argument von deferer() sollte aufgrund der W3C-Konformität &amp; statt & enthalten
183
 
184
function deferer($url) {
185
        return 'deferer.php?target='.urlencode($url);
186
}
187
 
188
function ip_tracer($ip) {
189
        return deferer('http://www.ripe.net/fcgi-bin/whois?form_type=simple&full_query_string=&searchtext='.$ip.'&submit.x=0&submit.y=0');
190
}
191
 
192
function url_protokoll_vorhanden($url)
193
{
194
        $ary = explode('://', $url);
195
        return ((strpos($ary[0], '/') === false) && (isset($ary[1])));
196
}
197
 
198
function wb_redirect_now($url) {
199
 
200
        if (url_protokoll_vorhanden($url)) {
201
                // Umwechseln von HTTP<->HTTPS ist bei gleicher Adresse ohne Deferrer erlaubt
202
                if ((str_replace('https://', '', $url) != $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) &&
203
                        (str_replace('http://',  '', $url) != $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
204
                {
205
                        $url = deferer($url); // Umleitung auf eine externe Seite
206
                }
207
        }
208
 
209
        if (!headers_sent()) {
210
                header('Location: '.$url);
211
        } else {
212
                // HTML-Weiterleitung
213
                echo 'Redirect: <a href="'.$url.'">'.$url.'</a><br>'."\r\n\r\n";
214
                echo '<script language ="JavaScript">
215
                <!--
216
                        window.location.replace("'.$url.'");
217
                // -->
218
                </script>';
219
        }
220
 
221
        die('');
222
}
223
 
224
function add_trailing_path_delimiter($url_or_directory) {
225
        if (substr($url_or_directory, strlen($url_or_directory)-1, 1) != '/') {
226
                $url_or_directory .= '/';
227
        }
228
        return $url_or_directory;
229
}
230
 
231
function dirname_with_pathdelimiter($directory)
232
{
233
        $tmp = dirname($directory);
234
        $tmp = str_replace('\\', '/', $tmp);
235
        $tmp = add_trailing_path_delimiter($tmp);
236
        return $tmp;
237
}
238
 
239
function string2hex($str)
240
{
241
        if (trim($str) != "")
242
        {
243
                $hex = "";
244
                $length = strlen($str);
245
                for ($i=0; $i<$length; $i++)
246
                {
247
                        $hex .= str_pad(dechex(ord($str[$i])), 2, 0, STR_PAD_LEFT);
248
                }
249
                return $hex;
250
        }
251
}
252
 
253
function hex2string($hex)
254
{
255
        $string = '';
256
 
257
        $hex = str_replace(array("\n","\r"," "), "", $hex);
258
 
259
        for ($ix=0; $ix < strlen($hex); $ix=$ix+2)
260
        {
261
                $ord = hexdec(substr($hex, $ix, 2));
262
                $string .= chr($ord);
263
        }
264
 
265
        return $string;
266
}
267
 
268
// http://lists.phpbar.de/pipermail/php/Week-of-Mon-20040322/007749.html
269
 
270
function fetchip()
271
{
272
        $client_ip = (isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : '';
273
        $x_forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
274
        $remote_addr = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '';
275
 
276
        if (!empty($client_ip))
277
        {
278
                $ip_expl = explode('.',$client_ip);
279
                $referer = explode('.',$remote_addr);
280
                if($referer[0] != $ip_expl[0])
281
                {
282
                        $ip=array_reverse($ip_expl);
283
                        $return=implode('.',$ip);
284
                }
285
                else
286
                {
287
                        $return = $client_ip;
288
                }
289
        }
290
        else if (!empty($x_forwarded_for))
291
        {
292
                if(strstr($x_forwarded_for,','))
293
                {
294
                        $ip_expl = explode(',',$x_forwarded_for);
295
                        $return = end($ip_expl);
296
                }
297
                else
298
                {
299
                        $return = $x_forwarded_for;
300
                }
301
        }
302
        else
303
        {
304
                $return = $remote_addr;
305
        }
306
        unset ($client_ip, $x_forwarded_for, $remote_addr, $ip_expl);
307
        return $return;
308
}
309
 
310
function my_htmlentities($inp, $charset = 'utf-8')
311
{
312
        // http://www.php.net/manual/de/function.htmlspecialchars.php
313
        // PHP-Version wird nicht kontrolliert...
314
        $cs = 'utf-8';
315
 
316
        if (strtolower($charset) == 'iso-8859-1') $cs = 'ISO-8859-1';
317
        if (strtolower($charset) == 'iso8859-1') $cs = 'ISO-8859-1';
318
        if (strtolower($charset) == 'iso-8859-15') $cs = 'ISO-8859-15';
319
        if (strtolower($charset) == 'iso8859-15') $cs = 'ISO-8859-15';
320
        if (strtolower($charset) == 'utf-8') $cs = 'UTF-8';
321
        if (strtolower($charset) == 'cp866') $cs = 'cp866';
322
        if (strtolower($charset) == 'ibm866') $cs = 'cp866';
323
        if (strtolower($charset) == '866') $cs = 'cp866';
324
        if (strtolower($charset) == 'cp1251') $cs = 'cp1251';
325
        if (strtolower($charset) == 'windows-1251') $cs = 'cp1251';
326
        if (strtolower($charset) == 'win-1251') $cs = 'cp1251';
327
        if (strtolower($charset) == '1251') $cs = 'cp1251';
328
        if (strtolower($charset) == 'cp1252') $cs = 'cp1252';
329
        if (strtolower($charset) == 'windows-1252') $cs = 'cp1252';
330
        if (strtolower($charset) == '1252') $cs = 'cp1252';
331
        if (strtolower($charset) == 'koi8-r') $cs = 'KOI8-R';
332
        if (strtolower($charset) == 'koi8-ru') $cs = 'KOI8-R';
333
        if (strtolower($charset) == 'koi8r') $cs = 'KOI8-R';
334
        if (strtolower($charset) == 'big5') $cs = 'BIG5';
335
        if (strtolower($charset) == '950') $cs = 'BIG5';
336
        if (strtolower($charset) == 'gb2312') $cs = 'GB2312';
337
        if (strtolower($charset) == '936') $cs = 'GB2312';
338
        if (strtolower($charset) == 'big5-hkscs') $cs = 'BIG5-HKSCS';
339
        if (strtolower($charset) == 'shift_jis') $cs = 'Shift_JIS';
340
        if (strtolower($charset) == 'sjis') $cs = 'Shift_JIS';
341
        if (strtolower($charset) == '932') $cs = 'Shift_JIS';
342
        if (strtolower($charset) == 'euc-jp') $cs = 'EUC-JP';
343
        if (strtolower($charset) == 'eucjp') $cs = 'EUC-JP';
344
 
345
        return @htmlentities($inp, ENT_NOQUOTES, $cs);
346
}
347
 
348
function check_email($email_adresse)
349
{
350
        if(eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$",$email_adresse))
351
                return true;
352
        else
353
                return false;
354
}
355
 
356
function return_bytes($val)
357
{
358
        $val = trim($val);
359
        $last = strtolower($val{strlen($val)-1});
360
        switch($last)
361
        {
362
                case 'g':
363
                        $val *= 1024;
364
                case 'm':
365
                        $val *= 1024;
366
                case 'k':
367
                        $val *= 1024;
368
        }
369
        return $val;
370
}
371
 
372
function zufall($size)
373
{
374
        $result = "";
375
 
376
        srand((double)microtime()*1000000);
377
 
378
         for($i=0; $i < $size; $i++)
379
        {
380
                $num = rand(48,120);
381
                while (($num >= 58 && $num <= 64) || ($num >= 91 && $num <= 96))
382
                         $num = rand(48,120);
383
 
384
                $result .= chr($num);
385
        }
386
        return $result;
387
}
388
 
389
function runden($inp, $nachkommastellen = 0)
390
{
391
        return number_format($inp, $nachkommastellen, ",", ".");
392
}
393
 
394
function dir_add_trailing_backslash($directory) {
395
        if (substr($directory, strlen($directory)-1, 1) != '/') $directory .= '/';
396
        return $directory;
397
}
398
 
399
// PHP-AntiSpam-Funktion "secure_email", Version 3.0
400
// von Daniel Marschall [www.daniel-marschall.de]
401
 
402
function secure_email($email, $linktext, $crypt_linktext)
403
{
404
        if (!function_exists('alas_js_crypt'))
405
        {
406
                function alas_js_crypt($text)
407
                {
408
                        $tmp = '';
409
                        for ($i=0; $i<strlen($text); $i++)
410
                        {
411
                                $tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");';
412
                        }
413
                        return $tmp;
414
                }
415
        }
416
 
417
        if (!function_exists('alas_js_write'))
418
        {
419
                function alas_js_write($text)
420
                {
421
                        $text = str_replace('\\', '\\\\', $text);
422
                        $text = str_replace('"', '\"', $text);
423
                        $text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
424
                        return 'document.write("'.$text.'");';
425
                }
426
        }
427
 
428
        $aus = '';
429
        if ($email != '')
430
        {
431
                $aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n";
432
                $aus .= alas_js_write('<a href="');
433
                $aus .= alas_js_crypt('mailto:'.$email);
434
                $aus .= alas_js_write('">');
435
                $aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
436
                $aus .= alas_js_write('</a>').'// --></script>';
437
        }
438
        return $aus;
439
}
440
 
441
function de_convertmysqldatetime($datum, $zeige_sekunden = false)
442
{
443
        if (($datum == '') || ($datum == '0000-00-00 00:00:00'))
444
        {
445
                return 'Unbekannt';
446
        }
447
        else
448
        {
449
 
450
                $date = explode(" ", $datum);
451
                $ddatum = explode("-", $date[0]);
452
                if (isset($date[1]))
453
                {
454
                        $date = explode(":", $date[1]);
455
                }
456
                else
457
                {
458
                        $date[0] = '';
459
                        $date[1] = '';
460
                        $date[2] = '';
461
                }
462
 
463
                if ($ddatum[1] == '01') $mon = 'Januar';
464
                if ($ddatum[1] == '02') $mon = 'Februar';
465
                if ($ddatum[1] == '03') $mon = 'M&auml;rz';
466
                if ($ddatum[1] == '04') $mon = 'April';
467
                if ($ddatum[1] == '05') $mon = 'Mai';
468
                if ($ddatum[1] == '06') $mon = 'Juni';
469
                if ($ddatum[1] == '07') $mon = 'Juli';
470
                if ($ddatum[1] == '08') $mon = 'August';
471
                if ($ddatum[1] == '09') $mon = 'September';
472
                if ($ddatum[1] == '10') $mon = 'Oktober';
473
                if ($ddatum[1] == '11') $mon = 'November';
474
                if ($ddatum[1] == '12') $mon = 'Dezember';
475
                $tag = sprintf("%d",$ddatum[2]);
476
                $datum = $tag.". ".$mon." ".$ddatum[0];
477
 
478
                if (($date[0] != '') && ($date[1] != ''))
479
                {
480
                        if ($zeige_sekunden) $zus = ':'.$date[2]; else $zus = '';
481
                        return $datum.', '.$date[0].':'.$date[1].$zus.' Uhr';
482
                }
483
                else
484
                        return $datum;
485
        }
486
}
487
 
488
function zwischen_str($str, $von, $bis, $flankierungen_miteinbeziehen = true)
489
{
490
        $ausgabe = $str;
491
 
492
        if ($von != '')
493
        {
494
                $pos = strpos($ausgabe, $von);
495
                if ($pos !== false)
496
                {
497
                        $ausgabe = substr($ausgabe, $pos, strlen($ausgabe)-$pos);
498
                        if (!$flankierungen_miteinbeziehen)
499
                                $ausgabe = substr($ausgabe, strlen($von), strlen($ausgabe)-strlen($von)-1); // -1 ?
500
                }
501
        }
502
 
503
        if ($bis != '')
504
        {
505
                $pos = strpos($ausgabe, $bis);
506
                if ($pos !== false)
507
                {
508
                        $ausgabe = substr($ausgabe, 0, $pos+strlen($bis));
509
                        if (!$flankierungen_miteinbeziehen)
510
                                $ausgabe = substr($ausgabe, 0, strlen($ausgabe)-strlen($bis));
511
                }
512
        }
513
 
514
        return $ausgabe;
515
}
516
 
517
//////////////////////////////////////////////////////////////////////////////
518
// GFX/LISTE/OOP-FUNKTIONEN                                                 //
519
//////////////////////////////////////////////////////////////////////////////
520
 
521
function oop_link_to_modul($modul, $seite = 'main', $titelzeile_modul = '')
522
{
523
        if ($titelzeile_modul == '') $titelzeile_modul = $modul;
524
 
525
        $module_information = WBModuleHandler::get_module_information($titelzeile_modul);
526
 
527
        if (file_exists('modules/'.$titelzeile_modul.'/images/menu/32.gif'))
528
                $g = 'modules/'.$titelzeile_modul.'/images/menu/32.gif';
529
        else if (file_exists('modules/'.$titelzeile_modul.'/images/menu/32.png'))
530
                $g = 'modules/'.$titelzeile_modul.'/images/menu/32.png';
531
        else
532
                $g = 'designs/spacer.gif';
533
 
534
        return "javascript:oop('".$modul."', '".$seite."', '".htmlentities($module_information->caption)."', '".$g."');";
535
}
536
 
537
function wb_list_items($modul, $table, $append, $dir = 0)
538
{
539
        global $benutzer;
540
 
541
        if (!isset($erg)) $erg = array();
542
 
543
        $i = 0;
544
        $res = db_query("SELECT * FROM `$table` WHERE `folder_cnid` = '".db_escape($dir)."' AND `user_cnid` = '".$benutzer['id']."' $append");
545
        while ($row = db_fetch($res))
546
        {
547
                $i++;
548
                $erg[$i] = $row;
549
        }
550
 
551
        return $erg;
552
}
553
 
554
function wb_list_items_filter($modul, $table, $append)
555
{
556
        $i = 0;
557
 
558
        $res = db_query("SELECT * FROM `$table` $append");
559
        while ($row = db_fetch($res))
560
        {
561
                $i++;
562
                $erg[$i] = $row;
563
        }
564
 
565
        return $erg;
566
}
567
 
568
function wb_draw_table_begin()
569
{
570
        echo '<div align="center"><table cellspacing="0" cellpadding="2" border="0" width="90%">';
571
}
572
 
573
function wb_draw_table_end()
574
{
575
        echo '</table></div><br>';
576
}
577
 
578
function wb_draw_table_content()
579
{
580
        echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">';
581
        $j = 0;
582
        for ($i=0; $i < @func_num_args(); $i=$i+2)
583
        {
584
                $j++;
585
                if (@func_get_arg($i) != '')
586
                        $w = 'width="'.@func_get_arg($i).'" ';
587
                else
588
                        $w = '';
589
                echo '<td valign="top" align="left" '.$w.'>'.@func_get_arg($i+1).'</td>';
590
        }
591
        if ($j == 0)
592
                echo '<td valign="top" align="left" width="100%">&nbsp;</td>';
593
        echo '</tr>'."\n";
594
}
595
 
596
function wb_draw_table_span_content($highlight, $span, $text)
597
{
598
        if ($highlight == 1) $hfarb = '4';
599
        if ($highlight == 0) $hfarb = '5';
600
        if ($highlight == 2) $hfarb = '6';
601
        echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">';
602
        echo '<td valign="top" align="left" colspan="'.$span.'">'.$text.'</td>';
603
        echo '</tr>';
604
 
605
}
606
 
607
function wb_draw_item_filter($modul, $table, $append)
608
{
609
        global $ordnereinzug, $WBConfig;
610
 
611
        $einzug = 0;
612
        $ary = wb_list_items_filter($modul, $table, $append);
613
        $durchlauf = 0;
614
        for ($i=1; isset($ary[$i]['id']); $i++)
615
        {
616
                $durchlauf++;
617
 
618
                if (file_exists('modules/'.$modul.'/includes/menuentry.inc.php'))
619
                        include('modules/'.$modul.'/includes/menuentry.inc.php');
620
 
621
                echo "\n";
622
        }
623
 
624
        return $durchlauf;
625
}
626
 
627
function wb_draw_item($modul, $table, $append, $folder = 0, $einzug = 0)
628
{
629
        global $ordnereinzug, $WBConfig;
630
 
631
        $ary = wb_list_items($modul, $table, $append, $folder);
632
        $durchlauf = 0;
633
        for ($i=1; isset($ary[$i]['id']); $i++)
634
        {
635
                $durchlauf++;
636
 
637
                if (file_exists('modules/'.$modul.'/includes/menuentry.inc.php'))
638
                        include('modules/'.$modul.'/includes/menuentry.inc.php');
639
        }
640
 
641
        return $durchlauf;
642
}
643
 
644
function wb_draw_menu_item($modul, $seite, $titel, $klein, $gross)
645
{
646
        if (file_exists($gross))
647
                $g = $gross;
648
        else
649
                $g = 'designs/spacer.gif';
650
 
651
        if (file_exists($klein))
652
                $k = $klein;
653
        else
654
                $k = 'designs/spacer.gif';
655
 
656
        return '<tr class="row_nav" onmouseover="this.className=\'row_nav_act\';" onmouseout="this.className=\'row_nav\';">
657
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="designs/spacer.gif" height="1" width="3" alt=""></td>
658
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="'.$k.'" height="16" width="16" alt=""></td>
659
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="designs/spacer.gif" height="1" width="5" alt=""></td>
660
        <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>
661
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="designs/spacer.gif" alt="" width="1" height="1"></td>
662
</tr>'."\n";
663
}
664
 
665
function wb_draw_menu_spacer()
666
{
667
        return '<tr>
668
        <td colspan="5"><img src="designs/spacer.gif" alt="" width="1" height="14"></td>
669
</tr>';
670
}
671
 
672
//////////////////////////////////////////////////////////////////////////////
673
// FUNKTIONEN FÜR MODUL-XML UND DESIGN-XML                                                                                                                                      //
674
//////////////////////////////////////////////////////////////////////////////
675
 
676
require 'includes/xml.class.inc.php';
677
require 'includes/SecureMailer.class.php';
678
 
679
//////////////////////////////////////////////////////////////////////////////
680
// FUNKTIONEN FÜR MODUL-XML UND DESIGN-XML                                                                                                                                      //
681
//////////////////////////////////////////////////////////////////////////////
682
 
683
require 'includes/WBModulHandler.class.php';
684
 
685
require 'includes/WBDesignHandler.class.php';
686
 
687
/* Konstanten */
688
 
689
define('RELATIVE_DIR', dir_add_trailing_backslash(dirname($_SERVER['PHP_SELF'])));
690
 
691
?>