| | #1 |
| Vernazza Otranto Join Date: 2009 Location: Manhatten
Posts: 179
Thanks: 20
Thanked 14 Times in 13 Posts
Blog Entries: 2 |
Iam working on some one time offers that I want to only show once (ie: if they refresh the page, or try to load the oto page at a later date, it will not be availabe to them) I had this script sitting on my hard drive for the longest time and now after almost an hour of searching I can't find it anymore, can't find it via Google either ![]() I think what it did was record the user's IP address to a text file so that when the oto page loaded it would compare their IP address to those recorded in the text file. Best regards ~ Ross |
| |
| | #2 |
| Advanced Warrior War Room Member Join Date: 2010 Location: New Delhi, IN
Posts: 978
Thanks: 93
Thanked 340 Times in 59 Posts
|
Here is the script.Wrote it for you. You need to create a "log.txt" file in the same directory and change its permission to writable.I could have inserted a line to create this file but sometimes web hosts disable file creation through PHP. Hope this helps. Cheers <?php $dateTime = date('Y/m/d G:i:s'); $fp = fopen('log.txt', 'r+'); if(!$fp){ echo "Log file doesn't exists."; } else{ $visited = FALSE; while (!feof($fp)) { $buffer = fgets($fp); list ($ip, $time) = split(' ', $buffer); //Checks if IP is already logged. if ($_SERVER['REMOTE_ADDR'] == trim($ip)) $visited = TRUE; echo "Not your first visit."; } if (!$visited){ fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n"); echo "First visit."; } fclose($fp); } ?> |
| |
| | #3 |
| HyperActive Warrior War Room Member Join Date: 2009 Location: SE Europe
Posts: 112
Thanks: 13
Thanked 8 Times in 8 Posts
|
And here's a simple code to check if a proxy is used if ($_SERVER['HTTP_X_FORWARD_FOR']) { $IP = $_SERVER['HTTP_X_FORWARD_FOR']; } else { $IP = $_SERVER['REMOTE_ADDR']; } |
| |
| | #4 |
| Vernazza Otranto Join Date: 2009 Location: Manhatten
Posts: 179
Thanks: 20
Thanked 14 Times in 13 Posts
Blog Entries: 2 |
Wicked! Thanks for the script, almost done with one oto and Ill be poutting this in there. And there are many good uses for detecting proxies, but I think that if my optins are that desperate (what with some of the questionable advertising integrated into them and God knows what else...) to take a second look at my oto through a proxy, than Ill just let them get a second look haha |
| |
| | #5 | |
| Advanced Warrior War Room Member Join Date: 2010 Location: New Delhi, IN
Posts: 978
Thanks: 93
Thanked 340 Times in 59 Posts
|
I uploaded the script here.www.salescanvastheme.com/notwice.php for testing purpose.Works clean. Cheers | |
| |
| | #6 |
| Advanced Warrior War Room Member Join Date: 2010 Location: New Delhi, IN
Posts: 978
Thanks: 93
Thanked 340 Times in 59 Posts
|
Script update.I realised,message "Not first visit." has to be inside conditional.Fixed now. <?php $dateTime = date('Y/m/d G:i:s'); $fp = fopen('log.txt', 'r+'); if(!$fp){ echo "Log file doesn't exists."; } else{ $visited = FALSE; while (!feof($fp)) { $buffer = fgets($fp); list ($ip, $time) = split(' ', $buffer); //Checks if IP is already logged. if ($_SERVER['REMOTE_ADDR'] == trim($ip)){ << '{' where missing $visited = TRUE; echo "Not your first visit."; } added '}' } if (!$visited){ fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n"); echo "First visit."; } fclose($fp); } ?> |
| |
|
| Bookmarks |
| Tags |
| page, php, show |
| |