CREATE TABLE `pw_members_mobile_book` (
`uid` int(10) unsigned NOT NULL,
`username` varchar(40) NOT NULL DEFAULT '',
`mobile` varchar(11) NOT NULL,
`status` tinyint(3) unsigned NOT NULL DEFAULT '0',
`createdtime` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`),
KEY `index_mobile` (`mobile`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `pw_sms_logs` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`mobile` char(11) NOT NULL DEFAULT '' COMMENT '手机号',
`content` varchar(255) NOT NULL DEFAULT '' COMMENT '内容',
`sendtime` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_mobile` (`mobile`),
KEY `idx_mobile_sendtime` (`mobile`,`sendtime`)
) ENGINE=InnoDB AUTO_INCREMENT=662726 DEFAULT CHARSET=gbk;
CREATE TABLE `pw_mobile_verifycode` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(11) unsigned NOT NULL DEFAULT '0',
`mobile` varchar(12) NOT NULL DEFAULT '',
`verifycode` varchar(10) NOT NULL DEFAULT '',
`expire_at` int(10) unsigned NOT NULL DEFAULT '0',
`created_at` int(10) unsigned NOT NULL DEFAULT '0',
`updated_at` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_mobile_createdat` (`mobile`,`created_at`)
) ENGINE=MyISAM AUTO_INCREMENT=3275 DEFAULT CHARSET=gbk;
/**
* 手机号验证判断
* @return bool
*/
function mobileBinded($uid){
global $db, $groupid;
// 自己的马甲不验证手机
if (in_array($groupid, array(80, 67))) {
return true;
}
$mobile = $db->get_value("SELECT mobile FROM pw_members_mobile_book WHERE uid=" . S::sqlEscape($uid) . " LIMIT 1");
return $mobile ? true : false;
}
<?php
define('SCR','thread');
require_once('global.php');
// 请将以下这段函数调用复制到文件中,其他不要
$mobileBinded = mobileBinded((int)$winduid);
<?php
define('SCR','read');
require_once('global.php');
// 请将以下这段函数调用复制到文件中,其他不要
$mobileBinded = mobileBinded((int)$winduid);
<?php
!function_exists('readover') && exit('Forbidden');
// 请将以下这段函数调用复制到文件中,其他不要
if (!mobileBinded($winduid)) {
Showmsg('请先<a href="http://i.hualongxiang.com/profile">绑定手机</a>');
}
<?php
// 请将以下这段函数调用复制到文件中,其他不要
if (!mobileBinded($winduid)) {
Showmsg('请先<a href="http://i.hualongxiang.com/profile">绑定手机</a>');
}
<div class="pop-mobile">
<div class="h_title">
<div class="txt">绑定手机</div>
<div class="closeds mclosed"></div>
</div>
<div class="bang-form-box">
<p class="mb20">应国家法规对账号实名的要求,<br />
进行下一步操作前,请先完成手机绑定。<a href="http://www.hualongxiang.com/read.php?tid=13599034" target="_blank">了解更多</a></p>
<form method="post" action="" class="clearfix mb20">
<div class="info-box">
<div class="input-box div-phone"><i class="icon-tel"></i><input type="text" id="phone" class="long_txt" maxlength="11" placeholder="请输入手机号码" autocomplete="off" datatype="m" errormsg="手机号码格式不正确" nullmsg="请填写正确的手机号码" /></div>
<a href="javascript:;" class="send1">发送验证码</a>
</div>
<div class="info-box">
<div class="input-box div-yzm"><i class="icon-yz"></i><input type="text" id="ranks" class="long_txt" maxlength="6" placeholder="请输入验证码" /></div>
</div>
<div class="info-box">
<a href="javascript:;" class="conform">立即绑定</a>
</div>
</form>
<p>
验证出现问题?
<br>
您可以在线客服求助或拨打客服电话0519-86601957
<br>
想要找回绑定手机的账号?你可以<a href="http://www.hualongxiang.com/chazuo/13599034#147851057" target="_blank">戳这里</a>。
</p>
</div>
<div class="success-box dn">
<div class="icon-ok"></div>
<p>绑定成功</p>
<p id="btime"></p>
</div>
</div>
<div class="markbg"></div>
<?php
/**
* Created by PhpStorm.
* User: liyifei
* Email: 119422342@qq.com
* Date: 17-8-23
* Time: 下午4:12
*/
require_once "global.php";
$action = $_POST['action'];
if (!$winduid) {
throw new Exception("illegal request");
}
$mobile = $_POST["mobile"];
// 验证手机号
if (!preg_match("/^1[34578][0-9]{9}$/", $mobile)) {
echo json_encode(array(
"status" => 1,
"message" => "请填写正确的手机号",
"target" => "phone"
));
exit(0);
}
$uid = $db->get_value("SELECT uid FROM pw_members_mobile_book WHERE mobile=" . S::sqlEscape($mobile));
if ($uid) {
echo json_encode(array(
"status" => 1,
"message" => "该手机号已经绑定了其他用户",
"target" => "phone"
));
exit(0);
}
$binded = $db->get_value("SELECT mobile FROM pw_members_mobile_book WHERE uid=" . S::sqlEscape($winduid));
if ($binded) {
echo json_encode(array(
"status" => 1,
"message" => "您已经绑定了手机",
"target" => "phone"
));
exit(0);
}
switch ($action) {
case "send":
require_once(R_P . 'require/Mandao.php');
//验证当天条数
$start = strtotime(date('Y-m-d 00:00:00'));
$end = time();
$num = $db->get_value("SELECT count(*) FROM pw_sms_logs WHERE mobile = " . S::sqlEscape($mobile)
. " AND sendtime between " . $start . " AND " . $end);
if ($num >= 10) {
echo json_encode(array(
"status" => 1,
"message" => "您当天发送次数过多",
"target" => "phone"
));
exit(0);
}
//验证省内手机号
$url = "http://cx.shouji.360.cn/phonearea.php?number=" . $mobile;
$content = curl_get_contents($url, 3);
$content = json_decode($content, TRUE);
if (isset($content['data']['province']) && $content['data']['province'] != '江苏') {
echo json_encode(array(
"status" => 1,
"message" => "非江苏省内的手机号无法进行实名认证",
"target" => "phone"
));
exit(0);
}
// 生成验证码
$yzm = rand(1000, 9999);
// 发送短信
$sdk = new Mandao(array(
'serialNumber' => 'DXX-WSS-100-08208',
'password' => '287532'
));
$message = mb_convert_encoding('【化龙巷】您的验证码为:' . $yzm . ',切勿将验证码泄露给他人。', 'GBK', 'UTF-8');
$result = $sdk->sendSms($mobile, $message);
if ($result == 0) {
// 入库
pwQuery::insert("pw_mobile_verifycode", array(
"uid" => $winduid,
"mobile" => $mobile,
"verifycode" => $yzm,
"expire_at" => $timestamp + 3600,
"created_at" => $timestamp,
"updated_at" => 0
));
pwQuery::insert("pw_sms_logs", array(
"mobile" => $mobile,
"content" => $message,
"sendtime" => $timestamp
));
}
echo json_encode(array(
'status' => 0,
'message' => ''
));
exit(0);
break;
case "bind":
$verifycode = $_POST['yzm'];
$log = $db->get_one("SELECT * FROM pw_mobile_verifycode WHERE mobile=" . S::sqlEscape($mobile) . " ORDER BY created_at DESC LIMIT 1");
// 验证码是否正切
if ($log['verifycode'] != $verifycode) {
echo json_encode(array(
"status" => 1,
"message" => "验证码不正确",
"target" => "yzm"
));
exit(0);
}
// 验证码是否过期
if ($log['expire_at'] - $timestamp > 3600) {
echo json_encode(array(
"status" => 1,
"message" => "验证码已过期,请重新发送",
"target" => "yzm"
));
exit(0);
}
// 是否是同一个用户
if ($log['uid'] != $winduid) {
echo json_encode(array(
"status" => 1,
"message" => "非法请求"
));
exit(0);
}
// 入库
$uid = $db->get_one("SELECT uid FROM pw_members_mobile_book WHERE uid = " . S::sqlEscape($winduid));
if ($uid) {
$db->update("UPDATE pw_members_mobile_book SET mobile = " . S::sqlEscape($mobile) . " WHERE uid=" . S::sqlEscape($winduid));
} else {
pwQuery::insert("pw_members_mobile_book", array(
"uid" => $winduid,
"username" => $windid,
"mobile" => $mobile,
"status" => 1,
"createdtime" => $timestamp
));
}
// 删除验证码
pwQuery::delete('pw_mobile_verifycode', 'mobile=:mobile', array($mobile));
echo json_encode(array(
'status' => 0,
'message' => ''
));
exit(0);
default:
break;
}
30.67 KB, 下载次数: 401
欢迎光临 千帆云 (http://bbs.qianfanyun.com/) | Powered by Discuz! X3.2 |