Esempio n. 1
0
/**
 * 验证手机
 */
function action_do_mobile_validate()
{
    // 获取全局变量
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    // // 检查是否通过安全验证
    // if($_SESSION['security_validate'] != true)
    // {
    // exit(json_encode(array('error' => 1, 'content' => '非法操作', 'url' => '')));
    // }
    /* 开启验证码检查 */
    if (intval($_CFG['captcha']) & CAPTCHA_REGISTER && gd_version() > 0 || TRUE) {
        if (empty($_POST['captcha'])) {
            exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '')));
        }
        /* 检查验证码 */
        include_once 'includes/cls_captcha.php';
        $captcha = new captcha();
        if (!$captcha->check_word(trim($_POST['captcha']))) {
            exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '')));
        }
    }
    require_once ROOT_PATH . 'includes/lib_passport.php';
    $mobile_phone = $_SESSION[VT_MOBILE_VALIDATE];
    $mobile_code = !empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : '';
    $result = validate_mobile_code($mobile_phone, $mobile_code);
    if ($result == 1) {
        exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_mobile_phone_blank'], 'url' => '')));
    } else {
        if ($result == 2) {
            exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_mobile_phone_format'], 'url' => '')));
        } else {
            if ($result == 3) {
                exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_mobile_phone_code_blank'], 'url' => '')));
            } else {
                if ($result == 4) {
                    exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '')));
                } else {
                    if ($result == 5) {
                        exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '')));
                    }
                }
            }
        }
    }
    $user_name = $_SESSION['user_name'];
    $result = $GLOBALS['user']->edit_user(array('username' => $user_name, 'mobile_phone' => $mobile_phone, 'mobile_validated' => 1));
    if ($result == false) {
        exit(json_encode(array('error' => 1, 'content' => '手机号码验证失败,请重新尝试', 'url' => '')));
    } else {
        // 验证完成
        $_SESSION['security_validate'] = false;
        exit(json_encode(array('error' => 0, 'content' => '', 'url' => '')));
    }
}
Esempio n. 2
0
/**
 * 找回密码第二步:验证身份
 */
function action_validate()
{
    //获取全局变量
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user = $_SESSION['find_password'];
    if (!isset($_SESSION['find_password'])) {
        //show_message('账户名不能为空', $_LANG['relogin_lnk'], 'findPwd.php', 'error');
        exit(json_encode(array('error' => 1, 'content' => '账户名不能为空', 'url' => 'findPwd.php')));
    }
    $validate_type = $_POST['validate_type'];
    if (!isset($_POST['validate_type']) || empty($_POST['validate_type'])) {
        exit(json_encode(array('error' => 1, 'content' => '验证类型不能为空', 'url' => 'findPwd.php')));
    }
    require_once ROOT_PATH . 'includes/lib_passport.php';
    if ($validate_type == 'email') {
        $email = $user['email'];
        $email_code = !empty($_POST['email_code']) ? trim($_POST['email_code']) : '';
        $result = validate_email_code($email, $email_code);
        if ($result == 1) {
            exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_email_blank'], 'url' => 'findPwd.php')));
        } else {
            if ($result == 2) {
                exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_email_format'], 'url' => 'findPwd.php')));
            } else {
                if ($result == 3) {
                    exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_email_code_blank'], 'url' => '')));
                } else {
                    if ($result == 4) {
                        exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '')));
                    } else {
                        if ($result == 5) {
                            exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '')));
                        }
                    }
                }
            }
        }
    } else {
        if ($validate_type == 'mobile_phone') {
            $mobile_phone = !empty($user['mobile_phone']) ? trim($user['mobile_phone']) : '';
            $mobile_code = !empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : '';
            $result = validate_mobile_code($mobile_phone, $mobile_code);
            if ($result == 1) {
                exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_mobile_phone_blank'], 'url' => 'findPwd.php')));
            } else {
                if ($result == 2) {
                    exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_mobile_phone_format'], 'url' => 'findPwd.php')));
                } else {
                    if ($result == 3) {
                        exit(json_encode(array('error' => 1, 'content' => $_LANG['msg_mobile_phone_code_blank'], 'url' => '')));
                    } else {
                        if ($result == 4) {
                            exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '')));
                        } else {
                            if ($result == 5) {
                                exit(json_encode(array('error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '')));
                            }
                        }
                    }
                }
            }
        } else {
            /* 无效的注册类型 */
            exit(json_encode(array('error' => 1, 'content' => '非法验证参数', 'url' => 'findPwd.php')));
        }
    }
    exit(json_encode(array('error' => 0, 'content' => '', 'url' => 'findPwd.php')));
}
Esempio n. 3
0
/**
 * 找回密码第二步:验证身份
 */
function action_validate()
{
    make_json_result('');
    //获取全局变量
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user = $_SESSION['find_password'];
    if (!isset($_SESSION['find_password'])) {
        make_json_error('账户名不能为空');
    }
    $validate_type = $_POST['validate_type'];
    if (!isset($_POST['validate_type']) || empty($_POST['validate_type'])) {
        make_json_error('验证类型不能为空');
    }
    require_once ROOT_PATH . 'includes/lib_passport.php';
    if ($validate_type == 'email') {
        $email = $user['email'];
        $email_code = !empty($_POST['email_code']) ? trim($_POST['email_code']) : '';
        $result = validate_email_code($email, $email_code);
        if ($result == 1) {
            make_json_error($_LANG['msg_email_blank']);
        } else {
            if ($result == 2) {
                make_json_error($_LANG['msg_email_format']);
            } else {
                if ($result == 3) {
                    make_json_error($_LANG['msg_email_code_blank']);
                } else {
                    if ($result == 4) {
                        make_json_error($_LANG['invalid_email_code']);
                    } else {
                        if ($result == 5) {
                            make_json_error($_LANG['invalid_email_code']);
                        }
                    }
                }
            }
        }
    } else {
        if ($validate_type == 'mobile_phone') {
            $mobile_phone = !empty($user['mobile_phone']) ? trim($user['mobile_phone']) : '';
            $mobile_code = !empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : '';
            $result = validate_mobile_code($mobile_phone, $mobile_code);
            if ($result == 1) {
                make_json_error($_LANG['msg_mobile_phone_blank']);
            } else {
                if ($result == 2) {
                    make_json_error($_LANG['msg_mobile_phone_format']);
                } else {
                    if ($result == 3) {
                        make_json_error($_LANG['msg_mobile_phone_code_blank']);
                    } else {
                        if ($result == 4) {
                            make_json_error($_LANG['invalid_mobile_phone_code']);
                        } else {
                            if ($result == 5) {
                                make_json_error($_LANG['invalid_mobile_phone_code']);
                            }
                        }
                    }
                }
            }
        } else {
            make_json_error('非法验证参数');
        }
    }
    make_json_result('验证通过');
}