PHP Classes

File: Examples

Recommend this page to a friend!
  Classes of Rolando Santamaría Masó   IP Auth   Examples   Download  
File: Examples
Role: Example script
Content type: text/plain
Description: Examples
Class: IP Auth
Authorize access based on IP address
Author: By
Last change:
Date: 15 years ago
Size: 880 bytes
 

Contents

Class file image Download



/* Example 1: Using the default ip addresses list(ip_default_list.ini) */
// ------------------------------
  require "IpAuth/IpAuth.php";
 
  if (TRUE == IpAuth::check_permissions_for_IP("10.208.1.66"))
      echo "Allowed";
  else
      echo "Not Allowed";


     
/* Example 2: Using other IP addresses list */
//------------------------------
  require "IpAuth/IpAuth.php";
 
  if (TRUE == IpAuth::check_permissions_for_IP("10.208.1.66", "my_ip_list.ini"))
      echo "Allowed";
  else
      echo "Not Allowed";
     
     
 
/* Example 3: A real example. Redirecting based on the IP address of the visitor */
// ------------------------------
  require "IpAuth/IpAuth.php";
 
  if (TRUE == IpAuth::check_permissions_for_IP($_SERVER['REMOTE_ADDR']))
  {
     
      /* Redirecting to the main page */
     
  }
  else
  {
     
    /* Redirecting to the ip address not allowed page */
     
  }