PDA

View Full Version : ip redirect



gatloc
12-27-2010, 11:16 PM
When user comes to website it stores there ip address. So next time they visit
the site it redirects them a different page.

bluewalrus
12-27-2010, 11:55 PM
You need server side coding to do this do you have php, asp, other?

Nile
12-28-2010, 12:13 AM
PHP


<?php
function find($file, $ip){
$test = strrpos($file, $ip);
$exception = array('0');
if($test !== false && !in_array($ip, $exception)){
header("Location: redirect.php");
} else if (!in_array($ip, $exception)){
file_put_contents('getout.txt', $_SERVER['REMOTE_ADDR']."\n", FILE_APPEND);
}
}
find(file_get_contents('getout.txt'), $_SERVER['REMOTE_ADDR']);
?>

Make a file called getout.txt. If you do not want some ips to always redirect when viewing the page (for example, you), insert it into the $exception array.