Copy code The code is as follows:
/**
* html conversion output (only escape ' " to keep Html running normally)
* @param $param
* @return string
*/
function htmlEscape($param) {
return trim(htmlspecialchars($param, ENT_QUOTES));
}
/**
* Whether it is an array (while checking whether there is a value in the array)
* @param $params
* @return boolean
*/
function isArray($params) {
return (!is_array($params) || !count($params)) ? false : true;
}
/**
* Whether the variable exists in the array (parameter tolerance, whether the string exists in the array)
* @param $param
* @param $params
* @return boolean
*/
function inArray($param, $params) {
return (!in_array((string)$param, (array)$params)) ? false : true;
}
/**
* Universal multi-type mixed escape function
* @param $var
* @param $strip
* @param $isArray
* @return mixture
*/
function sqlEscape($var, $strip = true, $isArray = false) {
if (is_array($var)) {
if (!$isArray) return " '' ";
foreach ($var as $key => $value) {
$var[$key] = trim(S::sqlEscape($value, $strip));
}
return $var;
} elseif (is_numeric($var)) {
return " '" . $var . "' ";
} else {
return " '" . addslashes($strip ? stripslashes($var) : $var) . "' ";
}
}
/**
* Get server variables
* @param $keys
* @return string
*/
function getServer($keys) {
$server = array();
$array = (array) $keys;
foreach ($array as $key) {
$server[$key] = NULL;
if (isset($_SERVER[$key])) {
$server[$key] = str_replace(array('<','>','"',"'",'%3C','%3E','%22','%27','%3c','%3e'), '', $_SERVER[$key]);
}
}
return is_array($keys) ? $server : $server[$keys];
}
/**
*/ function slashes(&$array) {
if (is_array($array)) { foreach ($array as $key => $value) {
if (is_array($value)) {
S::slashes($array[$key]);
} else {
$array[$key] = addslashes($value);
}
}
}
}
/**
*/
function escapeDir($dir) {
$dir = str_replace(array("'",'#','=','`','$','%','&',';'), '', $dir);
return rtrim(preg_replace('/(/){2,}|(\){1,}/', '/', $dir), '/');
}
/**
*/ function escapeChar($mixed, $isint = false, $istrim = false) {
if (is_array($mixed)) { foreach ($mixed as $key => $value) {
$mixed[$key] = S::escapeChar($value, $isint, $istrim);
}
} elseif ($isint) {
$mixed = (int) $mixed;
} elseif (!is_numeric($mixed) && ($istrim ? $mixed = trim($mixed) : $mixed) && $mixed) {
$mixed = S::escapeStr($mixed);
}
return $mixed;
}
/**
* Character conversion
* @param $string
* @return string
*/
function escapeStr($string) {
$string = str_replace(array("
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn