Ejemplo n.º 1
0
function _check_username($_string)
{
    $_string = trim($_string);
    if (mb_strlen($_string) < 2 || mb_strlen($_string) > 20) {
        _alert_err("验证码长度不得小于两位或大于20位!");
    }
    //限制敏感字符------- <> 单引号 双引号   空格   多个空格
    $_char_patten = '/[<>\'\\"\\ \\  ]/';
    if (preg_match($_char_patten, $_string)) {
        _alert_err('用户名不得包含敏感字符');
    }
    //限制敏感用户名注册
    $_msg[0] = '坏人1';
    $_msg[1] = '坏人2';
    $_msg[2] = '坏人3';
    foreach ($_msg as $value) {
        $_mg_string .= $value . '\\n';
    }
    echo $_mg_string;
    //采用绝对匹配
    if (in_array($_string, $_msg)) {
        _alert_err($_mg_string . '以上敏感用户名不得注册');
    }
    //转义后返回字符串 可以防止sql注入
    return mysql_real_escape_string($_string);
}
Ejemplo n.º 2
0
function _check_anwser($_ques, $_answ, $_min_num, $_max_num)
{
    if (strlen($_answ) < $_min_num || strlen($_answ) > $_max_num) {
        _alert_err('密码回答不得小于' . $_min_num . '位或大于' . $_max_num . '位');
    }
    if ($_ques == $_answ) {
        _alert_err('密码问题与密码回答不能相同');
    }
    //加密返回
    return sha1($_answ);
}
Ejemplo n.º 3
0
function _check_code($_code1, $_code2)
{
    if (!($_code1 == $_code2)) {
        _alert_err("验证码不正确");
    }
}
Ejemplo n.º 4
0
require dirname(__FILE__) . '/includes/common.php';
//方法一判断是否提交了数据
//if( $_GET['action'] == 'register' ){ //get可以获取url的参数
//echo "你提交了数据!";
//exit();
//}
//方法二判断是否提交了数据  通过隐藏域 用post获取 键值对  因为表单是post提交的
// if( $_POST['action'] == 'register' ){
// echo "你提交了数据!";
// exit();
// }
if ($_GET['action'] == 'register') {
    //get可以获取url的参数
    /*验证验证码是否正确  post获取表单提交的内容 因为表单是以post形式提交的*/
    if (!($_POST['yzm'] == $_SESSION['code'])) {
        _alert_err("验证码不正确");
    }
    /*定义一个变量存放 各字段的值*/
    $_clear = array();
    $_clear['username'] = $_POST['username'];
    $_clear['password'] = $_POST['password'];
    $_clear['notpassword'] = $_POST['notpassword'];
    print_r($_clear);
    /*下个版本--过滤用户名*/
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Ejemplo n.º 5
0
function _check_url($_string)
{
    if (empty($_string) || $_string == 'http://') {
        return null;
    } else {
        //[1-9]{1} 第一位 1-9之间的数字
        //[0-9]{4-9}  第二位开始也是0-9  位数4-9位
        //?表示可有可没有  http(s)? 表示s可有可没有   (\w+\.)? --》www.
        if (!preg_match('/^https?:\\/\\/(\\w+\\.)?[\\w\\-\\.]+(\\.\\w+)+$/', $_string)) {
            _alert_err('url码格式不正确');
        }
    }
    return $_string;
}
Ejemplo n.º 6
0
function _check_uniqid($_first_uniqid, $_end_uniqid)
{
    if (strlen($_first_uniqid) != 40 || $_first_uniqid != $_end_uniqid) {
        _alert_err('唯一标识符异常!');
    }
    return _mysql_string($_first_uniqid);
}