/**
* Obtain the Client IP address, which can go through a level-1 proxy
* @ Modify by lingl 2012-06-14
* @ Param PD
* @ Return
* @ Throws exception
*/
Public static string getipaddress (pagedata PD) throws exception {
Httpservletrequest request = Pd. getrequest ();
String IP = request. getheader ("X-forwarded-");
If (IP = NULL | IP. Length () = 0 | "unknown". equalsignorecase (IP )){
IP = request. getheader ("proxy-client-IP ");
}
If (IP = NULL | IP. Length () = 0 | "unknown". equalsignorecase (IP )){
IP = request. getheader ("wl-proxy-client-IP ");
}
If (IP = NULL | IP. Length () = 0 | "unknown". equalsignorecase (IP )){
IP = request. getremoteaddr ();
}
Return IP. Split (",") [0];
}
/**
* Obtain the Client IP address. If a proxy is used, the real IP address is obtained through the firewall.
* Getclientip
*
* @ Param PD
* @ Return
* @ Throws exception string
* @ Exception
* @ Author: lingl@asiainfo-linkage.com
* @ 2012-7-20 11:06:14 AM
* @ Update:
* @ 2012-7-20 11:06:14 AM
*/
Public static string getclientip (pagedata PD) throws exception {
Httpservletrequest request = Pd. getrequest ();
String strclientip = request. getheader ("X-forwarded-");
Log. debug ("======= all the IP address string is:" + strclientip );
If (strclientip = NULL | strclientip. Length () = 0 | "unknown". inclusignorecase (strclientip )){
Strclientip = request. getremoteaddr ();
} Else {
String [] iplist = strclientip. Split (",");
String strip = new string ();
For (INT Index = 0; index <iplist. length; index ++ ){
Strip = (string) iplist [Index];
If (! ("Unknown". inclusignorecase (strip ))){
Strclientip = strip;
Break;
}
}
}
Return strclientip;
}
/**
* Obtain the Client IP address. If a proxy is used, the real IP address is obtained through the firewall.
* Getclientip
*
* @ Param PD
* @ Return
* @ Throws exception string
* @ Exception
* @ Author: lingl@asiainfo-linkage.com
* @ 2012-7-20 11:06:14 AM
* @ Update:
* @ 2012-7-20 11:06:14 AM
*/
Public static string getclientip (pagedata PD) throws exception {
Httpservletrequest request = Pd. getrequest ();
String strclientip = request. getheader ("X-forwarded-");
Log. debug ("======= all the IP address string is:" + strclientip );
If (strclientip = NULL | strclientip. Length () = 0 | "unknown". inclusignorecase (strclientip )){
Strclientip = request. getremoteaddr ();
} Else {
String [] iplist = strclientip. Split (",");
String strip = new string ();
For (INT Index = 0; index <iplist. length; index ++ ){
Strip = (string) iplist [Index];
If (! ("Unknown". inclusignorecase (strip ))){
Strclientip = strip;
Break;
}
}
}
Return strclientip;
}