11-20-2010, 02:00 PM
This is one of the first things I ever made, it is quite useful and a bit messy.
Script (Click to View)
PHP Code:
<?php
SESSION_START();
$session = $_SESSION['ipGranted'];
if($session != "yesItIs"){
//IPs allowed to view the site
$ips[] = '127.0.0.1';
$ips[] = '';
foreach($ips as $ip){
if($ip == $_SERVER['REMOTE_ADDR'])
{
$access = true;
$session = "YesItIs";
echo "<center><p id='conf'>Your IP address has been confirmed <br> Welcome to the site</center>";
break;
}
else
{
$access = false;
}
}
if($url == $_SERVER["REQUEST_URI"])
{
echo "<center>Ip has been confirmed <br> Welcome to the site.<center>";
$access = true;
}
if(!$access)
header('Location:http://www.google.com');
}
?>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('p#conf').hide(2000);
});
</script>
</head>