", $kb ); logDebug("requested KB by URL: ".$kw." of ".$year."
", $kb); logDebug("global params: ".$ViewKB[0]." of ".$ViewKB[1]."
", $kb); $ValidKB = true; // global $skipToNextYear; // get the actual date for validation $timestamp_now = strtotime("+1 day"); // find the year of the requested KB: if ( $ViewKB[0]!= "" && $ViewKB[1] != "" ) { logDebug("global vars are set, take them: ".$ViewKB[0]." / ".$ViewKB[1]."
", $kb); } else //if ( $year != "" && $kw != "" ) { // set global var to know where we are $ViewKB[0] = $kw; $ViewKB[1] = $year; } logDebug("gesuchtes KB: ".$ViewKB[0]."/".$ViewKB[1]."
", $kb); logDebug("heutiges Jahr:".date ("Y" , $timestamp_now)."gesuchtes".$ViewKB[1]."heutige KW:".date ("W" , $timestamp_now)."gesuchte:".$ViewKB[0]."akt. Monat:".date ( "n" , $timestamp_now )."
", $kb); // check if the given week is valid and NOT in the future if ( ( ($ViewKB[1] > ( date ("Y" , $timestamp_now))) && ( $ViewKB[0] > 1 ) ) // verlangtes Jahr ist > akt. Jahr && verlangte KW ist > 1 || ( ($ViewKB[1] == ( date ("Y" , $timestamp_now))) && ( $ViewKB[0] > ( date ("W" , $timestamp_now)) ) //&& !(date ( "n" , $timestamp_now ) == 12) ) ) // verlangtes Jahr ist = akt. Jahr && verlangte KW ist > akt. KW && wir haben nicht Dezember { // in december it is possible to fwd to a new year kb ! i.e.: in 2007 ->1/2008 logDebug("kw is in the future
", $kb); $ValidKB = false; } if ( $ViewKB[0] < 1 ) { logDebug("INVALID: $ViewKB[0] < 1
", $kb); $ValidKB = false; } // check number of weeks logDebug("ist ein Schaltjahr (0=nein): ".date("L",mktime(0,0,0,1,1,$ViewKB[1]))."
", $kb); switch ( date("L",mktime(0,0,0,1,1,$ViewKB[1])) ) { case 0: if ( $ViewKB[0] > 52 ) $ValidKB = false; //$ViewKB[0]=1; break; case 1: if ( $ViewKB[0] > 53 ) $ValidKB = false; break; default: writeErrorEmail($QUERY_STRING,"Fehler bei Rückgabe, ob Schaltjahr im Jahr ".$ViewKB[1]); break; } // BEGIN *** specially for 1999 *** if ( $ViewKB[1] == 1999 ) { // arry of valid KBs in 1999: $elementNo = 0; foreach ( $ValidKB1999 as $Kw ) { $elementNo++; // take next KW if ( $Kw == $ViewKB[0] )//&& $direction == "fwd") { $ViewKB[0] = $ValidKB1999[$elementNo-1]; break; } else if ( $Kw > $ViewKB[0] && $direction == "fwd" ) { $ViewKB[0] = $ValidKB1999[$elementNo-1]; break; } else if ( $Kw > $ViewKB[0] && $direction == "rwd" ) { // if we are at start of array, take the first element if ( $elementNo == 1 ) { $ViewKB[0] = $ValidKB1999[0]; } else { $ViewKB[0] = $ValidKB1999[$elementNo-2]; } break; } } } // END *** specially for 1999 *** if ( !$ValidKB ) // try to find the next valid KW { logDebug("invalid KB requested -> getNextValidKB...
", $kb); getNextValidKB ($direction); // here the global array $ViewKB is changed ! logDebug("global params after getNextValidKB: ".$ViewKB[0]." of ".$ViewKB[1]."
", $kb); } // search for KB file if ( $ValidKB ) { // 1. format the week right, if < 10 AND the KW does contain a "0" in front of the KW if ( $ViewKB[0] < 10 && strncmp($ViewKB[0],"0",1) ) $ViewKB[0] = "0".$ViewKB[0]; // 2. skip to next year directory, if KW is "1" and we are still in the old year $wort_htm_datei = ""; logDebug("KW and year is valid(2010): ".$ViewKB[0]."/".$ViewKB[1]."
", $kb); // search the directory for the needed KB if ( $handle = opendir("../../kalenderblatt/".$ViewKB[1]."/") ) { while ( false !== ($file = readdir($handle) ) ) { if ( $file != "." && $file != ".." ) { logDebug("Dateiname(2010): ".$file."
", $kb); } if ( strncmp ( $file, $ViewKB[0], 2 ) == 0 ) { // check valid file extension $array = explode(".",$file); if ( $array[count($array) - 1] == "php" ) { $wort_htm_datei = "../".$ViewKB[1]."/".$file; // test : ."?kw=".$ViewKB[0]; logDebug("Ausgabe von(2010): ".$wort_htm_datei."
", $kb); } } } closedir($handle); } // ================================================================ // show the requested KB of the week // ================================================================ if ( $wort_htm_datei != "" ) { logDebug( getcwd()."
", $kb); // change into the correct KB directory if ( chdir ( "../../kalenderblatt/".$ViewKB[1]."/" ) != true ) logDebug( "konnte Verz. nicht wechseln
", $kb); logDebug( getcwd()."
", $kb ); } else { // put out error message ?>

 

 

 

 

Kein Kalenderblatt für diese Woche vorhanden !!! ", $kb ); // change to another folder for KBs of next/last year $wort_htm_datei = ""; if ( $direction == "fwd" ) { logDebug("fwd to next year:".$ViewKB[1]."
", $kb ); $nextYear = $ViewKB[1];//+1; $wort_htm_datei = "../".$nextYear."/turnKB.php"; logDebug("used turnKB.php: ".$wort_htm_datei."
", $kb ); logDebug("used turnKB.php: ".getcwd()."
", $kb ); } else if ( $direction == "rwd" ) { logDebug("rwd to last year
", $kb ); $lastYear = $ViewKB[1];//-1; $wort_htm_datei = "../".$lastYear."/turnKB.php"; logDebug("used turnKB.php: ".$wort_htm_datei."
", $kb ); logDebug("used turnKB.php: ".getcwd()."
", $kb ); } else { logDebug("unknown direction", $kb ); } } else // not a valid week for a KB found { logDebug("getcwd() in notValidWeek found:: ".getcwd()."
", $kb ); // $wort_htm_datei = "nextKBs.php"; ?> ", $kb ); require_once($wort_htm_datei); ?>