查看文件: apiuserp.php
大小: 3.7 KB
类型: application/octet-stream
<? require_once('../Connections/BE2.php'); if (!isset($_SESSION)){ session_start(); } function ge2($length = 2) { $characters = 'abcdefghijklmnopqrstuvwxyz'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function ge5($length = 5) { $characters = '012356789'; //0123456789 $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } $email=isset($_POST['email'])?$_POST['email']:'-1'; $mobile=isset($_POST['mobile'])?$_POST['mobile']:'-1'; $name=isset($_POST['name'])?$_POST['name']:'-1'; $errmsg=array('PASS','資料錯誤','帳號已存在','IP不合法'); $msgcode=0; $scode=" "; $pw=" "; $json_array = array(); //PASS 資料錯誤 帳號已存在 IP不合法 $json_array['msgcode']= $msgcode ; $json_array['msg']=$errmsg[$msgcode]; $json_array['usercode']=$scode; $json_array['userpw']=$pw; $json_array['mobile']=$mobile; $json_array['name']=$name; $json_array['email']=$email; $pass_ip=array('220.130.43.118','76.223.105.230','13.248.243.5'); if(in_array($_SERVER['REMOTE_ADDR'],$pass_ip)){ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $msgcode=1 ; // invalid emailaddress } if(!preg_match('/^09([0-9]{8})$/',$mobile)){ $msgcode=1 ;} if($name=='-1'){ $msgcode=1;} if($msgcode==0){ if(!preg_match('/^09([0-9]{8})$/',$mobile)){ $msgcode=1 ;} } //https://www.skybni.com/user/addapiuser.html?name=yskin&mobile=0912591892&email=yskin@gmail.com if($msgcode==0){ mysql_select_db($database_BE2, $BE2); $query_Rft2 = "SELECT * FROM member where mem_mobile='$mobile' "; $Rft2 = mysql_query($query_Rft2, $BE2) or die(mysql_error()); $row_Rft2 = mysql_fetch_assoc($Rft2); $totalRows_Rft2 = mysql_num_rows($Rft2); $t=$totalRows_Rft2; if($t>0){ $msgcode=2; }else{ $k=1; while($k>0){ $scode = ge2().ge5(); $q2= "SELECT * FROM member where scode='$scode' "; $Rq2 = mysql_query($q2, $BE2) or die(mysql_error()); $row_Rq2 = mysql_fetch_assoc($Rq2); $k = mysql_num_rows($Rq2); } mysql_free_result($Rq2); $mem_time=date('Y-m-d H:i:s'); //mysql_select_db($database_BE2, $BE2); $pw=rand(1000,9999); // mcapture=1 ;;/ set upload $insertSQL = sprintf("INSERT INTO member(mem_time,mem_uptime, mem_mobile,mem_mail,mem_name, mem_passwd, mem_free, mcapture, scode, mem_num) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s,%s)", GetSQLValueString($mem_time, "text"), GetSQLValueString($mem_time, "text"), GetSQLValueString($mobile, "text"), GetSQLValueString($email, "text"), GetSQLValueString($name, "text"), GetSQLValueString($pw, "text"), GetSQLValueString("0", "text"), GetSQLValueString("1", "text"), GetSQLValueString($scode, "text"), GetSQLValueString("1", "text")); mysql_select_db($database_BE2, $BE2); mysql_query($insertSQL, $BE2) or die(mysql_error()); //$scode='https:\/\/www.skybni.com\/ecard\/'.$scode; } mysql_free_result($Rft2); } $json_array['userpw']=$pw; $json_array['msgcode']= $msgcode ; $json_array['msg']=$errmsg[$msgcode]; $json_array['usercode']=$scode; }else{ $msgcode=3; $json_array['msgcode']= $msgcode ; $json_array['msg']=$errmsg[$msgcode]; } echo json_encode($json_array); ?>
保存
取消
返回文件列表