【www.gdgbn.com--安卓教程】

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;
 }

本文来源:http://www.gdgbn.com/shoujikaifa/20572/