MyBB Community Forums

Full Version: Allow login from a specific IP address
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi guys I want make moderators and admins to be able to login only with the IP address they have signed up! I mean to protect my forum I want to make some sort of filter that will reject everyone who is trying to login as a moderator or admin from different IP address even if they have the right username password combination

I am talking about /admin directory but home page
Add the following to your .htaccess file

Order deny,allow
Deny from all
Allow from 127.0.0.1

Change 127.0.0.1 to your IP.
(2013-07-25, 09:22 PM)Arbaz Wrote: [ -> ]Add the following to your .htaccess file

Order deny,allow
Deny from all
Allow from 127.0.0.1

Change 127.0.0.1 to your IP.

Thanks but this will reject all the users however I just want to do this with moderators and admins
Oh I'm sorry. I didn't read your first post completely. I believe it will require a core edit. I know that this is possible for ACP but for moderators to log in to the forum would require a core edit.
(2013-07-25, 09:29 PM)Arbaz Wrote: [ -> ]Oh I'm sorry. I didn't read your first post completely. I believe it will require a core edit. I know that this is possible for ACP but for moderators to log in to the forum would require a core edit.

Do you have any ideas how can this be done?
Honestly, I don't know much. I know it requires some stuff with PHP which I'm horrible at. I'm learning PHP and I only know the basics. I send someone a PM about this who I believe can help you out. Good Luck!
(2013-07-25, 09:34 PM)Arbaz Wrote: [ -> ]Honestly, I don't know much. I know it requires some stuff with PHP which I'm horrible at. I'm learning PHP and I only know the basics. I send someone a PM about this who I believe can help you out. Good Luck!

LOL thanks bro! I'll wait for someone who knows more about this
Its kinda easy if you know PHP.

You need to add this piece of code to maybe member.php in the $mybb->input['action'] == 'login' block & the $mybb->input['action'] == "do_login" block.

$currentip = $_SERVER['REMOTE_ADDR'];
if ($currentip != $mybb->user['regip'])
 {
   $errors[] = "IP doesn't match";
 }

I think this code should work.
(2013-07-26, 05:16 PM)Cedric Wrote: [ -> ]Its kinda easy if you know PHP.

You need to add this piece of code to maybe member.php in the $mybb->input['action'] == 'login' block & the $mybb->input['action'] == "do_login" block.

$currentip = $_SERVER['REMOTE_ADDR'];
if ($currentip != $mybb->user['regip'])
 {
   $errors[] = "IP doesn't match";
 }

I think this code should work.

Thanks very much but it looks like gonna effect all the users but I only want this to work for Admins and moderators groups! ConfusedConfused
Use this:

$currentip = $_SERVER['REMOTE_ADDR'];
    if ($mybb->user['gid'] == X || $mybb->user['gid'] == Y)
    {
     if ($currentip != $mybb->user['regip'])
     {
       $errors[] = "IP doesn't match";
     }
    }

Replace X & Y with your Moderator & Admin Group ID's.
Pages: 1 2