$line) { $ip_timestamp_array = split("( |-)",$line); $ip[$i] = $ip_timestamp_array[0]; $timestamp[$j] = $ip_timestamp_array[1]; $fivemins_ago = time() - 300; if($ip[$i] == $REMOTE_ADDR) { $search_toremove = $ip[$i] . "-" . $timestamp[$j]; $insert = $REMOTE_ADDR . "-" . time() . "\n"; $datei = fopen($counter_path . "stats/useronline.txt", "r"); $size = filesize($counter_path . "stats/useronline.txt"); $contents = fread($datei, $size); fclose($datei); $massreplace = preg_replace("/$search_toremove/", $insert, $contents); $datei = fopen($counter_path . "stats/useronline.txt", "w"); fputs($datei, $massreplace); fclose($datei); } if($fivemins_ago > $timestamp[$j]) { $search_toremove = $ip[$i] . "-" . $timestamp[$j]; $datei = fopen($counter_path . "stats/useronline.txt", "r"); $size = filesize($counter_path . "stats/useronline.txt"); $contents = fread($datei, $size); fclose($datei); $massreplace = preg_replace("/$search_toremove/", "", $contents); $datei = fopen($counter_path . "stats/useronline.txt", "w"); fputs($datei, $massreplace); fclose($datei); } $i++; $j++; } $to_test = implode("", @file($counter_path . "stats/useronline.txt")); if (!strstr($to_test, $REMOTE_ADDR)) { $put_in_file = $REMOTE_ADDR . "-" . time(); $datei = fopen($counter_path . "stats/useronline.txt", "a+"); fputs($datei, $put_in_file . "\n"); fclose($datei); } $filearray = file($counter_path . "stats/useronline.txt"); foreach($filearray as $num => $line) { $count_useronline++; } $maxuseronline_file = fopen($counter_path . "stats/maxuseronline.txt", "r"); $maxuseronline = fgets($maxuseronline_file, 100); fclose($maxuseronline_file); if($count_useronline > $maxuseronline) { $maxuseronline_file = fopen($counter_path . "stats/maxuseronline.txt", "w"); fputs($maxuseronline_file, "$count_useronline"); fclose($maxuseronline_file); } //#####Reset IP-List alle 24h immer 0 Uhr##### $lastreset_file = fopen($counter_path . "stats/lastreset.txt", "r"); $lastreset = fgets($lastreset_file, 100); fclose($lastreset_file); $today_code = date("dm"); $lastreset_code = date("dm", $lastreset); $get_today_day = date("j"); $get_today_month = date("n"); $get_today_year = date("Y"); $set_today_hour = 0; $set_today_minute = 0; $set_today_second = 0; $new_reset_timestamp = mktime($set_today_hour, $set_today_minute, $set_today_second, $get_today_month, $get_today_day, $get_today_year); if($today_code != $lastreset_code) { $ip_file = fopen($counter_path . "stats/ip.txt", "w"); fputs($ip_file, ""); fclose($ip_file); $lastreset_file = fopen($counter_path . "stats/lastreset.txt", "w"); fputs($lastreset_file, "$new_reset_timestamp"); fclose($lastreset_file); if(file_exists($counter_path . "stats/visitsjesterday.txt")) { unlink($counter_path . "stats/visitsjesterday.txt"); } rename($counter_path . "stats/visitstoday.txt", $counter_path . "stats/visitsjesterday.txt"); $visitstoday_file = fopen($counter_path . "stats/visitstoday.txt", "w"); fputs($visitstoday_file, ""); fclose($visitstoday_file); } //#####IP-Sperre##### $test_ip = implode("", @file($counter_path . "stats/ip.txt")); if (!strstr($test_ip, $REMOTE_ADDR)) { $ip_file = fopen($counter_path . "stats/ip.txt", "a+"); $add_ip_to_file = sprintf("%s,",$REMOTE_ADDR); fputs($ip_file, $add_ip_to_file); fclose($ip_file); $visits_today_file = fopen($counter_path . "stats/visitstoday.txt", "r"); $visits_today = fgets($visits_today_file, 100); fclose($visits_today_file); $visits_today_to_file = $visits_today + 1; $put_visits_today_file = fopen($counter_path . "stats/visitstoday.txt", "w"); fputs($put_visits_today_file, "$visits_today_to_file"); fclose($put_visits_today_file); $all_visits_file = fopen($counter_path . "stats/all_visits.txt", "r"); $all_visits = fgets($all_visits_file, 100); fclose($all_visits_file); $all_visits_to_file = $all_visits + 1; $put_all_visits_file = fopen($counter_path . "stats/all_visits.txt", "w"); fputs($put_all_visits_file, "$all_visits_to_file"); fclose($put_all_visits_file); } $get_visits_today_file = fopen($counter_path . "stats/visitstoday.txt", "r"); $get_visits_today = fgets($get_visits_today_file, 100); fclose($get_visits_today_file); $all_visits_file = fopen($counter_path . "stats/all_visits.txt", "r"); $all_visits = fgets($all_visits_file, 100); fclose($all_visits_file); $get_visits_jesterday_file = fopen($counter_path . "stats/visitsjesterday.txt", "r"); $get_visits_jesterday = fgets($get_visits_jesterday_file, 100); fclose($get_visits_jesterday_file); $get_maxuseronline_file = fopen($counter_path . "stats/maxuseronline.txt", "r"); $get_maxuseronline = fgets($get_maxuseronline_file, 100); fclose($get_maxuseronline_file); if(!$invisible) { eval("dooutput(\"".gettemplate($counter_path . "counter.htm")."\");"); } ?>