$val ) if ( is_array( $array2[ $akey ] ) ) $merged[ $akey ] = is_array($merged[ $akey] ) ? array_merge_recursive_distinct( $merged[ $akey ], $array2[ $akey ] ) : $array2[ $akey ] ; else $merged[ $akey ] = $val; return $merged; } function addusermessage( $text, $options = array() ) { global $gl_; $gl_['message'][] = $text; } function sortarr_order( $arr1, $arr2 ) { if ( $arr1[ 'order' ] == $arr2[ $compfield ] ) return 0; return ( $arr1[ 'order' ] < $arr2[ 'order' ] ) ? -1 : 1; } function number_format_de( $num, $dec = 0 ) { return number_format( $num, $dec, ',', '.' ); } function int_format_de( $int ) { return number_format( $num, 0, ',', '.' ); } function setdefault( $checktype, $comparewith, $defaultvalue ) { traceuser( __FUNCTION__, 12, "+", " aufgerufen checktype=".$checktype ); switch( $checktype ) { case "NE" : // means: not empty... if ( $comparewith == "" ) $returnvalue = $defaultvalue; else $returnvalue = $comparewith; break; default: $fldval .= $chr; break; } traceuser( __FUNCTION__, 12, "-", " ende returnvalue=".$returnvalue ); return $returnvalue; } function getdomain( $hostname ) { traceuser( __FUNCTION__, 4, "+", " aufgerufen subdomain=".$hostname ); $dotarr = explode( '.', $hostname ); $dotparts = count( $dotarr ); if ( $dotparts <= 2 ) { traceuser( __FUNCTION__, 4, "-", " keine subdomain, return=".$hostname ); return $hostname; } $domain = $dotarr[ $dotparts - 2 ].'.'.$dotarr[ $dotparts - 1 ]; traceuser( __FUNCTION__, 4, "-", " ende domain=".$domain ); return $domain; } function parse_csv( $data, $delim = ';', $enclosure = '"' ) { global $glretarray; $enclosed = false; $fldcount = 0; $linecount = 0; $fldval = ''; $ret_array = array(); for( $i = 0; $i < strlen( $data ); $i++ ) { $chr = $data{$i}; switch( $chr ) { case $enclosure: if( $enclosed && ( $data{$i+1} == $enclosure ) ) { //double enclosure means single one: only inside!! $fldval .=$chr; $i++; //skip next char } else $enclosed = !$enclosed; break; case $delim: if( !$enclosed ) { $ret_array[ $linecount ][ $fldcount++ ] = trim( $fldval ); $fldval=''; } else $fldval.=$chr; break; case "\r": if( !$enclosed && ( $data{$i+1} == "\n" ) ) continue; case "\n": if( !$enclosed ) { $ret_array[ $linecount++ ][ $fldcount ] = trim( $fldval ); $fldcount = 0; $fldval = ''; } else $fldval .= $chr; break; default: $fldval .= $chr; } } if ( $fldval ) $ret_array[ $linecount ][ $fldcount] = trim( $fldval ); $glretarray = $ret_array; return $ret_array; } function checkbrowser ( $useragent ) { traceuser( __FUNCTION__, 8, "+", "useragent=".$useragent ); $browsername = "NN"; $browserversion = "NN"; $browseropsys = "NN"; global $browser; global $opsys; while ( 1 ) { // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) // Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5 // Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) if ( preg_match_all( "=Mozilla/4\.0 \(compatible; MSIE (.*); (.*)[;)](.*?)=sU", $useragent, $browser ) ) { $browsername = "MSIE"; $browserversion = $browser[1][0]; $browseropsys = $browser[2][0]; break; } // Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1) Gecko/20061010 Firefox/2.0 WEB.DE // Mozilla/5.0 (X11; U; Linux i586; de-DE; rv:1.7.10) Gecko/20050717 Firefox/1.0.6 if ( preg_match_all( "=(.*)Gecko/(.*) Firefox/(.*)=", $useragent, $browser ) ) { $browsername = "Firefox"; $browserversion = $browser[3][0]; $browserdebug = $browser[1][0]; if ( preg_match_all( "=\((.*); U;(.*);(.*)\)=U", $browser[1][0], $opsys ) ) $browseropsys = $opsys[2][0]; break; } // 5;Opera/9.24 (Windows NT 5.0; U; de) // Opera/9.23 (Windows NT 5.1; U; de) if ( preg_match_all( "=Opera/(.*) \((.*); U;(.*)\)=U", $useragent, $browser ) ) { $browsername = "Opera"; $browserversion = $browser[1][0]; $browseropsys = $browser[2][0]; break; } // Mozilla/5.0 (Windows; U; Windows NT 5.1; de-AT; rv:1.7.12) Gecko/20050915 // Mozilla/5.0 (Windows; U; Windows NT 5.1; de-AT; rv:1.8.1.2) Gecko/20070222 SeaMonkey/1.1.1 if ( preg_match_all( "=Mozilla/5\.0 \((.*); U;(.*);(.*);(.*)Gecko/(.*)=U", $useragent, $browser ) ) { $browsername = "Mozilla"; $browserversion = "5.0"; $browseropsys = $browser[2][0]; break; } // Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de-de) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3 // Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de-de) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419 if ( preg_match_all( "=Mozilla/5.0 \((.*); U ;(.*);(.*)Safari/(.*)=", $useragent, $browser ) ) { $browsername = "Safari"; $browserversion = $browser[4][0]; $browseropsys = $browser[2][0]; break; } break; } setsession( 'browsername', $browsername ); setsession( 'browserversion', $browserversion ); setsession( 'browseropsys', $browseropsys ); setsession( 'browsercheck', "PHP" ); } // weil put_contents in 4.3.mist nicht existiert function my_file_put_contents( $filename, $contents ) { traceuser( __FUNCTION__, 3, "+", "aufgerufen" ." filename=".strlen( $filename ) ." laenge=".strlen( $contents ) ); $fp = fopen( $filename, "w" ); if ( !$fp ) { traceuser( __FUNCTION__, 0, "=", "fehler beim oeffnen=".$filename ); return -1; } fputs( $fp, $contents ); fclose( $fp ); traceuser( __FUNCTION__, 3, "-", "ende mit ok" ); return 0; } // 5.0.3. wrapper...: if ( !function_exists( 'file_put_contents' ) ) { function file_put_contents( $filename, $contents ) { return my_file_put_contents( $filename, $contents ); } } //irgendwas in hervorhebe-span einbetten function showclasswhen ( $spanclass, $text, $condition ) { if ( $condition ) $text = "".$text.""; return $text; } // some defaul-timestamps function now( $format = "myts" ) { switch( $format ) { case "my" : case "myts" : return date( "Y-m-d H:i:s" ); break; case "sort" : return date( "YmdHis" ); break; case "de" : case "dets" : case "ger-ts" : case "gerts" : return date( "d.m.Y H:i:s" ); break; case "ux" : case "uxts" : default; // gibt unix-TS?! return date(); } } function ts_not_set( $format = "myts" ) { switch( $format ) { case "myts" : return "0000-00-00 00:00:00"; break; default; return 0; } } function ts_far_away( $format = "myts" ) { switch( $format ) { case "myts" : return "9999-12-31 23:59:59"; break; default; return 0; } } function writephparray( $directory, $filename, $arrayname, $arrayvars, $options = array() ) { // schreibt ein includefile, in dem php-arrays als variablen deklariert sind // flaches array!! 1 ebene traceuser( __FUNCTION__, 8, "+", "dir=".$directory ." file=".$filename ); if ( !file_exists( $directory ) ) { traceuser( __FUNCTION__, 0, "file", "dir=".$directory." existiert nicht" ); return; } $countarr = 0; $countvar = 0; foreach ( $arrayvars as $key => $value ) { $countvar++; $varstring .= "\n ".str_pad( '$'.$arrayname."['".$key."']", 40 ) ."= '".$value."';"; } traceuser( __FUNCTION__, 8, "-", "arrays anzahl=".$countarr ." vars=".$countvar ); file_put_contents( $directory."/".$filename, "\n" ); } function printarr( $myarray, $prefix = "" ) { foreach ( $myarray as $key => $value ) { if ( is_array( $value ) ) $varstring .= printarr( $value, $prefix . $key . "==>\t" ); else $varstring .= "\n".$prefix.$key."\t ==> ".'"'.$value.'";'; } return $varstring; } function writearrays( $directory, $filename, $arraylist, $options = array() ) { traceuser( __FUNCTION__, 8, "+", "dir=".$directory ." file=".$filename ); if ( !file_exists( $directory ) ) { traceuser( __FUNCTION__, 0, "-", "dir=".$directory." existiert nicht" ); return; } $varstring = printarr( $arraylist ); file_put_contents( $directory."/".$filename, $varstring ); traceuser( __FUNCTION__, 8, "-", "len=".strlen($varstring) ); } function writevars( $directory, $filename, $vararray, $options = array() ) { traceuser( __FUNCTION__, 8, "file", "dir=".$directory ." file=".$filename ); if ( !file_exists( $directory ) ) { traceuser( __FUNCTION__, 0, "file", "dir=".$directory." existiert nicht" ); return; } foreach ( $vararray as $key => $value ) { $varstring .= "\n\t$".$key."\t\t = ".'"'.$value.'";'; } file_put_contents( $directory."/".$filename, "\n" ); } // das folgende dient zum kapseln, um das zeug auch mal über die // datenbank schleifen zu können function setsession( $para, $value ) { traceuser( __FUNCTION__, 4, "file", "para=".$para ." oldvalue=".$_SESSION[$para] ." newvalue=".$value ); $_SESSION[$para] = $value; } function getsession( $para, $defaultvalue = "", $dotrace = 1 ) { if ( $dotrace ) traceuser( __FUNCTION__, 25, "+", "para=".$para ." defaultvalue=".$defaultvalue ); if ( $_SESSION[$para] != "" ) $value = $_SESSION[$para]; else { if ( $defaultvalue != "" ) { setsession( $para, $defaultvalue ); $value = $defaultvalue; } else $value = ""; } // achtung der ist scheissgefaehrlich, // wenn getsession von traceuser aufgerufen wird // abrauchen ohne irgendwelche spuren ... wg rekursiv if ( $dotrace ) traceuser( __FUNCTION__, 25, "-", "para=".$para ." value=".$value ); return $value; } //neue funktionen function bool2str( $bool ) { // setzt logische variable in byte-string um.... return( $bool ) ? "Y" : "N"; } function str2bool( $str ) { // setzt logische variable in byte-string um.... return( $str == "Y" ); } // um emails vor robotern zu verstecken function hideemail( $email ) { $hidestr = ""; $l = strlen( $email ); for ( $i = 0; $i < $l; $i++ ) { $char = substr( $email, $i, 1 ); $hidestr .= "&#".ord( $char ).";"; } return $hidestr; } function writeemailref( $email ) { traceuser( __FUNCTION__, "12", "+", "aufgerufen mail=[".$email."]" ); $mailstr = "".hideemail( $email ).""; traceuser( __FUNCTION__, "12", "-", "return mailstr=[".$mailstr."]" ); return $mailstr; } function nop() { return; } // die brauchts immer! function lastchars( $string, $len = 1 ) { $l = strlen( $string ); if ( $l < $len ) return $string; return substr( $string, $l - $len); } // schreibt den kopf von bis und eventuell noch ein wenig danach function writeheader( $options = array() ) { global $def_; global $sgl_; global $gl_; global $refresh_url; global $refresh_sec; $pic_dir = "http://".$gl_['picturedom'].'/detail/'; if ( ( getsession( 'showmenu' ) == "N" ) || ( $options['showmenu'] == 'N' ) ) $docmenuclass = "disp_none"; else $docmenuclass = "disp_block"; if ( ( getsession( 'showtitel' ) == "N" ) || ( $options['showtitel'] == 'N' ) ) $doctitelclass = "disp_none"; else $doctitelclass = "disp_block"; echo "\n"; echo "\n"; echo "\n"; echo "".$def_['domainabbrev'].": ".$options['headtitlelong']."\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ( $refresh_url != "" ) { echo "\n"; } echo "\n"; echo "'."\n"; //echo "\n"; echo "\n"; echo "\n"; include_once( "biblio2.js" ); echo ''."\n"; echo "\n"; echo " \n"; echo "\n"; if ( !isset( $options[ 'objecttype' ] ) ) { echo "
\n"; include_once( 'legend.html' ); global $fpara, $rpara; echo "
\n"; echo "
\n"; echo "
\n"; echo "

".$def_['domaintitle']."

\n"; echo "
\n"; echo "
\n"; if ( !( $options['showheader'] == 'N' ) ) echo "

".$options['headtitlelong']."

\n"; } } function traceuser( $functionname, $tracelevel, $indent, $tracetext, $options = array() ) { global $gl_; //$gl_['message'][] = $functionname.": ".$tracetext; //return; $global_tracelevel = getsession( 'trace', "", 0 ); if ( $indent == "+" ) $gl_['trace_indent']++; $myindent = $gl_['trace_indent']; // mit dem muss gearbeitet werden! if ( $indent == "-" ) $gl_['trace_indent']--; // der ist nur für folgeaufrufe if ( $options['addusermessage'] == 1 ) addusermessage( $tracetext ); if ( $global_tracelevel < $tracelevel ) return; $indentprefix = ''; if ( $gl_['trace_indent'] > 1 ) $indentprefix .= str_pad( "", $myindent - 1, '.' ); if ( $myindent > 0 ) { switch( $indent ) { case "+" : $indentprefix .= '+'; break; case "-" : $indentprefix .= '-'; break; default; $indentprefix .= '.'; } } $text = sprintf( "%40.40s %20.20s |%2.2d-%2.2d-%2.2d| %s %s", lastchars($_SERVER[PHP_SELF], 40), $functionname, $global_tracelevel, $tracelevel, $gl_['trace_indent'], $indentprefix, $tracetext ); if ( isset( $gl_['file']['usertrace'] ) ) { if ( isset( $gl_['file']['usertrace']['error'] ) ) return; $fd = $gl_['file']['usertrace']['fd']; } else { $tracefile = $gl_['trace_dir']."/".session_id().".trc"; $fd = fopen( $tracefile, "a" ); if ( $fd ) { $gl_['file']['usertrace']['fd'] = $fd; $gl_['file']['usertrace']['filename'] = $tracefile; } else { loguser( __FUNCTION__, "FILE 1001", array( "file=>" => $tracefile ) ); $gl_['file']['usertrace']['error'] = "fileopen"; return; } } $text = sprintf( "%s %s", date( "H:i:s" ), $text ); fputs( $fd, $text."\n" ); return; } function loguser( $functionname , $meldungsnr , $argarray , $logfile = "" , $logpara = "" ) { global $_SERVER; global $gl_; //$gl_['message'][] = $meldungsnr.' '.serialize( $argarray ); //return; $text = sprintf( "%30.30s %20.20s %s", lastchars($_SERVER[PHP_SELF], 30), $functionname, $meldungsnr ); foreach( $argarray as $b ) { $text .= '\\'.$b; } $text = sprintf( "%s %15.15s %5.5s %s", date( "Y.m.d H:i:s" ), $_SERVER[REMOTE_ADDR], session_id(), $text.'\\' ); if ( $logfile == "" ) $logfile = $gl_['log_dir']."/log_001.txt"; $fp = fopen( $logfile, "a" ) or die( "fopen $logfile"); fputs( $fp, $text."\n" ); fclose( $fp ); return; } function replacechar( $oldstring ) { return urlencode( $oldstring );} // table formatting functions function tablehead() { echo ftablehead(); } function ftablehead(){ { return ""; } } function tabletitle() { echo ftabletitle(); } function ftabletitle() { return ""; } function holdtablerow() { echo fholdtablerow(); } function fholdtablerow() { global $tabrowcolor; if ( $tabrowcolor == "" ) $tabrowcolor = 1; return "class=\"".( ( $tabrowcolor == 1 ) ? "gerade" : "ungerade")."\""; } function fstarttablerow() { global $tabrowcolor; $tabrowcolor = 1; return fholdtablerow(); } function starttablerow() { global $tabrowcolor; $tabrowcolor = 1; holdtablerow(); } function tablerow() { global $tabrowcolor; $tabrowcolor = ( $tabrowcolor == 1 ) ? 2 : 1; holdtablerow(); } function ftablerow() { global $tabrowcolor; $tabrowcolor = ( $tabrowcolor == 1 ) ? 2 : 1; return fholdtablerow(); } function buildquery( $newname, $newvalue, $old ) { if ( $newvalue == "" ) return $old; if ( $old == "" ) $old = "?"; else $old = $old."&"; $old = $old.$newname."=".replacechar( $newvalue ); return $old; } function buildquerystr( $newstr, $oldstr ) { $oldstr = ( $oldstr == "" ) ? "?" : $oldstr."&"; $oldstr .= $newstr; return $oldstr; } function shownewmyts( $mytimestamp, $options = array() ) { // neuerdings kommen die mistdinger so 2005-02-21 06:55:26 traceuser( __FUNCTION__, "9", "+", "mytimestamp=$mytimestamp" ); $a = shownewux( myts2uxts( $mytimestamp, $options ) ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$a" ); return $a; } function shownewdets( $mytimestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "mytimestamp=$mytimestamp" ); $a = shownewux( dets2uxts( $mytimestamp ), $options ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$a" ); return $a; } function shownewts( $mytimestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "mytimestamp=$mytimestamp" ); $a = shownewux( dets2uxts( $mytimestamp ), $options ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$a" ); return $a; } function shownewux( $mytimestamp, $options = array() ) { // eingabeformat unixsekunden global $CONST_; $writetitle = ( isset( $options['dontwritetitle'] ) ) ? 0 : 1; traceuser( __FUNCTION__, "8", "+", "aufgerufen, mytimestamp=$mytimestamp" ); if ( $mytimestamp <= 0 ) $mytimestamp = 0; $diff = time() - $mytimestamp; while (1) { if ( $diff > 180 * 84400 ) { $format = "y9dot"; break; } if ( $diff > 56 * 84400 ) { $format = "m6dot"; break; } if ( $diff > 28 * 84400 ) { $format = "w8dot"; break; } if ( $diff > 7 * 84400 ) { $format = "w4dot"; break; } if ( $diff > 2 * 84400 ) { $format = "w1dot"; break; } $format = "d2dot"; break; } $myts = uxts2myts($mytimestamp); traceuser( __FUNCTION__, "11", "=", "ende, format=".$format ); $dotstr = ""; traceuser( __FUNCTION__, "8", "-", "ende, dotstr=".$dotstr ); return $dotstr; } function uxts2arts( $mytimestamp, $options = array() ) { traceuser( __FUNCTION__, "10", "+", "mytimestamp=$mytimestamp" ); $arr1 = getdate( $mytimestamp ); $tsarr['yyyy'] = $arr1["year"]; $tsarr['mm'] = $arr1["mon"]; $tsarr['dd'] = $arr1["mday"]; $tsarr['hh'] = $arr1["hours"]; $tsarr['mi'] = $arr1["minutes"]; $tsarr['ss'] = $arr1["seconds"]; traceuser( __FUNCTION__, "10", "-", "arr=".implode( ',', $tsarr ) ); return $tsarr; } function dets2arts( $mytimestamp, $options = array() ) { traceuser( __FUNCTION__, "10", "+", "mytimestamp=$mytimestamp" ); if ( strlen( $mytimestamp ) > 8 ) { $arr1 = explode( " ", $mytimestamp ); $mydate = $arr1[0]; $mytime = substr($arr1[1],0,8); //TODO: this drops millis... } else { $mydate = $mytimestamp; $mytime = "00:00:00"; } traceuser( __FUNCTION__, "10", "=", "mydate=$mydate mytime=$mytime" ); $datearr = explode( ".", $mydate ); $timearr = explode( ":", $mytime ); $tsarr['yyyy'] = $datearr[2]; $tsarr['mm'] = $datearr[1]; $tsarr['dd'] = $datearr[0]; $tsarr['hh'] = $timearr[0]; $tsarr['mi'] = $timearr[1]; $tsarr['ss'] = $timearr[2]; traceuser( __FUNCTION__, "10", "-", "arr=".implode( ',', $tsarr ) ); return $tsarr; } function myts2arts( $mytimestamp, $options = array() ) { // vor 4.1.9 war das 20051101173459, danach 2005-11-01 17:34:59 traceuser( __FUNCTION__, "10", "+", "mytimestamp=$mytimestamp" ); $tsarr['yyyy'] = substr( $mytimestamp, 0, 4 ); $tsarr['mm'] = substr( $mytimestamp, 5, 2 ); $tsarr['dd'] = substr( $mytimestamp, 8, 2 ); if ( strlen( $mytimestamp ) == 19 ) { $tsarr['hh'] = substr( $mytimestamp,11, 2 ); $tsarr['mi'] = substr( $mytimestamp,14, 2 ); $tsarr['ss'] = substr( $mytimestamp,17, 2 ); } if ( strlen( $mytimestamp ) == 14 ) { $tsarr['hh'] = substr( $mytimestamp, 8, 2 ); $tsarr['mi'] = substr( $mytimestamp,10, 2 ); $tsarr['ss'] = substr( $mytimestamp,12, 2 ); } if ( strlen( $mytimestamp ) == 10 ) { $tsarr['hh'] = '00'; $tsarr['mi'] = '00'; $tsarr['ss'] = '00'; } traceuser( __FUNCTION__, "10", "-", "arr=".implode( ',', $tsarr ) ); return $tsarr; } function arts2dets( $tsarr, $options = array() ) { traceuser( __FUNCTION__, "10", "+", "timestamp=".implode( ',', $tsarr ) ); $newts = sprintf( "%3\$02d.%2\$02d.%1\$04d %4\$02d:%5\$02d:%6\$02d", $tsarr['yyyy'], $tsarr['mm'] , $tsarr['dd'] , $tsarr['hh'] , $tsarr['mi'] , $tsarr['ss'] ); traceuser( __FUNCTION__, "10", "-", "ergebnis=$newts" ); return $newts; } function arts2myts( $tsarr, $options = array() ) { traceuser( __FUNCTION__, "10", "+", "timestamp=".implode( ',', $tsarr ) ); $newts = sprintf( "%1\$04d-%2\$02d-%3\$02d %4\$02d:%5\$02d:%6\$02d", $tsarr['yyyy'], $tsarr['mm'] , $tsarr['dd'] , $tsarr['hh'] , $tsarr['mi'] , $tsarr['ss'] ); traceuser( __FUNCTION__, "10", "-", "ergebnis=$newts" ); return $newts; } function arts2uxts( $tsarr, $options = array() ) { traceuser( __FUNCTION__, "10", "+", "timestamp=".implode( ',', $tsarr ) ); $newts = mymktime( $tsarr['yyyy'], $tsarr['mm'] , $tsarr['dd'] , $tsarr['hh'] , $tsarr['mi'] , $tsarr['ss'] ); traceuser( __FUNCTION__, "10", "-", "ergebnis=$newts" ); return $newts; } function switchts( $timestamp, $fromformat, $toformat, $options = array() ) { traceuser( __FUNCTION__, "8", "+", "timestamp=$timestamp" ."from=".$fromformat ."to=".$toformat ); $funcname = $fromformat.'ts2'. $toformat.'ts'; if ( function_exists( $funcname ) ) $timestamp = $funcname( $timestamp, $options ); traceuser( __FUNCTION__, "8", "-", "ergebnis=$timestamp" ); return $timestamp; } function uxts2myts( $timestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "timestamp=$timestamp" ); $newts = arts2myts( uxts2arts( $timestamp ) ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$newts" ); return $newts; } function uxts2dets( $timestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "timestamp=$timestamp" ); $newts = arts2dets( uxts2arts( $timestamp ) ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$newts" ); return $newts; } function myts2dets( $timestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "timestamp=$timestamp" ); $newts = arts2dets( myts2arts( $timestamp ) ); if ( isset( $options['length'] ) ) $newts = substr( $newts, 0, $options['length'] ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$newts" ); return $newts; } function myts2uxts( $timestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "timestamp=$timestamp" ); $newts = arts2uxts( myts2arts( $timestamp ) ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$newts" ); return $newts; } function dets2uxts( $timestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "timestamp=$timestamp" ); $newts = arts2uxts( dets2arts( $timestamp ) ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$newts" ); return $newts; } function dets2myts( $timestamp, $options = array() ) { traceuser( __FUNCTION__, "9", "+", "timestamp=$timestamp" ); $newts = arts2myts( dets2arts( $timestamp ) ); traceuser( __FUNCTION__, "9", "-", "ergebnis=$newts" ); return $newts; } function extractts( $filename, $timestampdir = '' ) { traceuser( __FUNCTION__, "8", "+", "filename=".$filename ." dir=".$timestampdir ); if ( $timestampdir != '' ) { if ( file_exists( $timestampdir.'/timestamp.php' ) == TRUE ) { $filename = $timestampdir.'/timestamp.php'; } } else { if ( substr( $filename, 0, 7 ) != "http://" ) { if ( file_exists( $filename ) == FALSE ) { traceuser( __FUNCTION__, "1", "-", "file does not exist=$filename" ); return ""; } } } $baserealdir= realpath( basename( $filename ) ); if ( substr( $filename, 0, 7 ) != "http://" ) { traceuser( __FUNCTION__, "15", "=", "filename=".$filename ." realdir=".$baserealdir ." filetime=".uxts2ts( filemtime( $filename ) ) ); } $contents = file_get_contents( $filename ); traceuser( __FUNCTION__, "19", "=", "contents=".substr($contents,0,100) ); $start = "timestamp.*\""; $ende = "\";"; if (preg_match_all( "=$start(.*)$ende=isU", $contents, $pr )) $timestr = $pr[1][0]; else { traceuser( __FUNCTION__, "6", "-", "no timestamp in file=$filename" ); return ""; } traceuser( __FUNCTION__, "9", "-", "timestr=$timestr" ); return $timestr; } // wrapper umd dos-like \ zu / zu konvertieren function mydirname( $directoryname ) { traceuser( __FUNCTION__, "11", "+", "aufgerufen: directoryname=".$directoryname ); $ergebnis = str_replace( '\\', '/', dirname( $directoryname ) ); traceuser( __FUNCTION__, "11", "-", "ergebnis=".$directoryname ); return $ergebnis; } function docrelpath( $directoryname ) { // liefert rest ab docroot mit startslash // funktionier (noch) nicht für darüberliegende (basedir!!) global $sgl_; traceuser( __FUNCTION__, "8", "+", "aufgerufen: directoryname=".$directoryname ); $realdir = baserealpath( $directoryname ); traceuser( __FUNCTION__, "9", "=", "realdir=".$realdir ); $docrlen = strlen( $sgl_[DOCUMENT_ROOT] ); if ( substr( $realdir, 0, $docrlen ) == $sgl_[DOCUMENT_ROOT] ) $docreldir = substr( $realdir, $docrlen ); traceuser( __FUNCTION__, "9", "-", "ergebnis=".$docreldir ); return $docreldir; } function dir2dir( $dir1, $dir2 ) { // liefert den relativen pfad zurück von dir 1 ohne docroot // zu dir2 traceuser( __FUNCTION__, "8", "file", "aufgerufen: dir1=".$dir1." dir2=".$dir2 ); $realdir1 = baserealpath( $dir1 ); $realdir2 = baserealpath( $dir2 ); traceuser( __FUNCTION__, "8", "file", "aufgerufen: real1=".$realdir1." dir2=".$realdir2 ); $dir1arr = explode( '/', $dir1 ); $dir2arr = explode( '/', $dir2 ); $uppath = ""; $downpath = ""; $i = 0; $equal = 1; $len1 = count( $dir1arr ); $len2 = count( $dir2arr ); $minlen = min( $len1, $len2 ); $maxlen = max( $len1, $len2 ); for ( $i = 0; ; $i++ ) { if ( $i >= $maxlen ) break; if ( $equal ) { if ( $i < $minlen ) $equal = ( $dir1arr[ $i ] == $dir2arr[ $i ] ); else $equal = 0; } if ( $equal ) continue; if ( $i <= $len1 - 1 ) $uppath .= "../"; if ( $i <= $len2 - 1 ) $downpath .= "/".$dir2arr[ $i ]; } $relpath = $uppath.$downpath; traceuser( __FUNCTION__, "8", "file", "ergebnis=".$relpath ); return $relpath; } function docdir2dir( $dir1, $dir2 ) { // liefert den relativen pfad zurück von dir 1 über docroot // zu dir2 // lässt sich natürlich verbessern: ohne docroot gehts auch, // könnte sogar kürzer sein; traceuser( __FUNCTION__, "8", "file", "aufgerufen: dir1=".$dir1." dir2=".$dir2 ); $relpath = back2doc( dir1 ).docrelpath( $dir2 ); traceuser( __FUNCTION__, "8", "file", "ergebnis=".$relpath ); return $relpath; } function back2doc( $directoryname ) { // liefert den relativen pfad zurück zum docroot // also eine gewisse anzahl von ../ hintereinander global $sgl_; traceuser( __FUNCTION__, "8", "file", "aufgerufen: directoryname=".$directoryname ); $reldir = docrelpath( $directoryname ); $slashcount = substr_count( $reldir, "/" ); $backdir = str_repeat( "../", $slashcount ); traceuser( __FUNCTION__, "8", "file", "reldir=".$reldir." slashes=".$slashcount." back=".$backdir ); return $backpath; } function baserealpath( $directoryname ) { // normalisiert realpath bzgl \ statt /; traceuser( __FUNCTION__, "8", "+", "aufgerufen: directoryname=".$directoryname ); $allname = str_replace( '\\', '/', realpath( $directoryname ) ); traceuser( __FUNCTION__, "8", "-", "ergebnis=".$allname ); return $allname; } function basefname( $filename ) { $base = basename( $filename ); $lastdot = strrpos( $base, '.' ); if ( $lastdot != "" ) return substr( $base, 0, $lastdot ); else return $base; } function basefext( $filename ) { $base = basename( $filename ); $lastdot = strrpos( $base, '.' ); return substr( $base, $lastdot + 1 ); } function ts2ux( $timestamp ) { traceuser( __FUNCTION__, "8", "+", "ts=$timestamp" ); $arr = dets2arts( $timestamp ); $uxts = mymktime( $arr['yyyy'], $arr['mm'] , $arr['dd'] , $arr['hh'] , $arr['mi'] , $arr['ss'] ); traceuser( __FUNCTION__, "8", "-", "ergebnis=$uxts" ); return $uxts; } function uxts2ts( $timestamp ) { traceuser( __FUNCTION__, "8", "file", "uxts=$timestamp" ); $arr = uxts2arts( $timestamp ); $ts = sprintf("%3\$02d.%2\$02d.%1\$04d %4\$02d:%5\$02d:%6\$02d", $arr['yyyy'], $arr['mm'] , $arr['dd'] , $arr['hh'] , $arr['mi'] , $arr['ss'] ); traceuser( __FUNCTION__, "8", "file", "ergebnis=$ts" ); return $ts; } function mymktime( $yyyy, $mm, $dd, $hh = 0, $mi = 0, $ss = 0, $isdst = -1 ) { $hh = ( $hh == "" ) ? 0 : $hh; $mi = ( $mi == "" ) ? 0 : $mi; $ss = ( $ss == "" ) ? 0 : $ss; traceuser( __FUNCTION__, "15", "file", "yyyy=".$yyyy." mm=".$mm." dd=".$dd ." hh=".$hh." mi=".$mi." ss=".$ss ); $mymktime = mktime( (int)$hh, (int)$mi, (int)$ss, (int)$mm, (int)$dd, (int)$yyyy, (int)$isdst ); traceuser( __FUNCTION__, "15", "file", "mymktime=".$mymktime ); return $mymktime; } function counter( $filename ) { if ( file_exists( $filename ) == FALSE ) { if ( getsession( 'login_usertyp' ) == "A" ) return 0; $fp = fopen( $filename , "w" ); fputs( $fp, "1" ); fclose( $fp ); return 1; } $fp = fopen( $filename , "r+" ); $count=( int ) fgets( $fp, 100 ); if ( getsession( 'login_usertyp' ) == "A" ) { fclose( $fp ); return $count; } $count++; rewind( $fp ); fputs( $fp, $count ); fclose( $fp ); return $count; } //<== return an array of files in dir; function getalldirfiles( $curdir, $extmask, $optarr = "" ) { traceuser( __FUNCTION__, 11, "file", "curdir=$curdir"." extmask=$extmask" ); clearstatcache(); $extmask = strtolower( $extmask ); $myhandle = opendir( $curdir ); $i = 0; while ( $curfile = readdir( $myhandle ) ) { traceuser( __FUNCTION__, 12, "file", "file found=$curfile" ); $myfext = strtolower(basefext( $curfile )); traceuser( __FUNCTION__, 13, "file", "ext=$myfext" ); $mypos = strpos( $extmask, ".".$myfext."."); traceuser( __FUNCTION__, 13, "file", "pos=$mypos mask=$extmask" ); if ( $mypos === false ) continue; traceuser( __FUNCTION__, 14, "file", "file $i listed=$curfile" ); $dirarray[$i] = $curfile; $i++; } closedir( $myhandle ); traceuser( __FUNCTION__, 11, "file", "files found=<".count($dirarray).">" ); return $dirarray; } // die folgende funktion kapselt emailversand // momentan wegen des bloeden header-separators, der selbst unter suse // postfix dauernd anders ist // später um attachments ins mime reinzuhaengen function sendmail( $to, $title, $text, $headers, $attachments = "", $parameters = "" ) { global $gl_; traceuser( __FUNCTION__, 4, "+", "aufruf " ." to=".$to ." title=".$title ); if ( !$gl_['send_email'] ) { traceuser( __FUNCTION__, 10, "-", "ausgeknipst" ); return; } if ( !isset( $gl_['mail_header_separator'] ) ) $gl_['mail_header_separator'] = "\n"; traceuser( __FUNCTION__, 10, "file", "text= ".$text ); $mailheaders = ""; $content_found = 0; $content_string= "Content-Type:"; foreach ( $headers as $headline ) { if ( stripos( $headline, "Content-Type:" ) ) $content_found = 1; $mailheaders .= $headline.$gl_['mail_header_separator']; } if ( !$content_found ) $mailheaders .= "Content-Type:text/plain; charset=ISO-8859-15; format=flowed" .$gl_['mail_header_separator']; //$mailheaders .= "X-mailer: PHP/".phpversion().$gl_['mail_header_separator']; traceuser( __FUNCTION__, 10, "-", "mailheaders= ".$mailheaders ); mail( $to, $title, $text, $mailheaders , "-f ".$_SERVER[SERVER_ADMIN] ); } function check_email_mx( $email ) { //if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) || //(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,}|[0-9]{1,4})(\]?)$/',$email)) ) { if (preg_match('/^[.a-zA-Z0-9\-]+@[.a-zA-Z0-9\-]+\.([a-zA-Z]{2,4})$/',$email)) { $host = explode('@', $email); if(checkdnsrr($host[1].'.', "MX") ) return true; if(checkdnsrr($host[1].'.', 'A') ) return true; if(checkdnsrr($host[1].'.', "CNAME") ) return true; } return false; } if (!function_exists('checkdnsrr')) { function checkdnsrr( $host, $type = '' ) { if( !empty($host) ) { if ( $type == '' ) $type = "MX"; @exec("nslookup -type=".$type." ".$host, $output); while(list($k, $line) = each($output)) { if(eregi("^$host", $line)) { return true; } } return false; } return false; } } // TODO!!! function getuserrights( $righttype, $tablename, $row ) { global $gl_; while( 1 ) { $enabled = "N"; $rightarr = explode( '/', $righttype ); $enabled = "J"; break; } return $enabled; } ?> $unixsec2 ) ? $timestamp1 : $timestamp2; traceuser( __FUNCTION__, 12, "file", "max=".$result ); return $result; } // fetches maximum timestamp in array of files // filename is prefixed with path and postfixed extension (with dot) // oldtimestamp is to compare against; // sucht in files function getmaxtimestamp( $curarray, $curdir, $curfext, $oldtimestamp ) { $i = 0; $max = count( $curarray ); traceuser( __FUNCTION__, 14, "file", "count array=".$max ); $timestamp = $oldtimestamp; while ( $i < $max ) { $thisfile = $curdir."/".$curarray[ $i ].".".$curfext; $filetimestamp = extractts( $thisfile ); traceuser( __FUNCTION__, 13, "file", "thisfile=".$thisfile ." filetimestamp=".$filetimestamp ); if ( $filetimestamp != "" ) $timestamp = maxtimestamp( $timestamp, $filetimestamp ); $i++; } traceuser( __FUNCTION__, 12, "file", "return max=".$timestamp ); return $timestamp; } // sucht im uebergebenem array function getmaxts( $tsarray, $options = "" ) { $i = 1; $max = count( $tsarray ); traceuser( __FUNCTION__, 14, "file", "count array=".$max ); $timestamp = $tsarray[0]; while ( $i < $max ) { $newtimestamp = $tsarray[$i]; $timestamp = maxtimestamp( $timestamp, $newtimestamp ); $i++; } traceuser( __FUNCTION__, 12, "file", "return max=".$timestamp ); return $timestamp; } // aus 2 unixtimestamps die differenz als array in tag/stunde/min/sec liefern function timestampdiff_dd( $ts1, $ts2 ) { $diff = abs( $ts1 - $ts2 ); $t['d'] = floor($diff / 24 / 60 / 60 ); $diff = $diff - ($t['d']*24*60*60); $t['h'] = floor($diff / 60 / 60); $diff = $diff - ($t['h']*60*60); $t['m'] = floor($diff / 60); $diff = $diff - ($t['m']*60); $t['s'] = floor($diff); return $t; } function tsdiff2ge_str( $ts1, $ts2 ) { $t = timestampdiff_dd( $ts1, $ts2 ); if ( $t['d'] == 0 ) $s = ""; if ( $t['d'] == 1 ) $s = "1 Tag, "; if ( $t['d'] > 1 ) $s = $t['d']." Tage, "; if ( $t['h'] == 0 ) if ( $s != "" ) $s .= "0 Stunden, "; if ( $t['h'] == 1 ) $s .= "1 Stunde, "; if ( $t['h'] > 1 ) $s .= $t['h']." Stunden, "; if ( $t['m'] == 0 ) if ( $s != "" ) $s .= "0 Minuten und "; if ( $t['m'] == 1 ) $s .= "1 Minute und "; if ( $t['m'] > 1 ) $s .= $t['m']." Minuten und "; if ( $t['s'] == 0 ) if ( $s != "" ) $s .= "0 Sekunden"; if ( $t['s'] == 1 ) $s .= "1 Sekunde"; if ( $t['s'] > 1 ) $s .= $t['s']." Sekunden"; return trim($s); } ?> $menuentry ) { if ( $menuentry['name'] == $gl_['myfname'] ) { if ( isset( $menuentry['anzeige'] ) ) $myfname = $menuentry['anzeige']; if ( isset( $menuentry['tooltip'] ) ) $myfname = $menuentry['tooltip']; break; } } return $myfname; } function getmycms( $menuarray ) { global $gl_; foreach ( $menuarray as $no => $menuentry ) { if ( $menuentry['name'] == $gl_['myfname'] ) { $gl_['mycms'] = $menuentry; break; } } } function writelayout ( $allarray, $layout ) { global $gllayarr; $layoutin = checkconds( $allarray, $layout ); $layoutout = ""; for ( $i = 1; 1>0; $i++ ) { traceuser( __FUNCTION__, 10, "=", "in for i=".$i." layoutlen=".strlen( $layoutout ) ); if ( preg_match( "=(.*)%%(.*)%%(.*?)=sU", $layoutin, $pregarr ) ) { $gllayarr[] = $pregarr; // prefix vor der cond einsammeln $layoutout .= $pregarr[ 1 ]; traceuser( __FUNCTION__, 15, "=", "var no=".$i." layoutlen=".strlen( $layoutout ) ); traceuser( __FUNCTION__, 12, "=", "var no=".$i." name=".$pregarr[ 2 ] ); traceuser( __FUNCTION__, 12, "=", "var no=".$i." funcvararr=".$pregarr[ 3 ] ); $funcnamearr = explode( ":", $pregarr[ 3 ] ); $funcname = $funcnamearr[ 0 ]; array_shift( $funcnamearr ); traceuser( __FUNCTION__, 25, "=", "var no=".$i." vararr=".implode( ';', $funcnamearr ) ); $valarr = array(); foreach ( $funcnamearr as $no => $namestr ) { $namearr = explode( '|', $namestr ); if ( substr( $varname, 0, 1 ) == "\"" ) { $valarr[] = substr( $namearr[0], 1, strlen($namearr[0])-2 ) ; } else { $valarr[] = parsevararr( $allarray['vars'], $namearr ); } } if ( ( $funcname != "" ) && ( function_exists( $funcname ) ) ) { $layoutout .= $funcname( $allarray, $valarr ); } else { if ( $funcname != "" ) traceuser( __FUNCTION__, 0, "=", "function=".$funcname." existiert nicht" ); $layoutout .= $valarr[0]; } traceuser( __FUNCTION__, 15, "=", "var no=".$i." layoutlen=".strlen( $layoutout ) ); $layoutin = $pregarr[ 3 ]; } else { break; } } // wenn nach dem letzten mal was übrig war, dann das anhängen $layoutout .= $layoutin; traceuser( __FUNCTION__, 4, "-", "ende laenge layout=".strlen( $layoutout ) ); return $layoutout; } function check_less( $allarray, $vararray ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." var1=".$vararray[0] ." var2=".$vararray[1] ." var3=".$vararray[2] ); $rc = ( $vararray[0] < $vararray[1] ) ? 1 : 0; traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function check_lessequal( $allarray, $vararray ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." var1=".$vararray[0] ." var2=".$vararray[1] ." var3=".$vararray[2] ); $rc = ( $vararray[0] <= $vararray[1] ) ? 1 : 0; traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function check_2equal( $allarray, $vararray ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." var1=".$vararray[0] ." var2=".$vararray[1] ." var3=".$vararray[2] ); $rc = ( $vararray[0] == $vararray[1] ) ? 1 : 0; traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function check_2notequal( $allarray, $vararray ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." var1=".$vararray[0] ." var2=".$vararray[1] ." var3=".$vararray[2] ); $rc = ( $vararray[0] != $vararray[1] ) ? 1 : 0; traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function check_mayinsert( $allarray, $vararray = array() ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." table=".$vararray[0] ); $rc = ( getsession( 'login_status' ) == "L" ) ? 1 : 0; traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function check_mayedit( $allarray, $vararray = array() ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." table=".$vararray[0] ." owner=".$vararray[1] ); $rc = ( ( getsession( 'login_usertyp' ) == "A" ) ||( getsession( 'login_userid' ) == $vararray[1] ) ) ? 1 : 0 ; traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function cms_ts( $allarray, $vararray ) { // syntax: timestamp / format traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." var1=".$vararray[0] ." var2=".$vararray[1] ); switch ( strtolower( $vararray[1] ) ) { case "ux" : $rc = shownewuxts( $vararray[0] ); break; case "de" : $rc = shownewdets( $vararray[0] ); break; case "my" : default : $rc = shownewmyts( $vararray[0] ); break; } $rc = shownewmyts( $vararray[0] ); traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function cms_rowcolor( $allarray, $dummy = "" ) { traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." var1=".$vararray[0] ." var2=".$vararray[1] ." var3=".$vararray[2] ); switch ( strtolower( $vararray[1] ) ) { case "h" : $rc = holdtablerow(); break; case "s" : $rc = starttablerow(); break; case "n" : default : $rc = ftablerow(); break; } traceuser( __FUNCTION__, 12, "-", "return=".$rc ); return $rc; } function cms_writekategorien( $allarray, $katarrname ) { $vararr = explode( '|', $tsvar ); $katarr = parsevar( $vars, $vararr ); return shownewmyts( $timestamp ); } function parsevararr( $vararray, $namearray ) { global $glparsevararr; $glparsevararr[] = $vararray; traceuser( __FUNCTION__, 12, "+", "aufgerufen" ." varcnt=".count($vararray) ." namecnt=".count($namearray) ." name0=".$namearray[0] ); if ( !isset( $vararray[ $namearray[0] ] ) ) { traceuser( __FUNCTION__, 0, "-", "fehler: var nicht gesetzt=".$namearray[0] ); return ""; } $newvars = $vararray[ $namearray[0] ]; if ( !is_array( $newvars ) ) { traceuser( __FUNCTION__, 0, "-", "fertig var name=".$namearray[0] ." val=".$newvars ); return $newvars; } if ( count( $namearray ) < 2 ) { traceuser( __FUNCTION__, 0, "-", "fertig array name=".$namearray[0] ); return $newvars; } array_shift( $namearray ); // der geht jetzt traceuser( __FUNCTION__, 0, "=", "rekursion für var=".$namearray[0] ); $retval = parsevararr( $newvars, $namearray ); traceuser( __FUNCTION__, 0, "-", "ende val=".$retval ); return $retval; } function checkconds( $allarray, $layoutin ) { traceuser( __FUNCTION__, 4, "+", "aufgerufen" ); global $glcondarr; global $glcondnamearr; global $glvarnamearr; global $glvarvalarr; global $checkconds_glallarray; $checkconds_glallarray[] = $allarray; $layoutout = ""; // parsen alle hintereinanderliegenden cond-klammern for ( $i = 1; 1>0; $i++ ) { traceuser( __FUNCTION__, 10, "=", "in for i=".$i." layoutlen=".strlen( $layoutout ) ); if ( preg_match( "=(.*)(.*)(.*?)=sU", $layoutin, $pregarr ) ) { $glcondarr[] = $pregarr; // prefix vor der cond einsammeln $layoutout .= $pregarr[ 1 ]; traceuser( __FUNCTION__, 15, "=", "cond no=".$i." layoutlen=".strlen( $layoutout ) ); traceuser( __FUNCTION__, 12, "=", "cond no=".$i." name=".$pregarr[ 2 ] ); traceuser( __FUNCTION__, 12, "=", "cond no=".$i." funcvararr=".$pregarr[ 3 ] ); $funcnamearr = explode( ":", $pregarr[ 3 ] ); $funcname = $funcnamearr[ 0 ]; traceuser( __FUNCTION__, 15, "=", "cond no=".$i." funcname=".$funcname ); array_shift( $funcnamearr ); traceuser( __FUNCTION__, 25, "=", "cond no=".$i." vararr=".implode( ';', $funcnamearr ) ); $valarr = array(); foreach ( $funcnamearr as $no => $namestr ) { $namearr = explode( '|', $namestr ); if ( substr( $varname, 0, 1 ) == "\"" ) { $valarr[] = substr( $namearr[0], 1, strlen($namearr[0])-2 ) ; } else { $valarr[] = parsevararr( $allarray['vars'], $namearr ); } } $glvarvalarr[] = $valarr; if ( function_exists( $funcname ) ) { if ( $funcname( $allarray, $valarr ) ) { // eventuelle inliegende cond-klammern verarzten $layoutout .= checkconds( $allarray, $pregarr[ 4 ] ); traceuser( __FUNCTION__, 10, "=", "function=".$funcname." sagt ja, laenge layout=".strlen( $layoutout ) ); } else traceuser( __FUNCTION__, 10, "=", "function=".$funcname." will das nicht" ); } else traceuser( __FUNCTION__, 0, "=", "function=".$funcname." existiert nicht" ); // iteration: das ist der rest.... $layoutin = $pregarr[ 5 ]; } else { break; } } // wenn nach dem letzten mal was übrig war, dann das anhängen $layoutout .= $layoutin; traceuser( __FUNCTION__, 4, "-", "ende laenge layout=".strlen( $layoutout ) ); return $layoutout; } function parselayoutfile( $layoutfilename = 'layout.html' ) { traceuser( __FUNCTION__, 4, "+", "aufgerufen für file=".$layoutfilename ); $layout = array(); global $layoutarr; global $layouttext; if ( !file_exists( $layoutfilename ) ) { traceuser( __FUNCTION__, 0, "-", "file=".$layoutfilename." existiert nicht" ); return $layout; } $layouttext = file_get_contents( $layoutfilename ); preg_match_all( "|(.*)|sU", $layouttext, $layoutarr, PREG_SET_ORDER ); foreach ( $layoutarr as $no => $match ) { $layout[ $match[ 1 ] ] = splitlayout( $match[ 2 ] ); } traceuser( __FUNCTION__, 4, "-", "ende anzahl layouts=".count($layout) ); return $layout; } function splitlayout( $layoutstr, $level = 0, $layoutarr = array() ) { } function writemenu( $menudir = '.', $options = array() ) { global $gl_; global $sgl_; global $glmenuarr; global $gldirmenu; global $gloptions; $realdir = realpath( $menudir ); $reldir = docrelpath( $realdir ); if ( strlen( $reldir ) > 0 ) if ( substr( $reldir, 0 , 1 ) != '/' ) $reldir = '/'.$reldir; traceuser( __FUNCTION__, 4, "+", "aufgerufen" ." für dir=".$menudir." real=".$realdir." reldir=".$reldir ); // schreibt menu // angenommen wird, dass jedes verzeichnis mit index.html drin dazugehoert // + jedes .html-file // liest die timestamps, und zieht bei bedarf den vom verzeichnis nach // sonderparameter stehen im verzeichnis in dirinc.php, // zb die uebersetzung der eintraege, ihre reihenfolge, oder anzeigebedingungen clearstatcache(); if ( !file_exists( $menudir ) ) { traceuser( __FUNCTION__, 0, "file", "verzeichnis existiert nicht=".$menudir ); return -1; } if ( !is_dir( $menudir ) ) { traceuser( __FUNCTION__, 0, "file", "datei ist kein verzeichnis=".$menudir ); return -2; } // eventuelle harte zusatzeintraege aus aufruf: if ( isset( $options['addentry'] ) ) { $menuarray = $options['addentry']; } else $menuarray = array(); $dirincname = ( isset( $options['incfilename'] ) ) ? $options['incfilename'] : "dirinc.php" ; $dirincfile = $menudir."/".$dirincname; if ( file_exists( $dirincfile ) ) { // damit einem nix kaputtet wird, müsste man eigentlich jetzt einen // namespace deklarieren, dann lesen, dann das geeignete rüberholen.. // später db-funktionen !! include( $dirincfile ); // der inhalt des dings sollte // $menuarray ergaenzen, und zwar: // $dirmenu['file/dirname']['anzeige'] = // $dirmenu['file/dirname']['sortorder'] = // $dirmenu['file/dirname']['doshow'] = boolean cond.... // achtung fuer letzteres muessen eventuell // sachen als global erklaert werden // da jetzt in einer funktion $gl_['included'][] = $dirincfile; $gldirmenu = $dirmenu; traceuser( __FUNCTION__, 3, "file", "incfile includiert=".$dirincfile ); if ( isset( $diroptions ) ) $options = array_merge( $diroptions, $options ); if ( isset( $dirmenu[ 'addentry' ] ) ) $menuarray = array_merge( $menuarray, $dirmenu[ 'addentry' ] ); if ( getsession( "trace" ) > 9 ) $gloptions = $options; } else traceuser( __FUNCTION__, 1, "file", "kein incfile vorhanden=".$menudir ); $j = count( $menuarray ) - 1; traceuser( __FUNCTION__, 4, "file", "addentries loaded=".($j+1)); $myhandle = opendir( $menudir ); $i = 0; // ok, soweit die vorbereitungen...; nun lesen wir den ... while ( $curfile = readdir( $myhandle ) ) { if ( isset ( $options[ 'noreaddir' ] ) ) break; $i++; traceuser( __FUNCTION__, 6, "file", "aktuelles file no=".$i." name=".$curfile ); // case 1 directory .... if ( ( $curfile == "." ) || ( $curfile == ".." ) ) { traceuser( __FUNCTION__, 7, "file", "wollen wir nicht=".$curfile ); continue; } if ( is_dir( $menudir."/".$curfile ) ) { traceuser( __FUNCTION__, 7, "file", "ist ein directory=".$curfile ); $curentry = $curfile; $dirindexfile = $menudir."/".$curfile."/index.html"; if ( file_exists( $dirindexfile ) ) { // ok, also anzeigen ... $j++; $menuarray[$j]['name'] = $curfile; $menuarray[$j]['fullname'] = $curfile; $menuarray[$j]['filetype'] = "dir"; $menuarray[$j]['tsdirfile']= $reldir."/".$curfile."/index.html";; } else { traceuser( __FUNCTION__, 7, "file", "kein index.html in=".$curfile ); continue; } } // case 2 ist ein flatfile, erlaubt ist nur *.html; else { traceuser( __FUNCTION__, 7, "file", "ist ein flatfile=".$curfile ); // erst mal falsche extensions ausschliessen: $curentry = basefname( $curfile ); $curfext = basefext( $curfile ); traceuser( __FUNCTION__, 7, "file", "ext=".$curfext ); if ( $curfext != "html" ) { traceuser( __FUNCTION__, 7, "file", "nicht anzeigen wg. extension" ); continue; } traceuser( __FUNCTION__, 7, "file", "ist ein html=".$curfile ); // ok, also anzeigen ... $j++; $menuarray[$j]['name'] = basefname( $curfile ); $menuarray[$j]['fullname'] = $curfile; $menuarray[$j]['filetype'] = "html"; $menuarray[$j]['tsdirfile'] = $reldir.'/'.$curfile; } if ( !isset( $dirmenu[$curentry]['sortorder'] ) ) { if ( $options[ 'sortorder' ] == "reverse" ) $menuarray[$j]['sortorder'] = - ( 100 + 10 * $j ); else $menuarray[$j]['sortorder'] = 100 + 10 * $j; } else $menuarray[$j]['sortorder'] = $dirmenu[$curentry]['sortorder']; if ( isset( $options['sortfield'] ) ) $menuarray[$j]['sortfield'] = $menuarray[$j][$options['sortfield']]; else $menuarray[$j]['sortfield'] = $menuarray[$j]['sortorder']; if ( isset( $dirmenu[$curentry]['anzeige'] ) ) $menuarray[$j]['anzeige'] = $dirmenu[$curentry]['anzeige']; else $menuarray[$j]['anzeige'] = ucfirst( $menuarray[$j]['name'] ); if ( isset( $dirmenu[$curentry]['doshow'] ) ) $menuarray[$j]['doshow'] = $dirmenu[$curentry]['doshow']; else $menuarray[$j]['doshow'] = "J"; if ( isset( $dirmenu[$curentry]['tsinclude'] ) ) $menuarray[$j]['tsinclude'] = $dirmenu[$curentry]['tsinclude']; else $menuarray[$j]['tsinclude'] = "J"; if ( isset( $dirmenu[$curentry]['target'] ) ) $menuarray[$j]['target'] = $dirmenu[$curentry]['target']; if ( isset( $dirmenu[$curentry]['tooltip'] ) ) $menuarray[$j]['tooltip'] = $dirmenu[$curentry]['tooltip']; // kuenftig vielleicht noch mehr variablen uebernehmen } closedir( $myhandle ); // nun sortieren // 2007-02-22 tb : timestamp erst hier holen, damit geht das auch fuer // addentries UND/ODER zusaetzliche entries aus dirinc.php foreach ( $menuarray as $no => $entry ) { traceuser( __FUNCTION__, 7, "file", "compute ts for no=".$no." name=".$entry['fullname'] ); $entrytimestamp = getdbtimestamp( "", $entry['tsdirfile'] ); $menuarray[ $no ][ 'timestamp' ] = $entrytimestamp; if ( $entry['tsinclude'] != "J" ) { traceuser( __FUNCTION__, 7, "file", "ts nicht einschliessen=".$entry['fullname'] ); continue; } $tsarray[] = $entrytimestamp; } if ( getsession( "trace" ) > 9 ) $glmenuarr['usort'][] = $menuarray; usort( $menuarray, "menudirsort" ); if ( getsession( "trace" ) > 9 ) $glmenuarr['sort'][] = $menuarray; if ( $options['sortorder'] == "desc" ) { $menuarray = array_reverse( $menuarray ); if ( getsession( "trace" ) > 9 ) $glmenuarr['sort'][] = $menuarray; } $maxts = getmaxts( $tsarray ); traceuser( __FUNCTION__, 4, "file", "maxts=".$maxts ); checkdbtimestamp( $maxts, "_", $reldir.'/index.html' ); // writebackmenu if any..; if ( isset( $options['uplayout' ] ) ) $layout = $options['uplayout' ]; else $layout = "up_std"; $funcname = "writemenu_".$layout; if ( function_exists( $funcname ) ) { traceuser( __FUNCTION__, 4, "file", "funcname existiert=".$funcname ); $funcname( $menudir, $options ); } else traceuser( __FUNCTION__, 4, "file", "funcname existiert nicht=".$funcname ); // writedirmenu...; if ( isset( $options['layout' ] ) ) $layout = $options['layout' ]; else $layout = "hor_std"; $funcname = "writemenu_".$layout; if ( $menudir == '.' ) getmycms( $menuarray ); if ( function_exists( $funcname ) ) { traceuser( __FUNCTION__, 4, "-", "funcname existiert=".$funcname ); $funcname( $menudir, $menuarray, $options ); } else traceuser( __FUNCTION__, 4, "-", "funcname existiert nicht=".$funcname ); return ( $menuarray ); } function menudirsort ( $a, $b ) { traceuser( __FUNCTION__, 18, "+", "a=".$a['name'] ." b=".$b['name'] ); if ( $a['sortfield'] == $b['sortfield'] ) $myrc = 0; else $myrc = ( $a['sortfield'] > $b['sortfield'] ) ? 1 : -1; traceuser( __FUNCTION__, 18, "-", "rc=".$myrc ); return $myrc; } function writemenu_ver_menuframe( $menudir, $menuarray, $options ) { traceuser( __FUNCTION__, 2, "file", "aufgerufen=" ."menudir=".$menudir ." entries=".count( $menuarray ) ); $row = 0; if ( $options[ 'showprint' ] != "J" ) echo "
\n"; echo "\n"; foreach ( $menuarray as $no => $entry ) { traceuser( __FUNCTION__, 4, "file", "no=".$no ." name=".$entry['name'] ); if ( $entry['doshow'] == "N" ) continue; $row++; $col++; echo " \n"; echo " \n"; echo " \n"; } echo "
\n"; if ( !isset( $options[ "no_ts" ] ) ) echo shownewts( $entry['timestamp'] )." "; echo ""; if ( $entry['filetype'] == "add" ) echo " ".$entry['anzeige']."\n"; echo "
\n"; if ( $options[ 'showprint' ] != "J" ) echo "
\n"; } function writemenu_hor_std( $menudir, $menuarray, $options ) { traceuser( __FUNCTION__, 2, "file", "aufgerufen=" ."menudir=".$menudir ." entries=".count( $menuarray ) ); $col = 0; $maxcol = ( isset( $options["hor_maxcol"] ) ) ? $options["hor_maxcol"] : 4; $row = 1; if ( $options[ 'showprint' ] != "J" ) echo "
\n"; echo "\n"; foreach ( $menuarray as $no => $entry ) { traceuser( __FUNCTION__, 4, "file", "no=".$no ." name=".$entry['name'] ); if ( $entry['doshow'] == "N" ) continue; $col++; if ( $col == 1 ) { if ( $row == 1 ) echo " \n"; else echo " \n \n"; } echo " \n"; if ( $col == $maxcol ) { $col = 0; $row++; } } echo " \n"; echo "
\n"; if ( !isset( $options[ "no_ts" ] ) ) echo shownewts( $entry['timestamp'] )." "; echo ""; if ( $entry['filetype'] == "add" ) echo " ".$entry['anzeige']."\n"; echo "
\n"; if ( $options[ 'showprint' ] != "J" ) echo "
\n"; } function check_true( $vars, $options ) { return true; } ?> "; $substchars[] = '<'; $substchars[] = '>'; $fpara['indentarr'] = $gl_indent; // formularerstellfunktionen function writeversionhistory( $history, $options = array() ) { $histlist = ""; $tsoptions = array( "dontwritetitle" => 1 ); foreach( $history['rows'] as $no => $histrow ) { $histlist .= " "; } return $histlist; } function getvalues( $rpara, $row ) { // im fehlerfall aufrufbar bei formularen, // nimmt die werte fuer die felder aus dem letzten versuch // TODO time/datetime foreach ( $rpara as $field => $arr ) { switch ( $arr[ "type" ] ) { case "time" : if ( ( isset( $row[ $field."hh" ] ) ) && ( isset( $row[ $field."mi" ] ) ) ) $rpara[ $field ][ "value" ] = $row[ $field."hh" ].":". $row[ $field."mi" ].":". ( isset( $row[ $field."ss" ] ) ?$row[ $field."ss" ] : '00' ) ; break; case "date" : if ( ( isset( $row[ $field."dd" ] ) ) && ( isset( $row[ $field."mm" ] ) ) && ( isset( $row[ $field."yy" ] ) ) ) $rpara[ $field ][ "value" ] = $row[ $field."yy" ]."-". $row[ $field."mm" ]."-". $row[ $field."dd" ] ; break; default: if ( isset( $row[ $field ] ) ) $rpara[ $field ][ "value" ] = $row[ $field ]; break; } } return $rpara; } // strings aus db formatieren function strdbout( $dbstring, $nbsp = 0 ) { global $specialchars; global $substchars; traceuser( __FUNCTION__, 8, "file", "string vorher l=".strlen($dbstring)." str=".$dbstring ); // $dbstring = stripslashes( trim( $dbstring ) ); $dbstring = str_replace ( $specialchars, $substchars, $dbstring ); if ( $nbsp == 1 ) $dbstring = ( trim(dbstring) == "" ) ? " " : $dbstring; traceuser( __FUNCTION__, 8, "file", "string nachher l=".strlen($dbstring)." str=".$dbstring ); return $dbstring; } // string in db formatieren function strdbin( $dbstring ) { traceuser( __FUNCTION__, 8, "file", "string vorher l=".strlen($dbstring)." str=".$dbstring ); $dbstring = addslashes( trim( $dbstring ) ); traceuser( __FUNCTION__, 8, "file", "string nachher l=".strlen($dbstring)." str=".$dbstring ); return $dbstring; } // check auf datum fuer die einzelfelder function datedbin( $chkyy, $chkmm = "01", $chkdd = "01", $chkhh = "00", $chkmi = "00", $chkss = "00" ) { $chkyy = trim($chkyy); $chkmm = trim($chkmm); $chkdd = trim($chkdd); $chkhh = ( $chkhh == "" ) ? "00" : trim($chkhh); $chkmi = ( $chkmi == "" ) ? "00" : trim($chkmi); $chkss = ( $chkss == "" ) ? "00" : trim($chkss); if ( checkdate( $chkmm, $chkdd, $chkyy ) ) return "$chkyy-$chkmm-$chkdd $chkhh:$chkmi:$chkss"; else return "0000-00-00 00:00:00"; } // check auf datum fuer die einzelfelder function timedbin( $chkhh, $chkmi = "00", $chkss = "00" ) { $chkmi = ( $chkmi == "" ) ? "00" : $chkmi; $chkss = ( $chkss == "" ) ? "00" : $chkss; if ( $chkhh != "" ) return "$chkhh:$chkmi:$chkss"; else return "00:00:00"; } // rowparameter auf standard setzen function getrowpara( $fpara, $row=array() ) { global $gl_; $tabarr = gettable( $fpara['tablename'] ); $userfieldstart = 100; $sysfieldstart = 100000; $userfieldstep = 100; $sysfieldstep = 100000; for ( $i = 1; $tabarr[ $i ][ 'name' ] != ""; $i++ ) { $rname = $tabarr[ $i ][ 'name' ]; $rtype = $tabarr[ $i ][ 'type' ]; $rowpara[$i] = $rname; $rowpara[$rname]['name'] = $rname; $rowpara[$rname]['label'] = ucfirst( $rname ); if ( $fpara[ 'setdefault' ] == "J" ) $rowpara[$rname]['value'] = $tabarr[ $i ][ 'default' ]; else $rowpara[$rname]['value'] = $row[$rname]; // drop timestamps $isready = true; switch ( $rname ) { case "pgeaendert" : $rowpara[$rname]['type'] = "timestamp"; $rowpara[$rname]['form'] = "hide"; $rowpara[$rname]['order'] = ( $sysfieldstart += $sysfieldstep ); break; case "geaendert" : $rowpara[$rname]['type'] = "timestamp"; $rowpara[$rname]['form'] = "hide"; $rowpara[$rname]['order'] = ( $userfieldstart += $userfieldstep ); break; case "version" : $rowpara[$rname]['type'] = "int"; $rowpara[$rname]['form'] = "hide"; $rowpara[$rname]['order'] = ( $sysfieldstart += $sysfieldstep ); break; case "groupid" : $rowpara[$rname]['type'] = "int"; $rowpara[$rname]['form'] = "hide"; $rowpara[$rname]['order'] = ( $userfieldstart += $userfieldstep ); break; case "geaendert_von" : $rowpara[$rname]['type'] = "int"; $rowpara[$rname]['form'] = "hide"; $rowpara[$rname]['order'] = ( $userfieldstart += $userfieldstep ); break; default : $isready = false; break; } if ( $isready ) continue; // check mandant if ( $rname == 'mandant' ) { $rowpara[$rname]['type'] = "system"; $rowpara[$rname]['form'] = "hide"; $rowpara[$rname]['order'] = ( $sysfieldstart += $sysfieldstep ); if ( $fpara[ 'setdefault' ] == "J" ) $rowpara[$rname]['value'] = $gl_['mandant']; else $rowpara[$rname]['value'] = $row[$rname]; continue; } $rowpara[$rname]['order'] = ( $userfieldstart += $userfieldstep ); // check autoincrement if ( $tabarr[ $i ][ 'extra' ] == 'auto_increment' ) { $rowpara[$rname]['type'] = "autoinc"; $rowpara[$rname]['form'] = "hide"; $rowpara['autoinc'] = $rname; continue; } // do the rest switch ( $rtype ) { case "date" : $rowpara[$rname]['type'] = "date"; $rowpara[$rname]['form'] = "date"; $rowpara[$rname]['time'] = 0; $rowpara[$rname]['secs'] = 0; break; case "datetime" : $rowpara[$rname]['type'] = "date"; $rowpara[$rname]['form'] = "date"; $rowpara[$rname]['time'] = 1; $rowpara[$rname]['secs'] = 1; break; case "time" : $rowpara[$rname]['type'] = "time"; $rowpara[$rname]['form'] = "time"; $rowpara[$rname]['secs'] = 1; break; case "decimal" : $rowpara[$rname]['type'] = "int"; $rowpara[$rname]['form'] = "input"; $stellen = explode( ",", $tabarr[ $i ][ 'typee' ] ); $rowpara[$rname]['length'] = $stellen[0] + 1 + $stellen[1]; case "int" : $rowpara[$rname]['type'] = "int"; $rowpara[$rname]['form'] = "input"; $rowpara[$rname]['length'] = $tabarr[ $i ][ 'typee' ]; break; case "enum" : $rowpara[$rname]['type'] = "enum"; $rowpara[$rname]['form'] = "radio"; $enumarr = explode(',', str_replace("'","",$tabarr[$i]['typee'])); while ( $rl = each( $enumarr ) ) { $rowpara[$rname]['setarr'][$rl[1]] = $rl[1]; } break; case "text" : case "longtext" : case "mediumtext" : $rowpara[$rname]['type'] = "text"; $rowpara[$rname]['form'] = "area"; $rowpara[$rname]['length'] = 2000; $rowpara[$rname]['rows'] = $fpara['arearows']; break; case "varchar" : case "char" : $rowpara[$rname]['type'] = "text"; if ( $rname == "email" ) $rowpara[$rname]['type'] = "email"; if ( $rname == "homepage" ) $rowpara[$rname]['type'] = "url"; $fieldlength = $tabarr[ $i ][ 'typee' ]; if ( $fieldlength > $fpara['areacols'] ) { $rowpara[$rname]['form'] = "area"; $rowpara[$rname]['length']= $fieldlength; $rowpara[$rname]['rows']= ceil( $fieldlength / $fpara['areacols'] ); } else { $rowpara[$rname]['type'] = "text"; $rowpara[$rname]['form'] = "input"; $rowpara[$rname]['length']= $fieldlength; } break; default : $rowpara[$rname]['type'] = "NN"; $rowpara[$rname]['form'] = "NN"; break; } } return $rowpara; } // titelzeile der form als thead-block function formwritetitle( $fpara, $title ) { formrow( $fpara, array( 'form' => 'row', 'type' => 'text', 'value' => $title, 'align' => 'center', 'starttag' => "thead", 'endtag' => "thead", 'trfunc' => "none", 'tdth' => 'th', 'doformat' => ( $fpara['doformattitle'] == 'N' ) ? 'N' : 'J' ) ); } // button und meldung als tfoot-block function formwritefooter( $fpara, $buttonarr ) { formbutton( $fpara, array( 'starttag' => "tfoot", 'endtag' => "tfoot", 'buttonarr' => $buttonarr, ) ); } // stdbutton und meldung als tfoot-block function formwritestdfoot( $fpara, $options = array() ) { $rowpara = array( 'starttag' => "tfoot", 'endtag' => "tfoot", ); $rowpara = array_merge( $rowpara, $options ); formstdbuttons( $fpara, $rowpara ); } // leere zeile mit prozentualer breitenverteilung! function formcolgrp( $fpara, $rowpara = array() ) { $widthstr = ( $fpara['tabwidth'] == "" ) ? "" : "width=\"".$fpara['tabwidth']."\""; $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; echo $ia[$io+0]."\n"; for ( $i = 0; $i < $fpara['cols']; $i++ ) { echo $ia[$io+1]."\n"; } echo $ia[$io+0]."\n"; } // switch je nach funktion, weiterverteilung! function formwrite( $fpara, $rowpara ) { $funcname = "form".$rowpara['form']; // label setzen auf namen, falls fehlt $rowpara['label'] = ( $rowpara['label'] == "" ) ? ucfirst( $rowpara['name'] ) : $rowpara['label']; if ( $rowpara['show'] == "N" ) return; if ( function_exists( $funcname ) ) $funcname( $fpara, $rowpara ); } // leere zeile ohne formatierung! function formempty( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $rowpara['trfunc'] = "none"; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]." \n"; formchkend( $fpara, $rowpara ); } // einfaches textfeld ueber alle spalten! function formrow( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $tdth = ( $rowpara['tdth'] == "" ) ? "td" : $rowpara['tdth']; $align = ( $rowpara['align'] == "" ) ? "left" : $rowpara['align']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."<$tdth align=\"$align\" colspan=\"".$fpara['cols']."\">\n"; if ( $rowpara['doformat'] == 'N' ) echo $ia[$io+3].$rowpara['value']."\n"; else echo $ia[$io+3].strdbout( $rowpara['value'], 1 )."\n"; echo $ia[$io+2]."\n"; formchkend( $fpara, $rowpara ); } // einfaches textfeld normale spaltenzahl function formtext( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; if ( $rowpara['format'] != "N" ) echo $ia[$io+3].strdbout( $rowpara['value'], 1 ); else echo $ia[$io+3].$rowpara['value']; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // verstecktes feld function formhide( $fpara, $rowpara ) { //formchkstart( $fpara, $rowpara ); //echo $ia[$io+2]."\n"; echo $ia[$io+3]."\n"; //echo $ia[$io+2]."\n"; //formchkend( $fpara, $rowpara ); } // fileupload function formfile( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $filenamelength = ( isset( $fpara['filenamelength'] ) ) ? $fpara['filenamelength'] : 80 ; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; echo $ia[$io+3].""; // letzteres ist bei blödbill eh ende der fahnenstange?? // also warum parametrieren....; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // einfaches inputfeld function forminput( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; if ( $rowpara['type'] == "password" ) echo $ia[$io+3]."\n"; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // textarea function formarea( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; //echo $ia[$io+3]."\n"; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // checkbox // not tested // seems difficult !! function formcheckbox( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $tdth = ( $rowpara['tdth'] == "" ) ? "td" : $rowpara['tdth']; $ch = ( $rowpara['tdth'] == "" ) ? "td" : $rowpara['tdth']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."<$tdth align=\"right\">".$rowpara['label']."\n"; echo $ia[$io+2]."<$tdth align=\"left\">\n"; echo $ia[$io+3]."\n"; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // optionbuttonlist function formoption( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $tdth = ( $rowpara['tdth'] == "" ) ? "td" : $rowpara['tdth']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."<$tdth align=\"right\">".$rowpara['label']."\n"; echo $ia[$io+2]."<$tdth align=\"left\">\n"; echo $ia[$io+3]."\n"; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // radiobuttonlist function formradio( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; while ( $rl = each( $rowpara['setarr'] ) ) { echo $ia[$io+3]."$rl[1]\n"; } echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // datum optional mit zeit aus unixtimestamp function formdate( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $dt = explode( " ", $rowpara['value'] ); $d = explode( "-", $dt[ 0 ] ); if ( $dt[ 0 ] == "0000-00-00" ) { $d[0] = ' '; $d[1] = ' '; $d[2] = ' '; $d[0] = ''; $d[1] = ''; $d[2] = ''; } if ( $dt[ 1 ] == "00:00:00" ) { $t[0] = ' '; $t[1] = ' '; $t[2] = ' '; $t[0] = ''; $t[1] = ''; $t[2] = ''; } else $t = explode( ":", $dt[ 1 ] ); formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; echo $ia[$io+3]."\n"; echo $ia[$io+3]." . \n"; echo $ia[$io+3]." . \n"; if ( $rowpara['time'] ) { echo $ia[$io+3]."   \n"; echo $ia[$io+3]." : \n"; if ( $rowpara['secs'] ) { echo $ia[$io+3]." : \n"; } } echo $ia[$io+1]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // uhrzeit optional mit sekunden aus string hh:mm:ss function formtime( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; if ( $rowpara['value'] == "00:00:00" ) { $datearr[0] = ' '; $datearr[1] = ' '; $datearr[2] = ' '; } else $datearr = explode( ':', $rowpara['value'] ); formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."".$rowpara['label']."\n"; echo $ia[$io+2]."\n"; echo $ia[$io+3]."\n"; echo $ia[$io+3]." : \n"; if ( $rowpara['secs'] ) { echo $ia[$io+3]." : \n"; } echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'] ); formchkend( $fpara, $rowpara ); } // anlegen/aendern/loeschen-knoepfe function formstdbuttons( $fpara, $rowpara ) { if ( !isset( $rowpara[ 'addonly' ] ) ) $rowpara[ 'addonly' ] = 0; $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; // $colspan = ( $fpara['comment'] ) ? $fpara['cols'] - 1 : $fpara['cols']; $rowpara['trfunc'] = "none"; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."\n"; echo $ia[$io+3]."\n"; if ( !( $rowpara[ 'addonly' ] ) ) { echo $ia[$io+3]."\n"; echo $ia[$io+3]."\n"; } echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'], "th" ); formchkend( $fpara, $rowpara ); } // andere-knoepfe function formreset( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $rowpara['trfunc'] = "none"; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."\n"; echo $ia[$io+3]."\n"; echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'], "th" ); formchkend( $fpara, $rowpara ); } // andere-knoepfe function formbutton( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; $rowpara['trfunc'] = "none"; formchkstart( $fpara, $rowpara ); echo $ia[$io+2]."\n"; while ( $rl = each( $rowpara['buttonarr'] ) ) { echo $ia[$io+3]."\n"; } echo $ia[$io+2]."\n"; formcomment( $fpara, $rowpara['comment'], "th" ); formchkend( $fpara, $rowpara ); } // kommentarfeld function formcomment( $fpara, $comment, $tdth = "td" ) { if ( $fpara['comment'] ) { echo $ia[$io+1]."<$tdth align=\"left\">\n"; echo $ia[$io+2].strdbout( $comment ); echo $ia[$io+1]."\n"; } } // zeilenbeginn formatieren function formchkstart( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; if ( $rowpara['starttag'] != "" ) { echo $ia[$io+0]."<".$rowpara['starttag'].">\n"; } if ( $rowpara['starttr'] != "N" ) { $trfunc = ( $rowpara ['trfunc'] == "none" ) ? "nop" : "ftablerow"; echo $ia[$io+1]."\n"; } } // zeilenende formatieren function formchkend( $fpara, $rowpara ) { $ia = $fpara['indentarr']; $io = $fpara['indentlevel']; if ( $rowpara['endtr'] != "N" ) { echo $ia[$io+1]."\n"; } if ( $rowpara['endtag'] != "" ) { echo $ia[$io+0]."\n"; } } ?> $gl_['tab']['user'], "member" =>$gl_['tab']['member'], "email" =>$gl_['tab']['email'], "anschrift" =>$gl_['tab']['anschrift'], "telefon" =>$gl_['tab']['telefon'], ); foreach( $tablearr as $name => $tablename ) { $recshort = substr( $name, 0, 2 ); $sqlbefehl = "select a.*" . " from ".$tablename." a" . " where a.userid = ".$userid ; $dbresult = mysql_query( $sqlbefehl ); $dberror = mydberror( $sqlbefehl, __FUNCTION__ ); if ( $dberror != 0 ) { $record[] = $recshort.":"."E"; continue; } $rowcount = mysql_num_rows( $dbresult ); if ( $rowcount == 0 ) { $record[] = $recshort.":"."0"; continue; } $record[] = $recshort.":".$rowcount; while ( $row = mysql_fetch_array ( $dbresult ) ) $userarr[ $name ][] = $row; } $record = implode( '-', $record ); traceuser( __FUNCTION__, 4, "-", "aufruf gelesen=".$record ); return $userarr; } function checklogin( $row ) { global $gl_; $loginemail = $row['email']; $loginpwd = $row['passwort']; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", "aufruf mail=$loginemail pwd=$loginpwd" ); // Login checken // email nach vorn gezogen, damit sie bei fehlerhaftem login // gemerkt ist ... (für die neu-machen-funktion) setsession( 'login_email', $loginemail ); $sqlbefehl = "select"; $sqlbefehl .= " a.*"; $sqlbefehl .= ", b.emailstatus"; $sqlbefehl .= ", b.emailid "; $sqlbefehl .= " from ".$gl_['tab']['user']." a,"; $sqlbefehl .= " ".$gl_['tab']['email']." b"; $sqlbefehl .= " where a.userid = b.userid"; $sqlbefehl .= " and lcase(b.email) = '".strtolower($loginemail)."'"; $ergebnis = mysql_query( $sqlbefehl ); if ( mydberror( $sqlbefehl, __FILE__ ) ) { $gl_[ 'message' ][] = "Datenbankfehler bei Userabfrage"; return "E"; } if ( mysql_num_rows( $ergebnis ) == 0 ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "loginfehler" ." für email=".$loginemail." email nicht vorhanden" ); loguser( __FUNCTION__, '2110 Loginversuch mit falscher email', array( $loginemail ) ); logloginerror( $loginemail, $loginpwd, "email nicht vorhanden" ); $gl_[ 'message' ][] = "User oder Passwort ungültig"; return "N"; } // normalfall: mail vorhanden $login = mysql_fetch_array ( $ergebnis ); // erst noch unterscheiden: status S ist emailsperre if ( $login['emailstatus'] == "S" ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "loginversuch mit gesperrter email=".$loginemail ); loguser( __FUNCTION__, '2111 Loginversuch mit gesperrter email', array( $loginemail ) ); logloginerror( $loginemail, $loginpwd, "email gesperrt" ); $gl_[ 'message' ][] = "Email gesperrt, bitte wenden Sie sich an den Webmaster"; return "N"; } // erst noch unterscheiden: status N muss passwort ziehen if ( $login['emailstatus'] == "N" ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "noch kein passwort generiert" ); $gl_[ 'message' ][] = "Bitte erst Passwort generieren lassen"; return "N"; } // pwd ok? if ( $login['passwort'] != $loginpwd ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "loginfehler" ." für email=".$loginemail." pwd=".$loginpwd ); loguser( __FUNCTION__, '2112 Loginfehler email/pwd=', array( $loginemail, $loginpwd ) ); logloginerror( $loginemail, $loginpwd, "passwort falsch" ); $login['loginerrorcount'] += 1; $inerror = doupdate( $gl_['tab']['user'], $login, "", array( "nomessage" => 1, ) ); $gl_[ 'message' ][] = "User oder Passwort ungültig"; return "N"; } $login['lastlogin'] = uxts2myts(time()); $login['loginokcount'] += 1; $inerror = doupdate( $gl_['tab']['user'], $login, "", array( "nomessage" => 1, "writehistory" => "N", ) ); if ( $inerror ) { $gl_[ 'message' ][] = "Datenbankfehler bei Userupdate"; return "E"; } if ( $login['emailstatus'] == "P" ) { $row = getrow( $gl_['tab']['email'], $login['emailid']); $row['emailstatus'] = "O"; $inerror = doupdate( $gl_['tab']['email'], $row, array(), array( "nomessage" => 1 ) ); if ( $inerror ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "Datenbankfehler bei Mailupdate, Login trotzdem erfolgreich"); } } setsession( 'login_userid', $login['userid'] ); setsession( 'login_pseudonym', $login['pseudonym'] ); setsession( 'login_usertyp', $login['usertyp'] ); setsession( 'login_emailid', $login['emailid'] ); // protokoll setuserenv( $login['emailid'], array( "start" => "J" ) ); return "L"; } function setuserenv( $emailid, $options=array() ) { global $gl_; traceuser( __FUNCTION__.'/'.__LINE__, 4, "+", "aufruf emailid=".$emailid ); $erow = getrow( $gl_['tab']['email'], $emailid ); traceuser( __FUNCTION__.'/'.__LINE__, 4, "=", "email=".$erow['email'] ); $urow = getrow( $gl_['tab']['user'], $erow['userid'] ); traceuser( __FUNCTION__.'/'.__LINE__, 4, "=", "pseudo=".$urow['pseudonym'] ); setsession( 'login_userid', $urow['userid'] ); setsession( 'login_pseudonym', $urow['pseudonym'] ); setsession( 'login_usertyp', $urow['usertyp'] ); setsession( 'login_emailid', $erow['emailid'] ); setsession( 'login_email', $erow['email'] ); switch( $urow['usertyp'] ) { case "A" : case "V" : // vorstand case "M" : case "F" : // freund, zb roman/sts case "E" : // freund, zb roman/sts setsession('login_ismember', "J"); break; default : setsession('login_ismember', "N"); break; } if ( $options["start"] == "J" ) { loglogin ( "I", getsession( 'login_emailid' ) ); setsession( 'save_userid', $urow['userid'] ); setsession( 'save_pseudonym', $urow['pseudonym'] ); setsession( 'save_usertyp', $urow['usertyp'] ); setsession( 'save_emailid', $erow['emailid'] ); setsession( 'save_email', $erow['email'] ); setsession( 'save_ismember', getsession( 'login_ismember' ) ); } else { loglogin ( "U", getsession( 'login_emailid' ) ); } $mysessionid = createsession(); setsession( 'mysessionid', $mysessionid ); $gl_[ 'message' ][] = "Login erfolgreich für: ".getsession( 'login_pseudonym' ); traceuser( __FUNCTION__.'/'.__LINE__, 4, "-", "ende egal=".$xxx ); } function checkanmeldung( $row ) { global $gl_; global $def_; $dberror = 0; $noerror = 0; $row['pseudonym'] = trim( $row['pseudonym']); $row['vorname'] = trim( $row['vorname'] ); $row['name'] = trim( $row['name'] ); $row['email'] = trim( $row['email'] ); $row['titel'] = trim( $row['titel'] ); $row['telefon'] = trim( $row['telefon'] ); traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", "aufruf " ." name=".$row['name'] ." vorname=".$row['vorname'] ." email=".$row['email'] ." telefon=".$row['telefon'] ." pseudonym=".$row['pseudonym'] ); loguser( __FUNCTION__, '2121 Anmeldeversuch mit email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); while ( 1 ) { // dummyloop // email-checks // mytransaction( 'start' ); if ( $row['email'] == "" ) { $message = "Emailadresse fehlt"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2122 Anmeldeversuch ohne emailadresse name/vorname/pseudonym/telefon', array( $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); $dberror = $noerror; break; } $noerror--; if ( !check_email_mx( $row['email'] ) ) { $message = "Emailadresse ungültig"; //$gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2123 Anmeldeversuch mit ungültiger email: email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); //$dberror = $noerror; //break; } $sqlbefehl = "select * "; $sqlbefehl .= " from ".$gl_['tab']['email']; $sqlbefehl .= " where lcase(email) = '".strtolower($row['email'])."'"; $ergebnis = mysql_query( $sqlbefehl ); if ( $dberror = mydberror( $sqlbefehl, __FUNCTION__ ) ) { $message = "Datenbankfehler bei Emailabfrage"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2124 Anmeldeversuch mit Datenbankfehler email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); break; } $noerror--; if ( mysql_num_rows( $ergebnis ) > 0 ) { $message = "E-Mail schon vorhanden" ." (Falls Sie der Inhaber dieser E-Mail-Adresse sind" .", verwenden Sie bitt den Punkt \"neues Passwort erzeugen\")"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2125 Anmeldeversuch mit vorhandener Email email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); $dberror = $noerror; break; } if ( $row['pseudonym'] == "" ) { $row['pseudonym'] = $row['vorname']." ".$row['name']; if ( trim( $row['pseudonym'] ) == "" ) { $row['pseudonym'] = $row['email']; } } $noerror--; $sqlbefehl = "select * "; $sqlbefehl .= " from ".$gl_['tab']['user']; $sqlbefehl .= " where pseudonym = '".$row['pseudonym']."'"; $ergebnis = mysql_query( $sqlbefehl ); if ( $dberror = mydberror( $sqlbefehl, __FUNCTION__ ) ) { $message = "Datenbankfehler bei Userabfrage"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2124 Anmeldeversuch mit Datenbankfehler email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); break; } $noerror--; if ( mysql_num_rows( $ergebnis ) > 0 ) { $message = "Anzeigename=".$row['pseudonym']." schon vorhanden"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); $dberror = $noerror; loguser( __FUNCTION__, '2125 Anmeldeversuch mit vorhandenem Pseudonym email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); break; } // so, alles in butter, email ist korrekt, neu und pseudonym gibts nicht: // also das notwendige anlegen: $urow['name'] = $row['name']; $urow['vorname'] = $row['vorname']; $urow['pseudonym'] = $row['pseudonym']; if ( !isset( $row['usertyp'] ) ) $urow['usertyp'] = "G"; else $urow['usertyp'] = $row['usertyp']; $urow['mandant'] = $gl_['extmandant']; $dberror = doinsert( $gl_['tab']['user'], $urow, "", array( "nomessage" => 1 ) ); if ( $dberror != 0 ) { $gl_[ 'message' ][] = "Datenbankfehler bei Anlegen User"; loguser( __FUNCTION__, '2124 Anmeldeversuch mit Datenbankfehler email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); break; } $gl_[ 'message' ][] = "Benutzer angelegt=".$row['pseudonym']; // nu die mail, die brauchts ja.. $erow['email'] = strtolower($row['email']); $erow['userid'] = $urow['userid']; $erow['isdefault'] = 'J'; $erow['mandant'] = $mandant; $dberror = doinsert( $gl_['tab']['email'], $erow, "", array( "nomessage" => 1 ) ); if ( $dberror != 0 ) { $gl_[ 'message' ][] = "Datenbankfehler bei Anlegen Email"; loguser( __FUNCTION__, '2124 Anmeldeversuch mit Datenbankfehler email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); break; } $gl_[ 'message' ][] = "Email angelegt=".$row['email']; if ( $row['telefon'] != "" ) { // telefon anlegen $trow['telefontyp'] = 'P'; $trow['isdefault'] = 'J'; $trow['userid'] = $urow['userid']; $trow['telefon'] = $row['telefon']; $dberror = doinsert( $gl_['tab']['telefon'], $trow, "", array( "xyz" => 1 ) ); if ( $dberror != 0 ) { $gl_[ 'message' ][] = "Datenbankfehler bei Anlegen Telefon=".$row['telefon']; loguser( __FUNCTION__, '2124 Anmeldeversuch mit Datenbankfehler email/name/vorname/pseudonym/telefon', array( $row['email'] , $row['name'] , $row['vorname'] , $row['pseudonym'], $row['telefon'] ) ); break; } $gl_[ 'message' ][] = "Telefon angelegt=".$row['telefon']; } $mailtext = "Anmeldung neuer User\n\n"; $mailtext .= "\nMail\t\t===> ".$row['email']."\n"; $mailtext .= "\nName\t\t===> ".$row['name']."\n"; $mailtext .= "\nvorname\t\t===> ".$row['vorname']."\n"; $mailtext .= "\npseudonym\t\t===> ".$row['pseudonym']."\n"; $mailtext .= "\ntelefon\t\t===> ".$row['telefon']."\n"; sendmail( $_SERVER[SERVER_ADMIN], "Neuer User ".$def_['domainabbrev'], $mailtext, array( "From: ".$_SERVER[SERVER_ADMIN], "Content-Type: text", "Reply-To: ".$_SERVER[SERVER_ADMIN] ) ); genpassword( $row['email'] ); $gl_[ 'message' ][] = "Bitte schauen Sie in Ihre Mail und melden sich dann" ." mit dem zugesendeten Passwort hier an (Auswahl \"login\")";; break; // dummyloopende } // commit/rollback... // if ( $dberror ) { // // } // else { // // } return $dberror; } function genpassword( $email ) { global $gl_; $dberror = 0; $noerror = 0; loguser( __FUNCTION__, '2118 Passwortgenerierversuch mit folgender email', array( $email ) ); traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", "aufruf "." email=".$email ); while ( 1 ) { // dummyloop // Login checken $noerror--; $sqlbefehl = "select a.* "; $sqlbefehl .= " from ".$gl_['tab']['email']." a"; $sqlbefehl .= " where lcase(a.email) = '".strtolower($email)."'" ; $ergebnis = mysql_query( $sqlbefehl ); if ( $dberror = mydberror( $sqlbefehl, __FUNCTION__ ) ) { $message = "Datenbankfehler bei Emailabfrage"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); break; } if ( mysql_num_rows( $ergebnis ) == 0 ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "newpasswortversuch mit nicht vorhandener email=".$email ); loguser( __FUNCTION__, '2119 Passwortgenerierversuch mit nicht vorhandener email', array( $email ) ); $gl_[ 'message' ][] = "Email=".$email." nicht vorhanden"; break; } $row = mysql_fetch_array( $ergebnis ); if ( $row['emailstatus'] == "S" ) { traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "newpasswortversuch mit gesperrter email=".$email ); loguser( __FUNCTION__, '2131 Passwortgenerierversuch mit gesperrter email', array( $email ) ); $gl_[ 'message' ][] = "Email gesperrt, bitte wenden Sie sich an den Webmaster"; break; } // eventuelle vorherige emails die passwort beantragt haben, // aber nicht gemeldet worden sind, wieder zurücksetzen $setrow['emailstatus'] = 'N'; $wherestring = " where userid=".$row['userid']; $wherestring .= " and emailstatus = 'P'"; $wherestring .= " and emailid != ".$row['emailid']; $inerror = updatewhere( $gl_['tab']['email'], $setrow, $wherestring, "", array( "nomessage" => 1 ) ); if ( $inerror ) { $gl_[ 'message' ][] = "Datenbankfehler bei Emailupdate1"; loguser( __FUNCTION__, '2131 Passwortgenerierversuch mit Datenbankfehler email=', array( $email ) ); break; } // un' nu die aktuelle auf P setzen $row['emailstatus'] = 'P'; $inerror = doupdate( $gl_['tab']['email'], $row, "", array( "nomessage" => 1 ) ); if ( $inerror ) { $gl_[ 'message' ][] = "Datenbankfehler bei Emailupdate2"; break; } srand( (double)microtime() * 1000000 ); $urow = getrow( $gl_['tab']['user'], $row['userid']); $passwort = strtolower(substr( md5( uniqid( rand() ) ), 7, 8 )); $urow['passwort'] = $passwort; $urow['passwordgencount'] += 1; $inerror = doupdate( $gl_['tab']['user'], $urow, "", array( "nomessage" => 1, "writehistory" => "N", ) ); if ( $inerror ) { $gl_[ 'message' ][] = "Datenbankfehler bei Userupdate"; loguser( __FUNCTION__, '2131 Passwortgenerierversuch mit Datenbankfehler email=', array( $email ) ); break; } // protokoll loglogin ( "G", $row['emailid'], $row['userid'] ); $mailtext = $_SERVER[HTTP_HOST]."\n"; $mailtext .= "für die Mailadresse ==>:\n".$row['email']."\n<==\n"; $mailtext .= "wurde folgendes Passwort neu generiert ==>:\n"; $mailtext .= $passwort."\n<==\n"; $mailtext .= "Es kann nach dem ersten Login selbst geändert werden\n"; $mailtext .= "Am besten kopieren Sie das Passwort zur Anmeldung.\n\n"; $mailtext .= "Hinweis: es enthält KEINE Grossbuchstaben,\n"; $mailtext .= "was eventuell ähnlich aussieht wie ein Oooh, ist eine 0 (Null)\n"; $mailtext .= "Hinweis 2: Es enthält auch keine Leerzeichen, und ist genau 8 Stellen lang\n\n"; $mailtext .= "\nViel Spass, Ihr Webmaster\n"; sendmail( $row['email'], "Neues Passwort ".$_SERVER[HTTP_HOST], $mailtext, array( "From: ".$_SERVER[SERVER_ADMIN], "Content-Type: text", "Reply-To: ".$_SERVER[SERVER_ADMIN], "Disposition-Notification-To: ".$_SERVER[SERVER_ADMIN], "BCC: ".$_SERVER[SERVER_ADMIN] ) ); loguser( __FUNCTION__, '2115 Neues Passwort gesendet, Email/Passwort', array( $row['email'], $passwort ) ); $gl_[ 'message' ][] = "Passwort gesendet an ".$row['email']."!"; break; // dummyloopende } // commit/rollback... // if ( $dberror ) { // // } // else { // // } return $dberror; } function chgpassword( $oldpwd, $newpwd1, $newpwd2 ) { global $gl_; $dberror = 0; $noerror = 0; traceuser( __FUNCTION__.'/'.__LINE__, 0, "file", "aufruf " ." oldpwd=".$oldpwd ." newpwd1=".$newpwd1 ." newpwd2=".$newpwd2 ); loguser( __FUNCTION__, '2116 Passwortchangeversuch mit email/pwdo/pwdn1/pwdn2', array( getsession( 'login_email' ), $oldpwd, $newpwd1, $newpwd2 ) ); while ( 1 ) { // dummyloop // Login checken $noerror--; if ( $newpwd1 != $newpwd2 ) { $message = "neues Passwort nicht gleich Wiederholung"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2117 Passwortchangeversuch fehlerhafte wiederholung mit email/pwdo/pwdn1/pwdn2', array( getsession( 'login_email' ), $oldpwd, $newpwd1, $newpwd2 ) ); $dberror = $noerror; break; } $urow = getrow( $gl_['tab']['user'], getsession( 'login_userid' ) ); $noerror--; if ( $urow['passwort'] != $oldpwd ) { $message = "altes Passwort ungültig, Benutzer abgemeldet!!"; $gl_[ 'message' ][] = $message; traceuser( __FUNCTION__.'/'.__LINE__, 4, "file", $message ); loguser( __FUNCTION__, '2119 Passwortchangeversuch falsches altes passwort mit email/pwdo/pwdn1/pwdn2', array( getsession( 'login_email' ), $oldpwd, $newpwd1, $newpwd2 ) ); $dberror = $noerror; resetsession(); break; } $urow['passwort'] = $newpwd1; $urow['passwordchangecount'] += 1; $inerror = doupdate( $gl_['tab']['user'], $urow, "", array( "nomessage" => 1, "writehistory" => "N", ) ); if ( $inerror ) { $gl_[ 'message' ][] = "Datenbankfehler bei Update Passwort"; loguser( __FUNCTION__, '2133 Passwortchangeversuch mit Datenbankfehler mit email/pwdo/pwdn1/pwdn2', array( getsession( 'login_email' ), $oldpwd, $newpwd1, $newpwd2 ) ); break; } loglogin ( "C", getsession( 'login_emailid' ), $urow['userid'] ); $gl_[ 'message' ][] = "Passwort geändert für: ".getsession( 'login_pseudonym' ); break; // dummyloopende } // commit/rollback... // if ( $dberror ) { // // } // else { // // } return $dberror; } ?> $tourrow , "rc" => -999 ); } $points = explode( "\n", $row['punktliste'] ); $maxpointno = count( $points ) - 1; traceuser( __FUNCTION__, 6, "=", "pointarr " ." laenge=".strlen( $row['punktliste'] ) ." zeilen=".( $maxpointno + 1 ) ); // erster durchlauf: x,y in rad umrechnen, wird so häufiger gebraucht $i = 0; foreach( $points as $no => $line ) { $i++; } } function get_dph_dist_rad2km( $x1r, $y1r, $h1, $x2r, $y2r, $h2, $x3r, $y3r, $h3, $options = array() ) { if ( is_array( $options['trace'] ) ) $traceoptions = $options['trace']; else $traceoptions = array( "set" => "no" ); // douglas-peucker-distance with weighted height-difference included traceuser( __FUNCTION__, 20, "+", "aufruf:" ." x1r=".$x1r ." y1r=".$y1r ." h1=".$h1 ." x2r=".$x2r ." y2r=".$y2r ." h2=".$h2 ." x3r=".$x3r ." y3r=".$y3r ." h3=".$h3 ." traceoptions=".serialize( $traceoptions ) ); // lat = y, long=x $d13 = 2 * asin( sqrt( pow( sin( ( $y1r - $y3r ) / 2 ), 2 ) + cos( $y1r ) * cos( $y3r ) * pow( sin( ( $x1r - $x3r ) / 2 ), 2 ) ) ) ; $d23 = 2 * asin( sqrt( pow( sin( ( $y2r - $y3r ) / 2 ), 2 ) + cos( $y2r ) * cos( $y3r ) * pow( sin( ( $x2r - $x3r ) / 2 ), 2 ) ) ) ; $dist = $d13 * EARTHRAD_KM; traceuser( __FUNCTION__, 25, "=", "zwischenschritte" ." d13-rad=".$d13 ." d13-km=".$dist ." d23-rad=".$d23 , $traceoptions ); if ( ( $x1r == $x2r ) && ( $y1r == $y2r ) ){ $dist = $d13 * EARTHRAD_KM; $disth = $dist + H_FACTOR * abs( $h1 - $h3 ); traceuser( __FUNCTION__, 20, "-", "points are equal, return d13km=".$dist." disth=".$disth, $traceoptions ); return $disth; } $a13 = atan2( sin( $x3r - $x1r ) * cos( $y3r ), cos( $y1r ) * sin( $y3r ) - sin( $y1r ) * cos( $y3r ) * cos( $x3r - $x1r ) ); $a23 = atan2( sin( $x3r - $x2r ) * cos( $y3r ), cos( $y2r ) * sin( $y3r ) - sin( $y2r ) * cos( $y3r ) * cos( $x3r - $x2r ) ); $a12 = atan2( sin( $x2r - $x1r ) * cos( $y2r ), cos( $y1r ) * sin( $y2r ) - sin( $y1r ) * cos( $y2r ) * cos( $x2r - $x1r ) ); traceuser( __FUNCTION__, 25, "=", "..." ." a13 rad=".$a13." deg=".fmod( rad2deg( $a13 ) + 360, 360 ) ." a23 rad=".$a23." deg=".fmod( rad2deg( $a23 ) + 360, 360 ) ." a12 rad=".$a12." deg=".fmod( rad2deg( $a12 ) + 360, 360 ) , $traceoptions ); // in the back of p1 in respect of dir to p2? while (1) { $a13delta = fmod( $a12 - $a13 + 3 * pi(), 2 * pi() ) - pi(); traceuser( __FUNCTION__, 25, "=", "..." ." a13delta rad=".$a13delta." deg=".fmod( rad2deg( $a13delta ) + 360, 360 ) , $traceoptions ); if ( abs( $a13delta ) > ( pi() / 2 ) ) { $disth = $dist + H_FACTOR * abs( $h1 - $h3 ); traceuser( __FUNCTION__, 25, "=", "ende: next p1 d13 km=".$dist." disth=".$disth , $traceoptions ); break; } $a21 = fmod( $a12 + 2* pi(), 2 * pi() ) - pi(); traceuser( __FUNCTION__, 25, "=", "..." ." a21 rad=".$a21." deg=".fmod( rad2deg( $a21 ) + 360, 360 ) , $traceoptions ); $a23delta = fmod( $a21 - $a23 + 3 * pi(), 2 * pi() ) - pi(); traceuser( __FUNCTION__, 25, "=", "..." ." a23delta rad=".$a23delta." deg=".fmod( rad2deg( $a23delta ) + 360, 360 ) , $traceoptions ); if ( abs( $a23delta ) > ( pi() / 2 ) ) { $dist = $d23 * EARTHRAD_KM; $disth = $dist + H_FACTOR * abs( $h2 - $h3 ); traceuser( __FUNCTION__, 25, "=", "ende: next p2 d23 km=".$dist." disth=".$disth , $traceoptions ); break; } // Formula: dxt = asin(sin(d13/R)*sin(a13-a12)) * R // where d13 is distance from start point to third point // a13 is (initial) bearing from start point to third point // a12 is (initial) bearing from start point to end point // R is the earth’s radius $dlot = asin( sin( $d13 ) * sin( $a13 - $a12 ) ); $dist = $dlot * EARTHRAD_KM; $dlot1 = sqrt( $d13 * $d13 - $dlot * $dlot ) * EARTHRAD_KM; $dlot2 = sqrt( $d23 * $d23 - $dlot * $dlot ) * EARTHRAD_KM; $d12 = 2 * asin( sqrt( pow( sin( ( $y1r - $y2r ) / 2 ), 2 ) + cos( $y1r ) * cos( $y2r ) * pow( sin( ( $x1r - $x2r ) / 2 ), 2 ) ) ) ; $d12km = $d12 * EARTHRAD_KM; traceuser( __FUNCTION__, 25, "=", "..." ." dlot arg=".$dlot." dlot km=".$dist." dlot1=".$dlot1." dlot2=".$dlot2 ." d12=".$d12." d12km=".$d12km , $traceoptions ); $hmiddle = $h1 + ( $h2 - $h1 ) * ( $dlot1 / $d12km ); $disth = $dist + H_FACTOR * abs( $hmiddle - $h3 ); traceuser( __FUNCTION__, 25, "=", "ende: between hmiddle=".$hmiddle." dist km=".$dist." disth=".$disth , $traceoptions ); break; } traceuser( __FUNCTION__, 20, "-", "ende disth".$disth ); return $disth; } function getdistp2seg_deg2km( $x1, $y1, $x2, $y2, $x3, $y3, $options = array() ) { //crosstrackdistance, point 3 to line segment from 1 to 2 // difference to next function: // if behind 1 or 2 take dist to 1 or 2 instead of lot to great circle through 1 and 2 if ( is_array( $options['trace'] ) ) $traceoptions = $options['trace']; else $traceoptions = array( "set" => "no" ); traceuser( __FUNCTION__, 20, "+", "aufruf:" ." x1=".$x1 ." y1=".$y1 ." x2=".$x2 ." y2=".$y2 ." x3=".$x3 ." y3=".$y3 ." traceoptions=".serialize( $traceoptions ) ); $x1r = deg2rad( $x1 ); $y1r = deg2rad( $y1 ); $x2r = deg2rad( $x2 ); $y2r = deg2rad( $y2 ); $x3r = deg2rad( $x3 ); $y3r = deg2rad( $y3 ); traceuser( __FUNCTION__, 30, "=", "radians:" ." x1=".$x1r ." y1=".$y1r ." x2=".$x2r ." y2=".$y2r ." x3=".$x3r ." y3=".$y3r ." rd=".$rd ); // lat = y, long=x $d13 = 2 * asin( sqrt( pow( sin( ( $y1r - $y3r ) / 2 ), 2 ) + cos( $y1r ) * cos( $y3r ) * pow( sin( ( $x1r - $x3r ) / 2 ), 2 ) ) ) ; $dist = $d13 * EARTHRAD_KM; traceuser( __FUNCTION__, 25, "=", "zwischenschritte" ." d13-rad=".$d13 ." d13-km=".$dist ." d23-rad=".$d23 , $traceoptions ); if ( ( $x1 == $x2 ) && ( $y1 == $y2 ) ){ traceuser( __FUNCTION__, 20, "-", "points are equal, use d13" ); addusermessage( __FUNCTION__.'/'.__LINE__." p1=p2, return d13=".$dist ); return $dist; } $a13 = atan2( sin( $x3r - $x1r ) * cos( $y3r ), cos( $y1r ) * sin( $y3r ) - sin( $y1r ) * cos( $y3r ) * cos( $x3r - $x1r ) ); $a23 = atan2( sin( $x3r - $x2r ) * cos( $y3r ), cos( $y2r ) * sin( $y3r ) - sin( $y2r ) * cos( $y3r ) * cos( $x3r - $x2r ) ); $a12 = atan2( sin( $x2r - $x1r ) * cos( $y2r ), cos( $y1r ) * sin( $y2r ) - sin( $y1r ) * cos( $y2r ) * cos( $x2r - $x1r ) ); traceuser( __FUNCTION__, 25, "=", "..." ." a13 rad=".$a13." deg=".fmod( rad2deg( $a13 ) + 360, 360 ) ." a23 rad=".$a23." deg=".fmod( rad2deg( $a23 ) + 360, 360 ) ." a12 rad=".$a12." deg=".fmod( rad2deg( $a12 ) + 360, 360 ) , $traceoptions ); // in the back of p1 in respect of dir to p2? while (1) { $a13delta = fmod( $a12 - $a13 + 3 * pi(), 2 * pi() ) - pi(); traceuser( __FUNCTION__, 25, "=", "..." ." a13delta rad=".$a13delta." deg=".fmod( rad2deg( $a13delta ) + 360, 360 ) , $traceoptions ); if ( abs( $a13delta ) > ( pi() / 2 ) ) { traceuser( __FUNCTION__, 25, "=", "ende: next p1 d13 km=".$dist , $traceoptions ); break; } $a21 = fmod( $a12 + 2* pi(), 2 * pi() ) - pi(); traceuser( __FUNCTION__, 25, "=", "..." ." a21 rad=".$a21." deg=".fmod( rad2deg( $a21 ) + 360, 360 ) , $traceoptions ); $a23delta = fmod( $a21 - $a23 + 3 * pi(), 2 * pi() ) - pi(); traceuser( __FUNCTION__, 25, "=", "..." ." a23delta rad=".$a23delta." deg=".fmod( rad2deg( $a23delta ) + 360, 360 ) , $traceoptions ); if ( abs( $a23delta ) > ( pi() / 2 ) ) { $d23 = 2 * asin( sqrt( pow( sin( ( $y2r - $y3r ) / 2 ), 2 ) + cos( $y2r ) * cos( $y3r ) * pow( sin( ( $x2r - $x3r ) / 2 ), 2 ) ) ) ; $dist = $d23 * EARTHRAD_KM; traceuser( __FUNCTION__, 25, "=", "ende: next p2 d23 km=".$dist." disth=".$disth , $traceoptions ); break; } // Formula: dxt = asin(sin(d13/R)*sin(a13-a12)) * R // where d13 is distance from start point to third point // a13 is (initial) bearing from start point to third point // a12 is (initial) bearing from start point to end point // R is the earth’s radius $dist = asin( sin( $d13 ) * sin( $a13 - $a12 ) ) * EARTHRAD_KM; traceuser( __FUNCTION__, 25, "=", "ende: between dist km=".$dist , $traceoptions ); break; } traceuser( __FUNCTION__, 20, "-", "ende dist".$dist ); return $dist; } function getctdistance_deg2km( $x1, $y1, $x2, $y2, $x3, $y3, $options = array() ) { // lat = y, long=x //crosstrackdistance, point 3 to great circle through 1, 2 traceuser( __FUNCTION__, 20, "+", "aufruf:" ." x1=".$x1 ." y1=".$y1 ." x2=".$x2 ." y2=".$y2 ." x3=".$x3 ." y3=".$y3 ); $rd = ( isset( $options['round'] ) ) ? $options['round'] : 4; $x1r = deg2rad( $x1 ); $y1r = deg2rad( $y1 ); $x2r = deg2rad( $x2 ); $y2r = deg2rad( $y2 ); $x3r = deg2rad( $x3 ); $y3r = deg2rad( $y3 ); traceuser( __FUNCTION__, 30, "=", "radians:" ." x1=".$x1r ." y1=".$y1r ." x2=".$x2r ." y2=".$y2r ." x3=".$x3r ." y3=".$y3r ." rd=".$rd ); $d13 = 2 * asin( sqrt( pow( sin( ( $y1r - $y3r ) / 2 ), 2 ) + cos( $y1r ) * cos( $y3r ) * pow( sin( ( $x1r - $x3r ) / 2 ), 2 ) ) ) ; $dist = $d13 * EARTHRAD_KM; traceuser( __FUNCTION__, 25, "=", "zwischenschritte" ." d13=".$d13 ." dist=".$dist ); addusermessage( __FUNCTION__.'/'.__LINE__." d13=".$dist ); if ( ( $x1 == $x2 ) && ( $y1 == $y2 ) ){ traceuser( __FUNCTION__, 20, "-", "points are equal, return d13=".$d13 ); //falsch, hier muss d(3,1) hin; // ansonsten 0 wenn P3 auf GC durch P1+P2 liegt return $d13; } // Formula: dxt = asin(sin(d13/R)*sin(a13-a12)) * R // where d13 is distance from start point to third point // a13 is (initial) bearing from start point to third point // a12 is (initial) bearing from start point to end point // R is the earth’s radius $a13 = atan2( sin( $x3r - $x1r ) * cos( $y3r ), cos( $y1r ) * sin( $y3r ) - sin( $y1r ) * cos( $y3r ) * cos( $x3r - $x1r ) ); addusermessage( __FUNCTION__.'/'.__LINE__." a13=".fmod( rad2deg( $a13 ) + 360, 360 ) ); $a12 = atan2( sin( $x2r - $x1r ) * cos( $y2r ), cos( $y1r ) * sin( $y2r ) - sin( $y1r ) * cos( $y2r ) * cos( $x2r - $x1r ) ); addusermessage( __FUNCTION__.'/'.__LINE__." a12=".fmod( rad2deg( $a12 ) +360, 360 ) ); traceuser( __FUNCTION__, 25, "=", "zwischenschritte" ." d13=".$d13 ." a13=".$a13 ." a12=".$a12 ); $dist = asin( sin( $d13 ) * sin( $a13 - $a12 ) ) * EARTHRAD_KM; traceuser( __FUNCTION__, 20, "-", "ende dist".$dist ); return $dist; } function getdistance_deg2km( $x1, $y1, $x2, $y2, $options = array() ) { traceuser( __FUNCTION__, 20, "+", "aufruf " ."x1=".$x1 ."x2=".$x2 ."y1=".$y1 ."y2=".$y2 ); // lat = y, long=x if ( ( $x1 == $x2 ) && ( $y1 == $y2 ) ){ traceuser( __FUNCTION__, 20, "-", "points are equal, 0.0" ); return 0.0; } $rd = ( isset( $options['round'] ) ) ? $options['round'] : 4; $x1r = deg2rad( $x1 ); $x2r = deg2rad( $x2 ); $y1r = deg2rad( $y1 ); $y2r = deg2rad( $y2 ); traceuser( __FUNCTION__, 30, "=", "radians " ."x1=".$x1r ."x2=".$x2r ."y1=".$y1r ."y2=".$y2r ."rd=".$rd ); $yd2 = ( $y1r - $y2r ) / 2; $xd2 = ( $x1r - $x2r ) / 2; // R*2*asin(sqrt((sin((lat1-lat2)/2))^2 + // cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2)) $distr = 2 * asin( sqrt( pow( sin( $yd2 ), 2 ) + cos( $y1r ) * cos( $y2r ) * pow( sin( $xd2 ), 2 ) ) ) ; traceuser( __FUNCTION__, 25, "=", "ende dist-rad".$distr ); $dist = round( EARTHRAD_KM * $distr, $rd ); traceuser( __FUNCTION__, 20, "-", "ende dist".$dist ); return $dist; } function getbearing_deg2deg( $x1, $y1, $x2, $y2, $options = array() ) { traceuser( __FUNCTION__, 20, "+", "aufruf " ." x1=".$x1 ." x2=".$x2 ." y1=".$y1 ." y2=".$y2 ); // lat = y, long=x //ATAN2(COS(lat1)*SIN(lat2)-SIN(lat1)*COS(lat2)*COS(lon2-lon1), SIN(lon2-lon1)*COS(lat2)) if ( ( $x1 == $x2 ) && ( $y1 == $y2 ) ){ traceuser( __FUNCTION__, 20, "-", "points are equal, 0.0" ); return 0.0; } $rd = ( isset( $options['round'] ) ) ? $options['round'] : 1; $x1r = deg2rad( $x1 ); $x2r = deg2rad( $x2 ); $y1r = deg2rad( $y1 ); $y2r = deg2rad( $y2 ); traceuser( __FUNCTION__, 30, "=", "radians " ." x1=".$x1r ." x2=".$x2r ." y1=".$y1r ." y2=".$y2r ." rd=".$rd ); $xd = $x2r - $x1r; //ATAN2(COS(lat1)*SIN(lat2)-SIN(lat1)*COS(lat2)*COS(lon2-lon1), SIN(lon2-lon1)*COS(lat2)) $bearr = atan2( sin( $xd ) * cos( $y2r ), cos( $y1r ) * sin( $y2r ) - sin( $y1r ) * cos( $y2r ) * cos( $xd ) ); traceuser( __FUNCTION__, 25, "=", "ende bear-rad".$bearr ); $bear = round( fmod( 360 + rad2deg( $bearr ), 360 ), $rd ); traceuser( __FUNCTION__, 20, "-", "ende bear".$bear ); return $bear; } function getmapicons( $options = array () ) { global $gl_; $style = ( isset( $options['style'] ) ) ? $options['style'] : 'st001'; traceuser( __FUNCTION__, 6, "+", "aufruf style=".$style ); $arrow_dir = $gl_['picturedir'].'/karte/'; $href_dir = "files.".$gl_['domain']."/pic/karte/"; $arrowarr = array(); if ( !is_dir( $arrow_dir ) ) { traceuser( __FUNCTION__, 0, "-", "ende " ."verzeichnis nicht vorhanden=".$arrow_dir ); } foreach ( glob( $arrow_dir."karte-".$style."-*.png" ) as $filename) { $namearr = explode( '-', basefname( $filename ) ); $iconname = $namearr[ 2 ]; // 0=karte, 1=style traceuser( __FUNCTION__, 10, "=", "filename=".$filename ."iconname=".$iconname ); $arrowarr[$iconname] = array( "fileid" => $filename, "href" => $href_dir . basename( $filename ), "jsname" => 'mapicon_'.$iconname ); } traceuser( __FUNCTION__, 6, "-", "ende " ."no icons=".count( $arrowarr ) ); return $arrowarr; } function getdirarrows( $options = array () ) { global $gl_; $style = ( isset( $options['style'] ) ) ? $options['style'] : 'st001'; traceuser( __FUNCTION__, 6, "+", "aufruf style=".$style ); $arrow_dir = $gl_['picturedir'].'/karte/'; $href_dir = "files.".$gl_['domain']."/pic/karte/"; $arrowarr = array(); if ( !is_dir( $arrow_dir ) ) { traceuser( __FUNCTION__, 0, "-", "ende " ."verzeichnis nicht vorhanden=".$arrow_dir ); } foreach ( glob( $arrow_dir."pfeil-".$style."-*.png" ) as $filename) { $namearr = explode( '-', basefname( $filename ) ); $angle = (int)( $namearr[ 2 ] ); // 0=karte, 1=style if ( isset( $oldangle ) ) $distangle = $angle - $oldangle; traceuser( __FUNCTION__, 10, "=", "filename=".$filename ."angle=".$angle ); $arrowarr[] = array( "fileid" => $filename, "href" => $href_dir.basename( $filename ), "jsname" => "diricon_".sprintf( "%03d", $angle ), "angle" => $angle ); $oldangle = $angle; } traceuser( __FUNCTION__, 6, "-", "ende " ."no arrows=".count( $arrowarr ) ); return array( "arrowarr" => $arrowarr, "distangle" => $distangle ); } function getsrtmheight ( $x, $y, $options = array() ) { global $_srtmarray; global $gl_; if ( $x >= 0 ) $filename = "N".sprintf( "%02d", floor( $y ) ); else $filename = "S".sprintf( "%02d", floor( abs( $y ) ) ); if ( $y >= 0 ) $filename .= "E".sprintf( "%03d", floor( $x ) ); else $filename .= "W".sprintf( "%03d", floor( abs( $x ) ) ); traceuser( __FUNCTION__, 14, "=", "ende "." fn=".$filename ); if ( !isset( $_srtmarray[$filename] ) ) { $srtmfile = $gl_['filedir'].'/srtm/'.$filename.".hgt"; $_srtmarray[$filename] = file_get_contents( $srtmfile ); } // xp, yp: 1200-er punktraster aufloesen $xp = 1200 * ( $x - floor( $x ) ); $yp = 1200 * ( $y - floor( $y ) ); // xd, yd sind die reste nach dem punktraster von unten/links $xd = $xp - floor( $xp ); $yd = $yp - floor( $yp ); traceuser( __FUNCTION__, 15, "=", "xp=".$xp." yp=".$yp." xd=".$xd." yd=".$yd ); // xl ist in x der untere (linke) messpunkt, xr der obere (rechte) $xl = floor( $xp ); $xr = ceil ( $xp ); $yu = floor( $yp ); $yo = ceil ( $yp ); traceuser( __FUNCTION__, 16, "=", "xl=".$xl." xr=".$xr." yu=".$yu." yo=".$yo ); // ul = unten links usw // im file ist der erste punkt oben links im quadrant, das heisst // ein breitengrad höher als der filename anzeigt für y // zumindest auf der nordhalbkugel ?! wie das suedlich ist??? // x=8 y=48 wie hier (ETTLINGEN) liefert als ersten punkt 8.0,49.0(ol), als 1201. 9.0/49.0 (or) // als letzten 9.0/48.0 (ur) und als 1201-vorletzten den namensgeberpunkt 8.0/48.0 (ul) $pul = 1201 * ( 1200 - $yu ) + $xl; $pur = 1201 * ( 1200 - $yu ) + $xr; $pol = 1201 * ( 1200 - $yo ) + $xl; $por = 1201 * ( 1200 - $yo ) + $xr; // die zustaendigen 2 bytes rausschneiden als string... $sul2 = substr( $_srtmarray[$filename], $pul * 2, 4 ); $sol2 = substr( $_srtmarray[$filename], $pol * 2, 4 ); $sul = substr( $sul2, 0, 2 ); $sur = substr( $sul2, 2, 2 ); $sol = substr( $sol2, 0, 2 ); $sor = substr( $sol2, 2, 2 ); // zum rechnen als hoehe, big endian, erstes byte * 256; $hul = 256 * ord( substr( $sul, 0, 1 ) ) + ord( substr( $sul, 1, 1 ) ); $hur = 256 * ord( substr( $sur, 0, 1 ) ) + ord( substr( $sur, 1, 1 ) ); $hol = 256 * ord( substr( $sol, 0, 1 ) ) + ord( substr( $sol, 1, 1 ) ); $hor = 256 * ord( substr( $sor, 0, 1 ) ) + ord( substr( $sor, 1, 1 ) ); traceuser( __FUNCTION__, 15, "=", "hul=".$hul." hur=".$hur." hol=".$hol." hor=".$hor ); // mitteln, strunzbloede, erst projektion auf obere kante ... if ( $hol < 32768 ) if ( $hor < 32768 ) $ho = $hol * ( 1 - $xd ) + $hor * $xd; else $ho = $hol; else // jetzt ist egal: entweder der geht oder beide invalide... $ho = $hor; // ... dann untere ... if ( $hul < 32768 ) if ( $hur < 32768 ) $hu = $hul * ( 1 - $xd ) + $hur * $xd; else $hu = $hul; else // jetzt ist egal: entweder der geht oder beide invalide... $hu = $hur; // ... dann vertikales mitteln ueber yd // und noch einmal: if ( $ho < 32768 ) if ( $hu < 32768 ) $h = round( $hu * ( 1 - $yd ) + $yd * $ho, 1 ) ; else $h = $ho; else $h = $hu; // waren alle 4 punkte kaputt, kommt immer noch 32768 raus, // das muss aufrufer filtern traceuser( __FUNCTION__, 12, "-", "ende "." h=".$h ); if ( isset( $options['showall'] ) ) { // zum debuggen mal in hex, das kann man ja im file suchen $xul = dechex( $hul ); $xur = dechex( $hur ); $xol = dechex( $hol ); $xor = dechex( $hor ); return array( "filename" => $filename, "srtmfile" => $srtmfile, "laenge" => strlen( $_srtmarray[$filename] ), "xp" => $xp, "yp" => $yp, "xd" => $xd, "yd" => $yd, "xl" => $xl, "xr" => $xr, "yu" => $yu, "yo" => $yo, "pul" => $pul, "pur" => $pur, "pol" => $pol, "por" => $por, "xul" => $xul, "xur" => $xur, "xol" => $xol, "xor" => $xor, "hul" => $hul, "hur" => $hur, "hol" => $hol, "hor" => $hor, "ho" => $ho, "hu" => $hu, "h" => $h ); } return $h; } function strippoints( $pointarray, $options = array() ) { if ( !isset( $options['maxpoints'] ) ) $options['maxpoints'] = 10000; $dropmodul = ceil( count( $pointarray) / $options['maxpoints'] ); if ( $dropmodul <= 1 ) return $pointarray; foreach ( $pointarray as $no => $line ) { if ( $no % $dropmodul == 0 ) $retarray[] = $line; } return $retarray; } function extractpoints( $pointstring, $punktfelder, $options = array() ) { $fieldlist = array_flip( explode( ',', $punktfelder ) ); // leeres array zurück wenn nicht da $xno = ( isset( $fieldlist['x'] ) ) ? $fieldlist['x'] : -1; $yno = ( isset( $fieldlist['y'] ) ) ? $fieldlist['y'] : -1; $hno = ( isset( $fieldlist['h'] ) ) ? $fieldlist['h'] : -1; $pointsin = explode( "\n", $pointstring ); traceuser( __FUNCTION__, 4, "+", "aufruf " ." laenge=".strlen( $pointstring ) ." punktfelder=".$punktfelder ." xno=".$xno ." yno=".$yno ); if ( ( $xno == -1 ) || ( $yno == -1 ) ) { traceuser( __FUNCTION__, 0, "-", "aufruf " ." koordinaten nicht definiert x=".$xnp." y=".$yno ) ; return array(); } foreach( $pointsin as $line ) { $linearr = explode( ",", $line ); $pointarray[] = array( "x" => $linearr[$xno], "y" => $linearr[$yno] ); } traceuser( __FUNCTION__, 4, "-", "ende " ." punkte=".count( $pointarray ) ); return ( $pointarray ); } function writedirection ( $tour, $options = array() ) { global $arrowarrerg; $pointsin = explode( "\n", $tour['punktliste'] ); $fieldlist = array_flip( explode( ',', $tour['punktfelder'] ) ); $xno = ( isset( $fieldlist['x'] ) ) ? $fieldlist['x'] : -1; $yno = ( isset( $fieldlist['y'] ) ) ? $fieldlist['y'] : -1; $distano = ( isset( $fieldlist['dista'] ) ) ? $fieldlist['dista'] : -1; $angleno = ( isset( $fieldlist['angle'] ) ) ? $fieldlist['angle'] : -1; traceuser( __FUNCTION__, 4, "+", "aufruf " ." punkte=".count( $pointsin ) ." punktfelder=".$tour['punktfelder'] ." xno=".$xno ." yno=".$yno ." angleno=".$angleno ." distano=".$distano ); // if ( $angleno == -1 ) return array( "erg" => "fehlerangle", "rc" => -1 ); // todo: bloedfunktion aufrufen, die am punkt den winkel nimmt...; ohne breitengrad... if ( empty( $pointsin ) ) return array( "erg" => "nopoint", "rc" => -2 ); $markdist = ( isset( $options['markdist'] ) ) ? $options['markdist'] : 10; $markpoints = ( isset( $options['markpoints'] ) ) ? $options['markpoints'] : 1000; $usemark = ( isset( $options['usemark'] ) ) ? $options['usemark'] : 'none'; $cntpoints = ( isset( $options['cntpoints'] ) ) ? $options['cntpoints'] : 11; if ( ( $distano == -1 ) && ( $usemark == "dist" ) ) { $usemark == "points"; traceuser( __FUNCTION__, 0, "=", " usemark auf points umgesetzt weil dista fehlt" ); } if ( $angleno == -1 ) { $usemark == "none"; traceuser( __FUNCTION__, 1, "=", " usemark auf none umgesetzt weil angle fehlt" ); } traceuser( __FUNCTION__, 4, "=", "parameter " ." markdist=".$markdist ." markpoints=".$markpoints ." usemark=".$usemark ." cntpoints=".$cntpoints ); $arrowarr = $arrowarrerg['arrowarr']; $arrowdist = $arrowarrerg['distangle']; $arrowcnt = count( $arrowarr ); traceuser( __FUNCTION__, 5, "=", " arrowdist".$arrowdist ." arrowcnt".$arrowcnt ); // else use "points".... $lastmarkpoint = 0; $lastmarkdist = 0; $lastangles = array(); $cntangles = false; foreach( $pointsin as $i => $line ) { $domark = false; $linearr = explode( ",", $line ); $curdista = $linearr[ $distano ]; $curangle = $linearr[ $angleno ]; $lastangles[] = $curangle; traceuser( __FUNCTION__, 12, "=", "i=".$i ." curangle=".$curangle ." curdista=".$curdista ." lastmarkpoint=".$lastmarkpoint ." lastmarkpoint=".$lastmarkpoint ." lastmarkdist=".$lastmarkdist ." cntangles=".$cntangles ); if ( 2 * count( $lastangles ) > $cntpoints ) array_shift( $lastangles ); if ( $cntangles ) { traceuser( __FUNCTION__, 11, "=", "i=".$i ." cntangles gesetzt, anzahl=".count($markangles) ); $markangles[] = $linearr[ $angleno ]; if ( count( $markangles ) >= $cntpoints ) { $cntangles = false; $lastangle = round( array_sum( $markangles ) / count( $markangles ) ); traceuser( __FUNCTION__, 11, "=", "i=".$i ." lastangle berechnet=".$lastangles ); } } if ( ( $usemark == "dist" ) && ( $linearr[ $distano ] > $lastmarkdist + $markdist ) ) { $lastmarkdist = $curdista; $domark = true; traceuser( __FUNCTION__, 11, "=", "i=".$i ." lastmarkdist gesetzt=".$lastmarkdist ); } if ( ( $usemark == "points" ) && ( $i > $lastmarkpoint + $markpoints ) ) { $lastmarkpoint = $i; $domark = true; traceuser( __FUNCTION__, 11, "=", "i=".$i ." lastmarkpoint gesetzt=".$lastmarkpoint ); } if ( $domark ) { if ( isset( $lastx ) ) { $arrarrcnt = ( round( $lastangle/$arrowdist ) ) % $arrowcnt; $distarr[] = array( "x" => $lastx, "y" => $lasty, "angle" => $lastangle, "arrarrcnt" => $arrarrcnt, "no" => $lastpoint, "km" => $lastkm ); traceuser( __FUNCTION__, 11, "=", "i=".$i ." distarr geschrieben x=".$lastx ." lastpoint=".$lastpoint ." lastkm=".$lastkm ); } $lastx = $linearr[ $xno ]; $lasty = $linearr[ $yno ]; $lastkm = $linearr[ $distano ]; $lastpoint = $i; $markangles = $lastangles; $cntangles = true; } } traceuser( __FUNCTION__, 4, "+", "ende " ." pfeile=".count( $distarr ) ); return $distarr; } function writepolygon ( $pointarray, $options ) { if ( empty( $pointarray ) ) return; $linename = "polyline".$options['lineno']; echo " var ".$linename." = new GPolyline([\n"; foreach( $pointarray as $i => $p ) { if ( $i > 0 ) echo ", "; echo "new GLatLng(".$p['y'].",".$p['x'].")\n"; } echo "], \"".$options['linecolor']."\""; echo ", ".$options['linesize']; if ( $options['opacity'] != "" ) echo ", ".$options['opacity']; echo ");\n"; echo "map.addOverlay(".$linename.");\n"; } function writemap( $maparray ) { global $gl_; global $sgl_; global $max1; global $max2; global $map2; $maxarray = array( "maxx" => -200, "maxy" => -200, "minx" => 999, "miny" => 999 ); global $arrowarrerg; global $iconsarrerg; $arrowarr = $arrowarrerg['arrowarr']; $arrowdist = $arrowarrerg['distangle']; $arrowcnt = count( $arrowarr ); traceuser( __FUNCTION__, 5, "=", " arrowdist".$arrowdist ." arrowcnt".$arrowcnt ); if ( !isset( $maparray['mapsizex'] ) ) $maparray['mapsizex'] = $gl_['gmaps']['defmapsize']; if ( !isset( $maparray['mapsizey'] ) ) $maparray['mapsizey'] = $gl_['gmaps']['defmapsize']; if ( !isset( $maparray['mapsizex'] ) ) $maparray['mapsizex'] = 400; if ( !isset( $maparray['mapsizey'] ) ) $maparray['mapsizey'] = 300; // aktuelle kartennr feststellen, 1 falls nix vorher, ++ sonst if ( !isset( $gl_['gmaps']['nr'] ) ) { $gl_['gmaps']['nr'] = 1; } else $gl_['gmaps']['nr']++; // google js bibliothek laden falls noch nicht geschehen // könnten ja mehrere karten auf einer seite sein if ( !isset( $gl_['gmaps']['js-loaded'] ) ) { echo "\n"; $gl_['gmaps']['js-loaded'] = true; echo "\n"; } $mapname = "map".$gl_['gmaps']['nr']; $msgname = "message".$gl_['gmaps']['nr']; // die divboxen reinballern echo "
\n
\n"; //echo "style=\"width: ".$maparray['mapsizex']."px; height: ".$maparray['mapsizey']."px\">\n
\n"; //echo "
"; //echo "\n
\n"; //echo "\n
\n"; // JS zum laden der map echo "\n"; } function convertgpxmap( $row, $options = array() ) { // in row->punktliste sind die punkte, in punktfelder ist die csv-like headerline $fieldlist = array_flip( explode( ',', $row['punktfelder'] ) ); $xno = ( isset( $fieldlist['x'] ) ) ? $fieldlist['x'] : -1; $yno = ( isset( $fieldlist['y'] ) ) ? $fieldlist['y'] : -1; $hno = ( isset( $fieldlist['h'] ) ) ? $fieldlist['h'] : -1; $rdkm = ( isset( $options['roundkm'] ) ) ? $options['roundkm'] : 5; $rdangle = ( isset( $options['roundang'] ) ) ? $options['roundkm'] : 1; $distsno = 100; $distano = 101; $angleno = 102; // TODO: falls da date-time drin ist, koennte man speed rechnen if ( is_array( $row['punktliste'] ) ) $maparray = $row['punktliste']; else $maparray = explode( "\n", $row['punktliste'] ); traceuser( __FUNCTION__, 4, "+", "aufruf " ." xno=".$xno ." yno=".$yno ." hno=".$hno ." zeilen=".count( $maparray ) ); $i = 0; foreach ( $maparray as $no => $line ) { if ( strlen( $line ) < 10 ) continue; $i++; $linearr = explode( ',', $line ); $x = $linearr[ $xno ]; $y = $linearr[ $yno ]; $h = $linearr[ $hno ]; traceuser( __FUNCTION__, 4, "=", "line=".$i ." x=".$x ." y=".$y ." h=".$h ); if ( $i == 1 ) { $dist = 0; $km = 0; $angle = 0; } else { // TODO: round! hier rein, nicht in die funktion..; $angle = round( getbearing_deg2deg( $x2, $y2, $x, $y, $options ), 1 ); $dist = round( getdistance_deg2km( $x2, $y2, $x, $y, $options ), 4 ); $km += $dist; } // wenn mans kompliziert will //ksort( $linearr, SORT_NUMERIC ); $newarray[] = $line .','.$dist .','.$km .','.$angle ; $x2 = $x; $y2 = $y; } $row['punktfelder'] .= ",dists,dista,angle"; $row['punktliste' ] = implode( "\n", $newarray ); $row["punktanzahl" ] = $i ; traceuser( __FUNCTION__, 4, "-", "ende " ." punkte=".$row['punktanzahl'] ." hoehenmeter=".$row['hoehenmeter_map'] ); return $row; } function convertwintecmap( $row, $options = array() ) { // in row->punktliste sind die punkte, in punktfelder ist die csv-like headerline $fieldlist = array_flip( explode( ',', $row['punktfelder'] ) ); // erwartet textarea, \n getrennte zeilen, darin wintec-format csv $dateno = ( isset( $fieldlist['date'] ) ) ? $fieldlist['date'] : -1; $angleno = ( isset( $fieldlist['angle'] ) ) ? $fieldlist['angle'] : -1; $nono = ( isset( $fieldlist['no'] ) ) ? $fieldlist['no'] : -1; $timediff = ( isset( $row[ 'timediff' ] ) ) ? $row[ 'timediff' ] : 0; if ( is_array( $row['punktliste'] ) ) $maparray = $row['punktliste']; else $maparray = explode( "\n", $row['punktliste'] ); traceuser( __FUNCTION__, 4, "+", "aufruf " ." no=".$nono ." laenge=".strlen( $row['punktliste'] ) ." zeilen=".count( $maparray ) ); $i = 0; foreach ( $maparray as $no => $line ) { if ( strlen( $line ) < 10 ) continue; $i++; $linearr = explode( ',', $line ); $ldate = $linearr[ $dateno ]; traceuser( __FUNCTION__, 15, "=", "aufruf " ." i=".$i ." ldate=".$ldate ); $oldh = $h; // wintec zählt sued als 0° und dreht dann uhrzeigersinn // der rest der erde zählt nord als 0°, also 180° drauf... if ( $angleno != -1 ) $linearr[ $angleno ] = fmod( $linearr[ $angleno ] + 180, 360 ); if ( $dateno != -1 ) $linearr[ $dateno ] = uxts2myts( strtotime( $ldate ) + $timediff ); if ( $i == 1 ) { if ( $dateno != -1 ) $row["mapstartdatum" ] = $linearr[ $dateno ]; } $newarray[] = implode( ',', $linearr ); } $row['punktliste' ] = implode( "\n", $newarray ); $row["punktanzahl" ] = $i ; if ( $dateno != -1 ) $row["mapendedatum" ] = $linearr[ $dateno ]; traceuser( __FUNCTION__, 4, "-", "ende " ." punkte=".$row['punktanzahl'] ." mapstartdatum=".$row['mapstartdatum'] ." mapendedatum=".$row['mapendedatum'] ); return $row; } function importmap( $row, $options = array() ) { // in row->punktliste sind die punkte, in punktfelder ist die csv-like headerline traceuser( __FUNCTION__, 4, "+", "aufruf " ." punktfelder=".$row['punktliste'] ." laenge=".strlen( $row['punktliste'] ) ." zeilen=".count( $maparray ) ); $fieldlist = array_flip( explode( ',', $row['punktfelder'] ) ); // erwartet textarea, \n getrennte zeilen, darin wintec-format csv $nono = ( isset( $fieldlist['no'] ) ) ? $fieldlist['no'] : -10; $xno = ( isset( $fieldlist['x'] ) ) ? $fieldlist['x'] : -1; $yno = ( isset( $fieldlist['y'] ) ) ? $fieldlist['y'] : -1; $hno = ( isset( $fieldlist['h'] ) ) ? $fieldlist['h'] : -1; $dateno = ( isset( $fieldlist['date'] ) ) ? $fieldlist['date'] : -1; $distsno = ( isset( $fieldlist['dists'] ) ) ? $fieldlist['dists'] : -1; $distano = ( isset( $fieldlist['dista'] ) ) ? $fieldlist['dista'] : -1; $hrno = ( isset( $fieldlist['hr'] ) ) ? $fieldlist['hr'] : -1; $htno = ( isset( $fieldlist['ht'] ) ) ? $fieldlist['ht'] : -1; $timediff = ( isset( $row[ 'timediff' ] ) ) ? $row[ 'timediff' ] : 0; $rdkm = ( isset( $options['roundkm'] ) ) ? $options['roundkm'] : 5; if ( is_array( $row['punktliste'] ) ) $maparray = $row['punktliste']; else $maparray = explode( "\n", $row['punktliste'] ); traceuser( __FUNCTION__, 4, "+", "aufruf " ." nono=".$nono ." xno=".$xno ." yno=".$yno ." hno=".$hno ." hrno=".$hrno ." htno=".$htno ." dists=".$distsno ." dateno=".$dateno ." dista=".$distano ." timediff=".$timediff ); $i = 0; if ( ( $hno != -1 ) || ( $hrno != -1 ) || ( $htno != -1 ) ){ $maxh = -900; $minh = 9999; } $maxx = -400; $maxy = -400; $minx = 400; $miny = 400; $hm = 0; $km = 0; $oldh = 99999; foreach ( $maparray as $no => $line ) { if ( strlen( $line ) < 10 ) continue; $i++; $linearr = explode( ',', $line ); $x = $linearr[ $xno ]; $y = $linearr[ $yno ]; if ( $hno != -1 ) $h = $linearr[ $hno ]; if ( $hrno != -1 ) $hr = $linearr[ $hrno ]; if ( $htno != -1 ) $ht = $linearr[ $htno ]; if ( $i == 1 ) { if ( $dateno != -1 ) $row["mapstartdatum" ] = $linearr[ $dateno ]; if ( $distsno != -1 ) $linearr[ $distsno ] = 0; if ( $distano != -1 ) $linearr[ $distano ] = 0; if ( $angleno != -1 ) $linearr[ $angleno ] = 0; } else { if ( $distsno != -1 ) { $km += $linearr[ $distsno ]; if ( $distano != -1 ) $linearr[ $distano ] = $km; } } if ( ( $hno != -1 ) || ( $hrno != -1 ) || ( $htno != -1 ) ){ if ( $hno != -1 ) { if ( $h > $maxh ) $maxh = $h; if ( $h < $minh ) $minh = $h; if ( $h > $oldh ) $hm += ( $h - $oldh ); $oldh = $h; } else { if ( $hrno != -1 ) { if ( $hr > $maxh ) $maxh = $hr; if ( $hr < $minh ) $minh = $hr; if ( $hr > $oldh ) $hm += ( $hr - $oldh ); $oldh = $hr; } else { if ( $ht > $maxh ) $maxh = $ht; if ( $ht < $minh ) $minh = $ht; if ( $ht > $oldh ) $hm += ( $ht - $oldh ); $oldh = $ht; } } } traceuser( __FUNCTION__, 15, "=", "loop " ." i=".$i ." km=".$km ." hm=".$hm ." error=".$php_errormsg ); if ( $x > $maxx ) $maxx = $x; if ( $y > $maxy ) $maxy = $y; if ( $x < $minx ) $minx = $x; if ( $y < $miny ) $miny = $y; if ( ( $dateno != -1 ) && ( $timediff != 0) ) $linearr[ $dateno ] = uxts2myts( myts2uxts( $ldate ) + $timediff ); if ( $distano != -1 ) $linearr[ $distano ] = round( $km, $rdkm ); if ( $nono == -10 ) $newarray[] = $i.','.implode( ',', $linearr ); else { $linearr[ $nono ] = $i; $newarray[] = implode( ',', $linearr ); } } if ( $nono == -10 ) $row[ 'punktfelder' ] = "no,".$row[ 'punktfelder' ]; $row['punktliste' ] = implode( "\n", $newarray ); $row["maxh" ] = $maxh; $row["minh" ] = $minh; $row["maxx" ] = $maxx; $row["maxy" ] = $maxy; $row["minx" ] = $minx; $row["miny" ] = $miny; $row["midx" ] = ( $maxx + $minx ) / 2; $row["midy" ] = ( $maxy + $miny ) / 2; if ( ( $hno != -1 ) || ( $hrno != -1 ) || ( $htno != -1 ) ) $row["hoehenmeter_map"] = $hm ; if ( $distano != -1 ) $row["kilometer_map" ] = $km ; $row["punktanzahl" ] = $i ; if ( $dateno != -1 ) $row["mapendedatum" ] = $linearr[ $dateno ]; traceuser( __FUNCTION__, 4, "-", "ende " ." punkte=".$row['punktanzahl'] ." kilometer=".$row['kilometer_map'] ." hoehenmeter=".$row['hoehenmeter_map'] ." mapstartdatum=".$row['mapstartdatum'] ); return $row; } function __test_shrinkwintecmap( $row ) { return shrinkwintecmap( explode( "\n", $row['inarea'] ), array( 'maxdropseq' => $row[ 'maxdropseq' ] ,'maxdropdst' => $row[ 'maxdropdst' ] ,'maxdwinkel' => $row[ 'maxdwinkel' ] ) ); } function shrinkwintecmap( $maparray, $options = array() ) { // erwartet ein array, das im wintec201 modus folgende spalten // kommagetrennt beinhaltet: // Order,Latitude,Longitude,Elevation,Date Created,Distance from Start,Distance from Last,Bearing,(Speed? // schmeisst je nach max-entfernung/winkel/anzahl punkte punkte raus // sollte durch 3-dimensionalen Douglas Peucker algorithmus ersetzt werden; $colno_order = 0; $colno_lat = 1; $colno_long = 2; $colno_height = 3; $colno_date = 4; $colno_distall = 5; $colno_distlast = 6; $colno_winkel = 7; $colno_speed = 8; $maxdropseq = ( isset( $options['maxdropseq'] ) ) ? $options['maxdropseq'] : 10; $maxdropdst = ( isset( $options['maxdropdst'] ) ) ? $options['maxdropdst'] : 1; $maxdwinkel = ( isset( $options['maxdwinkel'] ) ) ? $options['maxdwinkel'] : 10; $ignoredst = ( isset( $options['ignoredst'] ) ) ? $options['ignoredst'] : .005; $newarray = array(); $i = 0; $lastno = -1; $lastwinkel = -1; $lastdst = -1; traceuser( __FUNCTION__, 4, "+", "aufruf " ." maxdropseq=".$maxdropseq ." maxdropdst=".$maxdropdst ." maxdwinkel=".$maxdwinkel ." ignoredst=".$ignoredst ." arrsize=".count( $maparray ) ); foreach ( $maparray as $no => $line ) { $linearr = explode( ',', $line ); $i++; $curwinkel = $linearr[ $colno_winkel ]; $curdistall = $linearr[ $colno_distall ]; $dowrite = 0; $reason = ''; traceuser( __FUNCTION__, 4, "file", "aufruf " ." i=".$i." no cur=".$no." last=".$lastno ." winkel cur=".$curwinkel." last=".$lastwinkel ." dist cur=".$curdistall." last=".$lastdst ); if ( $i == 1 ) { $reason .= 'F'; $dowrite = 1; } else { if ( abs( $lastwinkel - $curwinkel ) > $maxdwinkel ) { $dowrite = 1; $reason .= "W"; } if ( $curdistall - $lastdst > $maxdropdst ) { $dowrite = 1; $reason .= "D"; } if ( ( $no - $lastno ) > $maxdropseq ) { $dowrite = 1; $reason .= "C"; } } if ( $dowrite ) { $lastno = $no; $lastwinkel = $curwinkel; $lastdst = $curdistall; $linearr[ $colno_date ] = uxts2myts( strtotime( $linearr[ $colno_date ] ) ); $linearr[] = $reason; $newarray[] = implode( ',', $linearr ); traceuser( __FUNCTION__, 4, "file", "aufruf " ." i=".$i." no cur=".$no." last=".$lastno ." winkel cur=".$curwinkel." last=".$lastwinkel ." dist cur=".$curdistall." last=".$lastdst ); } } $linearr[ $colno_date ] = uxts2myts( strtotime( $linearr[ $colno_date ] ) ); $linearr[] = "E"; $newarray[] = implode( ',', $linearr ); traceuser( __FUNCTION__, 4, "-", "ende " ." arrsize=".count( $newarray ) ); return $newarray; } ?>