Need to allow users entry Frontend only with right IP Addres
Verfasst: Mi 11. Feb 2004, 08:56
Hi All,
I found in front_content.php this code, how can I use it?
Is it the right way to allow users entering Frontoffice dependig their IP address?
Thanks
Alessandro
(....)
if ($public == 0 && $auth->auth["uid"] == "nobody") {
$sql = "SELECT user_id, value FROM " .$cfg["tab"]["user_prop"]." WHERE type='frontend' and name='allowed_ip'";
$db->query($sql);
while ($db->next_record())
{
$user_id = $db->f("user_id");
$range = $db->f("value");
$slash = strpos($range, "/");
if ($slash == false)
{
$netmask = "255.255.255.255";
$network = $range;
} else {
$network = substr($range, 0, $slash);
$netmask = substr($range, $slash+1, strlen($range)-$slash-1);
}
if (IP_match($network,$netmask,$_SERVER["REMOTE_ADDR"]))
{
$sql = "SELECT idright
FROM ". $cfg["tab"]["rights"]. " AS A,
". $cfg["tab"]["actions"] . " AS B,
". $cfg["tab"]["area"] ." AS C
WHERE B.name = 'front_allow' AND C.name = 'str' AND A.user_id = '".$user_id."' AND A.idcat = '$idcat'
AND A.idarea = C.idarea AND B.idaction = A.idaction";
$db2 = new DB_Contenido;
$db2->query($sql);
if ($db2->num_rows() > 0)
{
$auth->auth["uid"] = $user_id;
$validated = 1;
}
}
}
if ($validated != 1)
{
(....)
[/code]
I found in front_content.php this code, how can I use it?
Is it the right way to allow users entering Frontoffice dependig their IP address?
Thanks
Alessandro
(....)
if ($public == 0 && $auth->auth["uid"] == "nobody") {
$sql = "SELECT user_id, value FROM " .$cfg["tab"]["user_prop"]." WHERE type='frontend' and name='allowed_ip'";
$db->query($sql);
while ($db->next_record())
{
$user_id = $db->f("user_id");
$range = $db->f("value");
$slash = strpos($range, "/");
if ($slash == false)
{
$netmask = "255.255.255.255";
$network = $range;
} else {
$network = substr($range, 0, $slash);
$netmask = substr($range, $slash+1, strlen($range)-$slash-1);
}
if (IP_match($network,$netmask,$_SERVER["REMOTE_ADDR"]))
{
$sql = "SELECT idright
FROM ". $cfg["tab"]["rights"]. " AS A,
". $cfg["tab"]["actions"] . " AS B,
". $cfg["tab"]["area"] ." AS C
WHERE B.name = 'front_allow' AND C.name = 'str' AND A.user_id = '".$user_id."' AND A.idcat = '$idcat'
AND A.idarea = C.idarea AND B.idaction = A.idaction";
$db2 = new DB_Contenido;
$db2->query($sql);
if ($db2->num_rows() > 0)
{
$auth->auth["uid"] = $user_id;
$validated = 1;
}
}
}
if ($validated != 1)
{
(....)
[/code]