|
|
@ -48,7 +48,7 @@
|
|
|
|
echo "ERROR connection";
|
|
|
|
echo "ERROR connection";
|
|
|
|
echo $e->getMessage();
|
|
|
|
echo $e->getMessage();
|
|
|
|
echo $dsn;
|
|
|
|
echo $dsn;
|
|
|
|
header("HTTP/1.0 ".$e->getMessage());
|
|
|
|
//header("HTTP/1.0 ".$e->getMessage());
|
|
|
|
http_response_code(600); // Quel code pour les erreurs PDO?
|
|
|
|
http_response_code(600); // Quel code pour les erreurs PDO?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -92,237 +92,237 @@
|
|
|
|
switch ($request_method){
|
|
|
|
switch ($request_method){
|
|
|
|
case 'GET':
|
|
|
|
case 'GET':
|
|
|
|
if($method_name === "getUserById"){ // test : OK
|
|
|
|
if($method_name === "getUserById"){ // test : OK
|
|
|
|
if(empty($url[4])){
|
|
|
|
if(empty($url[3])){
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
$id = (int)$url[4];
|
|
|
|
$id = (int)$url[3];
|
|
|
|
$user = $usergw->getUserById($id);
|
|
|
|
$user = $usergw->getUserById($id);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($user, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($user, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getUserByUsername"){ // test : OK
|
|
|
|
elseif($method_name === "getUserByUsername"){ // test : OK
|
|
|
|
$username = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$username = !empty($url[3]) ? (string) $url[3] : null;
|
|
|
|
if ($username !== null){
|
|
|
|
if ($username !== null){
|
|
|
|
$user =$usergw->getUserByUsername($username);
|
|
|
|
$user =$usergw->getUserByUsername($username);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($user, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($user, JSON_PRETTY_PRINT);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 Username not given");
|
|
|
|
//header("HTTP/1.0 400 Username not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getUserForConnection"){ // test : OK
|
|
|
|
elseif($method_name === "getUserForConnection"){ // test : OK
|
|
|
|
$username = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$username = !empty($url[3]) ? (string) $url[3] : null;
|
|
|
|
$password = !empty($url[5]) ? (string) $url[5] : null;
|
|
|
|
$password = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
if ($username != null || $password != null){
|
|
|
|
if ($username != null || $password != null){
|
|
|
|
$user =$usergw->getUserForConnection($username,$password);
|
|
|
|
$user =$usergw->getUserForConnection($username,$password);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($user, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($user, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 Username or password not given");
|
|
|
|
//header("HTTP/1.0 400 Username or password not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getSkins"){ // test : OK
|
|
|
|
elseif($method_name === "getSkins"){ // test : OK
|
|
|
|
$tabSkin = $skingw->getSkins();
|
|
|
|
$tabSkin = $skingw->getSkins();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($tabSkin, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($tabSkin, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getGames"){ // test : OK
|
|
|
|
elseif($method_name === "getGames"){ // test : OK
|
|
|
|
$tabGame = $gamegw->getGames();
|
|
|
|
$tabGame = $gamegw->getGames();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($tabGame, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($tabGame, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getGameById"){ // test : OK
|
|
|
|
elseif($method_name === "getGameById"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if ($id !== null){
|
|
|
|
if ($id !== null){
|
|
|
|
$game = $gamegw->getGameById($id);
|
|
|
|
$game = $gamegw->getGameById($id);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($game, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($game, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getMatchById"){ // test : OK
|
|
|
|
elseif($method_name === "getMatchById"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if ($id !== null){
|
|
|
|
if ($id !== null){
|
|
|
|
$match = $matchgw->getMatchById($id);
|
|
|
|
$match = $matchgw->getMatchById($id);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($match, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($match, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "getConversations"){ // tests : OK
|
|
|
|
elseif($method_name === "getConversations"){ // tests : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if ($id !== null){
|
|
|
|
if ($id !== null){
|
|
|
|
$conversations = $conversationgw->getConversations($id);
|
|
|
|
$conversations = $conversationgw->getConversations($id);
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
//header('Content-Type: application/json');
|
|
|
|
echo json_encode($conversations, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($conversations, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
////header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
http_response_code(401);
|
|
|
|
http_response_code(401);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'POST':
|
|
|
|
case 'POST':
|
|
|
|
if($method_name === "postUser"){ // test : OK
|
|
|
|
if($method_name === "postUser"){ // test : OK
|
|
|
|
if (count($url)<8){
|
|
|
|
if (count($url)<7){
|
|
|
|
header("HTTP/1.0 400 Invalid number of arguments");
|
|
|
|
//header("HTTP/1.0 400 Invalid number of arguments");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$username = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$username = !empty($url[3]) ? (string) $url[3] : null;
|
|
|
|
$password = !empty($url[5]) ? (string) $url[5] : null;
|
|
|
|
$password = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$nationality = !empty($url[6]) ? (string) $url[6] : null;
|
|
|
|
$nationality = !empty($url[5]) ? (string) $url[5] : null;
|
|
|
|
$sex = !empty($url[7]) ? (string) $url[7] : null;
|
|
|
|
$sex = !empty($url[6]) ? (string) $url[6] : null;
|
|
|
|
$dateOfBirth = !empty($url[8]) ? (string) $url[8] : null;
|
|
|
|
$dateOfBirth = !empty($url[7]) ? (string) $url[7] : null;
|
|
|
|
$usergw->postUser($username,$password,$nationality,$sex,$dateOfBirth);
|
|
|
|
$usergw->postUser($username,$password,$nationality,$sex,$dateOfBirth);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "postMatch"){ // test : OK
|
|
|
|
elseif($method_name === "postMatch"){ // test : OK
|
|
|
|
$idGame = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idGame = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$idCreator = !empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$idCreator = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
if ($idGame != null || $idCreator != null){
|
|
|
|
if ($idGame != null || $idCreator != null){
|
|
|
|
$match =$matchgw->postMatch($idGame,$idCreator);
|
|
|
|
$match =$matchgw->postMatch($idGame,$idCreator);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 idGame or idCreator not given");
|
|
|
|
//header("HTTP/1.0 400 idGame or idCreator not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "postConversation"){ // test : OK
|
|
|
|
elseif($method_name === "postConversation"){ // test : OK
|
|
|
|
$name = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$name = !empty($url[3]) ? (string) $url[3] : null;
|
|
|
|
$idList = !empty($url[5]) ? (array) explode(",",$url[5]) : null;
|
|
|
|
$idList = !empty($url[4]) ? (array) explode(",",$url[4]) : null;
|
|
|
|
$name=urldecode($name);
|
|
|
|
$name=urldecode($name);
|
|
|
|
if ($name != null || $idList != null){
|
|
|
|
if ($name != null || $idList != null){
|
|
|
|
$id=$conversationgw->postConversation($name,$idList);
|
|
|
|
$id=$conversationgw->postConversation($name,$idList);
|
|
|
|
echo json_encode($id, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($id, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 name or creator not given");
|
|
|
|
//header("HTTP/1.0 400 name or creator not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
http_response_code(401);
|
|
|
|
http_response_code(401);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'PUT':
|
|
|
|
case 'PUT':
|
|
|
|
if($method_name === "putUser"){ // test : OK
|
|
|
|
if($method_name === "putUser"){ // test : OK
|
|
|
|
if (count($url)<12){
|
|
|
|
if (count($url)<11){
|
|
|
|
header("HTTP/1.0 400 Invalid number of arguments");
|
|
|
|
//header("HTTP/1.0 400 Invalid number of arguments");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$username = !empty($url[5]) ? (string) $url[5] : null;
|
|
|
|
$username = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$password = !empty($url[6]) ? (string) $url[6] : null;
|
|
|
|
$password = !empty($url[5]) ? (string) $url[5] : null;
|
|
|
|
$sexe = !empty($url[7]) ? (string) $url[7] : null;
|
|
|
|
$sexe = !empty($url[6]) ? (string) $url[6] : null;
|
|
|
|
$nationality = !empty($url[8]) ? (string) $url[8] : null;
|
|
|
|
$nationality = !empty($url[7]) ? (string) $url[7] : null;
|
|
|
|
$nbCurrentCoins = !empty($url[9]) ? (int) $url[9] : null;
|
|
|
|
$nbCurrentCoins = !empty($url[8]) ? (int) $url[8] : null;
|
|
|
|
$totalnbCoins = !empty($url[10]) ? (int) $url[10] : null;
|
|
|
|
$totalnbCoins = !empty($url[9]) ? (int) $url[9] : null;
|
|
|
|
$nbGames = !empty($url[11]) ? (int) $url[11] : null;
|
|
|
|
$nbGames = !empty($url[10]) ? (int) $url[10] : null;
|
|
|
|
$currentSkin = !empty($url[12]) ? (int) $url[12] : null;
|
|
|
|
$currentSkin = !empty($url[11]) ? (int) $url[11] : null;
|
|
|
|
$usergw->putUser($id,$username,$password,$sexe, $nationality, $nbCurrentCoins,$totalnbCoins,$nbGames,$currentSkin);
|
|
|
|
$usergw->putUser($id,$username,$password,$sexe, $nationality, $nbCurrentCoins,$totalnbCoins,$nbGames,$currentSkin);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "putSkinList"){ // test : OK
|
|
|
|
elseif($method_name === "putSkinList"){ // test : OK
|
|
|
|
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idUser = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$idSkin = !empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$idSkin = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
if ($idUser != null || $idSkin != null){
|
|
|
|
if ($idUser != null || $idSkin != null){
|
|
|
|
$usergw->putSkinList($idUser,$idSkin);
|
|
|
|
$usergw->putSkinList($idUser,$idSkin);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 idSkin or idUser not given");
|
|
|
|
//header("HTTP/1.0 400 idSkin or idUser not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "putMatch"){ // test : OK
|
|
|
|
elseif($method_name === "putMatch"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if ($id !== null){
|
|
|
|
if ($id !== null){
|
|
|
|
$matchgw->putMatch($id);
|
|
|
|
$matchgw->putMatch($id);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "addUserToMatch"){ // test : OK
|
|
|
|
elseif($method_name === "addUserToMatch"){ // test : OK
|
|
|
|
$idMatch = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idMatch = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$idUser = !empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
if ($idUser != null || $idMatch != null){
|
|
|
|
if ($idUser != null || $idMatch != null){
|
|
|
|
$matchgw->addUserToMatch($idMatch,$idUser);
|
|
|
|
$matchgw->addUserToMatch($idMatch,$idUser);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 idSkin or idUser not given");
|
|
|
|
//header("HTTP/1.0 400 idSkin or idUser not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "deleteUserFromMatch"){ // test : OK
|
|
|
|
elseif($method_name === "deleteUserFromMatch"){ // test : OK
|
|
|
|
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idUser = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if ($idUser != null){
|
|
|
|
if ($idUser != null){
|
|
|
|
$matchgw->deleteUserFromMatch($idUser);
|
|
|
|
$matchgw->deleteUserFromMatch($idUser);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 idUser not given");
|
|
|
|
//header("HTTP/1.0 400 idUser not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "putConversation"){ // test : OK
|
|
|
|
elseif($method_name === "putConversation"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$newName = !empty($url[5]) ? (string) $url[5] : null;
|
|
|
|
$newName = !empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$newName=urldecode($newName);
|
|
|
|
$newName=urldecode($newName);
|
|
|
|
|
|
|
|
|
|
|
|
if ($id != null && $newName != null){
|
|
|
|
if ($id != null && $newName != null){
|
|
|
|
$conversationgw->putConversation($id,$newName);
|
|
|
|
$conversationgw->putConversation($id,$newName);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 id or new name not given");
|
|
|
|
//header("HTTP/1.0 400 id or new name not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "addUserToConversation"){ // test : OK
|
|
|
|
elseif($method_name === "addUserToConversation"){ // test : OK
|
|
|
|
$idConv = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idConv = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$idUser = !empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
if ($idConv != null && $idUser != null){
|
|
|
|
if ($idConv != null && $idUser != null){
|
|
|
|
$conversationgw->addUserToConversation($idConv,$idUser);
|
|
|
|
$conversationgw->addUserToConversation($idConv,$idUser);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 id conv or id user not given");
|
|
|
|
//header("HTTP/1.0 400 id conv or id user not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "deleteUserFromConversation"){ // test : OK
|
|
|
|
elseif($method_name === "deleteUserFromConversation"){ // test : OK
|
|
|
|
$idConv = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idConv = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
$idUser = !empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
if ($idConv != null && $idUser != null){
|
|
|
|
if ($idConv != null && $idUser != null){
|
|
|
|
$conversationgw->deleteUserFromConversation($idConv,$idUser);
|
|
|
|
$conversationgw->deleteUserFromConversation($idConv,$idUser);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 id conv or id user not given");
|
|
|
|
//header("HTTP/1.0 400 id conv or id user not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "addMessageToConversation"){ // test : OK
|
|
|
|
elseif($method_name === "addMessageToConversation"){ // test : OK
|
|
|
|
$msg=!empty($url[4]) ? (string) $url[4] : null;
|
|
|
|
$msg=!empty($url[3]) ? (string) $url[3] : null;
|
|
|
|
$idSender=!empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$idSender=!empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$idConv=!empty($url[6]) ? (int) $url[6] : null;
|
|
|
|
$idConv=!empty($url[5]) ? (int) $url[5] : null;
|
|
|
|
$date=!empty($url[7]) ? (string) $url[7] : null;
|
|
|
|
$date=!empty($url[6]) ? (string) $url[6] : null;
|
|
|
|
$date=urldecode($date);
|
|
|
|
$date=urldecode($date);
|
|
|
|
$msg=urldecode($msg);
|
|
|
|
$msg=urldecode($msg);
|
|
|
|
|
|
|
|
|
|
|
@ -331,53 +331,53 @@
|
|
|
|
echo json_encode($id, JSON_PRETTY_PRINT);
|
|
|
|
echo json_encode($id, JSON_PRETTY_PRINT);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
} else{
|
|
|
|
} else{
|
|
|
|
header("HTTP/1.0 400 id conv or message or sender not given");
|
|
|
|
//header("HTTP/1.0 400 id conv or message or sender not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
http_response_code(401);
|
|
|
|
http_response_code(401);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'DELETE':
|
|
|
|
case 'DELETE':
|
|
|
|
if($method_name === "deleteUser"){ // test : OK
|
|
|
|
if($method_name === "deleteUser"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if($id!=null){
|
|
|
|
if($id!=null){
|
|
|
|
$usergw->deleteUser($id);
|
|
|
|
$usergw->deleteUser($id);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name == "deleteMatch"){ // test : OK
|
|
|
|
elseif($method_name == "deleteMatch"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if($id!=null){
|
|
|
|
if($id!=null){
|
|
|
|
$matchgw->deleteMatch($id);
|
|
|
|
$matchgw->deleteMatch($id);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($method_name === "deleteConversation"){ // test : OK
|
|
|
|
elseif($method_name === "deleteConversation"){ // test : OK
|
|
|
|
$id = !empty($url[4]) ? (int) $url[4] : null;
|
|
|
|
$id = !empty($url[3]) ? (int) $url[3] : null;
|
|
|
|
if($id!=null){
|
|
|
|
if($id!=null){
|
|
|
|
$conversationgw->deleteConversation($id);
|
|
|
|
$conversationgw->deleteConversation($id);
|
|
|
|
http_response_code(200);
|
|
|
|
http_response_code(200);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
header("HTTP/1.0 400 Id not given");
|
|
|
|
//header("HTTP/1.0 400 Id not given");
|
|
|
|
http_response_code(400);
|
|
|
|
http_response_code(400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
|
|
|
http_response_code(401);
|
|
|
|
http_response_code(401);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
default :
|
|
|
|
header("HTTP/1.0 405 Invalid request method");
|
|
|
|
//header("HTTP/1.0 405 Invalid request method");
|
|
|
|
http_response_code(405);
|
|
|
|
http_response_code(405);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|