/* Get client IP address */
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);
}
/* Verify the IP address function */
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?];
}
/* User Input Content Filter function */
function Getstr ($STR) {
$tmpstr = Trim ($STR);
$tmpstr = Strip_tags ($TMPSTR);
$tmpstr = Htmlspecialchars ($TMPSTR);
/* Add character escapes */
$tmpstr = Addslashes ($TMPSTR);
return $tmpstr;
}
/* Capacity Size calculation function */
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;
}
/* Simple anti-SQL injection function */
function GetSQL ($feild) {
$tmpfeild = mysql_escape_string ($feild);
return $tmpfeild;
}
/* $num must be an English character or a number 0-9*/
function Getnums ($num) {
Return (Ctype_alnum ($num));
}
/* $char must be English characters */
function GetChar ($char) {
Return (Ctype_alpha ($char));
}
/* Match QQ (5-12) */
function Getqq ($QQ) {
Return Preg_match ("/^\b[0-9]{5,12}\b/", $QQ);
}
/* Match Email address */
function Getemail ($email) {
return strlen ($email) >6 && preg_match ("/^\w+@ (\w+\.) +[com]| [cn]$/", $email);
Preg_match ("/^[\w\-\.") +@[\w\-\.] + (\.\w+) +$/", $email);
}
/* Generate an email connection */
function Emailconv ($email, $tolink =1) {
$email =str_replace (Array (' @ ', '. '), array (' @ ', '. '), $email);
Return $tolink? ". $email. ': $email;
}
/* Check if IP is allowed to access */
function ipaccess ($ip, $accesslist) {
Return Preg_match ("/^ (") (". Str_replace"), Array (' | ', '), Preg_quote ($accesslist, '/')) /", $IP);
}
/* If the title is too long, this function can display the first few characters, the remaining characters with ... Instead of */
function Cutstr ($string, $length) {
if (strlen ($string) > $length) {
for ($i = 0; $i < $length-3; $i + +) {
/* Returns the ordinal value of a character */
$strcut. = Ord ($string [$i]) > 127? $string [$i]. $string [+ + $i]: $string [$i];
}
return $strcut. ' ... ';
} else {
return $string;
}
}
The above describes the Presentationfontcache.exe php a number of common functions of the collection, including the presentationfontcache.exe aspects of the content, I hope that the PHP tutorial interested in a friend helpful.