From a32bec9a7e60a707de8560b9fe2a087f295a7311 Mon Sep 17 00:00:00 2001 From: Juan Date: Tue, 15 Mar 2022 23:37:46 +0100 Subject: [PATCH] session updates and evaluation database --- b1-bak/evaluation/b1evaluation.sql | 77 ++++++++++++++++++++++++++++++++++++++ b1-bak/session2/blog/exercice.txt | 5 +++ b1-bak/session4/api/.htaccess | 15 ++++++++ b1-bak/session4/api/README.md | 1 + b1-bak/session4/api/ajax.php | 24 ++++++++++++ b1-bak/session4/api/appel.php | 17 +++++++++ b1-bak/session4/api/curl.php | 30 +++++++++++++++ b1-bak/session4/api/index.php | 30 +++++++++++++++ 8 files changed, 199 insertions(+) create mode 100644 b1-bak/evaluation/b1evaluation.sql create mode 100644 b1-bak/session4/api/.htaccess create mode 100644 b1-bak/session4/api/README.md create mode 100644 b1-bak/session4/api/ajax.php create mode 100644 b1-bak/session4/api/appel.php create mode 100644 b1-bak/session4/api/curl.php create mode 100644 b1-bak/session4/api/index.php diff --git a/b1-bak/evaluation/b1evaluation.sql b/b1-bak/evaluation/b1evaluation.sql new file mode 100644 index 0000000..495d45d --- /dev/null +++ b/b1-bak/evaluation/b1evaluation.sql @@ -0,0 +1,77 @@ +-- phpMyAdmin SQL Dump +-- version 5.1.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Mar 15, 2022 at 11:33 PM +-- Server version: 10.4.22-MariaDB +-- PHP Version: 7.4.27 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `b1evaluation` +-- +CREATE DATABASE IF NOT EXISTS `b1evaluation` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `b1evaluation`; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `passagers` +-- + +DROP TABLE IF EXISTS `passagers`; +CREATE TABLE IF NOT EXISTS `passagers` ( + `id_passager` int(11) NOT NULL AUTO_INCREMENT, + `nom` varchar(255) NOT NULL, + `prenom` varchar(255) NOT NULL, + `age` int(11) NOT NULL, + `siege` varchar(4) NOT NULL, + `vol_id` int(11) NOT NULL, + PRIMARY KEY (`id_passager`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `passagers` +-- + +INSERT INTO `passagers` (`id_passager`, `nom`, `prenom`, `age`, `siege`, `vol_id`) VALUES +(1, 'Welma', 'Roucier', 68, 'b047', 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `vol` +-- + +DROP TABLE IF EXISTS `vol`; +CREATE TABLE IF NOT EXISTS `vol` ( + `id_vol` int(11) NOT NULL AUTO_INCREMENT, + `de` varchar(255) NOT NULL, + `a` varchar(255) NOT NULL, + `via` varchar(255) NOT NULL, + `places` int(11) NOT NULL, + `reservations` int(11) NOT NULL, + PRIMARY KEY (`id_vol`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `vol` +-- + +INSERT INTO `vol` (`id_vol`, `de`, `a`, `via`, `places`, `reservations`) VALUES +(1, 'Prague', 'Cork', 'Rennes', 25, 11); +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/b1-bak/session2/blog/exercice.txt b/b1-bak/session2/blog/exercice.txt index fd66028..f8ff28d 100644 --- a/b1-bak/session2/blog/exercice.txt +++ b/b1-bak/session2/blog/exercice.txt @@ -30,4 +30,9 @@ commentaire --------- Construire une authentification +faire un page login.php contenant un formulaire +de connexion + +aller vérifier en base qiue l'utilisteur saisi +existe dans la base de données diff --git a/b1-bak/session4/api/.htaccess b/b1-bak/session4/api/.htaccess new file mode 100644 index 0000000..861c8d8 --- /dev/null +++ b/b1-bak/session4/api/.htaccess @@ -0,0 +1,15 @@ +# si le module mod-rewrite est activé + + # init du moteur + RewriteEngine On + # url de départ de l'api + RewriteBase / + # si ce n'est pas index.php + RewriteRule ^index\.php$ - [L] + # si le fichier existe pas + RewriteCond %{REQUEST_FILENAME} !-f + # si le dossier existe pas + RewriteCond %{REQUEST_FILENAME} !-d + # je renvoie vers l'index de lapi + RewriteRule . /b1api/index.php [L] + \ No newline at end of file diff --git a/b1-bak/session4/api/README.md b/b1-bak/session4/api/README.md new file mode 100644 index 0000000..5932792 --- /dev/null +++ b/b1-bak/session4/api/README.md @@ -0,0 +1 @@ +# API diff --git a/b1-bak/session4/api/ajax.php b/b1-bak/session4/api/ajax.php new file mode 100644 index 0000000..2eb63d8 --- /dev/null +++ b/b1-bak/session4/api/ajax.php @@ -0,0 +1,24 @@ + + + + + jQuery Query + + + + + + \ No newline at end of file diff --git a/b1-bak/session4/api/appel.php b/b1-bak/session4/api/appel.php new file mode 100644 index 0000000..76ef25d --- /dev/null +++ b/b1-bak/session4/api/appel.php @@ -0,0 +1,17 @@ + + + + + Réservation (saisie) + + +

Réserver pour ?

+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/b1-bak/session4/api/curl.php b/b1-bak/session4/api/curl.php new file mode 100644 index 0000000..ffd3a8f --- /dev/null +++ b/b1-bak/session4/api/curl.php @@ -0,0 +1,30 @@ + + + + + Appel de l'API en CURL + + +

APPEL de l'adresse http://localhost/b1api/vol/liste

+ Vol n°" . $ligne_de_resultat->id_vol . ""; + echo "
"; + echo "
de
" . $ligne_de_resultat->de . "
"; + echo "
à
" . $ligne_de_resultat->a . "
"; + echo "
via
" . $ligne_de_resultat->via . "
"; + echo "
Places restantes
" . ($ligne_de_resultat->places - $ligne_de_resultat->reservations) . "
"; + echo "
"; + ?> + + \ No newline at end of file diff --git a/b1-bak/session4/api/index.php b/b1-bak/session4/api/index.php new file mode 100644 index 0000000..d5a3f79 --- /dev/null +++ b/b1-bak/session4/api/index.php @@ -0,0 +1,30 @@ +connect_errno) { + header('HTTP/1.1 500 OK'); + echo json_encode( array('erreur mysql' => "Échec lors de la connexion à MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error)); + } + else { + $resultat = $mysqli->query('SELECT * FROM `vol`'); + $ligne_de_resultat = $resultat->fetch_array(MYSQLI_ASSOC); + header('HTTP/1.1 200 OK'); + echo json_encode( $ligne_de_resultat); + } + } + else + { + header('HTTP/1.1 404 OK'); + echo json_encode( array('erreur' => "route inconnue ".$_SERVER['REQUEST_URI']) ); + } + } + else + { + header('HTTP/1.1 404 OK'); + echo json_encode( array('erreur' => "METHODE NON SUPPORTEE : ".$_SERVER['REQUEST_METHOD'])); + } \ No newline at end of file