Exemplo n.º 1
0
 function set_fromhost()
 {
     global $proxyIPs;
     global $fullfromhost;
     global $fromhost;
     @($fullfromhost = $_SERVER["HTTP_X_FORWARDED_FOR"]);
     if ($fullfromhost == "") {
         @($fullfromhost = $_SERVER["REMOTE_ADDR"]);
         $fromhost = $fullfromhost;
     } else {
         $ips = explode(",", $fullfromhost);
         $c = count($ips);
         if ($c > 1) {
             $fromhost = trim($ips[$c - 1]);
             if (isset($proxyIPs) && in_array($fromhost, $proxyIPs)) {
                 $fromhost = $ips[$c - 2];
             }
         } else {
             $fromhost = $fullfromhost;
         }
     }
     if ($fromhost == "") {
         $fromhost = "127.0.0.1";
         $fullfromhost = "127.0.0.1";
     }
     if (defined("IPV6_LEGACY_IPV4_DISPLAY")) {
         if (strchr($fromhost, '.') && ($p = strrchr($fromhost, ':'))) {
             $fromhost = substr($p, 1);
         }
     }
     //sometimes,fromhost has strang space
     bbs_setfromhost(trim($fromhost), trim($fullfromhost));
 }
Exemplo n.º 2
0
 public static function setFrom($ip)
 {
     bbs_setfromhost($ip, "");
 }