diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index f545e92..09b1c77 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -13,10 +13,10 @@ "state": { "type": "pdf", "state": { - "file": "ISEN/Web/CIPA 4/TP/TP4/tp4.pdf" + "file": "ISEN/Web/CIPA 4/TP/TP5/tp5.pdf" }, "icon": "lucide-file-text", - "title": "tp4" + "title": "tp5" } } ] @@ -194,23 +194,25 @@ }, "active": "e11a6a080eb83632", "lastOpenFiles": [ - "ISEN/Web/CIPA 4/TP/TP4/process_f2.php", - "ISEN/Web/CIPA 4/TP/TP4/process_f1.php", - "ISEN/Web/CIPA 4/TP/TP4/test.php", - "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/Crypto Cours 2.md", + "ISEN/Web/CIPA 4/TP/TP5/docker-compose.yml", + "ISEN/Web/CIPA 4/TP/TP5/query.sql", + "ISEN/Web/CIPA 4/TP/TP5/php/chat.php", + "ISEN/Web/CIPA 4/TP/TP5/php/database.php", + "ISEN/Web/CIPA 4/TP/TP5/php/constants.php", + "ISEN/Web/CIPA 4/TP/TP5/php", + "ISEN/Web/CIPA 4/TP/TP5/sql/model.sql", + "ISEN/Web/CIPA 4/TP/TP5/sql/data.sql", + "ISEN/Web/CIPA 4/TP/TP5/sql", + "ISEN/Web/CIPA 4/TP/TP5/MPD.png", + "ISEN/Web/CIPA 4/TP/TP5/MCD.png", + "ISEN/Web/CIPA 4/TP/TP5/MCD.mcd", "ISEN/Web/CIPA 4/TP/TP4/tp4.pdf", - "ISEN/Web/CIPA 4/TP/TP4/tp4.php", + "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/Crypto Cours 2.md", "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/Crypto Cours 1.md", "ISEN/Réunion/CIPA 3/Rentrée 2024-25.md", - "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/tables_gf256.res", - "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/20250708_CRYPTO_slides.pdf", - "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/20250708_CRYPTO_exos_avec_corriges.pdf", - "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/20011126_fips-197.pdf", "ISEN/Réunion/CIPA 3/Départ en entreprise 1 20-09-2024.md", - "ISEN/Réunion/CIPA 3/CR Conseil de scolarité S6.pdf", "ISEN/Réunion/CIPA 3/CR Conseil de scolarité S6.md", "ISEN/Sécurité IOT/CIPA4/Sécurité IOT Cours 1.md", - "ISEN/Traitement du signal/CIPA4/TP/TP4/~WRL0001.tmp", "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/Cyber Cours 2.md", "ISEN/Introduction a la cyber et a la cryptographie/CIPA 4/Cyber Cours 1.md", "ISEN/Réunion/CIPA 4/Réunion international.md", @@ -241,8 +243,6 @@ "src/Pasted image 20240123120807.png", "ISEN/Réseau/A2/TP Ansible et docker.canvas", "ISEN/BDD/CIR2/TD2.canvas", - "Pasted image 20250905143950.png", - "Pasted image 20250905144746.png", "ISEN/Modelec/NB point.canvas", "Untitled.canvas", "ISEN/Other/Graph Overseer.canvas", diff --git a/ISEN/Web/CIPA 4/TP/TP5/MCD.mcd b/ISEN/Web/CIPA 4/TP/TP5/MCD.mcd new file mode 100644 index 0000000..d0f2129 Binary files /dev/null and b/ISEN/Web/CIPA 4/TP/TP5/MCD.mcd differ diff --git a/ISEN/Web/CIPA 4/TP/TP5/MCD.png b/ISEN/Web/CIPA 4/TP/TP5/MCD.png new file mode 100644 index 0000000..6f9744f Binary files /dev/null and b/ISEN/Web/CIPA 4/TP/TP5/MCD.png differ diff --git a/ISEN/Web/CIPA 4/TP/TP5/MPD.png b/ISEN/Web/CIPA 4/TP/TP5/MPD.png new file mode 100644 index 0000000..4982606 Binary files /dev/null and b/ISEN/Web/CIPA 4/TP/TP5/MPD.png differ diff --git a/ISEN/Web/CIPA 4/TP/TP5/docker-compose.yml b/ISEN/Web/CIPA 4/TP/TP5/docker-compose.yml new file mode 100644 index 0000000..25db2a4 --- /dev/null +++ b/ISEN/Web/CIPA 4/TP/TP5/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' +services: + db: + image: postgres:17 + environment: + POSTGRES_DB: devweb + POSTGRES_USER: postgres + POSTGRES_PASSWORD: a + ports: + - "5432:5432" + volumes: + - ./sql:/docker-entrypoint-initdb.d diff --git a/ISEN/Web/CIPA 4/TP/TP5/php/chat.php b/ISEN/Web/CIPA 4/TP/TP5/php/chat.php new file mode 100644 index 0000000..14f6974 --- /dev/null +++ b/ISEN/Web/CIPA 4/TP/TP5/php/chat.php @@ -0,0 +1,15 @@ + diff --git a/ISEN/Web/CIPA 4/TP/TP5/php/constants.php b/ISEN/Web/CIPA 4/TP/TP5/php/constants.php new file mode 100644 index 0000000..9f9e005 --- /dev/null +++ b/ISEN/Web/CIPA 4/TP/TP5/php/constants.php @@ -0,0 +1,6 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + return $pdo; + } catch (PDOException $e) { + return false; + } +} + +function dbGetChannels($db) { + try { + $query = "SELECT * FROM channels"; + $statement = $db->query($query); + $channels = $statement->fetchAll(PDO::FETCH_ASSOC); + return $channels; + } catch (PDOException $e) { + return false; + } +} diff --git a/ISEN/Web/CIPA 4/TP/TP5/query.sql b/ISEN/Web/CIPA 4/TP/TP5/query.sql new file mode 100644 index 0000000..82c8c68 --- /dev/null +++ b/ISEN/Web/CIPA 4/TP/TP5/query.sql @@ -0,0 +1,3 @@ +-- Requête pour la liste des salons (channels) (Step 9) +SELECT * FROM channels; + diff --git a/ISEN/Web/CIPA 4/TP/TP5/sql/data.sql b/ISEN/Web/CIPA 4/TP/TP5/sql/data.sql new file mode 100644 index 0000000..103a5e3 --- /dev/null +++ b/ISEN/Web/CIPA 4/TP/TP5/sql/data.sql @@ -0,0 +1,31 @@ + +DELETE FROM users; +DELETE FROM channels; +DELETE FROM messages; + +-- ------------------------------------------------------------------------------- +-- --- Populate users database ---------------------------------------------------------------------------------------------------------------------------------- +INSERT INTO users(login, nickname, password) VALUES('etudiant0', 'E0','mp0'); +INSERT INTO users(login, nickname, password) VALUES('etudiant1', 'E1','mp1'); +INSERT INTO users(login, nickname, password) VALUES('etudiant2', 'E2','mp2'); +INSERT INTO users(login, nickname, password) VALUES('etudiant3', 'E3','mp3'); + +-- ------------------------------------------------------------------------------- +-- --- Populate channels database --------------------------------------------------- +-- ------------------------------------------------------------------------------- +ALTER SEQUENCE channels_id_seq RESTART; +INSERT INTO channels(name) VALUES('General'); +INSERT INTO channels(name) VALUES('Musique'); +INSERT INTO channels(name) VALUES('Voyage'); +INSERT INTO channels(name) VALUES('Cinema'); +INSERT INTO channels(name) VALUES('Bricolage'); + +------------------------------------------------------------------------------- +--- Populate messages database ------------------------------------------------ +------------------------------------------------------------------------------- +ALTER SEQUENCE messages_id_seq RESTART; +INSERT INTO messages(userLogin, channelid, message) VALUES('etudiant0', 1, 'a'); +INSERT INTO messages(userLogin, channelid, message) VALUES('etudiant1', 1, 'b'); +INSERT INTO messages(userLogin, channelid, message) VALUES('etudiant0', 1, 'c'); +INSERT INTO messages(userLogin, channelid, message) VALUES('etudiant2', 3, 'd'); +INSERT INTO messages(userLogin, channelid, message) VALUES('etudiant3', 4, 'e'); diff --git a/ISEN/Web/CIPA 4/TP/TP5/sql/model.sql b/ISEN/Web/CIPA 4/TP/TP5/sql/model.sql new file mode 100644 index 0000000..a35b377 --- /dev/null +++ b/ISEN/Web/CIPA 4/TP/TP5/sql/model.sql @@ -0,0 +1,37 @@ + +-- USE devweb_m1; + +DROP TABLE IF EXISTS messages; +DROP TABLE IF EXISTS channels; +DROP TABLE IF EXISTS users; + +CREATE TABLE users +( + login VARCHAR(20) PRIMARY KEY, + nickname VARCHAR(20) NOT NULL, + password VARCHAR(40) NOT NULL +); + + +CREATE TABLE channels +( + id SERIAL PRIMARY KEY, + name VARCHAR(20) NOT NULL +); + + +CREATE TABLE messages +( + id SERIAL PRIMARY KEY, + userLogin VARCHAR(20) NOT NULL, + channelId INT NOT NULL, + message VARCHAR(256) NOT NULL, + timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP, + FOREIGN KEY(userLogin) REFERENCES users(login) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY(channelId) REFERENCES channels(id) + ON UPDATE CASCADE ON DELETE CASCADE +); + + + diff --git a/ISEN/Web/CIPA 4/TP/TP5/tp5.pdf b/ISEN/Web/CIPA 4/TP/TP5/tp5.pdf new file mode 100644 index 0000000..a75965d Binary files /dev/null and b/ISEN/Web/CIPA 4/TP/TP5/tp5.pdf differ