forked from amzik/officemanage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (41 loc) · 1.27 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require('common.php');
if(empty($_POST)){
require('office.html');
exit();
}
if($is_invitation_code){
if(empty($_POST['invitation_code'])){
response(1,'请输入邀请码');
}
$conn = mysql_conn();
$code = $_POST['invitation_code'];
$invitation_code = mysqli_fetch_assoc(mysqli_query($conn,"select * from invitation_code where `code`='$code'"));
if(empty($invitation_code)){
response(1,'邀请码不存在');
}
if($invitation_code['status'] != 0){
response(1,'邀请码已被使用');
}
}
$request = [
'username'=>$_POST['username'],
'firstname'=>$_POST['firstname'],
'lastname'=>$_POST['lastname'],
];
$password = get_rand_string();
$token = get_ms_token($tenant_id,$client_id,$client_secret);
if(empty($token)){
response(1,'获取token失败,请检查参数配置是否正确');
}
if($is_invitation_ck == "1"){
create_user($request,$token,$domain,$sku_id,$password);
}
if($is_invitation_ck == "2"){
create_user($request,$token,$domain,$sku_id2,$password);
}
$email = $_POST['username'].'@'.$domain;
if($is_invitation_code){
mysqli_query($conn,"UPDATE `invitation_code` SET `update_time` = ".time().", `status` = 1,`email`='$email' WHERE `code` = $code");
}
response(0,'申请账号成功',['email'=>$email,'password'=>$password]);