<?php
$ip = $_SERVER['REMOTE_ADDR']; 
$file = "ip.txt";
$aLines = file($file);
$iAantal = count($aLines);
$sContent = " ";

if ($iaantal >1000) // het aantal IP adressen wat het script bewaard.
{
    $sContent = " ";
    $fp = fopen($file, 'w');
    fwrite($fp, $sContent);
    fclose($fp);
}
$content = file_get_contents("$file");
	if(strstr($content, $ip)){ 
	echo "Welkom terug " . $ip;
							 }
else {
$echo = 1;
echo "Hallo " . $ip . "," . "<br>" . "dit is u eerste bezoek aan deze website en u bent bezoeker NR ";	
						 
if(!strstr($content, $ip)){
		$file = fopen ("$file","a");           
		fputs ($file, "$ip \r\n");
		fclose($file);
		}           							 

if (file_exists("counter.txt")) {
$fp = fopen("counter.txt", "r+"); 
	$count = fgets($fp, 6);
	$count++;
	rewind ($fp);
	fputs($fp, $count, 6);
	fclose($fp);
} else {
	$fp = fopen("counter.txt", "w");
	$count="1";
	fputs ($fp, $count, 6);
	fclose($fp);
	}}
if ($echo != 1)
{
echo "<br>" . "U bent bezoeker ";
}
include ('counter.txt')
?>