/[LeafOK_CVS]/fenglin/lib/client_addr.inc.php
ViewVC logotype

Diff of /fenglin/lib/client_addr.inc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 by sysadm, Sun Jun 20 19:49:02 2004 UTC Revision 1.4 by sysadm, Sat Jun 26 21:49:13 2004 UTC
# Line 1  Line 1 
1  <?  <?
2    
3  function Client_Address()  function Client_Address($addr=null,$x_addr=null)
4  {  {
5          $proxy_ip = array(          $proxy_ip = array(
6                  "^61.129.42.22[01]$",                  "^61.129.42.22[01]$",
7                  "^203.95.5.66$",                  "^10.85.31."
                 "^10.85.31.[0-9]{1,3}$",  
                 "^192.168.176.57$"  
8          );          );
9    
10            if ($addr == null)
11                    $addr = $_SERVER["REMOTE_ADDR"];
12    
13            if ($x_addr == null && isset($_SERVER["HTTP_X_CLIENT_ADDR"]))
14                    $x_addr = $_SERVER["HTTP_X_CLIENT_ADDR"];
15    
16          foreach($proxy_ip as $ip)          foreach($proxy_ip as $ip)
17          {          {
18                  if (ereg($ip,$_SERVER["REMOTE_ADDR"]))                  if (ereg($ip,$addr))
19                  {                  {
20                          if (isset($_SERVER["HTTP_X_CLIENT_ADDR"]))                          if ($x_addr != null)
21                          {                          {
22                                  $client_addr = explode(",",$_SERVER["HTTP_X_CLIENT_ADDR"]);                                  $client_addr = explode(",",$x_addr);
23                                  for($i=count($_SERVER["HTTP_X_CLIENT_ADDR"])-1;$i>=0;$i--)                                  for($i=count($client_addr)-1;$i>=0;$i--)
24                                  {                                  {
25                                          $proxy = false;                                          $proxy = false;
26                                          foreach($proxy_ip as $ip)                                          foreach($proxy_ip as $ip)
27                                          {                                          {
28                                                  if (ereg($ip,$_SERVER["REMOTE_ADDR"]))                                                  if (ereg($ip,$client_addr[$i]))
29                                                          $proxy = true;                                                          $proxy = true;
30                                          }                                          }
31                                          if (!$proxy)                                          if (!$proxy)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1