/[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.1 by sysadm, Thu Jun 10 11:27:10 2004 UTC Revision 1.2 by sysadm, Thu Jun 10 20:37:11 2004 UTC
# Line 2  Line 2 
2    
3  function Client_Address()  function Client_Address()
4  {  {
5          if (isset($_SERVER["HTTP_X_CLIENT_ADDR"]))          $proxy_ip = array(
6                  return $_SERVER["HTTP_X_CLIENT_ADDR"];                  "^61.129.42.22[01]$",
7          else                  "^10.85.31.[0-9]{1,3}$",
8                  return $_SERVER["REMOTE_ADDR"];                  "^192.168.176.57$"
9            );
10    
11            foreach($proxy_ip as $ip)
12            {
13                    if (ereg($ip,$_SERVER["REMOTE_ADDR"]))
14                    {
15                            if (isset($_SERVER["HTTP_X_CLIENT_ADDR"]))
16                            {
17                                    $client_addr = explode(",",$_SERVER["HTTP_X_CLIENT_ADDR"]);
18                                    for($i=count($_SERVER["HTTP_X_CLIENT_ADDR"])-1;$i>=0;$i--)
19                                    {
20                                            $proxy = false;
21                                            foreach($proxy_ip as $ip)
22                                            {
23                                                    if (ereg($ip,$_SERVER["REMOTE_ADDR"]))
24                                                            $proxy = true;
25                                            }
26                                            if (!$proxy)
27                                                    return trim($client_addr[$i]);
28                                    }
29                                    return trim($client_addr[0]);
30                            }
31                            else
32                            {
33                                    return $_SERVER["REMOTE_ADDR"];
34                            }
35                    }
36            }
37    
38            return $_SERVER["REMOTE_ADDR"];
39  }  }
40    
41  ?>  ?>


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

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