This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Securing Admin Panel


  1. TFteam
    Member

    I have installed the form under www.mydomain.com/form and I tried using htpassword trick to secure this directory. However, by doing this, it seems to lock up ALL my forms (not only the admin panel). Is there a way to secure the admin panel so no one can access to it easily? At least a IP-restriction or some sort will be nice.

    Thanks.

    Posted 11 years ago #
  2. williamansley
    Member

    It is not clear to me what you want to do. Why isn't the built-in password protection of the Admin panel sufficient for you?

    Posted 11 years ago #
  3. yuniar

    A simple workaround to restrict the login page to be available for certain ip address is by modifying the index.php file under your machform folder.
    Search around line 10 for this code:

    require('includes/init.php');

    Below that line, you can add this code:

    $ip_address = $_SERVER['REMOTE_ADDR'];
    if($ip_address != '192.168.1.1'){
      die("You don't have permission to access this page");
    }

    Change the above ip address with your own of course.


    MachForm Founder

    Posted 11 years ago #
  4. AcEw1zArD
    Member

    Im guessing it would be fairly easy to adapt that code to allow an IP block through, IE 192.168.0.1 - 192.168.0.254?

    Posted 11 years ago #
  5. AMurray
    Pro Member

    Instead of not equal to != use greater/equal or less/equal. II don't know much PHP and the syntax is probably wrong, but should be something like:

    $ip_address = $_SERVER['REMOTE_ADDR'];
    if($ip_address >='192.x.x.x') AND ($ip_address <= 192..x.x.x) {
    die("you don't have permission......");
    }
    Posted 11 years ago #
  6. TFteam
    Member

    $ip_address = $_SERVER['REMOTE_ADDR']; if($ip_address != '192.168.1.1'){ die("You don't have permission to access this page"); }

    What if I have multiple IPs rather than one? How would I do this?

    Let say I want to be able to access with 3 IPs, home, office #1 and office #2.

    Home = 192.151.32.32
    Office #1 = 24.122.321.322
    Office #2 = 62.23.45.212

    Please advise. Thanks.

    Posted 11 years ago #
  7. yuniar

    You can do it like this:

    $ip_address = $_SERVER['REMOTE_ADDR'];
    $allowed_ip_addresses = array('192.151.32.32','24.122.321.322','62.23.45.212');
    
    if(!in_array($ip_address, $allowed_ip_addresses)){
      die("You don't have permission to access this page");
    }

    MachForm Founder

    Posted 11 years ago #

RSS feed for this topic

Reply