<?php
if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgeführt werden.');
//////////////////////////////////////////////////////////////////////////////
// CODIERUNGSFUNKTIONEN //
//////////////////////////////////////////////////////////////////////////////
function encode_critical_html_characters($inp)
{
//$inp = str_replace('"', '"', $inp);
return $inp;
}
function decode_critical_html_characters($inp)
{
//$inp = str_replace('"', '"', $inp);
return $inp;
}
function executable_html_code($inp)
{
// Wenn der Benutzer z.B. ä im HTML-Formular eingegeben hat, würde hier aufgrund von Unicode quatsch rauskommen
$inp = decode_critical_html_characters($inp);
foreach ($trans as $m1 => $m2)
{
if (($m2 != '<') && ($m2 != '>'))
{
}
}
// Erweiterte Zeichensatztabelle, die auch da Euro-Zeichen enthält
// Entnommen von http://www.php.net/manual/de/function.get-html-translation-table.php#73410
$trans2 = array('''=>''', '−'=>'-', 'ˆ'=>'^', '˜'=>'~', 'Š'=>'Š', '‹'=>'‹', 'Œ'=>'Œ', '‘'=>'‘', '’'=>'’', '“'=>'“', '”'=>'”', '•'=>'•', '–'=>'–', '—'=>'—', '˜'=>'˜', '™'=>'™', 'š'=>'š', '›'=>'›', 'œ'=>'œ', 'Ÿ'=>'Ÿ', 'ÿ'=>'ÿ', 'Œ'=>'Œ', 'œ'=>'œ', 'Š'=>'Š', 'š'=>'š', 'Ÿ'=>'Ÿ', 'ƒ'=>'ƒ', 'ˆ'=>'ˆ', '˜'=>'˜', 'Α'=>'Α', 'Β'=>'Β', 'Γ'=>'Γ', 'Δ'=>'Δ', 'Ε'=>'Ε', 'Ζ'=>'Ζ', 'Η'=>'Η', 'Θ'=>'Θ', 'Ι'=>'Ι', 'Κ'=>'Κ', 'Λ'=>'Λ', 'Μ'=>'Μ', 'Ν'=>'Ν', 'Ξ'=>'Ξ', 'Ο'=>'Ο', 'Π'=>'Π', 'Ρ'=>'Ρ', 'Σ'=>'Σ', 'Τ'=>'Τ', 'Υ'=>'Υ', 'Φ'=>'Φ', 'Χ'=>'Χ', 'Ψ'=>'Ψ', 'Ω'=>'Ω', 'α'=>'α', 'β'=>'β', 'γ'=>'γ', 'δ'=>'δ', 'ε'=>'ε', 'ζ'=>'ζ', 'η'=>'η', 'θ'=>'θ', 'ι'=>'ι', 'κ'=>'κ', 'λ'=>'λ', 'μ'=>'μ', 'ν'=>'ν', 'ξ'=>'ξ', 'ο'=>'ο', 'π'=>'π', 'ρ'=>'ρ', 'ς'=>'ς', 'σ'=>'σ', 'τ'=>'τ', 'υ'=>'υ', 'φ'=>'φ', 'χ'=>'χ', 'ψ'=>'ψ', 'ω'=>'ω', 'ϑ'=>'ϑ', 'ϒ'=>'ϒ', 'ϖ'=>'ϖ', ' '=>' ', ' '=>' ', ' '=>' ', '‌'=>'‌', '‍'=>'‍', '‎'=>'‎', '‏'=>'‏', '–'=>'–', '—'=>'—', '‘'=>'‘', '’'=>'’', '‚'=>'‚', '“'=>'“', '”'=>'”', '„'=>'„', '†'=>'†', '‡'=>'‡', '•'=>'•', '…'=>'…', '‰'=>'‰', '′'=>'′', '″'=>'″', '‹'=>'‹', '›'=>'›', '‾'=>'‾', '⁄'=>'⁄', '€'=>'€', 'ℑ'=>'ℑ', '℘'=>'℘', 'ℜ'=>'ℜ', '™'=>'™', 'ℵ'=>'ℵ', '←'=>'←', '↑'=>'↑', '→'=>'→', '↓'=>'↓', '↔'=>'↔', '↵'=>'↵', '⇐'=>'⇐', '⇑'=>'⇑', '⇒'=>'⇒', '⇓'=>'⇓', '⇔'=>'⇔', '∀'=>'∀', '∂'=>'∂', '∃'=>'∃', '∅'=>'∅', '∇'=>'∇', '∈'=>'∈', '∉'=>'∉', '∋'=>'∋', '∏'=>'∏', '∑'=>'∑', '−'=>'−', '∗'=>'∗', '√'=>'√', '∝'=>'∝', '∞'=>'∞', '∠'=>'∠', '∧'=>'∧', '∨'=>'∨', '∩'=>'∩', '∪'=>'∪', '∫'=>'∫', '∴'=>'∴', '∼'=>'∼', '≅'=>'≅', '≈'=>'≈', '≠'=>'≠', '≡'=>'≡', '≤'=>'≤', '≥'=>'≥', '⊂'=>'⊂', '⊃'=>'⊃', '⊄'=>'⊄', '⊆'=>'⊆', '⊇'=>'⊇', '⊕'=>'⊕', '⊗'=>'⊗', '⊥'=>'⊥', '⋅'=>'⋅', '⌈'=>'⌈', '⌉'=>'⌉', '⌊'=>'⌊', '⌋'=>'⌋', '⟨'=>'〈', '⟩'=>'〉', '◊'=>'◊', '♠'=>'♠', '♣'=>'♣', '♥'=>'♥', '♦'=>'♦');
foreach ($trans2 as $m1 => $m2)
{
// Funktioniert chr() bei den 8... Einträgen? Finde Eurozeichen nicht bei chr(8364)!
if (($m2 != '<') && ($m2 != '>'))
}
return decode_critical_html_characters($inp);
}
//////////////////////////////////////////////////////////////////////////////
// VERSCHLÜSSELUNGSFUNKTIONEN FÜR SESSIONS U.A. //
//////////////////////////////////////////////////////////////////////////////
function special_hash($string)
{
$iterations = 10;
$last = $string;
$out = '';
for ($i=0; $i<$iterations; $i++)
{
$out .= $last;
}
$garbarge_count = 0;
for ($i=0; $i<strlen($last); $i++)
{
if (($last[$i] == '0') || ($last[$i] == '1') || ($last[$i] == '2') || ($last[$i] == '3') ||
($last[$i] == '4') || ($last[$i] == '5') || ($last[$i] == '6') || ($last[$i] == '7') ||
($last[$i] == '8') || ($last[$i] == '9'))
{
$garbarge_count = $garbarge_count + $last[$i];
}
}
for ($i=0; $i<=$garbarge_count; $i++)
{
$out = $last[0].$out.$last[1];
}
return $out;
}
function get_rnd_iv($iv_len)
{
$iv = '';
while ($iv_len-- > 0) {
}
return $iv;
}
function md5_encrypt($plain_text, $password, $iv_len = 16)
{
$plain_text .= "\x13";
if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
$i = 0;
$enc_text = get_rnd_iv($iv_len);
$iv = substr($password ^
$enc_text, 0, 512);
while ($i < $n) {
$enc_text .= $block;
$iv = substr($block . $iv, 0, 512) ^
$password;
$i += 16;
}
}
function md5_decrypt($enc_text, $password, $iv_len = 16)
{
$i = $iv_len;
$plain_text = '';
$iv = substr($password ^
substr($enc_text, 0, $iv_len), 0, 512);
while ($i < $n) {
$block = substr($enc_text, $i, 16);
$plain_text .= $block ^
pack('H*', md5($iv));
$iv = substr($block . $iv, 0, 512) ^
$password;
$i += 16;
}
}
function wb_encrypt($message, $key)
{
return md5_encrypt($message, $key);
}
function wb_decrypt($message, $key)
{
return md5_decrypt($message, $key);
}
//////////////////////////////////////////////////////////////////////////////
// NÜTZLICHE FUNKTIONEN //
//////////////////////////////////////////////////////////////////////////////
function WBUserAgent() {
global $WBConfig;
return 'ViaThinkSoft Personal WebBase '.$WBConfig->getRevision().' (PHP/'.phpversion().')';
}
// Anmerkung: Subdomains sind nicht gültig.
// @param $name Name des Cookies
// @value $value Wert des Cookies
// @param $time 0 für "Ende der Sitzung" oder Sekundenanzahl als Gültigkeit
function wbSetCookie($name, $value, $time) {
global $WBConfig;
if ($time != 0) $time += time();
setCookie($name, $value, $time, RELATIVE_DIR
, /* $_SERVER['HTTP_HOST'] */ '', $WBConfig->getForceSSLFlag());
}
// @param $name
// @param $wb_rel_path Path relative to the WebBase directory (for third-party systems!)
function wbUnsetCookie($name, $wb_rel_path = '') {
global $WBConfig;
setCookie($name, '', -1, RELATIVE_DIR
.$wb_rel_path, /* $_SERVER['HTTP_HOST'] */ '', $WBConfig->getForceSSLFlag());
}
// TODO (Prüfen)
// Das Argument von deferer() sollte aufgrund der W3C-Konformität & statt & enthalten
function deferer($url) {
return 'deferer.php?target='.urlencode($url);
}
function ip_tracer($ip) {
return deferer('http://www.ripe.net/fcgi-bin/whois?form_type=simple&full_query_string=&searchtext='.$ip.'&submit.x=0&submit.y=0');
}
function url_protokoll_vorhanden($url)
{
return ((strpos($ary[0], '/') === false) && (isset($ary[1])));
}
function wb_redirect_now($url) {
if (url_protokoll_vorhanden($url)) {
// Umwechseln von HTTP<->HTTPS ist bei gleicher Adresse ohne Deferrer erlaubt
if ((str_replace('https://', '', $url) != $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) &&
(str_replace('http://', '', $url) != $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
$url = deferer($url); // Umleitung auf eine externe Seite
}
}
} else {
// HTML-Weiterleitung
echo 'Redirect: <a href="'.$url.'">'.$url.'</a><br>'."\r\n\r\n";
echo '<script language ="JavaScript">
<!--
window.location.replace("'.$url.'");
// -->
</script>';
}
}
function add_trailing_path_delimiter($url_or_directory) {
if (substr($url_or_directory, strlen($url_or_directory)-1, 1) != '/') {
$url_or_directory .= '/';
}
return $url_or_directory;
}
function dirname_with_pathdelimiter($directory)
{
$tmp = add_trailing_path_delimiter($tmp);
return $tmp;
}
function string2hex($str)
{
{
$hex = "";
for ($i=0; $i<$length; $i++)
{
}
return $hex;
}
}
function hex2string($hex)
{
$string = '';
for ($ix=0; $ix < strlen($hex); $ix=$ix+2)
{
}
return $string;
}
// http://lists.phpbar.de/pipermail/php/Week-of-Mon-20040322/007749.html
function fetchip()
{
$client_ip = (isset($_SERVER['HTTP_CLIENT_IP'])) ?
$_SERVER['HTTP_CLIENT_IP'] : '';
$x_forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$remote_addr = (isset($_SERVER['REMOTE_ADDR'])) ?
$_SERVER['REMOTE_ADDR'] : '';
{
$ip_expl = explode('.',$client_ip);
$referer = explode('.',$remote_addr);
if($referer[0] != $ip_expl[0])
{
}
else
{
$return = $client_ip;
}
}
else if (!empty($x_forwarded_for))
{
if(strstr($x_forwarded_for,','))
{
$ip_expl = explode(',',$x_forwarded_for);
}
else
{
$return = $x_forwarded_for;
}
}
else
{
$return = $remote_addr;
}
unset ($client_ip, $x_forwarded_for, $remote_addr, $ip_expl);
return $return;
}
function my_htmlentities($inp, $charset = 'utf-8')
{
// http://www.php.net/manual/de/function.htmlspecialchars.php
// PHP-Version wird nicht kontrolliert...
$cs = 'utf-8';
if (strtolower($charset) == 'iso-8859-1') $cs = 'ISO-8859-1';
if (strtolower($charset) == 'iso8859-1') $cs = 'ISO-8859-1';
if (strtolower($charset) == 'iso-8859-15') $cs = 'ISO-8859-15';
if (strtolower($charset) == 'iso8859-15') $cs = 'ISO-8859-15';
if (strtolower($charset) == 'utf-8') $cs = 'UTF-8';
if (strtolower($charset) == 'cp866') $cs = 'cp866';
if (strtolower($charset) == 'ibm866') $cs = 'cp866';
if (strtolower($charset) == 'cp1251') $cs = 'cp1251';
if (strtolower($charset) == 'windows-1251') $cs = 'cp1251';
if (strtolower($charset) == 'win-1251') $cs = 'cp1251';
if (strtolower($charset) == '1251') $cs = 'cp1251';
if (strtolower($charset) == 'cp1252') $cs = 'cp1252';
if (strtolower($charset) == 'windows-1252') $cs = 'cp1252';
if (strtolower($charset) == '1252') $cs = 'cp1252';
if (strtolower($charset) == 'koi8-r') $cs = 'KOI8-R';
if (strtolower($charset) == 'koi8-ru') $cs = 'KOI8-R';
if (strtolower($charset) == 'koi8r') $cs = 'KOI8-R';
if (strtolower($charset) == 'gb2312') $cs = 'GB2312';
if (strtolower($charset) == '936') $cs = 'GB2312';
if (strtolower($charset) == 'big5-hkscs') $cs = 'BIG5-HKSCS';
if (strtolower($charset) == 'shift_jis') $cs = 'Shift_JIS';
if (strtolower($charset) == 'sjis') $cs = 'Shift_JIS';
if (strtolower($charset) == '932') $cs = 'Shift_JIS';
if (strtolower($charset) == 'euc-jp') $cs = 'EUC-JP';
if (strtolower($charset) == 'eucjp') $cs = 'EUC-JP';
}
function check_email($email_adresse)
{
if(eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$",$email_adresse))
return true;
else
return false;
}
function return_bytes($val)
{
switch($last)
{
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
function zufall($size)
{
$result = "";
for($i=0; $i < $size; $i++)
{
while (($num >= 58 && $num <= 64) || ($num >= 91 && $num <= 96))
}
return $result;
}
function runden($inp, $nachkommastellen = 0)
{
}
function dir_add_trailing_backslash($directory) {
if (substr($directory, strlen($directory)-1, 1) != '/') $directory .= '/';
return $directory;
}
// PHP-AntiSpam-Funktion "secure_email", Version 3.0
// von Daniel Marschall [www.daniel-marschall.de]
function secure_email($email, $linktext, $crypt_linktext)
{
{
function alas_js_crypt($text)
{
$tmp = '';
for ($i=0; $i<strlen($text); $i++)
{
$tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");';
}
return $tmp;
}
}
{
function alas_js_write($text)
{
$text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
return 'document.write("'.$text.'");';
}
}
$aus = '';
if ($email != '')
{
$aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n";
$aus .= alas_js_write('<a href="');
$aus .= alas_js_crypt('mailto:'.$email);
$aus .= alas_js_write('">');
$aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
$aus .= alas_js_write('</a>').'// --></script>';
}
return $aus;
}
function de_convertmysqldatetime($datum, $zeige_sekunden = false)
{
if (($datum == '') || ($datum == '0000-00-00 00:00:00'))
{
return 'Unbekannt';
}
else
{
{
}
else
{
$date[0] = '';
$date[1] = '';
$date[2] = '';
}
if ($ddatum[1] == '01') $mon = 'Januar';
if ($ddatum[1] == '02') $mon = 'Februar';
if ($ddatum[1] == '03') $mon = 'März';
if ($ddatum[1] == '04') $mon = 'April';
if ($ddatum[1] == '05') $mon = 'Mai';
if ($ddatum[1] == '06') $mon = 'Juni';
if ($ddatum[1] == '07') $mon = 'Juli';
if ($ddatum[1] == '08') $mon = 'August';
if ($ddatum[1] == '09') $mon = 'September';
if ($ddatum[1] == '10') $mon = 'Oktober';
if ($ddatum[1] == '11') $mon = 'November';
if ($ddatum[1] == '12') $mon = 'Dezember';
$datum = $tag.". ".$mon." ".$ddatum[0];
if (($date[0] != '') && ($date[1] != ''))
{
if ($zeige_sekunden) $zus = ':'.$date[2]; else $zus = '';
return $datum.', '.$date[0].':'.$date[1].$zus.' Uhr';
}
else
return $datum;
}
}
function zwischen_str($str, $von, $bis, $flankierungen_miteinbeziehen = true)
{
$ausgabe = $str;
if ($von != '')
{
$pos = strpos($ausgabe, $von);
if ($pos !== false)
{
if (!$flankierungen_miteinbeziehen)
}
}
if ($bis != '')
{
$pos = strpos($ausgabe, $bis);
if ($pos !== false)
{
if (!$flankierungen_miteinbeziehen)
}
}
return $ausgabe;
}
//////////////////////////////////////////////////////////////////////////////
// GFX/LISTE/OOP-FUNKTIONEN //
//////////////////////////////////////////////////////////////////////////////
function oop_link_to_modul($modul, $seite = 'main', $titelzeile_modul = '')
{
if ($titelzeile_modul == '') $titelzeile_modul = $modul;
$module_information = WBModuleHandler::get_module_information($titelzeile_modul);
if (file_exists('modules/'.$titelzeile_modul.'/images/menu/32.gif'))
$g = 'modules/'.$titelzeile_modul.'/images/menu/32.gif';
else if (file_exists('modules/'.$titelzeile_modul.'/images/menu/32.png'))
$g = 'modules/'.$titelzeile_modul.'/images/menu/32.png';
else
$g = 'designs/spacer.gif';
return "javascript:oop('".$modul."', '".$seite."', '".htmlentities($module_information->caption)."', '".$g."');";
}
function wb_list_items($modul, $table, $append, $dir = 0)
{
global $benutzer;
$i = 0;
$res = db_query("SELECT * FROM `$table` WHERE `folder_cnid` = '".db_escape($dir)."' AND `user_cnid` = '".$benutzer['id']."' $append");
while ($row = db_fetch($res))
{
$i++;
$erg[$i] = $row;
}
return $erg;
}
function wb_list_items_filter($modul, $table, $append)
{
$i = 0;
$res = db_query("SELECT * FROM `$table` $append");
while ($row = db_fetch($res))
{
$i++;
$erg[$i] = $row;
}
return $erg;
}
function wb_draw_table_begin()
{
echo '<div align="center"><table cellspacing="0" cellpadding="2" border="0" width="90%">';
}
function wb_draw_table_end()
{
echo '</table></div><br>';
}
function wb_draw_table_content()
{
echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">';
$j = 0;
{
$j++;
else
$w = '';
echo '<td valign="top" align="left" '.$w.'>'.@func_get_arg($i+1).'</td>';
}
if ($j == 0)
echo '<td valign="top" align="left" width="100%"> </td>';
echo '</tr>'."\n";
}
function wb_draw_table_span_content($highlight, $span, $text)
{
if ($highlight == 1) $hfarb = '4';
if ($highlight == 0) $hfarb = '5';
if ($highlight == 2) $hfarb = '6';
echo '<tr class="row_tab" onmouseover="this.className=\'row_tab_act\';" onmouseout="this.className=\'row_tab\';">';
echo '<td valign="top" align="left" colspan="'.$span.'">'.$text.'</td>';
echo '</tr>';
}
function wb_draw_item_filter($modul, $table, $append)
{
global $ordnereinzug, $WBConfig;
$einzug = 0;
$ary = wb_list_items_filter($modul, $table, $append);
$durchlauf = 0;
for ($i=1; isset($ary[$i]['id']); $i++)
{
$durchlauf++;
if (file_exists('modules/'.$modul.'/includes/menuentry.inc.php'))
include('modules/'.$modul.'/includes/menuentry.inc.php');
echo "\n";
}
return $durchlauf;
}
function wb_draw_item($modul, $table, $append, $folder = 0, $einzug = 0)
{
global $ordnereinzug, $WBConfig;
$ary = wb_list_items($modul, $table, $append, $folder);
$durchlauf = 0;
for ($i=1; isset($ary[$i]['id']); $i++)
{
$durchlauf++;
if (file_exists('modules/'.$modul.'/includes/menuentry.inc.php'))
include('modules/'.$modul.'/includes/menuentry.inc.php');
}
return $durchlauf;
}
function wb_draw_menu_item($modul, $seite, $titel, $klein, $gross)
{
$g = $gross;
else
$g = 'designs/spacer.gif';
$k = $klein;
else
$k = 'designs/spacer.gif';
return '<tr class="row_nav" onmouseover="this.className=\'row_nav_act\';" onmouseout="this.className=\'row_nav\';">
<td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="designs/spacer.gif" height="1" width="3" alt=""></td>
<td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="'.$k.'" height="16" width="16" alt=""></td>
<td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="bottom" align="left"><img src="designs/spacer.gif" height="1" width="5" alt=""></td>
<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>
<td onclick="oop(\''.$modul.'\', \''.$seite.'\', \''.$titel.'\', \''.$g.'\');" valign="middle" align="left"><img src="designs/spacer.gif" alt="" width="1" height="1"></td>
</tr>'."\n";
}
function wb_draw_menu_spacer()
{
return '<tr>
<td colspan="5"><img src="designs/spacer.gif" alt="" width="1" height="14"></td>
</tr>';
}
//////////////////////////////////////////////////////////////////////////////
// FUNKTIONEN FÜR MODUL-XML UND DESIGN-XML //
//////////////////////////////////////////////////////////////////////////////
require 'includes/xml.class.inc.php';
require 'includes/SecureMailer.class.php';
//////////////////////////////////////////////////////////////////////////////
// FUNKTIONEN FÜR MODUL-XML UND DESIGN-XML //
//////////////////////////////////////////////////////////////////////////////
require 'includes/WBModulHandler.class.php';
require 'includes/WBDesignHandler.class.php';
/* Konstanten */
define('RELATIVE_DIR', dir_add_trailing_backslash
(dirname($_SERVER['PHP_SELF'])));
?>