Home » Support Forums for PMBT 2.X » General Help for 2.X » ip system
ip system [message #2923] Thu, 10 September 2009 20:21
joeroberts  is currently offline joeroberts  United States
Messages: 1581
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
replace
function getip() {
   if (isset($_SERVER)) {
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) {
       $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
       $ip = $_SERVER['HTTP_CLIENT_IP'];
     } else {
       $ip = $_SERVER['REMOTE_ADDR'];
     }
   } else {
     if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
       $ip = getenv('HTTP_X_FORWARDED_FOR');
     } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
       $ip = getenv('HTTP_CLIENT_IP');
     } else {
       $ip = getenv('REMOTE_ADDR');
     }
   }

   return $ip;
}
with this in include/functions.php
function getip() {
  $check = array('HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED',
                 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED',
                 'HTTP_VIA', 'HTTP_X_COMING_FROM', 'HTTP_COMING_FROM');

  foreach ($check as $c) {
    if (ip_valid(&$_SERVER[$c])) {
      return ip_first($_SERVER[$c]);
    }
  }

  return $_SERVER['REMOTE_ADDR'];
}
function ip_first($ips) {
  if (($pos = strpos($ips, ',')) != false) {
    return substr($ips, 0, $pos);
  } else {
    return $ips;
  }
}

function ip_valid($ips) {
  if (isset($ips)) {
    $ip    = ip_first($ips);
    $ipnum = ip2long($ip);
    if ($ipnum !== -1 && $ipnum !== false && (long2ip($ipnum) === $ip)) { // PHP 4 and PHP 5
      if (($ipnum < 167772160   || $ipnum >   184549375) && // Not in 10.0.0.0/8
          ($ipnum < -1408237568 || $ipnum > -1407188993) && // Not in 172.16.0.0/12
          ($ipnum < -1062731776 || $ipnum > -1062666241))   // Not in 192.168.0.0/16
        return true;
    }
  }
  return false;
}


http://p2p-evolution.com/torrentbar/torrentbar.php?id=1&style=default_cyan
Previous Topic:Setup PhpBB3 after PhpMyBittorrent
Next Topic:phpBB forum not linking correctly
Goto Forum:
  


Current Time: Fri Jul 30 04:33:48 BST 2010

Total time taken to generate the page: 0.00724 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.0.
Copyright ©2001-2009 FUDforum Bulletin Board Software