Subversion Repositories personal-webbase

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 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 wb_htmlentities($x) {
10
        return htmlentities($x, ENT_COMPAT, 'iso-8859-1');
1 daniel-mar 11
}
12
 
10 daniel-mar 13
function encode_critical_html_characters($inp)
14
{
15
        $inp = str_replace('&', '&amp;', $inp);
16
        //$inp = str_replace('"', '&quot;', $inp);
17
        $inp = str_replace('<', '&lt;', $inp);
18
        $inp = str_replace('>', '&gt;', $inp);
19
 
20
        return $inp;
21
}
22
 
23
function decode_critical_html_characters($inp)
24
{
25
        $inp = str_replace('&amp;', '&', $inp);
26
        //$inp = str_replace('&quot;', '"', $inp);
27
        $inp = str_replace('&lt;', '<', $inp);
28
        $inp = str_replace('&gt;', '>', $inp);
29
 
30
        return $inp;
31
}
32
 
33
function executable_html_code($inp)
34
{
35
        // Wenn der Benutzer z.B. ä im HTML-Formular eingegeben hat, würde hier aufgrund von Unicode quatsch rauskommen
36
        $inp = wb_htmlentities($inp, ENT_COMPAT, 'UTF-8');
37
 
38
        $inp = decode_critical_html_characters($inp);
39
 
40
        $trans = get_html_translation_table(HTML_ENTITIES);
41
        foreach ($trans as $m1 => $m2)
42
        {
43
                if (($m2 != '&lt;') && ($m2 != '&gt;'))
44
                {
45
                        $inp = str_replace(str_replace('&', '&amp;', $m2), $m2, $inp);
46
                }
47
        }
48
        unset($m1);
49
        unset($m2);
50
 
51
        // Erweiterte Zeichensatztabelle, die auch da Euro-Zeichen enthält
52
        // Entnommen von http://www.php.net/manual/de/function.get-html-translation-table.php#73410
53
        $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;');
54
        $trans2 = array_flip($trans2);
55
        foreach ($trans2 as $m1 => $m2)
56
        {
57
                // Funktioniert chr() bei den 8... Einträgen? Finde Eurozeichen nicht bei chr(8364)!
58
                $m1 = chr(substr($m1, 2, strlen($m1)-3));
59
 
60
                if (($m2 != '&lt;') && ($m2 != '&gt;'))
61
                        $inp = str_replace(str_replace('&', '&amp;', $m2), $m2, $inp);
62
        }
63
        unset($m1);
64
        unset($m2);
65
 
66
        return decode_critical_html_characters($inp);
67
}
68
 
69
//////////////////////////////////////////////////////////////////////////////
70
// VERSCHLÜSSELUNGSFUNKTIONEN FÜR SESSIONS U.A.                             //
71
//////////////////////////////////////////////////////////////////////////////
72
 
73
function special_hash($string)
74
{
75
        $iterations = 10;
76
 
77
        $last = $string;
78
        $out = '';
79
        for ($i=0; $i<$iterations; $i++)
80
        {
81
                $last = md5($last);
82
                $out .= $last;
83
        }
84
 
85
        $garbarge_count = 0;
86
        for ($i=0; $i<strlen($last); $i++)
87
        {
88
                if (($last[$i] == '0') || ($last[$i] == '1') || ($last[$i] == '2') || ($last[$i] == '3') ||
89
                                ($last[$i] == '4') || ($last[$i] == '5') || ($last[$i] == '6') || ($last[$i] == '7') ||
90
                                ($last[$i] == '8') || ($last[$i] == '9'))
91
                {
92
                        $garbarge_count = $garbarge_count + $last[$i];
93
                }
94
        }
95
 
96
        for ($i=0; $i<=$garbarge_count; $i++)
97
        {
98
                $out = $last[0].$out.$last[1];
99
        }
100
 
101
        if (strlen($out) > 1024) $out = substr($out, 0, 1024);
102
 
103
        return $out;
104
}
105
 
106
function get_rnd_iv($iv_len)
107
{
108
        $iv = '';
109
        while ($iv_len-- > 0) {
110
                $iv .= chr(mt_rand() & 0xff);
111
        }
112
        return $iv;
113
}
114
 
115
function md5_encrypt($plain_text, $password, $iv_len = 16)
116
{
117
        $plain_text .= "\x13";
118
        $n = strlen($plain_text);
119
        if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
120
        $i = 0;
121
        $enc_text = get_rnd_iv($iv_len);
122
        $iv = substr($password ^ $enc_text, 0, 512);
123
        while ($i < $n) {
124
                $block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
125
                $enc_text .= $block;
126
                $iv = substr($block . $iv, 0, 512) ^ $password;
127
                $i += 16;
128
        }
129
        return base64_encode($enc_text);
130
}
131
 
132
function md5_decrypt($enc_text, $password, $iv_len = 16)
133
{
134
        $enc_text = base64_decode($enc_text);
135
        $n = strlen($enc_text);
136
        $i = $iv_len;
137
        $plain_text = '';
138
        $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512);
139
        while ($i < $n) {
140
                $block = substr($enc_text, $i, 16);
141
                $plain_text .= $block ^ pack('H*', md5($iv));
142
                $iv = substr($block . $iv, 0, 512) ^ $password;
143
                $i += 16;
144
        }
145
        return preg_replace('/\\x13\\x00*$/', '', $plain_text);
146
}
147
 
148
function wb_encrypt($message, $key)
149
{
150
        return md5_encrypt($message, $key);
151
}
152
 
153
function wb_decrypt($message, $key)
154
{
155
        return md5_decrypt($message, $key);
156
}
157
 
158
//////////////////////////////////////////////////////////////////////////////
159
// NÜTZLICHE FUNKTIONEN                                                     //
160
//////////////////////////////////////////////////////////////////////////////
161
 
162
function WBUserAgent() {
163
        global $WBConfig;
164
        return 'ViaThinkSoft Personal WebBase '.$WBConfig->getRevision().' (PHP/'.phpversion().')';
165
}
166
 
167
// Anmerkung: Subdomains sind nicht gültig.
168
 
169
// @param $name Name des Cookies
170
// @value $value Wert des Cookies
171
// @param $time 0 für "Ende der Sitzung" oder Sekundenanzahl als Gültigkeit
172
function wbSetCookie($name, $value, $time) {
173
        global $WBConfig;
174
        if ($time != 0) $time += time();
175
        setCookie($name, $value, $time, RELATIVE_DIR, /* $_SERVER['HTTP_HOST'] */ '', $WBConfig->getForceSSLFlag());
176
}
177
 
178
// @param $name
179
// @param $wb_rel_path Path relative to the WebBase directory (for third-party systems!)
180
function wbUnsetCookie($name, $wb_rel_path = '') {
181
        global $WBConfig;
182
        setCookie($name, '', -1, RELATIVE_DIR.$wb_rel_path, /* $_SERVER['HTTP_HOST'] */ '', $WBConfig->getForceSSLFlag());
183
}
184
 
185
// TODO (Prüfen)
186
// Das Argument von deferer() sollte aufgrund der W3C-Konformität &amp; statt & enthalten
187
 
188
function deferer($url) {
189
        return 'deferer.php?target='.urlencode($url);
190
}
191
 
192
function ip_tracer($ip) {
193
        return deferer('http://www.ripe.net/fcgi-bin/whois?form_type=simple&full_query_string=&searchtext='.$ip.'&submit.x=0&submit.y=0');
194
}
195
 
196
function url_protokoll_vorhanden($url)
197
{
198
        $ary = explode('://', $url);
199
        return ((strpos($ary[0], '/') === false) && (isset($ary[1])));
200
}
201
 
202
function wb_redirect_now($url) {
203
 
204
        if (url_protokoll_vorhanden($url)) {
205
                // Umwechseln von HTTP<->HTTPS ist bei gleicher Adresse ohne Deferrer erlaubt
206
                if ((str_replace('https://', '', $url) != $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) &&
207
                        (str_replace('http://',  '', $url) != $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
208
                {
209
                        $url = deferer($url); // Umleitung auf eine externe Seite
210
                }
211
        }
212
 
213
        if (!headers_sent()) {
214
                header('Location: '.$url);
215
        } else {
216
                // HTML-Weiterleitung
217
                echo 'Redirect: <a href="'.$url.'">'.$url.'</a><br>'."\r\n\r\n";
218
                echo '<script language ="JavaScript">
219
                <!--
220
                        window.location.replace("'.$url.'");
221
                // -->
222
                </script>';
223
        }
224
 
225
        die('');
226
}
227
 
228
function add_trailing_path_delimiter($url_or_directory) {
229
        if (substr($url_or_directory, strlen($url_or_directory)-1, 1) != '/') {
230
                $url_or_directory .= '/';
231
        }
232
        return $url_or_directory;
233
}
234
 
235
function dirname_with_pathdelimiter($directory)
236
{
237
        $tmp = dirname($directory);
238
        $tmp = str_replace('\\', '/', $tmp);
239
        $tmp = add_trailing_path_delimiter($tmp);
240
        return $tmp;
241
}
242
 
243
function string2hex($str)
244
{
245
        if (trim($str) != "")
246
        {
247
                $hex = "";
248
                $length = strlen($str);
249
                for ($i=0; $i<$length; $i++)
250
                {
251
                        $hex .= str_pad(dechex(ord($str[$i])), 2, 0, STR_PAD_LEFT);
252
                }
253
                return $hex;
254
        }
255
}
256
 
257
function hex2string($hex)
258
{
259
        $string = '';
260
 
261
        $hex = str_replace(array("\n","\r"," "), "", $hex);
262
 
263
        for ($ix=0; $ix < strlen($hex); $ix=$ix+2)
264
        {
265
                $ord = hexdec(substr($hex, $ix, 2));
266
                $string .= chr($ord);
267
        }
268
 
269
        return $string;
270
}
271
 
272
// http://lists.phpbar.de/pipermail/php/Week-of-Mon-20040322/007749.html
273
 
274
function fetchip()
275
{
276
        $client_ip = (isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : '';
277
        $x_forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
278
        $remote_addr = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '';
279
 
280
        if (!empty($client_ip))
281
        {
282
                $ip_expl = explode('.',$client_ip);
283
                $referer = explode('.',$remote_addr);
284
                if($referer[0] != $ip_expl[0])
285
                {
286
                        $ip=array_reverse($ip_expl);
287
                        $return=implode('.',$ip);
288
                }
289
                else
290
                {
291
                        $return = $client_ip;
292
                }
293
        }
294
        else if (!empty($x_forwarded_for))
295
        {
296
                if(strstr($x_forwarded_for,','))
297
                {
298
                        $ip_expl = explode(',',$x_forwarded_for);
299
                        $return = end($ip_expl);
300
                }
301
                else
302
                {
303
                        $return = $x_forwarded_for;
304
                }
305
        }
306
        else
307
        {
308
                $return = $remote_addr;
309
        }
310
        unset ($client_ip, $x_forwarded_for, $remote_addr, $ip_expl);
311
        return $return;
312
}
313
 
314
function my_wb_htmlentities($inp, $charset = 'utf-8')
315
{
316
        // http://www.php.net/manual/de/function.htmlspecialchars.php
317
        // PHP-Version wird nicht kontrolliert...
318
        $cs = 'utf-8';
319
 
320
        if (strtolower($charset) == 'iso-8859-1') $cs = 'ISO-8859-1';
321
        if (strtolower($charset) == 'iso8859-1') $cs = 'ISO-8859-1';
322
        if (strtolower($charset) == 'iso-8859-15') $cs = 'ISO-8859-15';
323
        if (strtolower($charset) == 'iso8859-15') $cs = 'ISO-8859-15';
324
        if (strtolower($charset) == 'utf-8') $cs = 'UTF-8';
325
        if (strtolower($charset) == 'cp866') $cs = 'cp866';
326
        if (strtolower($charset) == 'ibm866') $cs = 'cp866';
327
        if (strtolower($charset) == '866') $cs = 'cp866';
328
        if (strtolower($charset) == 'cp1251') $cs = 'cp1251';
329
        if (strtolower($charset) == 'windows-1251') $cs = 'cp1251';
330
        if (strtolower($charset) == 'win-1251') $cs = 'cp1251';
331
        if (strtolower($charset) == '1251') $cs = 'cp1251';
332
        if (strtolower($charset) == 'cp1252') $cs = 'cp1252';
333
        if (strtolower($charset) == 'windows-1252') $cs = 'cp1252';
334
        if (strtolower($charset) == '1252') $cs = 'cp1252';
335
        if (strtolower($charset) == 'koi8-r') $cs = 'KOI8-R';
336
        if (strtolower($charset) == 'koi8-ru') $cs = 'KOI8-R';
337
        if (strtolower($charset) == 'koi8r') $cs = 'KOI8-R';
338
        if (strtolower($charset) == 'big5') $cs = 'BIG5';
339
        if (strtolower($charset) == '950') $cs = 'BIG5';
340
        if (strtolower($charset) == 'gb2312') $cs = 'GB2312';
341
        if (strtolower($charset) == '936') $cs = 'GB2312';
342
        if (strtolower($charset) == 'big5-hkscs') $cs = 'BIG5-HKSCS';
343
        if (strtolower($charset) == 'shift_jis') $cs = 'Shift_JIS';
344
        if (strtolower($charset) == 'sjis') $cs = 'Shift_JIS';
345
        if (strtolower($charset) == '932') $cs = 'Shift_JIS';
346
        if (strtolower($charset) == 'euc-jp') $cs = 'EUC-JP';
347
        if (strtolower($charset) == 'eucjp') $cs = 'EUC-JP';
348
 
349
        return @wb_htmlentities($inp, ENT_NOQUOTES, $cs);
350
}
351
 
352
function check_email($email_adresse)
353
{
354
        if(preg_match("|^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$|ismU",$email_adresse))
355
                return true;
356
        else
357
                return false;
358
}
359
 
360
function return_bytes($val)
361
{
362
        $val = trim($val);
363
        $last = strtolower($val{strlen($val)-1});
364
        switch($last)
365
        {
366
                case 'g':
367
                        $val *= 1024;
368
                case 'm':
369
                        $val *= 1024;
370
                case 'k':
371
                        $val *= 1024;
372
        }
373
        return $val;
374
}
375
 
376
function zufall($size)
377
{
378
        $result = "";
379
 
380
        srand((double)microtime()*1000000);
381
 
382
         for($i=0; $i < $size; $i++)
383
        {
384
                $num = rand(48,120);
385
                while (($num >= 58 && $num <= 64) || ($num >= 91 && $num <= 96))
386
                         $num = rand(48,120);
387
 
388
                $result .= chr($num);
389
        }
390
        return $result;
391
}
392
 
393
function runden($inp, $nachkommastellen = 0)
394
{
395
        return number_format($inp, $nachkommastellen, ",", ".");
396
}
397
 
398
function dir_add_trailing_backslash($directory) {
399
        if (substr($directory, strlen($directory)-1, 1) != '/') $directory .= '/';
400
        return $directory;
401
}
402
 
403
// PHP-AntiSpam-Funktion "secure_email", Version 3.0
404
// von Daniel Marschall [www.daniel-marschall.de]
405
 
406
function secure_email($email, $linktext, $crypt_linktext)
407
{
408
        if (!function_exists('alas_js_crypt'))
409
        {
410
                function alas_js_crypt($text)
411
                {
412
                        $tmp = '';
413
                        for ($i=0; $i<strlen($text); $i++)
414
                        {
415
                                $tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");';
416
                        }
417
                        return $tmp;
418
                }
419
        }
420
 
421
        if (!function_exists('alas_js_write'))
422
        {
423
                function alas_js_write($text)
424
                {
425
                        $text = str_replace('\\', '\\\\', $text);
426
                        $text = str_replace('"', '\"', $text);
427
                        $text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
428
                        return 'document.write("'.$text.'");';
429
                }
430
        }
431
 
432
        $aus = '';
433
        if ($email != '')
434
        {
435
                $aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n";
436
                $aus .= alas_js_write('<a href="');
437
                $aus .= alas_js_crypt('mailto:'.$email);
438
                $aus .= alas_js_write('">');
439
                $aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
440
                $aus .= alas_js_write('</a>').'// --></script>';
441
        }
442
        return $aus;
443
}
444
 
445
function de_convertmysqldatetime($datum, $zeige_sekunden = false)
446
{
447
        if (($datum == '') || ($datum == '0000-00-00 00:00:00'))
448
        {
449
                return 'Unbekannt';
450
        }
451
        else
452
        {
453
 
454
                $date = explode(" ", $datum);
455
                $ddatum = explode("-", $date[0]);
456
                if (isset($date[1]))
457
                {
458
                        $date = explode(":", $date[1]);
459
                }
460
                else
461
                {
462
                        $date[0] = '';
463
                        $date[1] = '';
464
                        $date[2] = '';
465
                }
466
 
467
                if ($ddatum[1] == '01') $mon = 'Januar';
468
                if ($ddatum[1] == '02') $mon = 'Februar';
469
                if ($ddatum[1] == '03') $mon = 'M&auml;rz';
470
                if ($ddatum[1] == '04') $mon = 'April';
471
                if ($ddatum[1] == '05') $mon = 'Mai';
472
                if ($ddatum[1] == '06') $mon = 'Juni';
473
                if ($ddatum[1] == '07') $mon = 'Juli';
474
                if ($ddatum[1] == '08') $mon = 'August';
475
                if ($ddatum[1] == '09') $mon = 'September';
476
                if ($ddatum[1] == '10') $mon = 'Oktober';
477
                if ($ddatum[1] == '11') $mon = 'November';
478
                if ($ddatum[1] == '12') $mon = 'Dezember';
479
                $tag = sprintf("%d",$ddatum[2]);
480
                $datum = $tag.". ".$mon." ".$ddatum[0];
481
 
482
                if (($date[0] != '') && ($date[1] != ''))
483
                {
484
                        if ($zeige_sekunden) $zus = ':'.$date[2]; else $zus = '';
485
                        return $datum.', '.$date[0].':'.$date[1].$zus.' Uhr';
486
                }
487
                else
488
                        return $datum;
489
        }
490
}
491
 
492
function zwischen_str($str, $von, $bis, $flankierungen_miteinbeziehen = true)
493
{
494
        $ausgabe = $str;
495
 
496
        if ($von != '')
497
        {
498
                $pos = strpos($ausgabe, $von);
499
                if ($pos !== false)
500
                {
501
                        $ausgabe = substr($ausgabe, $pos, strlen($ausgabe)-$pos);
502
                        if (!$flankierungen_miteinbeziehen)
503
                                $ausgabe = substr($ausgabe, strlen($von), strlen($ausgabe)-strlen($von)-1); // -1 ?
504
                }
505
        }
506
 
507
        if ($bis != '')
508
        {
509
                $pos = strpos($ausgabe, $bis);
510
                if ($pos !== false)
511
                {
512
                        $ausgabe = substr($ausgabe, 0, $pos+strlen($bis));
513
                        if (!$flankierungen_miteinbeziehen)
514
                                $ausgabe = substr($ausgabe, 0, strlen($ausgabe)-strlen($bis));
515
                }
516
        }
517
 
518
        return $ausgabe;
519
}
520
 
521
//////////////////////////////////////////////////////////////////////////////
522
// GFX/LISTE/OOP-FUNKTIONEN                                                 //
523
//////////////////////////////////////////////////////////////////////////////
524
 
525
function oop_link_to_modul($modul, $seite = 'main', $titelzeile_modul = '')
526
{
527
        if ($titelzeile_modul == '') $titelzeile_modul = $modul;
528
 
529
        $module_information = WBModuleHandler::get_module_information($titelzeile_modul);
530
 
531
        if (file_exists('modules/'.$titelzeile_modul.'/images/menu/32.gif'))
532
                $g = 'modules/'.$titelzeile_modul.'/images/menu/32.gif';
533
        else if (file_exists('modules/'.$titelzeile_modul.'/images/menu/32.png'))
534
                $g = 'modules/'.$titelzeile_modul.'/images/menu/32.png';
535
        else
536
                $g = 'designs/spacer.gif';
537
 
538
        return "javascript:oop('".$modul."', '".$seite."', '".wb_htmlentities($module_information->caption)."', '".$g."');";
539
}
540
 
541
function wb_list_items($modul, $table, $append, $dir = 0)
542
{
543
        global $benutzer;
544
 
545
        if (!isset($erg)) $erg = array();
546
 
547
        $i = 0;
548
        $res = db_query("SELECT * FROM `$table` WHERE `folder_cnid` = '".db_escape($dir)."' AND `user_cnid` = '".$benutzer['id']."' $append");
549
        while ($row = db_fetch($res))
550
        {
551
                $i++;
552
                $erg[$i] = $row;
553
        }
554
 
555
        return $erg;
556
}
557
 
558
function wb_list_items_filter($modul, $table, $append)
559
{
560
        $i = 0;
561
 
562
        $res = db_query("SELECT * FROM `$table` $append");
563
        while ($row = db_fetch($res))
564
        {
565
                $i++;
566
                $erg[$i] = $row;
567
        }
568
 
569
        return $erg;
570
}
571
 
572
function wb_draw_table_begin()
573
{
574
        echo '<div align="center"><table cellspacing="0" cellpadding="2" border="0" width="90%">';
575
}
576
 
577
function wb_draw_table_end()
578
{
579
        echo '</table></div><br>';
580
}
581
 
582
function wb_draw_table_content()
583
{
584
        echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">';
585
        $j = 0;
586
        for ($i=0; $i < @func_num_args(); $i=$i+2)
587
        {
588
                $j++;
589
                if (@func_get_arg($i) != '')
590
                        $w = 'width="'.@func_get_arg($i).'" ';
591
                else
592
                        $w = '';
593
                echo '<td valign="top" align="left" '.$w.'>'.@func_get_arg($i+1).'</td>';
594
        }
595
        if ($j == 0)
596
                echo '<td valign="top" align="left" width="100%">&nbsp;</td>';
597
        echo '</tr>'."\n";
598
}
599
 
600
function wb_draw_table_span_content($highlight, $span, $text)
601
{
602
        if ($highlight == 1) $hfarb = '4';
603
        if ($highlight == 0) $hfarb = '5';
604
        if ($highlight == 2) $hfarb = '6';
605
        echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">';
606
        echo '<td valign="top" align="left" colspan="'.$span.'">'.$text.'</td>';
607
        echo '</tr>';
608
 
609
}
610
 
611
function wb_draw_item_filter($modul, $table, $append)
612
{
613
        global $ordnereinzug, $WBConfig;
614
 
615
        $einzug = 0;
616
        $ary = wb_list_items_filter($modul, $table, $append);
617
        $durchlauf = 0;
618
        for ($i=1; isset($ary[$i]['id']); $i++)
619
        {
620
                $durchlauf++;
621
 
622
                if (file_exists('modules/'.$modul.'/includes/menuentry.inc.php'))
623
                        include('modules/'.$modul.'/includes/menuentry.inc.php');
624
 
625
                echo "\n";
626
        }
627
 
628
        return $durchlauf;
629
}
630
 
631
function wb_draw_item($modul, $table, $append, $folder = 0, $einzug = 0)
632
{
633
        global $ordnereinzug, $WBConfig;
634
 
635
        $ary = wb_list_items($modul, $table, $append, $folder);
636
        $durchlauf = 0;
637
        for ($i=1; isset($ary[$i]['id']); $i++)
638
        {
639
                $durchlauf++;
640
 
641
                if (file_exists('modules/'.$modul.'/includes/menuentry.inc.php'))
642
                        include('modules/'.$modul.'/includes/menuentry.inc.php');
643
        }
644
 
645
        return $durchlauf;
646
}
647
 
648
function wb_draw_menu_item($modul, $seite, $titel, $klein, $gross)
649
{
650
        if (file_exists($gross))
651
                $g = $gross;
652
        else
653
                $g = 'designs/spacer.gif';
654
 
655
        if (file_exists($klein))
656
                $k = $klein;
657
        else
658
                $k = 'designs/spacer.gif';
659
 
660
        return '<tr class="row_nav" onmouseover="this.className=\'row_nav_act\';" onmouseout="this.className=\'row_nav\';">
661
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="designs/spacer.gif" height="1" width="3" alt=""></td>
662
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="'.$k.'" height="16" width="16" alt=""></td>
663
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="designs/spacer.gif" height="1" width="5" alt=""></td>
664
        <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>
665
        <td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="designs/spacer.gif" alt="" width="1" height="1"></td>
666
</tr>'."\n";
667
}
668
 
669
function wb_draw_menu_spacer()
670
{
671
        return '<tr>
672
        <td colspan="5"><img src="designs/spacer.gif" alt="" width="1" height="14"></td>
673
</tr>';
674
}
675
 
676
//////////////////////////////////////////////////////////////////////////////
677
// FUNKTIONEN FÜR MODUL-XML UND DESIGN-XML                                                                                                                                      //
678
//////////////////////////////////////////////////////////////////////////////
679
 
680
require 'includes/xml.class.inc.php';
681
require 'includes/SecureMailer.class.php';
682
 
683
//////////////////////////////////////////////////////////////////////////////
684
// FUNKTIONEN FÜR MODUL-XML UND DESIGN-XML                                                                                                                                      //
685
//////////////////////////////////////////////////////////////////////////////
686
 
687
class WebBase_Module_Info
688
{
689
        private $f_name;
690
        private $f_author;
691
        private $f_version;
692
        private $f_language;
693
 
694
        // 0 = Public Freeware
695
        // 1 = Public Shareware
696
        // 2 = Private Secured
697
        // 3 = Personal WebBase-Core
698
        // 4 = Personal WebBase-Enclosure
699
        private $f_license;
700
 
701
        function name() {
702
                return $this->f_name;
703
        }
704
 
705
        function author() {
706
                return $this->f_author;
707
        }
708
 
709
        function version() {
710
                return $this->f_version;
711
        }
712
 
713
        function language() {
714
                return $this->f_language;
715
        }
716
 
717
        function license() {
718
                return $this->f_license;
719
        }
720
 
721
        function WebBase_Module_Info($name, $author, $version, $language, $license) {
722
                $this->f_name = $name;
723
                $this->f_author = $author;
724
                $this->f_version = $version;
725
                $this->f_language = $language;
726
                $this->f_license = $license;
727
        }
728
};
729
 
730
class WBModuleHandler {
731
 
732
        private static $cache_module_information = Array();
733
 
734
        function get_module_information($modulename)
735
        {
736
                if (isset(self::$cache_module_information[$modulename])) {
737
                        return self::$cache_module_information[$modulename];
738
                }
739
 
740
                if (function_exists('getmicrotime')) $ss = getmicrotime();
741
 
742
                $xml = new xml();
743
 
744
                if ((!strpos($modulename, '..')) && (file_exists('modules/'.$modulename.'/info.xml')))
745
                {
746
                        $object = $xml->xml_file_to_object('modules/'.$modulename.'/info.xml');
747
 
748
                        if ($object->name == 'moduleinfo')
749
                        {
750
                                $v_expected_name = '';
751
                                $v_author = '';
752
                                $v_version = '';
753
                                $v_language = '';
754
                                $v_license = '';
755
 
756
                                foreach ($object->children as $m1 => $m2)
757
                                {
758
                                        if ($object->children[$m1]->name == 'expected_name') $v_expected_name = $object->children[$m1]->content;
759
                                        if ($object->children[$m1]->name == 'author') $v_author = $object->children[$m1]->content;
760
                                        if ($object->children[$m1]->name == 'version') $v_version = $object->children[$m1]->content;
761
                                        if ($object->children[$m1]->name == 'language') $v_language = $object->children[$m1]->content;
762
                                        if ($object->children[$m1]->name == 'license') $v_license = $object->children[$m1]->content;
763
                                }
764
 
765
                                $output = new WebBase_Module_Info($v_expected_name, $v_author, $v_version, $v_language, $v_license);
766
 
767
                                if ($output->caption == '') $output->caption = $modulename;
768
 
769
                                if (function_exists('getmicrotime')) {
770
                                        $ee = getmicrotime();
771
                                        global $xml_time;
772
                                        $xml_time += $ee-$ss;
773
                                        global $xml_count;
774
                                        $xml_count++;
775
                                }
776
 
777
                                self::$cache_module_information[$modulename] = $output;
778
 
779
                                return $output;
780
                        }
781
                        else
782
                        {
783
                                return NULL;
784
                        }
785
                }
786
                else
787
                {
788
                        return NULL;
789
                }
790
        }
791
 
792
}
793
 
794
class WebBase_Design_Info
795
{
796
        private $f_name;
797
        private $f_author;
798
        private $f_version;
799
 
800
        // 0 = Third-Party-Product
801
        // 1 = Official Product
802
        private $f_license;
803
 
804
        function name() {
805
                return $this->f_name;
806
        }
807
 
808
        function author() {
809
                return $this->f_author;
810
        }
811
 
812
        function version() {
813
                return $this->f_version;
814
        }
815
 
816
        function license() {
817
                return $this->f_license;
818
        }
819
 
820
        function WebBase_Design_Info($name, $author, $version, $license) {
821
                $this->f_name = $name;
822
                $this->f_author = $author;
823
                $this->f_version = $version;
824
                $this->f_license = $license;
825
        }
826
};
827
 
828
class WBModuleHandler {
829
 
830
        private static $cache_design_information = Array();
831
 
832
        function get_design_information($designname)
833
        {
834
                if (isset(self::$cache_design_information[$designname])) {
835
                        return self::$cache_design_information[$designname];
836
                }
837
 
838
                if (function_exists('getmicrotime')) $ss = getmicrotime();
839
 
840
                $xml = new xml();
841
 
842
                if ((!strpos($designname, '..')) && (file_exists('designs/'.$designname.'/info.xml')))
843
                {
844
                        $object = $xml->xml_file_to_object('designs/'.$designname.'/info.xml');
845
 
846
                        if ($object->name == 'designinfo')
847
                        {
848
                                $v_name = '';
849
                                $v_author = '';
850
                                $v_version = '';
851
                                $v_license = '';
852
 
853
                                foreach ($object->children as $m1 => $m2)
854
                                {
855
                                        if ($object->children[$m1]->name == 'name') $v_name = $object->children[$m1]->content;
856
                                        if ($object->children[$m1]->name == 'author') $v_author = $object->children[$m1]->content;
857
                                        if ($object->children[$m1]->name == 'version') $v_version = $object->children[$m1]->content;
858
                                        if ($object->children[$m1]->name == 'license') $v_license = $object->children[$m1]->content;
859
                                }
860
 
861
                                $output = new WebBase_Design_Info($v_name, $v_author, $v_version, $v_license);
862
 
863
                                if ($output->name == '') $output->name = $designname;
864
 
865
                                if (function_exists('getmicrotime')) {
866
                                        $ee = getmicrotime();
867
                                        global $xml_time;
868
                                        $xml_time += $ee-$ss;
869
                                        global $xml_count;
870
                                        $xml_count++;
871
                                }
872
 
873
                                self::$cache_design_information[$designname] = $output;
874
 
875
                                return $output;
876
                        }
877
                        else
878
                        {
879
                                return NULL;
880
                        }
881
                }
882
                else
883
                {
884
                        return NULL;
885
                }
886
        }
887
}
888
 
889
/* Konstanten */
890
 
891
define('RELATIVE_DIR', dir_add_trailing_backslash(dirname($_SERVER['PHP_SELF'])));
892
 
1 daniel-mar 893
?>