//error_reporting(0);
include "boot.php";
include ROOT."/vendor/SQLiteDB.php";
/*
DROP TABLE users;
DROP TABLE logs;
DROP TABLE resource;
DROP TABLE event;
DROP TABLE system;
DROP TABLE smscode;
CREATE TABLE users(id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,email TEXT,mobile TEXT,useroptions TEXT,account INTEGER,createtime TEXT,date TEXT);
CREATE TABLE logs(id INTEGER PRIMARY KEY AUTOINCREMENT,resource_id TEXT,event_id INTEGER,userid INTEGER,mobile TEXT,attachment TEXT,link TEXT,freq INTEGER,createtime TEXT,date TEXT);
CREATE TABLE resource(id INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT,content TEXT,url TEXT,type TEXT,createtime TEXT,date TEXT);
CREATE TABLE event(id INTEGER PRIMARY KEY AUTOINCREMENT,code INTEGER,msg TEXT,sub_code TEXT,sub_msg TEXT);
CREATE TABLE system(id INTEGER PRIMARY KEY AUTOINCREMENT,url TEXT,current_title TEXT);
CREATE TABLE smscode(id INTEGER PRIMARY KEY AUTOINCREMENT,mobile TEXT,ip TEXT,code TEXT,status INTEGER,createtime TEXT);
http://n.zhimatiao.com/arYZg
*/
$mobile = $_POST['mobile'];
$link = trim($_POST['link']);
$getinfo = intval($_POST['getinfo']);
$vcode = $_POST['vcode'];
$token = str_replace('http://n.zhimatiao.com/','',$link);
session_start();
if(sha1($vcode) != $_SESSION['authnum_session'])
{
header('Content-type:text/json');
die(json_encode(array(
'code'=>470129,
'msg'=>'图形验证码不正确',
)));
}
if (strlen ( $mobile ) != 11 || ! preg_match ( '/^1[3|4|5|7|8][0-9]\d{4,8}$/', $mobile )) {
$_SESSION['authnum_session'] = null;
header('Content-type:text/json');
die(json_encode(array(
'code'=>470125,
'msg'=>'手机格式不正确',
)));
}
$_mobile = $mobile;
if(empty($_SESSION['authuid_session_'.$_mobile.$token]) || $getinfo == 1)
{
$sql = 'SELECT userid FROM `logs` WHERE resource_id="'.$token.'" and mobile="'.$_mobile.'"';
$exist = DBUtils::querySingle($sql);
$sql = 'SELECT id FROM `users` WHERE id="'.$exist.'"';
$userid = DBUtils::querySingle($sql);
if($userid <= 0)
{
$_SESSION['authnum_session'] = null;
header('Content-type:text/json');
die(json_encode(array(
'code'=>470121,
'msg'=>'信息不匹配',
)));
}
//find mode
$_SESSION['authuid_session_'.$_mobile.$token] = $userid;
$_SESSION['uid'] = $userid;
header('Content-type:text/json');
die(json_encode(array(
'code'=>470000
)));
}else{
//find mode
if(empty($_SESSION['authuid_session_'.$_mobile.$token]))
{
$_SESSION['authnum_session'] = null;
header('Content-type:text/json');
die(json_encode(array(
'code'=>470122,
'msg'=>'请先查找账户',
)));
}else{
//设置模式
$useroptions = array();
if($_POST['neu'] == 'true')
{
$useroptions['neu'] = 1;
}
if($_POST['ise'] == 'true')
{
$useroptions['ise'] = 1;
}
if($_POST['graduate'] == 'true')
{
$useroptions['graduate'] = 1;
}
if($_POST['me'] == 'true')
{
$useroptions['me'] = 1;
}
if($_POST['sc'] == 'true')
{
$useroptions['sc'] = 1;
}
if($_POST['mse'] == 'true')
{
$useroptions['mse'] = 1;
}
$useroptions = base64_encode(json_encode($useroptions));
$sql = 'UPDATE `users` SET useroptions="'.$useroptions.'" WHERE id="'.$_SESSION['authuid_session_'.$_mobile.$token].'"';
if(DBUtils::execute($sql))
{
header('Content-type:text/json');
die(json_encode(array(
'code'=>470200,
'msg'=>'设置成功',
)));
}else{
$_SESSION['authnum_session'] = null;
header('Content-type:text/json');
die(json_encode(array(
'code'=>470123,
'msg'=>'设置失败',
)));
}
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史