Location: PHPKode > scripts > XIP Class > xip-class/Examples/blacklist_local.php
<?
/**
 XIP Class - Proxy Detection and IP Functions class for PHP - File Name: blacklist_local.php
 Copyright (C) 2004-2006 Volkan Küçükçakar. All Rights Reserved.
 (Volkan Kucukcakar)
 http://www.developera.com

 You are requested to retain this copyright notice in order to use
 this software.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the  Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
?>
<?     /*
       XIP Class - EXAMPLE 3 - blacklist_local.php
       This example demonstrates:
       Another local blacklist example using an external flat text file
       */
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title>XIP Class - developera.com/xip</title>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<p><a href="proxydetect.php">Proxy Detection</a> | <a href="ipfunctions.php">IP Functions</a> | Blacklist (Local) | <a href="iplog.php">IP Log</a> | <a href="CheckRBL.php">Blacklist (Check RBL)</a></p>
<p align="left"><font color="#FF6666">XIP Class - EXAMPLE 3 - blacklist_local.php - </font><font color="#707070"> Another local blacklist example using an external flat text file</font></p>
<p>&nbsp; </p>
  <table width="600" border="1" cellspacing="0" cellpadding="0">
    <tr>
      <td width="300">Your Proxy IP is </td>
      <td width="300">&nbsp;

<?
   require('../class.XIP.php');
   $XIP=new XIP();
   echo $XIP->IP['proxy'];
   $test_ip=!(empty($_POST['t_ip'])) ? trim($_POST['t_ip']) : $XIP->IP['client'];
?>

      </td>
    </tr>
    <tr>
      <td>Your Client IP is </td>
      <td>&nbsp;

<? echo $XIP->IP['client']; ?>

      </td>
    </tr>
    <tr>
      <td>Test IP is </td>
      <td>&nbsp;
<?
   $test_ip=!(empty($_POST['t_ip'])) ? $_POST['t_ip'] : '1.2.3.4';
   echo $test_ip;
?>

      </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <table width="600" border="1" cellspacing="0" cellpadding="0">
    <tr>
      <td width="300">is Proxy IP in blacklist? </td>
      <td width="300">&nbsp;

<?
    $blacklist=implode('', file("blacklist.txt"));
    /*
      CheckNet function can accept the whole blacklist file contents as parameter, so file / file_get_contents can be used.
      If you have really huge blacklist file, you can read file in a loop, line by line and use CheckNet function for every line to consume less memory
    */
    if ($XIP->CheckNet($blacklist, $XIP->IP['proxy'])) {echo "YES";} else {echo "NO";}
?>

      </td>
    </tr>
    <tr>
      <td>is Client IP in blacklist? </td>
      <td>&nbsp;

<?
    if ($XIP->CheckNet($blacklist)) {echo "YES";} else {echo "NO";}
?>

      </td>
    </tr>
    <tr>
      <td>is Test IP in blacklist ? </td>
      <td>&nbsp;

<?
    if ($XIP->CheckNet($blacklist,$test_ip)) {echo "YES";} else {echo "NO";}
?>

      </td>
    </tr>
  </table><br><br>
  <form name="form1" method="post" action="">
    <p>Test IP:
      <input type="text" name="t_ip" value="<? echo $test_ip; ?>" size="32" maxlength="15">
</p>
    <p>BLACKLIST (loaded from an external flat text file):
      <textarea name="t_blacklist" cols="32" rows="4" id="t_blacklist" readonly>
<? echo $blacklist; ?>
</textarea>
    </p>
    <p>
      <input type="submit" name="Submit" value="Check Local Blacklist">
</p>
  </form>
  <p>&nbsp;</p>
  <p><strong>XIP Class<br>
    </strong>Proxy Detection and IP Functions class for PHP<strong><br>
  </strong><a href="http://www.developera.com/xip">www.developera.com/xip</a></p>
  <p>&nbsp; </p>
</center>
</body>
</html>
Return current item: XIP Class