-
-
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);
-
}
-
-
-
function checkIP($ip) {
-
return preg_match((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?);
-
}
-
-
-
function getStr($str) {
-
$tmpstr = trim($str);
-
$tmpstr = strip_tags($tmpstr);
-
$tmpstr = htmlspecialchars($tmpstr);
-
-
-
$tmpstr = addslashes($tmpstr);
-
-
return $tmpstr;
-
}
-
-
-
function sizecount($filesize) {
-
if($filesize >= 1073741824) {
-
$filesize = round($filesize / 1073741824 * 100) / 100 . ' G';
-
} elseif($filesize >= 1048576) {
-
$filesize = round($filesize / 1048576 * 100) / 100 . ' M';
-
} elseif($filesize >= 1024) {
-
$filesize = round($filesize / 1024 * 100) / 100 . ' K';
-
} else {
-
$filesize = $filesize . ' bytes';
-
}
-
return $filesize;
-
}
-
-
-
function getSQL($feild) {
-
$tmpfeild = mysql_escape_string($feild);
-
-
return $tmpfeild;
-
}
-
-
function getNums($num) {
-
return (ctype_alnum($num));
-
}
-
-
-
function getChar($char) {
-
return (ctype_alpha($char));
-
}
-
-
function getQQ($qq) {
-
return preg_match("/^\b[0-9]{5,12}\b/",$qq);
-
}
-
-
function getEmail($email) {
-
return strlen($email)>6 && preg_match("/^\w+@(\w+\.)+[com]|[cn]$/" , $email);
-
-
}
-
-
-
function emailconv($email,$tolink=1) {
-
$email=str_replace(array('@','.'),array('@','.'),$email);
-
return $tolink ? '<a href="mailto: '.$email.'">'.$email.'</a>':$email;
-
}
-
-
-
function ipaccess($ip,$accesslist) {
-
return preg_match("/^(".str_replace(array("\r\n",' '),array('|',''),preg_quote($accesslist,'/')).")/",$ip);
-
}
-
-
-
function cutstr($string, $length) {
-
if(strlen($string) > $length) {
-
for($i = 0; $i < $length - 3; $i++) {
-
-
$strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
-
}
-
return $strcut.' ...';
-
} else {
-
return $string;
-
}
-
}