In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to achieve PHP security detection, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The code is as follows:
/ * *
* html conversion output (only escape'"keep Html running normally)
* @ param $param
* @ return string
, /
Function htmlEscape ($param) {
Return trim (htmlspecialchars ($param, ENT_QUOTES))
}
/ * *
* whether it is an array (also detect 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 fault 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
}
/ * *
* General 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,','), $_ SERVER [$key])
}
}
Return is_array ($keys)? $server: $server [$keys]
}
/ * *
* variable escape
* @ param $array
, /
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)
}
}
}
}
/ * *
* Directory conversion
* @ param unknown_type $dir
* @ return string
, /
Function escapeDir ($dir) {
$dir = str_replace (array ("'",'#','=','','$','%','&',';),'', $dir)
Return rtrim (preg_replace ('/ (\ /) {2,} | (\\) {1,} /,'/', $dir),'/')
}
/ * *
* generic multi-type conversion
* @ param $mixed
* @ param $isint
* @ param $istrim
* @ return mixture
, /
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 ("\ 0", "", "\ r"),'', $string); / / modified@2010-7-5
$string = preg_replace (array ('/ [\\ x00 -\\ x08\\ x0B\\ x0C\\ x0E -\\ x1F] /','/! (# [0-9] + | [Amurz] +);) / is'), array ('','&'), $string)
$string = str_replace (array ("% 3C",'', $string)
$string = str_replace (array ('','',\ t','), array ('', & # 39), $string)
Return $string
}
/ * *
* variable check
* @ param $var
, /
Function checkVar (& $var) {
If (is_array ($var)) {
Foreach ($var as $key = > $value) {
S::checkVar ($var [$key])
}
} elseif (paid W! = 'admincp') {
$var = str_replace (array ('..,')','
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.