= time() ) { # cache gültig $ResultArray = file($CacheFile); # lese ins array $ResultArray den inhalt des $CacheFiles ein -> hoffentlich mit \n am ende jedes elementes # debug: print_r(file($CacheFile)); if ( count($ResultArray) >= 1 ){ # wenn mindestens 1 result gefunden wurde #echo "

debug: CACHE HIT $CacheFile

" . count($ResultArray); $_SESSION['ISTHISACACHE'] = 1; return $ResultArray; } else { # der cache enthält keine gültigen anzahl an ergebnissen @unlink($CacheFile); # fehlermeldungen unterdrücken $_SESSION['ISTHISACACHE'] = 0; return -1; }; # if ( count($ResultArray) >= 1 ){ } else { # cache abgelaufen -> ABER X/Y -> lösche datei $IsAllowedToUseOldCache = IsCurrentLoadHigher( OLDCACHEISALLOWEDTOUSEATTHISLOAD ); if ( $IsAllowedToUseOldCache == 1) { $ResultArray = file($CacheFile); $_SESSION['ISTHISACACHE'] = 1; return $ResultArray; } else { @unlink($CacheFile); # fehlermeldungen unterdrücken $_SESSION['ISTHISACACHE'] = 0; return -1; }; # if ( $IsAllowedToUseOldCache == 1) { }; # if ( $CacheValidTime >= time() ) { }; # if (file_exists($CacheFile)) { # never reached $_SESSION['ISTHISACACHE'] = 0; return -1; #################### ###### Read Cache Ende #################### }; # function ReadCache( $CacheType, $SqlQuery ){ function WriteCache( $ResultArray ){ #################### ###### Write Cache #################### if ( strcasecmp($_SESSION['MAINCAT'], "emule") == 0 ) { $CachePath = WEBCACHEEMULE; } elseif ( strcasecmp($_SESSION['MAINCAT'], "bittorrent") == 0 || strcasecmp($_SESSION['MAINCAT'], "torrent") == 0 ) { $CachePath = WEBCACHETORRENT; } elseif ( strcasecmp($_SESSION['MAINCAT'], "rapidshare") == 0 ) { $CachePath = WEBCACHERAPIDSHARE; } elseif ( strcasecmp($_SESSION['MAINCAT'], "serial") == 0 || strcasecmp($_SESSION['MAINCAT'], "serials") == 0) { $CachePath = WEBCACHESERIALS; } elseif ( strcasecmp($_SESSION['MAINCAT'], "lyrics") == 0 || strcasecmp($_SESSION['MAINCAT'], "songtext") == 0) { $CachePath = WEBCACHESONGTEXT; } elseif ( strcasecmp($_SESSION['MAINCAT'], "usenet") == 0 ) { $CachePath = WEBCACHEUSENEXT; } elseif ( strcasecmp($_SESSION['MAINCAT'], "subtitle") == 0 || strcasecmp($_SESSION['MAINCAT'], "subtitles") == 0 || strcasecmp($_SESSION['MAINCAT'], "subtitel") == 0 || strcasecmp($_SESSION['MAINCAT'], "subtitels") == 0) { $CachePath = WEBCACHESUBTITLE; } else { $CachePath = WEBCACHEUSENEXT; }; # if ( strcasecmp($_SESSION['MAINCAT'], "emule") == 0 ) { $CacheRealFile = $CachePath . "/" . md5( $_SESSION['SEARCH'] ); if ( ( is_array($ResultArray) ) && ( count($ResultArray) >= 1 ) ){ $fh = fopen($CacheRealFile, 'wb'); flock($fh, LOCK_EX); # für jeden Eintrag des arrays, schreibe diesen Eintrag in die cache datei foreach ($ResultArray as $string) { $string = trim($string); # \n entfernen fwrite($fh,"$string\n" ); }; # foreach ($ResultArray as $string) { fclose($fh); }; # if ( is_array($ResultArray) ){ return 1; #################### ###### Write Cache Ende #################### }; # function WriteCache( $ResultArray ){ /* function WriteCache( $ResultArray ){ #################### ###### Write Cache #################### if ( ( is_array($ResultArray) ) && ( count($ResultArray) >= 1 ) ){ $CacheFile = $_SESSION['CACHEFILENAME']; $fh = fopen($CacheFile, 'wb'); flock($fh, LOCK_EX); # für jeden Eintrag des arrays, schreibe diesen Eintrag in die cache datei foreach ($ResultArray as $string) { $string = trim($string); # \n entfernen fwrite($fh,"$string\n" ); }; # foreach ($ResultArray as $string) { fclose($fh); }; # if ( is_array($ResultArray) ){ return 1; #################### ###### Write Cache Ende #################### }; # function WriteCache( $ResultArray ){ */ return 1; /* # öffne cache datei und lese sie ein! $fh = fopen($CacheFile, 'r') or warn("Error!!"); flock($fh, LOCK_EX); while (!feof($fh)) { $ResultString .= fread($fh, 2048); }; # while (!feof($fh)) { fclose($fh); # teile die ergebnisse jetzt anhand \n auf und speichere sie in einem neuen Array mit \n foreach ( explode("\n", $ResultString) as $string) { array_push($ResultArray, "$string\n"); }; # foreach ( explode("\n", $ResultString) as $string) { return $ResultArray; */ ?>