本文整理汇总了PHP中check_mobile函数的典型用法代码示例。如果您正苦于以下问题:PHP check_mobile函数的具体用法?PHP check_mobile怎么用?PHP check_mobile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_mobile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$email = strim($GLOBALS['request']['email']);
//用户名或邮箱
$pwd = strim($GLOBALS['request']['pwd']);
//密码
if (app_conf("SMS_ON") == 0) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['SMS_OFF'];
//短信未开启
output($root);
}
//检查用户,用户密码
$user = user_check($email, $pwd);
$user_id = intval($user['id']);
$root['user_id'] = $user_id;
if ($user_id > 0) {
$mobile = $user['mobile'];
$code = intval($user['bind_verify']);
if ($mobile == '') {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_EMPTY_TIP'];
output($root);
}
if (!check_mobile($mobile)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
output($root);
}
if (!check_ipop_limit(get_client_ip(), "mobile_verify", 60, 0)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_SMS_SEND_FAST'];
//短信发送太快
output($root);
}
//开始生成手机验证
if ($code == 0) {
//已经生成过了,则使用旧的验证码;反之生成一个新的
$code = rand(1111, 9999);
$GLOBALS['db']->query("update " . DB_PREFIX . "user set bind_verify = '" . $code . "',verify_create_time = '" . TIME_UTC . "' where id = " . $user_id);
}
//使用立即发送方式
$result = send_verify_sms($mobile, $code, $user, true);
//
$root['response_code'] = $result['status'];
if ($root['response_code'] == 1) {
$root['show_err'] = $GLOBALS['lang']['MOBILE_VERIFY_SEND_OK'];
} else {
$root['show_err'] = $result['msg'];
if ($root['show_err'] == null || $root['show_err'] == '') {
$root['show_err'] = "验证码发送失败";
}
}
} else {
$root['response_code'] = 0;
$root['show_err'] = "未登录";
$root['user_login_status'] = 0;
}
output($root);
}
示例2: save
public function save()
{
if (trim($_REQUEST['consignee']) == '') {
showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE']);
}
if (trim($_REQUEST['address']) == '') {
showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS']);
}
if (trim($_REQUEST['zip']) == '') {
showErr($GLOBALS['lang']['FILL_CORRECT_ZIP']);
}
if (trim($_REQUEST['mobile']) == '') {
showErr($GLOBALS['lang']['FILL_MOBILE_PHONE']);
}
if (!check_mobile($_REQUEST['mobile'])) {
showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE']);
}
$consignee_data['user_id'] = $GLOBALS['user_info']['id'];
$consignee_data['region_lv1'] = intval($_REQUEST['region_lv1']);
$consignee_data['region_lv2'] = intval($_REQUEST['region_lv2']);
$consignee_data['region_lv3'] = intval($_REQUEST['region_lv3']);
$consignee_data['region_lv4'] = intval($_REQUEST['region_lv4']);
$consignee_data['address'] = addslashes(trim(htmlspecialchars($_REQUEST['address'])));
$consignee_data['mobile'] = addslashes(trim(htmlspecialchars($_REQUEST['mobile'])));
$consignee_data['consignee'] = addslashes(trim(htmlspecialchars($_REQUEST['consignee'])));
$consignee_data['zip'] = addslashes(trim(htmlspecialchars($_REQUEST['zip'])));
$consignee_id = intval($_REQUEST['id']);
if ($consignee_id == 0) {
$GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data);
} else {
$GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data, "UPDATE", "id=" . $consignee_id);
}
rm_auto_cache("consignee_info", array("consignee_id" => intval($consignee_id)));
showSuccess($GLOBALS['lang']['UPDATE_SUCCESS']);
}
示例3: index
public function index()
{
$mobile = strim($GLOBALS['request']['mobile']);
if (app_conf("SMS_ON") == 0) {
$root['status'] = 0;
$root['info'] = '短信功能关闭';
output($root);
}
if ($mobile == '') {
$root['status'] = 0;
$root['info'] = '手机号码不能为空';
output($root);
}
if (!check_mobile($mobile)) {
$root['status'] = 0;
$root['info'] = "请输入正确的手机号码";
output($root);
}
if (!check_ipop_limit(CLIENT_IP, "register_verify_phone", 60, 0)) {
$root['status'] = 0;
$root['info'] = '发送太快了';
output($root);
}
$sql = "SELECT * FROM " . DB_PREFIX . "user WHERE mobile = " . $mobile;
$user = $GLOBALS['db']->getRow($sql);
if (empty($user)) {
$root['status'] = 0;
$root['info'] = "手机号未在本站注册过";
output($root);
}
//删除超过5分钟的验证码
$sql = "DELETE FROM " . DB_PREFIX . "sms_mobile_verify WHERE mobile_phone = '{$mobile}' and add_time <=" . (get_gmtime() - 300);
$GLOBALS['db']->query($sql);
$code = rand(100000, 999999);
$message = "您正在找回密码,验证码:" . $code . ",如非本人操作,请忽略本短信【" . app_conf("SHOP_TITLE") . "】";
require_once APP_ROOT_PATH . "system/utils/es_sms.php";
$sms = new sms_sender();
$send = $sms->sendSms($mobile, $message);
if ($send['status']) {
$add_time = get_gmtime();
$GLOBALS['db']->query("insert into " . DB_PREFIX . "sms_mobile_verify(mobile_phone,code,add_time,send_count,ip) values('{$mobile}','{$code}','{$add_time}',1," . "'" . CLIENT_IP . "')");
/* 插入一条发送成功记录到队列表中 */
$msg_data['dest'] = $mobile;
$msg_data['send_type'] = 0;
$msg_data['content'] = addslashes($message);
$msg_data['send_time'] = $add_time;
$msg_data['is_send'] = 1;
$msg_data['is_success'] = 1;
$msg_data['create_time'] = $add_time;
$msg_data['user_id'] = intval($user['id']);
$msg_data['title'] = "密码找回验证";
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
$root['info'] = "验证码发出,请注意查收";
$root['status'] = 1;
} else {
$root['info'] = "发送失败" . $send['msg'];
$root['status'] = 0;
}
output($root);
}
示例4: index
public function index()
{
require_once APP_ROOT_PATH . "system/libs/user.php";
$mobile = trim($GLOBALS['request']['mobile']);
$pwd = strim($GLOBALS['request']['password']);
if ($mobile == '') {
$root['status'] = 0;
$root['info'] = '手机号码不能为空';
output($root);
}
if (!check_mobile($mobile)) {
$root['status'] = 0;
$root['info'] = "请输入正确的手机号码";
output($root);
}
if (strlen($pwd) < 4) {
$root['status'] = 0;
$root['info'] = "密码不能低于四位";
output($root);
}
$db_code = $GLOBALS['db']->getRow("select id from " . DB_PREFIX . "sms_mobile_verify where status=1 and mobile_phone = '{$mobile}' and type=0 order by id desc");
if (!$db_code) {
$root['status'] = 0;
$root['info'] = "手机号码未通过验证";
output($root);
}
$root = mobile_reg($mobile, $pwd);
output($root);
}
示例5: index
public function index()
{
$mobile = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile'])));
$root = array();
if (app_conf("SMS_ON") == 0) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['SMS_OFF'];
//短信未开启
output($root);
}
if ($mobile == '') {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_EMPTY_TIP'];
//请输入你的手机号
output($root);
}
if (!check_mobile($mobile)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
//请填写正确的手机号码
output($root);
}
if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where mobile = '" . $mobile . "'") > 0) {
$field_show_name = $GLOBALS['lang']['USER_TITLE_mobile'];
//手机号码
$root['response_code'] = 0;
$root['show_err'] = sprintf($GLOBALS['lang']['EXIST_ERROR_TIP'], $field_show_name);
//已存在,请重新输入
output($root);
}
if (!check_ipop_limit(CLIENT_IP, "mobile_verify", 60, 0)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_SMS_SEND_FAST'];
//短信发送太快
output($root);
}
//删除超过5分钟的验证码
$GLOBALS['db']->query("DELETE FROM " . DB_PREFIX . "mobile_verify_code WHERE create_time <=" . TIME_UTC - 300);
$verify_code = $GLOBALS['db']->getOne("select verify_code from " . DB_PREFIX . "mobile_verify_code where mobile = '" . $mobile . "' and create_time>=" . (TIME_UTC - 180) . " ORDER BY id DESC");
if (intval($verify_code) == 0) {
//如果数据库中存在验证码,则取数据库中的(上次的 );确保连接发送时,前后2条的验证码是一至的.==为了防止延时
//开始生成手机验证
$verify_code = rand(1111, 9999);
$GLOBALS['db']->autoExecute(DB_PREFIX . "mobile_verify_code", array("verify_code" => $verify_code, "mobile" => $mobile, "create_time" => TIME_UTC, "client_ip" => CLIENT_IP), "INSERT");
}
//使用立即发送方式
$result = send_verify_sms($mobile, $verify_code, null, true);
//
$root['response_code'] = $result['status'];
if ($root['response_code'] == 1) {
$root['show_err'] = $GLOBALS['lang']['MOBILE_VERIFY_SEND_OK'];
} else {
$root['show_err'] = $result['msg'];
if ($root['show_err'] == null || $root['show_err'] == '') {
$root['show_err'] = "验证码发送失败";
}
}
//../system/sms/FW_sms.php 提示账户或密码错误地址
output($root);
}
示例6: index
public function index()
{
$mobile = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile'])));
$root = array();
if (app_conf("SMS_ON") == 0) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['SMS_OFF'];
output($root);
}
if ($mobile == '') {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_EMPTY_TIP'];
output($root);
}
if (!check_mobile($mobile)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
output($root);
}
if (!check_ipop_limit(get_client_ip(), "mobile_verify", 60, 0)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_SMS_SEND_FAST'];
output($root);
}
$sql = "select id,bind_verify from " . DB_PREFIX . "user where mobile = '" . $mobile . "' and is_delete = 0";
$user_info = $GLOBALS['db']->getRow($sql);
$user_id = intval($user_info['id']);
$code = intval($user_info['bind_verify']);
if ($user_id == 0) {
//$field_show_name = $GLOBALS['lang']['USER_TITLE_mobile'];
$root['response_code'] = 0;
$root['show_err'] = '手机号码不存在或被禁用';
output($root);
}
//开始生成手机验证
if ($code == 0) {
//已经生成过了,则使用旧的验证码;反之生成一个新的
$code = rand(1111, 9999);
$GLOBALS['db']->query("update " . DB_PREFIX . "user set bind_verify = '" . $code . "',verify_create_time = '" . TIME_UTC . "' where id = " . $user_id);
}
//使用立即发送方式
$result = send_verify_sms($mobile, $code, null, true);
//
$root['response_code'] = $result['status'];
if ($root['response_code'] == 1) {
$root['show_err'] = $GLOBALS['lang']['MOBILE_VERIFY_SEND_OK'];
} else {
$root['show_err'] = $result['msg'];
if ($root['show_err'] == null || $root['show_err'] == '') {
$root['show_err'] = "验证码发送失败";
}
}
$root['post_type'] = trim($GLOBALS['request']['post_type']);
output($root);
}
示例7: init
public static function init()
{
//过滤输入
$_POST = inject_filter($_POST);
$_GET = inject_filter($_GET);
self::init_input();
//是否为移动设备
check_mobile();
//获取移动设备名
check_device();
}
示例8: index
public function index()
{
$mobile = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile'])));
$verify = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile_code'])));
$user_pwd = addslashes(htmlspecialchars(trim($GLOBALS['request']['user_pwd'])));
$user_pwd_confirm = addslashes(htmlspecialchars(trim($GLOBALS['request']['user_pwd_confirm'])));
$root = array();
if ($user_pwd != $user_pwd_confirm) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['USER_PWD_CONFIRM_ERROR'];
output($root);
}
if ($user_pwd == null || $user_pwd == '') {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['USER_PWD_ERROR'];
output($root);
}
if ($verify == "") {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['BIND_MOBILE_VERIFY_ERROR'];
output($root);
}
if ($mobile == '') {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['MOBILE_EMPTY_TIP'];
output($root);
}
if (!check_mobile($mobile)) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
output($root);
}
$sql = "select id,code from " . DB_PREFIX . "user where mobile = '" . $mobile . "' and bind_verify = '" . $verify . "' and is_delete = 0";
$user_info = $GLOBALS['db']->getRow($sql);
$user_id = intval($user_info['id']);
$code = $user_info['code'];
if ($user_id == 0) {
$root['response_code'] = 0;
$root['show_err'] = $GLOBALS['lang']['BIND_MOBILE_VERIFY_ERROR'];
output($root);
} else {
$new_pwd = md5($user_pwd . $code);
$sql = "update " . DB_PREFIX . "user set user_pwd='" . $new_pwd . "', bind_verify = '', verify_create_time = 0 where id = " . $user_id;
$GLOBALS['db']->query($sql);
$root['response_code'] = 1;
$root['show_err'] = "密码更新成功!";
//$GLOBALS['lang']['MOBILE_BIND_SUCCESS'];
$root['sql'] = $sql;
output($root);
}
$root['program_title'] = "修改密码";
output($root);
}
示例9: index
public function index()
{
$mobile = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile'])));
$root = array();
if (app_conf("SMS_ON") == 0) {
$root['response_code'] = 0;
$root['show_err'] = '短信未开启';
output($root);
}
if ($mobile == '') {
$root['response_code'] = 0;
$root['show_err'] = '请输入你的手机号';
output($root);
}
if (!check_mobile($mobile)) {
$root['response_code'] = 0;
$root['show_err'] = '请填写正确的手机号码';
output($root);
}
if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where mobile = '" . $mobile . "'") > 0) {
$field_show_name = '手机号码';
$root['response_code'] = 0;
$root['show_err'] = sprintf('%s已存在,请重新输入', $field_show_name);
output($root);
}
if (!check_ipop_limit(get_client_ip(), "mobile_verify", 60, 0)) {
$root['response_code'] = 0;
$root['show_err'] = '短信发送太快,请稍后再试';
output($root);
}
//删除超过5分钟的验证码
$GLOBALS['db']->query("DELETE FROM " . DB_PREFIX . "mobile_verify_code WHERE create_time <=" . get_gmtime() - 300);
$verify_code = $GLOBALS['db']->getOne("select verify_code from " . DB_PREFIX . "mobile_verify_code where mobile = '" . $mobile . "' and create_time>=" . (TIME_UTC - 180) . " ORDER BY id DESC");
if (intval($verify_code) == 0) {
//如果数据库中存在验证码,则取数据库中的(上次的 );确保连接发送时,前后2条的验证码是一至的.==为了防止延时
//开始生成手机验证
$verify_code = rand(1111, 9999);
$GLOBALS['db']->autoExecute(DB_PREFIX . "mobile_verify_code", array("verify_code" => $verify_code, "mobile" => $mobile, "create_time" => get_gmtime(), "client_ip" => get_client_ip()), "INSERT");
}
//使用立即发送方式
$result = send_verify_sms($mobile, $verify_code, null, true);
//
$root['response_code'] = $result['status'];
if ($root['response_code'] == 1) {
$root['show_err'] = '验证短信已经发送,请注意查收';
} else {
$root['show_err'] = $result['msg'];
if ($root['show_err'] == null || $root['show_err'] == '') {
$root['show_err'] = "验证码发送失败";
}
}
output($root);
}
示例10: index
public function index()
{
$mobile = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile'])));
$verify = addslashes(htmlspecialchars(trim($GLOBALS['request']['mobile_code'])));
$user_pwd = addslashes(htmlspecialchars(trim($GLOBALS['request']['user_pwd'])));
$user_pwd_confirm = addslashes(htmlspecialchars(trim($GLOBALS['request']['user_pwd_confirm'])));
$root = array();
if ($user_pwd != $user_pwd_confirm) {
$root['response_code'] = 0;
$root['show_err'] = '密码确认失败';
output($root);
}
if ($user_pwd == null || $user_pwd == '') {
$root['response_code'] = 0;
$root['show_err'] = '请输入密码';
output($root);
}
if ($verify == "") {
$root['response_code'] = 0;
$root['show_err'] = '验证码错误';
output($root);
}
if ($mobile == '') {
$root['response_code'] = 0;
$root['show_err'] = '请输入你的手机号';
output($root);
}
if (!check_mobile($mobile)) {
$root['response_code'] = 0;
$root['show_err'] = '请填写正确的手机号码';
output($root);
}
$sql = "select id,code from " . DB_PREFIX . "user where mobile = '" . $mobile . "' and bind_verify = '" . $verify . "' and is_delete = 0";
$user_info = $GLOBALS['db']->getRow($sql);
$user_id = intval($user_info['id']);
$code = $user_info['code'];
if ($user_id == 0) {
$root['response_code'] = 0;
$root['show_err'] = '验证码错误';
output($root);
} else {
$new_pwd = md5($user_pwd . $code);
$sql = "update " . DB_PREFIX . "user set user_pwd='" . $new_pwd . "', bind_verify = '', verify_create_time = 0 where id = " . $user_id;
$GLOBALS['db']->query($sql);
$root['response_code'] = 1;
$root['show_err'] = "密码更新成功!";
//$GLOBALS['lang']['MOBILE_BIND_SUCCESS'];
$root['sql'] = $sql;
output($root);
}
output($root);
}
示例11: save
public function save()
{
global_run();
if (check_save_login() != LOGIN_STATUS_LOGINED) {
$result['status'] = 2;
ajax_return($result);
}
$consignee_id = intval($_REQUEST['region_id']);
$region_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_consignee where user_id = " . $GLOBALS['user_info']['id']);
if ($region_count >= 5 && $consignee_id == 0) {
$result['status'] = 3;
ajax_return($result);
}
if (strim($_REQUEST['consignee']) == '') {
showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'], 1);
}
if (strim($_REQUEST['address']) == '') {
showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS'], 1);
}
if (strim($_REQUEST['zip']) == '') {
showErr($GLOBALS['lang']['FILL_CORRECT_ZIP'], 1);
}
if (strim($_REQUEST['mobile']) == '') {
showErr($GLOBALS['lang']['FILL_MOBILE_PHONE'], 1);
}
if (!check_mobile($_REQUEST['mobile'])) {
showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'], 1);
}
$consignee_data['user_id'] = $GLOBALS['user_info']['id'];
$consignee_data['region_lv1'] = intval($_REQUEST['region_lv1']);
$consignee_data['region_lv2'] = intval($_REQUEST['region_lv2']);
$consignee_data['region_lv3'] = intval($_REQUEST['region_lv3']);
$consignee_data['region_lv4'] = intval($_REQUEST['region_lv4']);
$consignee_data['address'] = strim($_REQUEST['address']);
$consignee_data['mobile'] = strim($_REQUEST['mobile']);
$consignee_data['consignee'] = strim($_REQUEST['consignee']);
$consignee_data['zip'] = strim($_REQUEST['zip']);
$consignee_count = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_consignee where user_id = " . $GLOBALS['user_info']['id']));
if ($consignee_count == 0) {
$consignee_data['is_default'] = 1;
}
if ($consignee_id == 0) {
$GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data);
} else {
$GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $consignee_data, "UPDATE", "id=" . $consignee_id . " and user_id=" . $GLOBALS['user_info']['id']);
}
rm_auto_cache("consignee_info", array("consignee_id" => intval($consignee_id)));
$result['status'] = 1;
$result['url'] = url('index', 'uc_consignee');
ajax_return($result);
}
示例12: index
public function index()
{
// require_once APP_ROOT_PATH."system/libs/user.php";
$mobile = trim($GLOBALS['request']['mobile']);
$pwd = strim($GLOBALS['request']['password']);
$password_confirm = strim($GLOBALS['request']['password_confirm']);
$gender = intval($GLOBALS['request']['gender']);
$sms_verify = intval($GLOBALS['request']['sms_verify']);
if ($mobile == '') {
$root['status'] = 0;
$root['info'] = '手机号码不能为空';
output($root);
}
if (!check_mobile($mobile)) {
$root['status'] = 0;
$root['info'] = "请输入正确的手机号码";
output($root);
}
if (strlen($pwd) < 4) {
$root['status'] = 0;
$root['info'] = "密码不能低于四位";
output($root);
}
if ($pwd != $password_confirm) {
$root['status'] = 0;
$root['info'] = "您两次输入的密码不匹配";
output($root);
}
if ($sms_verify == "") {
$root['status'] = 0;
$root['info'] = "请输入收到的验证码";
output($root);
}
$sql = "DELETE FROM " . DB_PREFIX . "sms_mobile_verify WHERE add_time <=" . (NOW_TIME - SMS_EXPIRESPAN);
$GLOBALS['db']->query($sql);
$mobile_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '" . $mobile . "'");
if ($mobile_data['code'] != $sms_verify) {
$root['status'] = 0;
$root['info'] = "验证码错误";
output($root);
}
// $db_code = $GLOBALS['db']->getRow("select id from ".DB_PREFIX."sms_mobile_verify where status=1 and mobile_phone = '$mobile' and type=0 order by id desc");
// if(!$db_code)
// {
// $root['status'] = 0;
// $root['info'] ="手机号码未通过验证";
// output($root);
// }
$root = mobile_reg($mobile, $pwd, $gender);
output($root);
}
示例13: index
public function index()
{
$mobile = trim($GLOBALS['request']['mobile']);
$code = strim($GLOBALS['request']['code']);
/*验证码*/
if ($mobile == '') {
$root['status'] = 0;
$root['info'] = '手机号码不能为空';
output($root);
}
if (!check_mobile($mobile)) {
$root['status'] = 0;
$root['info'] = "请输入正确的手机号码";
output($root);
}
if ($code == '') {
$root['info'] = "请输入验证码!";
$root['status'] = 0;
output($root);
}
$db_code = $GLOBALS['db']->getRow("select id,code,add_time from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '{$mobile}' order by id desc");
if ($db_code['code'] != $code) {
$root['info'] = "请输入正确的验证码!";
$root['status'] = 0;
output($root);
}
$new_time = get_gmtime();
if ($new_time - $db_code['add_time'] > 60 * 30) {
$root['info'] = "验证码已失效,请重新获取!";
$root['status'] = 0;
$GLOBALS['db']->query("delete from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = " . $mobile . "");
output($root);
}
$GLOBALS['db']->query("delete from " . DB_PREFIX . "sms_mobile_verify where id=" . $db_code['id'] . "");
$sql = "SELECT * FROM " . DB_PREFIX . "user WHERE mobile = " . $mobile;
$user = $GLOBALS['db']->getRow($sql);
$res = $GLOBALS['db']->query("update " . DB_PREFIX . "user set password_verify=" . $code . " where id=" . $user['id']);
if ($res) {
$root['info'] = "验证成功";
$root['status'] = 1;
$root['user_id'] = $user['id'];
} else {
$root['info'] = "验证出错";
$root['status'] = 0;
}
output($root);
}
示例14: check_user
/**
* 验证会员数据
*/
function check_user($field_name, $field_data)
{
//开始数据验证
$user_data[$field_name] = $field_data;
$res = array('status' => 1, 'info' => '', 'data' => '');
//用于返回的数据
if (trim($user_data['user_name']) == '' && $field_name == 'user_name') {
$field_item['field_name'] = 'user_name';
$field_item['error'] = EMPTY_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
if ($field_name == 'user_name' && $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where user_name = '" . trim($user_data['user_name']) . "' and id <> " . intval($user_data['id'])) > 0) {
$field_item['field_name'] = 'user_name';
$field_item['error'] = EXIST_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
if ($field_name == 'email' && $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where email = '" . trim($user_data['email']) . "' and id <> " . intval($user_data['id'])) > 0) {
$field_item['field_name'] = 'email';
$field_item['error'] = EXIST_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
if ($field_name == 'email' && trim($user_data['email']) == '') {
$field_item['field_name'] = 'email';
$field_item['error'] = EMPTY_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
if ($field_name == 'email' && !check_email(trim($user_data['email']))) {
$field_item['field_name'] = 'email';
$field_item['error'] = FORMAT_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
if ($field_name == 'mobile' && intval(app_conf("MOBILE_MUST")) == 1 && trim($user_data['mobile']) == '') {
$field_item['field_name'] = 'mobile';
$field_item['error'] = EMPTY_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
if ($field_name == 'mobile' && !check_mobile(trim($user_data['mobile']))) {
$field_item['field_name'] = 'mobile';
$field_item['error'] = FORMAT_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
// if($field_name=='mobile'&&$user_data['mobile']!=''&&$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user where mobile = '".trim($user_data['mobile'])."' and id <> ".intval($user_data['id']))>0)
// {
// $field_item['field_name'] = 'mobile';
// $field_item['error'] = EXIST_ERROR;
// $res['status'] = 0;
// $res['data'] = $field_item;
// return $res;
// }
//验证扩展字段
$field_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_field where field_name = '" . $field_name . "'");
if ($field_item['is_must'] == 1 && trim($user_data[$field_item['field_name']]) == '') {
$field_item['error'] = EMPTY_ERROR;
$res['status'] = 0;
$res['data'] = $field_item;
return $res;
}
return $res;
}
示例15: send_sms_code
/**
* 发送手机验证码
*/
public function send_sms_code()
{
$verify_code = strim($_REQUEST['verify_code']);
$mobile_phone = strim($_REQUEST['mobile']);
if ($mobile_phone == "") {
$data['status'] = false;
$data['info'] = "请输入手机号";
$data['field'] = "user_mobile";
ajax_return($data);
}
if (!check_mobile($mobile_phone)) {
$data['status'] = false;
$data['info'] = "手机号格式不正确";
$data['field'] = "user_mobile";
ajax_return($data);
}
if (intval($_REQUEST['unique']) == 1) {
if (intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier_submit where account_mobile = '" . $mobile_phone . "'")) > 0) {
$data['status'] = false;
$data['info'] = "手机号已被注册";
$data['field'] = "account_mobile";
ajax_return($data);
}
}
$sms_ipcount = load_sms_ipcount();
if ($sms_ipcount > 1) {
//需要图形验证码
if (es_session::get("verify") != md5($verify_code)) {
$data['status'] = false;
$data['info'] = "验证码错误";
$data['field'] = "verify_code";
ajax_return($data);
}
}
if (!check_ipop_limit(CLIENT_IP, "send_sms_code", SMS_TIMESPAN)) {
showErr("请勿频繁发送短信", 1);
}
//删除失效验证码
$sql = "DELETE FROM " . DB_PREFIX . "sms_mobile_verify WHERE add_time <=" . (NOW_TIME - SMS_EXPIRESPAN);
$GLOBALS['db']->query($sql);
$mobile_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '" . $mobile_phone . "'");
if ($mobile_data) {
//重新发送未失效的验证码
$code = $mobile_data['code'];
$mobile_data['add_time'] = NOW_TIME;
$GLOBALS['db']->query("update " . DB_PREFIX . "sms_mobile_verify set add_time = '" . $mobile_data['add_time'] . "',send_count = send_count + 1 where mobile_phone = '" . $mobile_phone . "'");
} else {
$code = rand(100000, 999999);
$mobile_data['mobile_phone'] = $mobile_phone;
$mobile_data['add_time'] = NOW_TIME;
$mobile_data['code'] = $code;
$mobile_data['ip'] = CLIENT_IP;
$GLOBALS['db']->autoExecute(DB_PREFIX . "sms_mobile_verify", $mobile_data, "INSERT", "", "SILENT");
}
send_verify_sms($mobile_phone, $code);
es_session::delete("verify");
//删除图形验证码
$data['status'] = true;
$data['info'] = "发送成功";
$data['lesstime'] = SMS_TIMESPAN - (NOW_TIME - $mobile_data['add_time']);
//剩余时间
$data['sms_ipcount'] = load_sms_ipcount();
ajax_return($data);
}