function thirdBindUser(){
$Phone = sql($_POST['Phone']);
if($Phone == ""){
echo json_encode(array(
'ret' => false,
'errorMsg' => "手机号不能为空!"
));
exit();
}else if(!preg_match("/^1\d{10}$/",$Phone)){
echo json_encode(array(
'ret' => false,
'errorMsg' => "手机号格式错误!"
));
exit();
}
$PassWord = sql($_POST['PassWord']);
if($PassWord == ""){
echo json_encode(array(
'ret' => false,
'errorMsg' => "密码不能为空!"
));
exit();
}else if(strlen($PassWord) > 25){
echo json_encode(array(
'ret' => false,
'errorMsg' => "密码不得超过25个字符!"
));
exit();
}
$NickName = sql($_POST['NickName']);
if(strlen($NickName) > 10){
echo json_encode(array(
'ret' => false,
'errorMsg' => "昵称不得超过10个字符!"
));
exit();
}
$AuthTime = $_POST['AuthTime'];
if($AuthTime == ""){
echo json_encode(array(
'ret' => false,
'errorMsg' => "激活时间不能为空!"
));
exit();
}
$activetime = $_POST['activetime'];
if($activetime == ""){
echo json_encode(array(
'ret' => false,
'errorMsg' => "到期时间不能为空!"
));
exit();
}
$db = new db("tbl_user");
$isPhone = $db -> where('Phone="'.$Phone.'"')->select();
if (count($isPhone)>0){
//账号存在 续费
$checkPW = $db->where('Phone="'.$Phone.'" and PassWord="'.md5($PassWord).'"')->find();
if(count($checkPW) > 0){
// 'AuthTime'=> '"'.date('Y-m-d H:i:s',$AuthTime).'"',
// 'activetime' => $activetime,
$result=$db->where("Phone=$Phone")->update('AuthTime="'.date('Y-m-d H:i:s',$AuthTime).'",activetime="'.$activetime.'"');
if($result >= 0){
echo json_encode(array(
'ret' => true,
'errorMsg' => "续费成功!"
));
}else{
echo json_encode(array(
'ret' => false,
'errorMsg' => "续费失败!"
));
}
}else{
echo json_encode(array(
'ret' => false,
'errorMsg' => "密码错误!"
));
}
exit();
}
//默认权限
$accessdb = new db('tbl_companydata');
$id = $accessdb->select();
$accessData = array();
foreach ($id as $key=>$value){
$accessData[$key] = array(
0 => (int)$value['id'],
1 => 0,
);
}
$val = new \ZYMessage\FileAccess();
$arr = array();
for ($i=0;$i<count($accessData);$i++){
array_push($arr,unpack("P",pack("L*",(int)$accessData[$i][1],(int)$accessData[$i][0]))[1]);
}
$val->setAccesslist($arr);
$data=$val->serializeToString();
$access=base64_encode($data);
$val = new \ZYMessage\FileAccess();
$val -> mergeFromString(base64_decode($access));
$_access=$val->getAccesslist();
$arr=array();
for ($j=0;$j<count($_access);$j++){
array_push($arr,unpack('Lval/Lid',pack('P',$_access[$j])));
// $arr=implode("&",unpack("Lval/Lid",pack("P",$access[$j])));
}
$ret = $db->insert(
array(
'Phone'=> '"'.$Phone.'"',
'PassWord'=> '"'.md5($PassWord).'"',
'NickName'=> '"'.$NickName.'"',
'savelimit' => 200,
'AuthTime'=> '"'.date('Y-m-d H:i:s',$AuthTime).'"',
'activetime' => $activetime,
'fileaccess' => '"'.$access.'"'
)
);
if ($ret>0){
$result = $db->where('Phone="'.$Phone.'" and PassWord="'.md5($PassWord).'"')->find();
echo json_encode(array(
'ret' => true,
'msg' => "账号绑定成功!"
));
}else{
echo json_encode(array(
'ret' => false,
'msg' => "账号绑定失败!"
));
}
}
网友评论