摘要:
function remove_xss($val) { // remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed // this prevents some character re-spacing such as <java\0script> // note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs $val = preg_.. 阅读全文
摘要:
//输出安全的htmlfunction h($text, $tags = null){ $text = trim($text); //完全过滤注释 $text = preg_replace('/<!--?.*-->/','',$text); //完全过滤动态代码 $text = preg_replace('/<\?|\?'.'>/','',$text); //完全过滤js $text = preg_replace('/<script?.*\/script>/',& 阅读全文
摘要:
/** +---------------------------------------------------------- * 检查字符串是否是UTF8编码 +---------------------------------------------------------- * @param string $string 字符串 +---------------------------------------------------------- * @return Boolean +---------------------------------------------------- 阅读全文
摘要:
/** +---------------------------------------------------------- * 字节格式化 把字节数格式为 B K M G T 描述的大小 +---------------------------------------------------------- * @return string +---------------------------------------------------------- */function byte_format($size, $dec=2){ $a = array("B", &q 阅读全文
摘要:
/** +---------------------------------------------------------- * 产生随机字串,可用来自动生成密码 默认长度6位 字母和数字混合 +---------------------------------------------------------- * @param string $len 长度 * @param string $type 字串类型 * 0 字母 1 数字 其它 混合 * @param string $addChars 额外字符 +----------------------------------------- 阅读全文
摘要:
/** +---------------------------------------------------------- * 字符串截取,支持中文和其他编码 +---------------------------------------------------------- * @static * @access public +---------------------------------------------------------- * @param string $str 需要转换的字符串 * @param string $start 开始位置 * @param stri 阅读全文
摘要:
function get_client_ip() {
static $ip = NULL;
if ($ip !== NULL) return $ip;
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$pos = array_search('unknown',$arr);
if(false !== $pos) unset($arr[$pos]);
$ip = trim($arr[0]);
}elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMO 阅读全文