Need to allow users entry Frontend only with right IP Addres
-
- Beiträge: 53
- Registriert: Fr 14. Nov 2003, 10:08
- Wohnort: Switzerland
- Kontaktdaten:
Need to allow users entry Frontend only with right IP Addres
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]
Alessandro Marrarosa
Dipl. Wirtschaftsinformatiker HF
The Swiss Post
Information Technology Services
CH-6501 Bellinzona
Dipl. Wirtschaftsinformatiker HF
The Swiss Post
Information Technology Services
CH-6501 Bellinzona
-
- Beiträge: 53
- Registriert: Fr 14. Nov 2003, 10:08
- Wohnort: Switzerland
- Kontaktdaten:
Ciao emergence,
thanks for this info but...
If I set this info for a specific user... how can it work for all user visiting the frontend site?
My need is that:
1) somebody go to www.somesite.ch
2) if the user is in some IP range he can enter the site else
3) ... else he receive a login mask
4) if login OK he can enter the site like point 2)
Can I use what you propose me for that?
Ciao
Alessandro
thanks for this info but...
If I set this info for a specific user... how can it work for all user visiting the frontend site?
My need is that:
1) somebody go to www.somesite.ch
2) if the user is in some IP range he can enter the site else
3) ... else he receive a login mask
4) if login OK he can enter the site like point 2)
Can I use what you propose me for that?
Ciao
Alessandro
Alessandro Marrarosa
Dipl. Wirtschaftsinformatiker HF
The Swiss Post
Information Technology Services
CH-6501 Bellinzona
Dipl. Wirtschaftsinformatiker HF
The Swiss Post
Information Technology Services
CH-6501 Bellinzona
i have just tested the behavior on my localhostalessandro hat geschrieben:1) somebody go to www.somesite.ch
2) if the user is in some IP range he can enter the site else
3) ... else he receive a login mask
4) if login OK he can enter the site like point 2)
it should work this way... but you must give the user the right Frontend access in categories...
it does not work when you only set the right in areas... (might be a bug $idcat = 0 is ignored)
it should be possible to define the range with
127.0.0.1/128.0.0.1
if only entered 127.0.0.1 (without slash) -> the range is 127.0.0.1/255.255.255.255
it seems that there is a little bug in front_content.php
you'll find there
but it should be written as
then it works as i descriped it...
you'll find there
Code: Alles auswählen
$range = $db->f("value");
Code: Alles auswählen
$range = urldecode($db->f("value"));
-
- Beiträge: 53
- Registriert: Fr 14. Nov 2003, 10:08
- Wohnort: Switzerland
- Kontaktdaten: