well hopefully i can get some help on this new little project...
heres the break down:
- 1:grab users IP address
2:connect to the dB for verification
3:test if the user knows an IP in the allowed dB
4:verify the IP they supplied is their IP, Since the Allowed IP's are static only check the node# or 4th set of digits
5:function to wirte the users IP to file if they are not in the Allowed dB
6:checking if the user is in the Allowed dB if not send it to functio ban()
7:if the user is in the Allowed dB
8:process the for said page
- Code: Select all
session_start()
//grab users IP address
$myIP = $_SERVER['REMOTE_ADDR'];
//connect to the dB for verifacation
@mysql_connect("$host", "$user", "$password")or die ('Error connecting to mysql');
@mysql_select_db("myAllowedIPnodes");
//test if the user knows an IP in the allowed dB
echo "whats your IP?<form method='post'><input type='text' size='12' name='iVerifiedIP' /> </form>";
$iPHostNumb = $_POST['iVerifiedIP'];
$iCheckIP = mysql_query("SELECT * FROM provoca1_myAllowedIPnodes.iIP WHERE Allowed LIKE '$myIP' LIMIT 0, 1");
$ipAllowed = mysql_numrows($iCheckIP);
//verify the IP they supplied is their IP, Since the Allowed IP's are static only check the node# or 4th set of digits
$iVerifyIP4thSec = explode(".", $iCheckIP);
$iVerifyIP4thSec = $iVerifyIP4thSec[3];
//function to wirte the users IP to file if they are not in the Allowed dB
Function ban()
{
$file = fopen(IPs.txt,"w");
echo fwrite($file,"$myIP\n");
fclose($file);
}
//checking if the user is in the Allowed dB if not send it to functio ban()
if($iPHostNumb != $iCheckIP)
{
ban("$myIP");
}
//if the user is in the Allowed dB
ELSE if($iPHostNumb == (base64_decode($_SERVER['REMOTE_ADDR']))
{
@require("Includes/Content/Header.php");
@require("Includes/Content/$iPage.php");
@require("Includes/Content/Footer.php");
}
my issue is when its checking the database its returning 1 for every one that connects where as i want only the users IP's that are in the database to be allowed to connect, there fore if said user A connects and is not in the Allowed dB they should return 0, not 1.
however i am also wanting to test if the user knowns an IP in the allowed dB, if so return 1; and if not return 0.
originally i have the server check against a base64 encoded IP address with an encoded variable it looked like so:
- Code: Select all
if(base64_decode($_SERVER['REMOTE_ADDR']) == "NzYuNzkuMjI5LiRpUEhvc3ROdW1i")
however i am unsure if encoding and decoding it will cause room for error as its an allowed server IP with the nodes as a variable as such
- Code: Select all
if(base64_decode($_SERVER['REMOTE_ADDR']) == "192.168.0.$iPHostNumb")



