<?
/**
XIP Class - Proxy Detection and IP Functions class for PHP - File Name: ipfunctions.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 2 - ipfunctions.php
This example demonstrates:
IP Functions, IP validate, public/private IP check, network check, local blacklist
*/
?>
<!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> | IP Functions | <a href="blacklist_local.php">Blacklist (Local)</a> | <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 2 - ipfunctions.php - </font><font color="#707070"> IP Functions, IP validate, public/private IP check, network check, local blacklist </font></p>
<p> </p>
<table width="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="300">Your Client IP is </td>
<td width="300">
<?
require('../class.XIP.php');
$XIP=new XIP();
echo $XIP->IP['client'];
?>
</td>
</tr>
<tr>
<td>is Client IP in blacklist? </td>
<td>
<?
$blacklist=!(empty($_POST['t_blacklist'])) ? $_POST['t_blacklist'] : "10.0.5.0\r\n10.0.4.0/24\r\n10.0.3.0/255.255.255.0";
if ($XIP->CheckNet($blacklist)) {echo "YES";} else {echo "NO";}
?>
</td>
</tr>
</table>
<p> </p>
<table width="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="300">Test IP is </td>
<td width="300">
<?
$test_ip=!(empty($_POST['t_ip'])) ? $_POST['t_ip'] : $XIP->IP['client'];
echo $test_ip;
?>
</td>
</tr>
<tr>
<td>is Test IP Valid ? </td>
<td>
<?
if ($XIP->isValid($test_ip)) {echo "YES";} else {echo "NO";}
?>
</td>
</tr>
<tr>
<td>is Test IP Public or Private(local) ? </td>
<td>
<?
//if ($_POST['priv_ip_list']=="extended") $XIP->ex_private=true;
if (array_key_exists('priv_ip_list',$_POST)&&($_POST['priv_ip_list']=="extended")) $XIP->ex_private=true;
if ($XIP->isValid($test_ip)){
if ($XIP->isPublic($test_ip)) {echo "Public IP";} else {echo "Private IP (local)";}
}
?>
</td>
</tr>
<tr>
<td>is Test IP in blacklist? </td>
<td>
<?
if ($XIP->CheckNet($blacklist,$test_ip)) {echo "YES";} else {echo "NO";}
?>
</td>
</tr>
<tr>
<td>Test IP belongs to given network? </td>
<td>
<?
$network=!(empty($_POST['t_network'])) ? $_POST['t_network'] : "192.168.0.0/16\r\n10.0.0.2";
if ($XIP->CheckNet($network,$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>Normal Private IP List
<input name="priv_ip_list" type="radio" value="normal" checked>
<input name="priv_ip_list" type="radio" value="extended">
Extended Private IP List: </p>
<p>BLACKLIST:
<textarea name="t_blacklist" cols="32" rows="4" id="t_blacklist">
<? echo $blacklist; ?>
</textarea>
</p>
<p>Network:
<textarea name="t_network" cols="32" rows="4" id="t_network">
<? echo $network; ?>
</textarea>
</p>
<p>
<input type="submit" name="Submit" value="Test IP">
</p>
</form>
<p> </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> </p>
</center>
</body>
</html>
|