Anthony2oo4
07-09-2005, 08:04 PM
Ok, I want to put ads on my site, buy like you all know ads are annoying. Well I thought that if i only show the user the ads one per day then that would be great. I know this can be done with cookies and javascript, and I have managed to do that succesfully but its not really reliable as people may have javascript disabled etc.
So I thought, If I record the IP of the user in a file, and then make a script that says, if the ip already exsist in the file, dont show the ads script. if it doesnt, show the ads script.
I managed to get the users IP address and write it to a file, but the IP dosnt go to a new line :S
How can I make the IP record to a new line every time and read the file to check if the IP alread exsists. Here is my code so far:
//get IP Address
$domain = GetHostByName($REMOTE_ADDR);
//Open File for writeing
$filename = 'ip.txt';
$fp = fopen($filename, "a");
//Write IP to file
$write = fputs($fp, $domain);
fclose($fp);
I know I can read the file like this:
$filename = 'ip.txt';
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);
But how do I check the file to see if the IP is there?
thanks for your help ;) :thumbsup:
So I thought, If I record the IP of the user in a file, and then make a script that says, if the ip already exsist in the file, dont show the ads script. if it doesnt, show the ads script.
I managed to get the users IP address and write it to a file, but the IP dosnt go to a new line :S
How can I make the IP record to a new line every time and read the file to check if the IP alread exsists. Here is my code so far:
//get IP Address
$domain = GetHostByName($REMOTE_ADDR);
//Open File for writeing
$filename = 'ip.txt';
$fp = fopen($filename, "a");
//Write IP to file
$write = fputs($fp, $domain);
fclose($fp);
I know I can read the file like this:
$filename = 'ip.txt';
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);
But how do I check the file to see if the IP is there?
thanks for your help ;) :thumbsup: