mirror of
https://github.com/BreizhHardware/cours-ISEN-MD.git
synced 2026-03-18 21:50:46 +01:00
Obisidian vault auto-backup: 27-01-2026 11:43:39 on . 12 files edited
This commit is contained in:
30
.obsidian/workspace.json
vendored
30
.obsidian/workspace.json
vendored
@@ -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",
|
||||
|
||||
BIN
ISEN/Web/CIPA 4/TP/TP5/MCD.mcd
Normal file
BIN
ISEN/Web/CIPA 4/TP/TP5/MCD.mcd
Normal file
Binary file not shown.
BIN
ISEN/Web/CIPA 4/TP/TP5/MCD.png
Normal file
BIN
ISEN/Web/CIPA 4/TP/TP5/MCD.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
ISEN/Web/CIPA 4/TP/TP5/MPD.png
Normal file
BIN
ISEN/Web/CIPA 4/TP/TP5/MPD.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
12
ISEN/Web/CIPA 4/TP/TP5/docker-compose.yml
Normal file
12
ISEN/Web/CIPA 4/TP/TP5/docker-compose.yml
Normal file
@@ -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
|
||||
15
ISEN/Web/CIPA 4/TP/TP5/php/chat.php
Normal file
15
ISEN/Web/CIPA 4/TP/TP5/php/chat.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require_once 'database.php';
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$db = dbConnect();
|
||||
|
||||
if (isset($_GET['request']) && $_GET['request'] == 'channels') {
|
||||
$channels = dbGetChannels($db);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($channels);
|
||||
}
|
||||
?>
|
||||
6
ISEN/Web/CIPA 4/TP/TP5/php/constants.php
Normal file
6
ISEN/Web/CIPA 4/TP/TP5/php/constants.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
define('DB_USER', 'postgres');
|
||||
define('DB_PASSWORD', 'a');
|
||||
define('DB_NAME', 'devweb');
|
||||
define('DB_SERVER', '127.0.0.1');
|
||||
define('DB_PORT', '5432');
|
||||
24
ISEN/Web/CIPA 4/TP/TP5/php/database.php
Normal file
24
ISEN/Web/CIPA 4/TP/TP5/php/database.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once 'constants.php';
|
||||
|
||||
function dbConnect() {
|
||||
$dsn = 'pgsql:dbname=' . DB_NAME . ';host=' . DB_SERVER . ';port=' . DB_PORT;
|
||||
try {
|
||||
$pdo = new PDO($dsn, DB_USER, DB_PASSWORD);
|
||||
$pdo->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;
|
||||
}
|
||||
}
|
||||
3
ISEN/Web/CIPA 4/TP/TP5/query.sql
Normal file
3
ISEN/Web/CIPA 4/TP/TP5/query.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
-- Requête pour la liste des salons (channels) (Step 9)
|
||||
SELECT * FROM channels;
|
||||
|
||||
31
ISEN/Web/CIPA 4/TP/TP5/sql/data.sql
Normal file
31
ISEN/Web/CIPA 4/TP/TP5/sql/data.sql
Normal file
@@ -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');
|
||||
37
ISEN/Web/CIPA 4/TP/TP5/sql/model.sql
Normal file
37
ISEN/Web/CIPA 4/TP/TP5/sql/model.sql
Normal file
@@ -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
|
||||
);
|
||||
|
||||
|
||||
|
||||
BIN
ISEN/Web/CIPA 4/TP/TP5/tp5.pdf
Normal file
BIN
ISEN/Web/CIPA 4/TP/TP5/tp5.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user