function GetIP(){
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER[‘REMOTE_ADDR‘]) && $_SERVER[‘REMOTE_ADDR‘] && strcasecmp($_SERVER[‘REMOTE_ADDR‘], "unknown"))
$ip = $_SERVER[‘REMOTE_ADDR‘];
else
$ip = "unknown";
return($ip);
}
// 调用方法 :昨日 $start= strftime( "%Y-%m-%d %H:%M:%S", $this->DateAdd(‘d‘,-1,time()) );
function DateAdd ($interval, $number, $date) {
$date_time_array = getdate($date);
$hours = $date_time_array["hours"];
$minutes = $date_time_array["minutes"];
$seconds = $date_time_array["seconds"];
$month = $date_time_array["mon"];
$day = $date_time_array["mday"];
$year = $date_time_array["year"];
switch ($interval) {
case "yyyy": $year +=$number; break;
case "q": $month +=($number*3); break;
case "m": $month +=$number; break;
case "y":
case "d":
case "w": $day+=$number; break;
case "ww": $day+=($number*7); break;
case "h": $hours+=$number; break;
case "n": $minutes+=$number; break;
case "s": $seconds+=$number; break;
}
$timestamp = mktime($hours ,$minutes, $seconds,$month ,$day, $year);
return $timestamp;}
//二维码生成则可以参考 phpqrcode