本文整理汇总了PHP中logger::validip方法的典型用法代码示例。如果您正苦于以下问题:PHP logger::validip方法的具体用法?PHP logger::validip怎么用?PHP logger::validip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger
的用法示例。
在下文中一共展示了logger::validip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getip
/**
* Attempt to find the IP a connection to the board is from.
*
* @return string The best guess as to the IP a connection to the board is
* from.
*/
public static function getip()
{
if (logger::validip($_SERVER["HTTP_CLIENT_IP"])) {
return $_SERVER["HTTP_CLIENT_IP"];
}
foreach (explode(",", $_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {
if (logger::validip(trim($ip))) {
return $ip;
}
}
if (logger::validip($_SERVER["HTTP_X_FORWARDED"])) {
return $_SERVER["HTTP_X_FORWARDED"];
} else {
if (logger::validip($_SERVER["HTTP_FORWARDED_FOR"])) {
return $_SERVER["HTTP_FORWARDED_FOR"];
} else {
if (logger::validip($_SERVER["HTTP_FORWARDED"])) {
return $_SERVER["HTTP_FORWARDED"];
} else {
if (logger::validip($_SERVER["HTTP_X_FORWARDED"])) {
return $_SERVER["HTTP_X_FORWARDED"];
} else {
if ($_SERVER["REMOTE_ADDR"]) {
return $_SERVER["REMOTE_ADDR"];
} else {
return "127.0.0.1";
}
}
}
}
}
}