Merge branch 'testDockerToto' into peristanceBDD
continuous-integration/drone/push Build is passing Details

peristanceBDD
Thomas Chazot 2 years ago
commit ab9da76344

@ -1,23 +1,93 @@
# database container deployment
# This file creates our 2 docker containers
kind: pipeline
name: BD
name: Dockers_Builder
# Creation of the DB docker
steps:
# database container deployment
- name: deploy-container-mysql
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: mysql
settings:
dockerfile: ./Dockerfile
context: .
IMAGENAME: mysql:latest
CONTAINERNAME: mysql
COMMAND: create
# OVERWRITE: false
#OVERWRITE: true
PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
from_secret: P@s$w0rd123
from_secret: MYSQL_ROOT_PASSWORD
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
from_secret: BDBOB
from_secret: MYSQL_DATABASE
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
from_secret: bob
from_secret: MYSQL_USER_TOM
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
from_secret: P@s$w0rd123
scripts:
- GRANT ALL PRIVILEGES ON *.* TO 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER'@'localhost' IDENTIFIED BY 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD';
from_secret: MYSQL_PASSWORD_TOM
ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours
# docker image build
- name: container-api
image: plugins/docker
settings:
dockerfile: ./api-rest/Dockerfile
context: .
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/bob_parteam/bob_party
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
#container deployment
- name: deploy-api-containers
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/bob_parteam/bob_party:latest
CONTAINERNAME: api-bobParty
COMMAND: create
OVERWRITE: true
#PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_DB_SERVER:
from_secret: db_server
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
from_secret: MYSQL_USER_TOM
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
from_secret: MYSQL_PASSWORD_TOM
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
from_secret: MYSQL_ROOT_PASSWORD
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
from_secret: MYSQL_DATABASE
ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours
depends_on: [ deploy-container-mysql, container-api ]
# # docker image build
# - name: docker-build-and-push
# image: plugins/docker
# settings:
# dockerfile: Dockerfile
# context: .
# registry: hub.codefirst.iut.uca.fr
# repo: hub.codefirst.iut.uca.fr/thomas.chazot2/bobparty
# username:
# from_secret: SECRET_REGISTRY_USERNAME_TOM
# password:
# from_secret: SECRET_REGISTRY_PASSWORD_TOM
# #container deployment
# - name: deploy-bob_party-container
# image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
# environment:
# IMAGENAME: hub.codefirst.iut.uca.fr/thomas.chazot2/bobparty:latest
# CONTAINERNAME: bob_party_container
# COMMAND: create
# OVERWRITE: true
# ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours,thomasbellembois

@ -0,0 +1,8 @@
FROM mysql:latest
COPY setup.sh /mysql/setup.sh
COPY bobParty.sql /mysql/bobParty.sql
RUN chmod +x /mysql/setup.sh
RUN /mysql/setup.sh

@ -0,0 +1,13 @@
FROM php:8.0-apache
RUN docker-php-ext-install mysqli pdo pdo_mysql
COPY api-rest/start-apache /usr/local/bin
RUN chmod 755 /usr/local/bin/start-apache
# Copy application source
ADD api-rest /var/www/html
RUN chown -R www-data:www-data /var/www/html
CMD ["start-apache"]

@ -1,4 +1,4 @@
[database]
dsn = "mysql:host=localhost;port=8888;dbname=bobParty"
username = "root"
password = "root";
dsn = "mysql:host=". getenv("db_server").";dbname=". getenv("MYSQL_DATABASE")
username = getenv("MYSQL_USER_TOM")
password = getenv("MYSQL_PASSWORD_TOM")

@ -1,33 +1,59 @@
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST,GET,DELETE,PUT');
/*
$conn = new mysqli("BOB_PARTEAM-mysql",getenv("MYSQL_USER"),getenv("MYSQL_PASSWORD"),getenv("MYSQL_DATABASE"));
$conn->query("DROP TABLE IF EXISTS `common_absences`;");
$conn->query("CREATE TABLE coucou (`COUCOU_ID` int(10) unsigned NOT NULL,`COUCOU_TEXT` char(10) NOT NULL);");
$res = $conn->query("SELECT * FROM coucou");
while ($une_valeur = $res->fetch_array()) {
echo $une_valeur["COUCOU_ID"]." ".$une_valeur["COUCOU_TEXT"];
}
exit;
*/
//require_once("initBdd.php");
//header('Access-Control-Allow-Origin: *');
//header('Access-Control-Allow-Methods: POST,GET,DELETE,PUT');
/// Good to know :
/// All the values must be cleaned on the application side before using this API
///
include ('dbConnection.php');
include ('gateways/userGateway.php');
include ('gateways/matchGateway.php');
include ('gateways/conversationGateway.php');
include ('gateways/gameGateway.php');
include ('gateways/skinGateway.php');
include (__DIR__ .'/gateways/userGateway.php');
include (__DIR__ .'/gateways/matchGateway.php');
include (__DIR__ .'/gateways/conversationGateway.php');
include (__DIR__ .'/gateways/gameGateway.php');
include (__DIR__ .'/gateways/skinGateway.php');
// Connection to database
// ------
// Comment faire un fichier .htaccess pour protéger ce fichier ?????????
// ------
$ini_array= parse_ini_file("config.ini");
//$ini_array= parse_ini_file("config.ini");
$dsn = "mysql:host=BOB_PARTEAM-mysql;dbname=" . getenv("MYSQL_DATABASE");
$username = getenv("MYSQL_USER");
$password = getenv("MYSQL_PASSWORD");
// Initializing Database
try{
$database = new DatabaseConnection($ini_array['dsn'],$ini_array['username'],$ini_array['password']);
$database = new DatabaseConnection($dsn,$username,$password);
} catch (PDOException $e) {
echo "ERROR connection";
header("HTTP/1.0 ".$e->getMessage());
echo $e->getMessage();
echo $dsn;
//header("HTTP/1.0 ".$e->getMessage());
http_response_code(600); // Quel code pour les erreurs PDO?
}
// Initializing Gateways
// ------
// Passer en mode objet ou rester en mode comportemental mais assumé ???
@ -48,151 +74,160 @@
$url = rtrim($request_uri,"/");
$url = filter_var($url, FILTER_SANITIZE_URL);
$url = explode('/', $url);
$method_name = !empty($url[3]) ? (string)$url[3] : null;
$i=0;
while ($url[$i]!=="index.php"){
unset($url[$i]);
$i++;
}
echo json_encode($url);
$method_name = !empty($url[2]) ? (string)$url[2] : null;
if($method_name == null){
header("HTTP/1.0 400 Request Name Empty");
//header("HTTP/1.0 400 Request Name Empty");
http_response_code(400);
}
switch ($request_method){
case 'GET':
if($method_name === "getUserById"){ // test : OK
if(empty($url[4])){
header("HTTP/1.0 400 Id not given");
if(empty($url[3])){
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
} else{
$id = (int)$url[4];
$id = (int)$url[3];
$user = $usergw->getUserById($id);
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($user, JSON_PRETTY_PRINT);
http_response_code(200);
}
}
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){
$user =$usergw->getUserByUsername($username);
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($user, JSON_PRETTY_PRINT);
} else{
header("HTTP/1.0 400 Username not given");
//header("HTTP/1.0 400 Username not given");
http_response_code(400);
}
}
elseif($method_name === "getUserForConnection"){ // test : OK
$username = !empty($url[4]) ? (string) $url[4] : null;
$password = !empty($url[5]) ? (string) $url[5] : null;
$username = !empty($url[3]) ? (string) $url[3] : null;
$password = !empty($url[4]) ? (string) $url[4] : null;
if ($username != null || $password != null){
$user =$usergw->getUserForConnection($username,$password);
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($user, JSON_PRETTY_PRINT);
http_response_code(200);
} 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);
}
}
elseif($method_name === "getSkins"){ // test : OK
$tabSkin = $skingw->getSkins();
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($tabSkin, JSON_PRETTY_PRINT);
http_response_code(200);
}
elseif($method_name === "getGames"){ // test : OK
$tabGame = $gamegw->getGames();
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($tabGame, JSON_PRETTY_PRINT);
http_response_code(200);
}
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){
$game = $gamegw->getGameById($id);
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($game, JSON_PRETTY_PRINT);
http_response_code(200);
} else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
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){
$match = $matchgw->getMatchById($id);
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($match, JSON_PRETTY_PRINT);
http_response_code(200);
} else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
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){
$conversations = $conversationgw->getConversations($id);
header('Content-Type: application/json');
//header('Content-Type: application/json');
echo json_encode($conversations, JSON_PRETTY_PRINT);
http_response_code(200);
} else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
else{
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
////header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401);
}
break;
case 'POST':
if($method_name === "postUser"){ // test : OK
if (count($url)<8){
header("HTTP/1.0 400 Invalid number of arguments");
if (count($url)<7){
//header("HTTP/1.0 400 Invalid number of arguments");
http_response_code(400);
}
$username = !empty($url[4]) ? (string) $url[4] : null;
$password = !empty($url[5]) ? (string) $url[5] : null;
$nationality = !empty($url[6]) ? (string) $url[6] : null;
$sex = !empty($url[7]) ? (string) $url[7] : null;
$dateOfBirth = !empty($url[8]) ? (string) $url[8] : null;
$username = !empty($url[3]) ? (string) $url[3] : null;
$password = !empty($url[4]) ? (string) $url[4] : null;
$nationality = !empty($url[5]) ? (string) $url[5] : null;
$sex = !empty($url[6]) ? (string) $url[6] : null;
$dateOfBirth = !empty($url[7]) ? (string) $url[7] : null;
$usergw->postUser($username,$password,$nationality,$sex,$dateOfBirth);
http_response_code(200);
}
elseif($method_name === "postMatch"){ // test : OK
$idGame = !empty($url[4]) ? (int) $url[4] : null;
$idCreator = !empty($url[5]) ? (int) $url[5] : null;
$idGame = !empty($url[3]) ? (int) $url[3] : null;
$idCreator = !empty($url[4]) ? (int) $url[4] : null;
if ($idGame != null || $idCreator != null){
$match =$matchgw->postMatch($idGame,$idCreator);
echo json_encode($match, JSON_PRETTY_PRINT);
http_response_code(200);
} 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);
}
}
elseif($method_name === "postConversation"){ // test : OK
$name = !empty($url[4]) ? (string) $url[4] : null;
$idList = !empty($url[5]) ? (array) explode(",",$url[5]) : null;
$name = !empty($url[3]) ? (string) $url[3] : null;
$idList = !empty($url[4]) ? (array) explode(",",$url[4]) : null;
$name=urldecode($name);
if ($name != null || $idList != null){
$id=$conversationgw->postConversation($name,$idList);
echo json_encode($id, JSON_PRETTY_PRINT);
http_response_code(200);
} 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);
}
}
else{
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401);
}
break;
case 'PUT':
if($method_name === "putUser"){ // test : OK
if (count($url)<12){
header("HTTP/1.0 400 Invalid number of arguments");
if (count($url)<11){
//header("HTTP/1.0 400 Invalid number of arguments");
http_response_code(400);
}
$id = !empty($url[4]) ? (int) $url[4] : null;
@ -208,87 +243,87 @@
http_response_code(200);
}
elseif($method_name === "putSkinList"){ // test : OK
$idUser = !empty($url[4]) ? (int) $url[4] : null;
$idSkin = !empty($url[5]) ? (int) $url[5] : null;
$idUser = !empty($url[3]) ? (int) $url[3] : null;
$idSkin = !empty($url[4]) ? (int) $url[4] : null;
if ($idUser != null || $idSkin != null){
$usergw->putSkinList($idUser,$idSkin);
http_response_code(200);
} 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);
}
}
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){
$matchgw->putMatch($id);
http_response_code(200);
} else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
elseif($method_name === "addUserToMatch"){ // test : OK
$idMatch = !empty($url[4]) ? (int) $url[4] : null;
$idUser = !empty($url[5]) ? (int) $url[5] : null;
$idMatch = !empty($url[3]) ? (int) $url[3] : null;
$idUser = !empty($url[4]) ? (int) $url[4] : null;
if ($idUser != null || $idMatch != null){
$matchgw->addUserToMatch($idMatch,$idUser);
http_response_code(200);
} 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);
}
}
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){
$matchgw->deleteUserFromMatch($idUser);
http_response_code(200);
} else{
header("HTTP/1.0 400 idUser not given");
//header("HTTP/1.0 400 idUser not given");
http_response_code(400);
}
}
elseif($method_name === "putConversation"){ // test : OK
$id = !empty($url[4]) ? (int) $url[4] : null;
$newName = !empty($url[5]) ? (string) $url[5] : null;
$id = !empty($url[3]) ? (int) $url[3] : null;
$newName = !empty($url[4]) ? (string) $url[4] : null;
$newName=urldecode($newName);
if ($id != null && $newName != null){
$conversationgw->putConversation($id,$newName);
http_response_code(200);
} 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);
}
}
elseif($method_name === "addUserToConversation"){ // test : OK
$idConv = !empty($url[4]) ? (int) $url[4] : null;
$idUser = !empty($url[5]) ? (int) $url[5] : null;
$idConv = !empty($url[3]) ? (int) $url[3] : null;
$idUser = !empty($url[4]) ? (int) $url[4] : null;
if ($idConv != null && $idUser != null){
$conversationgw->addUserToConversation($idConv,$idUser);
http_response_code(200);
} 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);
}
}
elseif($method_name === "deleteUserFromConversation"){ // test : OK
$idConv = !empty($url[4]) ? (int) $url[4] : null;
$idUser = !empty($url[5]) ? (int) $url[5] : null;
$idConv = !empty($url[3]) ? (int) $url[3] : null;
$idUser = !empty($url[4]) ? (int) $url[4] : null;
if ($idConv != null && $idUser != null){
$conversationgw->deleteUserFromConversation($idConv,$idUser);
http_response_code(200);
} 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);
}
}
elseif($method_name === "addMessageToConversation"){ // test : OK
$msg=!empty($url[4]) ? (string) $url[4] : null;
$idSender=!empty($url[5]) ? (int) $url[5] : null;
$idConv=!empty($url[6]) ? (int) $url[6] : null;
$date=!empty($url[7]) ? (string) $url[7] : null;
$msg=!empty($url[3]) ? (string) $url[3] : null;
$idSender=!empty($url[4]) ? (int) $url[4] : null;
$idConv=!empty($url[5]) ? (int) $url[5] : null;
$date=!empty($url[6]) ? (string) $url[6] : null;
$date=urldecode($date);
$msg=urldecode($msg);
@ -297,53 +332,53 @@
echo json_encode($id, JSON_PRETTY_PRINT);
http_response_code(200);
} 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);
}
}
else{
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401);
}
break;
case 'DELETE':
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){
$usergw->deleteUser($id);
http_response_code(200);
}else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
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){
$matchgw->deleteMatch($id);
http_response_code(200);
}else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
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){
$conversationgw->deleteConversation($id);
http_response_code(200);
}else{
header("HTTP/1.0 400 Id not given");
//header("HTTP/1.0 400 Id not given");
http_response_code(400);
}
}
else{
header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401);
}
break;
default :
header("HTTP/1.0 405 Invalid request method");
//header("HTTP/1.0 405 Invalid request method");
http_response_code(405);
break;
}

@ -0,0 +1,210 @@
<?php
$conn = new mysqli("BOB_PARTEAM-mysql",getenv("MYSQL_USER"),getenv("MYSQL_PASSWORD"),getenv("MYSQL_DATABASE"));
$conn->query("CREATE TABLE `T_J_OWN_SKIN_OWN` (
`FK_USER` int(11) NOT NULL,
`FK_SKIN` int(11) NOT NULL
); ");
$conn->query("CREATE TABLE `T_E_GAME_GAM` (
`PK_ID` int(11) NOT NULL,
`GAM_NAME` varchar(50) DEFAULT NULL,
`GAM_IMAGE` varchar(200) DEFAULT NULL,
`GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL,
`GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL,
`GAM_TYPE` varchar(50) NOT NULL
);");
$conn->query("CREATE TABLE `T_E_MATCH_MTC` (
`PK_ID` int(11) NOT NULL,
`MTC_IN_GAME` tinyint(1) DEFAULT NULL,
`FK_GAME` int(11) DEFAULT NULL
);");
$conn->query("CREATE TABLE `T_H_CONVERSATION_COV` (
`PK_ID` int(11) NOT NULL,
`COV_NAME` varchar(20) DEFAULT NULL
) ;");
$conn->query("CREATE TRIGGER `before_delete_conversation` BEFORE DELETE ON `T_H_CONVERSATION_COV` FOR EACH ROW DELETE FROM T_H_MESSAGE_MSG WHERE PK_ID = (SELECT FK_MESSAGE
FROM T_J_CONTAIN_MESSAGE_CMG
WHERE FK_CONVERSATION=OLD.PK_ID);");
$conn->query("CREATE TABLE `T_H_MESSAGE_MSG` (
`PK_ID` int(11) NOT NULL,
`MSG_MESSAGE` text,
`FK_SENDER` int(11) DEFAULT NULL,
`MSG_DATEENVOIE` datetime NOT NULL
);");
$conn->query("CREATE TABLE `T_H_SKIN_SKI` (
`PK_ID` int(11) NOT NULL,
`SKI_NAME` varchar(50) NOT NULL,
`SKI_IMAGE` varchar(200) NOT NULL,
`SKI_PRICE` varchar(30) DEFAULT NULL
);");
$conn->query("CREATE TABLE `T_J_CONTAIN_MESSAGE_CMG` (
`FK_CONVERSATION` int(11) NOT NULL,
`FK_MESSAGE` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_J_DISCUSS_DIS` (
`FK_USER` int(11) NOT NULL,
`FK_CONVERSATION` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_J_GAME_MAP_GMP` (
`FK_GAME` int(11) NOT NULL,
`GMP_KEY` int(11) NOT NULL,
`GMP_VALUE` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_J_PLAY_MATCH_PLM` (
`FK_USER` int(11) NOT NULL,
`FK_MATCH` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_S_USER_USR` (
`PK_ID` int(11) NOT NULL,
`USR_USERNAME` varchar(50) NOT NULL,
`USR_PASSWORD` varchar(50) NOT NULL,
`USR_NATIONALITY` varchar(20) NOT NULL,
`USR_SEX` varchar(30) NOT NULL,
`USR_DATE_OF_BIRTH` date DEFAULT NULL,
`USR_CURRENT_NB_COINS` int(11) DEFAULT '0',
`USR_TOTAL_NB_COINS` int(11) DEFAULT '0',
`USR_NB_GAMES_PLAYED` int(11) DEFAULT '0',
`FK_CURRENT_SKIN` int(11) DEFAULT '1'
);");
$conn->query("CREATE TRIGGER `after_insert_user` AFTER INSERT ON `T_S_USER_USR` FOR EACH ROW INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1);");
$conn->query("ALTER TABLE `T_E_GAME_GAM`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`);");
$conn->query("ALTER TABLE `T_E_MATCH_MTC`
ADD PRIMARY KEY (`PK_ID`),
ADD KEY `FK_GAME` (`FK_GAME`);");
$conn->query("ALTER TABLE `T_H_CONVERSATION_COV`
ADD PRIMARY KEY (`PK_ID`);");
$conn->query("ALTER TABLE `T_H_MESSAGE_MSG`
ADD PRIMARY KEY (`PK_ID`),
ADD KEY `FK_SENDER` (`FK_SENDER`);");
$conn->query("ALTER TABLE `T_H_SKIN_SKI`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `SKI_NAME` (`SKI_NAME`),
ADD UNIQUE KEY `SKI_IMAGE` (`SKI_IMAGE`);");
$conn->query("ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
ADD PRIMARY KEY (`FK_CONVERSATION`,`FK_MESSAGE`),
ADD KEY `FK_MESSAGE` (`FK_MESSAGE`);");
$conn->query("ALTER TABLE `T_J_DISCUSS_DIS`
ADD PRIMARY KEY (`FK_USER`,`FK_CONVERSATION`),
ADD KEY `FK_CONVERSATION` (`FK_CONVERSATION`);");
$conn->query("ALTER TABLE `T_J_GAME_MAP_GMP`
ADD PRIMARY KEY (`FK_GAME`,`GMP_KEY`,`GMP_VALUE`);");
$conn->query("ALTER TABLE `T_J_OWN_SKIN_OWN`
ADD PRIMARY KEY (`FK_SKIN`,`FK_USER`),
ADD KEY `FK_USER` (`FK_USER`);");
$conn->query("ALTER TABLE `T_J_PLAY_MATCH_PLM`
ADD PRIMARY KEY (`FK_USER`,`FK_MATCH`),
ADD KEY `FK_MATCH` (`FK_MATCH`);");
$conn->query("ALTER TABLE `T_S_USER_USR`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `USR_USERNAME` (`USR_USERNAME`),
ADD KEY `FK_CURRENT_SKIN` (`FK_CURRENT_SKIN`);");
$conn->query("ALTER TABLE `T_E_GAME_GAM`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_E_MATCH_MTC`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_H_CONVERSATION_COV`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_H_MESSAGE_MSG`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_H_SKIN_SKI`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_S_USER_USR`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_E_MATCH_MTC`
ADD CONSTRAINT `t_e_match_mtc_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);");
$conn->query("ALTER TABLE `T_H_MESSAGE_MSG`
ADD CONSTRAINT `t_h_message_msg_ibfk_1` FOREIGN KEY (`FK_SENDER`) REFERENCES `T_S_USER_USR` (`PK_ID`);");
$conn->query("ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_1` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_2` FOREIGN KEY (`FK_MESSAGE`) REFERENCES `T_H_MESSAGE_MSG` (`PK_ID`) ON DELETE CASCADE;");
$conn->query("ALTER TABLE `T_J_DISCUSS_DIS`
ADD CONSTRAINT `t_j_discuss_dis_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_discuss_dis_ibfk_2` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE;");
$conn->query("ALTER TABLE `T_J_GAME_MAP_GMP`
ADD CONSTRAINT `t_j_game_map_gmp_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);");
$conn->query("ALTER TABLE `T_J_OWN_SKIN_OWN`
ADD CONSTRAINT `t_j_own_skin_own_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_own_skin_own_ibfk_2` FOREIGN KEY (`FK_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);");
$conn->query("ALTER TABLE `T_J_PLAY_MATCH_PLM`
ADD CONSTRAINT `t_j_play_match_plm_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_play_match_plm_ibfk_2` FOREIGN KEY (`FK_MATCH`) REFERENCES `T_E_MATCH_MTC` (`PK_ID`) ON DELETE CASCADE;");
$conn->query("ALTER TABLE `T_S_USER_USR`
ADD CONSTRAINT `t_s_user_usr_ibfk_1` FOREIGN KEY (`FK_CURRENT_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);");
$conn->query("INSERT INTO `T_J_GAME_MAP_GMP` (`FK_GAME`, `GMP_KEY`, `GMP_VALUE`) VALUES
(1, 0, 0),
(1, 100, 25),
(1, 1000, 30),
(1, 10000, 40),
(1, 100000, 50),
(1, 1000000, 75),
(2, 0, 5),
(3, 0, 0),
(3, 1, 25),
(3, 2, 50);");
$conn->query("INSERT INTO `T_H_SKIN_SKI` (`PK_ID`, `SKI_NAME`, `SKI_IMAGE`, `SKI_PRICE`) VALUES
(1, 'Bob', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png', '0'),
(2, 'Bob blue', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png', '100'),
(3, 'Bob green', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobGreen.png', '100'),
(4, 'Bob BW', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBW.png', '100');");
$conn->query("INSERT INTO `T_E_GAME_GAM` (`PK_ID`, `GAM_NAME`, `GAM_IMAGE`, `GAM_NB_PLAYER_MIN`, `GAM_NB_PLAYER_MAX`, `GAM_TYPE`) VALUES
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.png', 1, 1, 'GameSolo'),
(2, 'TicTacToe', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 1, 1, 'GameSolo'),
(3, 'TicTacToe Online', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 2, 2, 'GameMulti'),
(4, 'BlackJack', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg', 1, 1, 'GameCasino');");
$conn->query("INSERT INTO `T_S_USER_USR` (`PK_ID`, `USR_USERNAME`, `USR_PASSWORD`, `USR_NATIONALITY`, `USR_SEX`, `USR_DATE_OF_BIRTH`, `USR_CURRENT_NB_COINS`, `USR_TOTAL_NB_COINS`, `USR_NB_GAMES_PLAYED`, `FK_CURRENT_SKIN`) VALUES
(1, 'to', 't', 'Anglais(e)', 'M', '2003-07-01', 105, 230, 12, 2);");
?>

@ -0,0 +1,4 @@
#!/usr/bin/env bash
sed -i "s/Listen 80/Listen ${PORT:-80}/g" /etc/apache2/ports.conf
sed -i "s/:80/:${PORT:-80}/g" /etc/apache2/sites-enabled/*
apache2-foreground

@ -0,0 +1,5 @@
<php?
echo "coucou";
?>

@ -33,6 +33,7 @@ CREATE TABLE `T_E_GAME_GAM` (
`GAM_IMAGE` varchar(200) DEFAULT NULL,
`GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL,
`GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL,
`GAM_TYPE` varchar(50) NOT NULL,
`GAM_TYPE` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -46,6 +47,16 @@ INSERT INTO `T_E_GAME_GAM` (`PK_ID`, `GAM_NAME`, `GAM_IMAGE`, `GAM_NB_PLAYER_MIN
(3, 'TicTacToe Online', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 2, 2, 'GameMulti'),
(4, 'BlackJack', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg', 1, 1, 'GameCasino');
--
-- Déchargement des données de la table `T_E_GAME_GAM`
--
INSERT INTO `T_E_GAME_GAM` (`PK_ID`, `GAM_NAME`, `GAM_IMAGE`, `GAM_NB_PLAYER_MIN`, `GAM_NB_PLAYER_MAX`, `GAM_TYPE`) VALUES
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.png', 1, 1, 'GameSolo'),
(2, 'TicTacToe', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 1, 1, 'GameSolo'),
(3, 'TicTacToe Online', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 2, 2, 'GameMulti'),
(4, 'BlackJack', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg', 1, 1, 'GameCasino');
-- --------------------------------------------------------
--
@ -74,7 +85,12 @@ CREATE TABLE `T_H_CONVERSATION_COV` (
--
INSERT INTO `T_H_CONVERSATION_COV` (`PK_ID`, `COV_NAME`) VALUES
(32, 'Wesh la conv');
(32, 'Wesh la conv'),
(33, 'bonjour'),
(34, 'bony'),
(35, 'la conversation'),
(36, 'fratitude'),
(37, 'coucouuuuuuuuu');
--
-- Déclencheurs `T_H_CONVERSATION_COV`
@ -116,7 +132,16 @@ INSERT INTO `T_H_MESSAGE_MSG` (`PK_ID`, `MSG_MESSAGE`, `FK_SENDER`, `MSG_DATEENV
(64, 'Cc', 2, '2022-12-30 11:21:06'),
(65, 'Bonjour', 2, '2022-12-30 11:24:58'),
(66, 'Hé ho', 2, '2022-12-30 11:25:02'),
(68, 'Salut ça va marcher', 1, '2022-12-30 11:55:21');
(68, 'Salut ça va marcher', 1, '2022-12-30 11:55:21'),
(69, 'Bonjour', 1, '2023-01-04 14:24:12'),
(70, 'to created a conversation', 1, '2023-01-04 22:39:07'),
(71, 'Salut !!!', 2, '2023-01-04 22:42:01'),
(72, 'leilla20 created a conversation', 2, '2023-01-04 22:42:16'),
(73, 'to created a conversation', 1, '2023-01-04 22:44:07'),
(74, 'Salut les bags', 1, '2023-01-04 22:44:16'),
(75, 'to created a conversation', 1, '2023-01-05 08:15:50'),
(76, 'Wesh les fratés', 2, '2023-01-05 08:16:18'),
(77, 'to created a conversation', 1, '2023-01-05 08:25:54');
-- --------------------------------------------------------
@ -169,7 +194,16 @@ INSERT INTO `T_J_CONTAIN_MESSAGE_CMG` (`FK_CONVERSATION`, `FK_MESSAGE`) VALUES
(32, 64),
(32, 65),
(32, 66),
(32, 68);
(32, 68),
(32, 69),
(33, 70),
(33, 71),
(34, 72),
(35, 73),
(35, 74),
(36, 75),
(36, 76),
(37, 77);
-- --------------------------------------------------------
@ -237,13 +271,16 @@ INSERT INTO `T_J_OWN_SKIN_OWN` (`FK_USER`, `FK_SKIN`) VALUES
(1, 1),
(1, 2),
(1, 3),
(1, 4),
(2, 1),
(2, 2),
(3, 1),
(6, 1),
(7, 1),
(8, 1),
(10, 1),
(11, 1),
(12, 1),
(12, 1);
-- --------------------------------------------------------
@ -289,6 +326,7 @@ INSERT INTO `T_S_USER_USR` (`PK_ID`, `USR_USERNAME`, `USR_PASSWORD`, `USR_NATION
(8, 'Marche', 'je45tE**', 'Anglais(e)', 'Femme', '1999-12-27', 0, 0, 0, 1),
(10, 'dsqdz', 'AEZQzze1*', 'Francais(e)', 'null', '2005-12-27', 0, 0, 0, 1),
(11, 'qdsqdz', 'dqzA12****', 'Francais(e)', 'Homme', '2002-12-27', 0, 0, 0, 1),
(12, 'thilde', 'coucoulesnazes*M0', 'Francais(e)', 'Femme', '2004-11-02', 0, 0, 0, 1),
(12, 'thilde', 'coucoulesnazes*M0', 'Francais(e)', 'Femme', '2004-11-02', 0, 0, 0, 1);
--
@ -358,6 +396,12 @@ ALTER TABLE `T_J_DISCUSS_DIS`
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD PRIMARY KEY (`FK_GAME`,`GMP_KEY`,`GMP_VALUE`) USING BTREE;
--
-- Index pour la table `T_J_GAME_MAP_GMP`
--
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD PRIMARY KEY (`FK_GAME`,`GMP_KEY`,`GMP_VALUE`) USING BTREE;
--
-- Index pour la table `T_J_OWN_SKIN_OWN`
--
@ -406,7 +450,7 @@ ALTER TABLE `T_H_CONVERSATION_COV`
-- AUTO_INCREMENT pour la table `T_H_MESSAGE_MSG`
--
ALTER TABLE `T_H_MESSAGE_MSG`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69;
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=78;
--
-- AUTO_INCREMENT pour la table `T_H_SKIN_SKI`
@ -456,6 +500,12 @@ ALTER TABLE `T_J_DISCUSS_DIS`
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD CONSTRAINT `t_j_game_map_gmp_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);
--
-- Contraintes pour la table `T_J_GAME_MAP_GMP`
--
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD CONSTRAINT `t_j_game_map_gmp_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);
--
-- Contraintes pour la table `T_J_OWN_SKIN_OWN`
--

@ -0,0 +1,5 @@
#!/bin/bash
set -e
service mysql start
mysql < /mysql/bobParty.sql
service mysql stop
Loading…
Cancel
Save