/**
* 文本轉HTML
*
* @param string $txt;
* return string;
*/
function Text2Html($txt){
$txt = str_replace(" "," ",$txt);
$txt = str_replace("<","<",$txt);
$txt = str_replace(">",">",$txt);
$txt = preg_replace("/[rn]{1,}/isU","<br/>rn",$txt);
return $txt;
}
/**
* 獲得IP
* return string;
*/
function GetIP(){
if(!empty($_SERVER["HTTP_CLIENT_IP"])) { $cip = $_SERVER["HTTP_CLIENT_IP"]; }
else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { $cip = $_SERVER["HTTP_X_FORWARDED_FOR"]; }
else if(!empty($_SERVER["REMOTE_ADDR"])) { $cip = $_SERVER["REMOTE_ADDR"]; }
else $cip = "";
preg_match("/[d.]{7,15}/", $cip, $cips);
$cip = $cips[0] ? $cips[0] : 'unknown';
unset($cips);
return $cip;
}