php 获取用户IP与IE信息程序

2593 2016-11-25 16:03

php 获取用户IP与IE信息程序

function onlineip()
 {
  global $_SERVER;
  if(getenv('HTTP_CLIENT_IP'))
  {
   $onlineip = getenv('HTTP_CLIENT_IP');
  }
  elseif(getenv('HTTP_X_FORWARDED_FOR'))
  {
   list($onlineip) = explode(',', getenv('HTTP_X_FORWARDED_FOR'));
  }
  elseif(getenv('REMOTE_ADDR'))
  {
   $onlineip = getenv('REMOTE_ADDR');
  }
  else
  {
   $onlineip = $_SERVER['REMOTE_ADDR'];
  }
  return $onlineip;
 }
 function imgdecode($string)
 {
  global $_SERVER;

  $key = md5(onlineip()."\t".$_SERVER['HTTP_USER_AGENT']);
  $coded = '';
  $string = base64_decode($string);
  $keylength = strlen($key);
  for($i = 0; $i < strlen($string); $i += $keylength)
  {
   $coded .= substr($string, $i, $keylength) ^ $key;
  }
  return $coded;
 }