<?php
error_reporting(0); 
include("../../config/wap.php");
if($reg=='0'){
$code=$_SERVER["REQUEST_URI"];
$html ='<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
$html.='<html><head>';
$html.='<meta charset="gb2312">';
$html.='<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />';
$html.='<title>404 Not Found</title>';
$html.='</head><body>';
$html.='<h1>Not Found</h1>';
$html.='<p>The requested URL '.$code.' was not found on this server.</p>';
$html.='</body>';
$html.='</html>';
echo $html;
exit;
}
if(ubo($_POST)){
$type="where zt='正常' and qx='1'  order by rand() limit 1";
$zym=queryall(zym,$type);
if($zym[url]){
$zymurl=$zym[url];
}else{
$zymurl=$url;
}
$name=ubo(iconv("UTF-8","GB2312",$_POST["name"]));
$pass=ubo(iconv("UTF-8","GB2312",$_POST["pass"]));
$nikname=ubo(iconv("UTF-8","GB2312",$_POST["nikname"]));
$yqm=ubo(iconv("UTF-8","GB2312",$_POST["yqm"]));
$postpass=md5($pass);
$type="WHERE name='$name'";
$user=queryall(user,$type); 
$yqmtype="WHERE yqm='$yqm'";
$yqmsj=queryall(yqm,$yqmtype); 
$tjr=$yqmsj['userid'];
if($user){
$err=iconv("GB2312","UTF-8","代理已经存在");
$errtip = array ('status'=>"false",'msg'=>$err);   
echo json_encode($errtip);
}else{
if($yqmkg==1){
if($yqmsj==null){
$err=iconv("GB2312","UTF-8","邀请码不存在");
$errstr = array ('status'=>"false",'msg'=>$err);   
echo json_encode($errstr);
}elseif($yqmsj['zt']=='已使用'){
$err=iconv("GB2312","UTF-8","邀请码已经被使用");
$errstr = array ('status'=>"false",'msg'=>$err);   
echo json_encode($errstr);
}else{
$sjtype="order by id DESC limit 0,1";
$sjuser=queryall(user,$sjtype);
if ($sjuser['userid']==null){
$userid="10000";
}else{
$userid=$sjuser['userid']+1;
}
$type="(`id`, `userid`, `name`, `tx`, `pass`,`tixian`, `qq`, `weixin`, `txname`, `shijian`,`money`,`zt`,`tjr`,`nikname`,`txmoney`,`txfl`,`yqm`,`ypass`,`pb`,`mb`,`hzmb`,`dsmb`,`skm`,`fy`,`fs`,`url`) VALUES (null,'$userid','$name','/2019newui/images/tx.png','$postpass','---','未填写','未填写','---','$shijian', '0','true','$tjr','$nikname', '0', '$fl', '$yqm', '$pass', '2', '$linkmb','$hezimb','$dsmb','','$fy','1','$zymurl')"; 
dbinsert(user,$type);
$linktype="(`id`, `userid`, `cs`, `ns`) VALUES (null, '$userid', '30', '10')";
dbinsert(link,$linktype);
$yqmtype="zt='已使用',name='$name'  where yqm='$yqm'";
upalldt(yqm,$yqmtype);
$err= array ('status'=>"true");   
echo json_encode($err);
}
}else{
$sjtype="order by id DESC limit 0,1";
$sjuser=queryall(user,$sjtype);
if ($sjuser['userid']==null){
$userid="10000";
}else{
$userid=$sjuser['userid']+1;
}
$type="(`id`, `userid`, `name`, `tx`, `pass`,`tixian`, `qq`, `weixin`, `txname`, `shijian`,`money`,`zt`,`tjr`,`nikname`,`txmoney`,`txfl`,`yqm`,`ypass`,`pb`,`mb`,`hzmb`,`dsmb`,`skm`,`fy`,`fs`,`url`) VALUES (null,'$userid','$name','/2019newui/images/tx.png','$postpass','---','未填写','未填写','---','$shijian', '0','true','---','$nikname', '0', '$fl', '---', '$pass', '2', '$linkmb','$hezimb','$dsmb','','$fy','1','$zymurl')"; 
dbinsert(user,$type);
$linktype="(`id`, `userid`, `cs`, `ns`) VALUES (null, '$userid', '30', '10')";
dbinsert(link,$linktype);
$err= array ('status'=>"true");   
echo json_encode($err);
}
}
}else{
$code=$_SERVER["REQUEST_URI"];
$html ='<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
$html.='<html><head>';
$html.='<meta charset="gb2312">';
$html.='<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />';
$html.='<title>404 Not Found</title>';
$html.='</head><body>';
$html.='<h1>Not Found</h1>';
$html.='<p>The requested URL '.$code.' was not found on this server.</p>';
$html.='</body>';
$html.='</html>';
echo $html;
exit;
}
?>