Do NOT remove any of the copyright notices in the script. # -> This script can not be distribuated by anyone else than the author, unless special permisson is given. # # The author is not responible if this script causes any damage to your server or computers. # ################################# $bad_ip = array(); $run_debug=0; ################################# require "config.php"; include("functions.php"); $debug=0; if($run_debug==1) { $debug=1; } if ( ( (stristr($HTTP_REFERER, "$server_url") == false) && (stristr($HTTP_REFERER, "$new_server_url") == false) ) && $debug==0) { echo"Nije dozvoljeno pokrenuti x-stat odavde!
->Posetite x-stat forume za vise informacija."; } else { $ok="1"; foreach($bad_ip as $ip) { $ip_arr = explode(".", $ip); $v_ip = explode(".", $REMOTE_ADDR); if($ip_arr[0] != "*") { if($ip_arr[0] == $v_ip[0]) { $match1="1"; } } else { $match1="1"; } if($ip_arr[1] != "*") { if($ip_arr[1] == $v_ip[1]) { $match2="1"; } } else { $match2="1"; } if($ip_arr[2] != "*") { if($ip_arr[2] == $v_ip[2]) { $match3="1"; } } else { $match3="1"; } if($ip_arr[3] != "*") { if($ip_arr[3] == $v_ip[3]) { $match4="1"; } } else { $match4="1"; } if(isset($match1) && isset($match2) && isset($match3) && isset($match4)) { $ok="0"; } } if($ok == 1) { $cookie_time = time(); $cookie_reset_time = time()+259200; if (isset($x_stat_cookie)) { if ($cookie_time > $x_stat_cookie) { $is_uniqe = "1"; } else { $is_uniqe = "0"; } } else { $is_uniqe = "1"; } if ($reffer != "") { $reffering = str_replace("|", "l", $reffer); } else { $reffering = "Direct Hit"; } if (isset($HTTP_REFERER)) { $loaded = $HTTP_REFERER; } else { $loaded = "Unknown"; } $new_log_time1 = date("G"); $new_log_time2 = date("j"); $new_log_time3 = date("n"); $new_log_time4 = date("Y"); $hostmask = gethostbyaddr($REMOTE_ADDR); $file_size = filesize("logs/stats.txt"); if ($file_size > $max_log_size) { //start resetting stats if ($want_monthly_log == "1") { gen_monthly_log(); } $resett_stats = fopen ("logs/stats.txt", "w"); flock($resett_stats, 2); // Write lock fwrite($resett_stats, "$new_log_time1|$new_log_time2|$new_log_time3|$new_log_time4|$reffering|$HTTP_USER_AGENT|$REMOTE_ADDR|$loaded|$hostmask|$is_uniqe"); fclose ($resett_stats); $new_time = fopen("logs/reset_time.txt", w); flock($new_time, 2); // Write lock fwrite($new_time, time()); fclose($new_time); $file_size = filesize("logs/stats.txt"); } // ends resetting stats else { if ($file_size==0) { $line = "$new_log_time1|$new_log_time2|$new_log_time3|$new_log_time4|$reffering|$HTTP_USER_AGENT|$REMOTE_ADDR|$loaded|$hostmask|$is_uniqe"; } else { $line = "\n$new_log_time1|$new_log_time2|$new_log_time3|$new_log_time4|$reffering|$HTTP_USER_AGENT|$REMOTE_ADDR|$loaded|$hostmask|$is_uniqe"; } $fp = fopen ("logs/stats.txt", "a"); flock($fp, 2); // Write lock fwrite ($fp, "$line"); flock($fp, LOCK_UN); fclose ($fp); } $total_visits = file ("logs/count.txt"); $total_visits = $total_visits[0] + 1; $new_total_visits = fopen ("logs/count.txt", "w"); fwrite ($new_total_visits, "$total_visits"); fclose ($new_total_visits); setcookie("x_stat_cookie", $cookie_reset_time,time()+604800); } Header("Location: x_stat.gif"); } ?>