-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleUser.php
81 lines (69 loc) · 2.73 KB
/
deleUser.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
$username = $_GET['username'];
$idRoom = $_GET['idRoom'];
$file = file_get_contents('room.json');
$datajson = json_decode($file,true);
switch ($idRoom){
case 0:
$usernameList= array_column($datajson["chambre1"],'name');
if( in_array($username,$usernameList) ){
$key = array_search($username,$usernameList);
array_splice($datajson["chambre1"], $key,1);
}
for($i=0; $i< count( $datajson["chambre1"] );$i++){
$datajson["chambre1"][$i]["gameStatus"] = "false";
$datajson["chambre1"][$i]["cartes"] = [];
$datajson["chambre1"][$i]["order"] = "";
$datajson["chambre1"][$i]["cartesCentre"] = [];
$datajson["chambre1"][$i]["note"] = 0;
$datajson["chambre1"][$i]["outall"] = false;
$datajson["chambre1"][$i]["lastper"] = "";
}
break;
case 1:
$usernameList= array_column($datajson["chambre2"],'name');
if( in_array($username,$usernameList) ){
$key = array_search($username,$usernameList);
array_splice($datajson["chambre2"], $key,1);
}
for($i=0; $i< count( $datajson["chambre2"] );$i++){
$datajson["chambre2"][$i]["gameStatus"] = "false";
$datajson["chambre2"][$i]["cartes"] = [];
$datajson["chambre2"][$i]["order"] = "";
$datajson["chambre2"][$i]["cartesCentre"] = [];
$datajson["chambre2"][$i]["note"] = 0;
$datajson["chambre2"][$i]["outall"] = false;
$datajson["chambre2"][$i]["lastper"] = "";
}
break;
case 2:
$usernameList= array_column($datajson["chambre3"],'name');
if( in_array($username,$usernameList) ){
$key = array_search($username,$usernameList);
array_splice($datajson["chambre3"], $key,1);
}
for($i=0; $i< count( $datajson["chambre3"] );$i++){
$datajson["chambre3"][$i]["gameStatus"] = "false";
$datajson["chambre3"][$i]["cartes"] = [];
$datajson["chambre3"][$i]["order"] = "";
$datajson["chambre3"][$i]["cartesCentre"] = [];
$datajson["chambre3"][$i]["note"] = 0;
$datajson["chambre3"][$i]["outall"] = false;
$datajson["chambre3"][$i]["lastper"] = "";
}
break;
}
$json_string = json_encode($datajson);
file_put_contents('room.json', $json_string);
$file = file_get_contents('messages.json');
$datajson = json_decode($file,true);
for ($i = 0 ; $i< count($datajson); $i++){
if($datajson[$i]["idRoom"] == $idRoom){
$datajson[$i]["messages"] = array();
break;
}
}
$json_string = json_encode($datajson);
file_put_contents('messages.json', $json_string);
echo "success";
?>