More explanatory examples would be:
Wherever you choose to put this, is ok as long as it's included in a global way
[php]
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
[/php]
Then somewhere in your tracking preperations
PHP Code:
$guest_ip = getRealIpAddr();
From here you can handle this multiple ways, but two examples of storing and tracking the IP address is this.
- A db insert for EACH time an IP has viewed the system.
- A db insert with an a UNIQUE entity, then UPDATE the db with a db call to see how many times that IP's been logged and calling it ip_logged['count']; and do some basic math $ip_logged_new = $ip_logged['count']+1; from there we can ip_logged_times='".$ip_logged_new."' WHERE ip_logged_id='".$guest_ip."'
Either way, when the page loads you can do a basic check of settings to see if
We want to run $ip_logged['count'] against sometime type of settings check, etc.
PHP Code:
if ($ip_logged['count'] > 30) { // 30 is the amount of views allowed // RUN FUNCTIONS FOR NEEDING TO REGISTER OR WHATEVER YOU WANT } // Otherwise continue
Should be simple enough. If you need help let someone here know!
Last edited by DrewDown; 05-15-2010 at 02:41 PM..
|