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


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

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