diff --git a/bdd/notehub.sql b/bdd/notehub.sql new file mode 100644 index 0000000..f65fda2 --- /dev/null +++ b/bdd/notehub.sql @@ -0,0 +1,326 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost +-- Generation Time: May 21, 2023 at 09:05 PM +-- Server version: 10.5.19-MariaDB-0+deb11u2 +-- PHP Version: 7.4.33 + +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: `notehub` +-- + +CREATE Database IF NOT EXISTS notehub; +USE notehub; +-- -------------------------------------------------------- + +-- +-- Table structure for table `annees` +-- + +CREATE TABLE `annees` ( + `ID` int(11) NOT NULL, + `annees` varchar(255) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `annees` +-- + +INSERT INTO `annees` (`ID`, `annees`) VALUES +(1, '2022-2023'),(2, '2023-2024'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `annonces` +-- + +CREATE TABLE `annonces` ( + `ID` int(11) NOT NULL, + `emetteur` int(11) NOT NULL, + `couleur` varchar(255) DEFAULT NULL, + `titre` varchar(255) DEFAULT NULL, + `message` text DEFAULT NULL, + `date` datetime NOT NULL DEFAULT current_timestamp(), + `visible` tinyint(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `annonces` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `devoirs` +-- + +CREATE TABLE `devoirs` ( + `ID` int(11) NOT NULL, + `prof` int(11) NOT NULL, + `contenu` varchar(255) DEFAULT NULL, + `ressource` int(11) DEFAULT NULL, + `date` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `devoirs` +-- +-- -------------------------------------------------------- + +-- +-- Table structure for table `groupes` +-- + +CREATE TABLE `groupes` ( + `ID` int(11) NOT NULL, + `nom` varchar(255) NOT NULL, + `annee` int(11) NOT NULL, + `alternance` tinyint(1) NOT NULL COMMENT 'FI ou FA' +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Table des groupes de TP'; + +-- +-- Dumping data for table `groupes` +-- + +INSERT INTO `groupes` (`ID`, `nom`, `annee`, `alternance`) VALUES +(1, 'RT1-FI-A1', 1, 0), +(2, 'RT1-FI-A2', 1, 0), +(3, 'RT1-FI-B1', 1, 0), +(4, 'RT1-FA', 1, 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `profs` +-- + +CREATE TABLE `profs` ( + `ID` int(11) NOT NULL, + `nom` varchar(255) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `profs` +-- + +INSERT INTO `profs` (`ID`, `nom`) VALUES +(1, 'Sébastien Le Moel'), +(2, 'Samuel Marty'), +(3, 'Amar Ramdane-Cherif'), +(4, 'Willy Guillemin'), +(5, 'Marie-Bernard Bat'), +(6, 'Jenny Fancett'), +(7, 'Dana Marinca'), +(8, 'Etienne Huot'), +(9, 'Abdelaziz Benallegue'), +(10, 'Luc Bondant'), +(11, 'Stephan Soulayrol') +; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `publications` +-- + +CREATE TABLE `publications` ( + `ID` int(11) NOT NULL, + `type` int(11) NOT NULL, + `id_pub` int(11) NOT NULL COMMENT 'ID publication dans sa table', + `groupe` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `publications` + +-- -------------------------------------------------------- + +-- +-- Table structure for table `ressources` +-- + +CREATE TABLE `ressources` ( + `ID` int(11) NOT NULL, + `semestre` int(11) NOT NULL, + `nom` varchar(255) DEFAULT NULL, + `code` int(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `semestres` +-- + +CREATE TABLE `semestres` ( + `ID` int(11) NOT NULL, + `numero` int(11) NOT NULL, + `annee` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `semestres` +-- + +INSERT INTO `semestres` (`ID`, `numero`, `annee`) VALUES +(1, 1, 1), +(2, 2, 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `utilisateurs` +-- + +CREATE TABLE `utilisateurs` ( + `ID` int(11) NOT NULL, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `usercas` varchar(255) DEFAULT NULL, + `passcas` varchar(255) DEFAULT NULL, + `iv` varchar(255) DEFAULT NULL, + `pp_url` varchar(255) DEFAULT NULL, + `verified` tinyint(1) NOT NULL, + `admin` tinyint(1) NOT NULL, + `groupe` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Table utilisateurs'; + +-- +-- Dumping data for table `utilisateurs` +-- + +INSERT INTO `utilisateurs` (`ID`, `username`, `password`, `usercas`, `passcas`, `iv`, `pp_url`, `verified`, `admin`, `groupe`) VALUES (1, 'admin', '5f4dcc3b5aa765d61d8327deb882cf99', NULL, NULL, NULL, NULL, 0, 1, 1); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `annees` +-- +ALTER TABLE `annees` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `annonces` +-- +ALTER TABLE `annonces` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `devoirs` +-- +ALTER TABLE `devoirs` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `groupes` +-- +ALTER TABLE `groupes` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `profs` +-- +ALTER TABLE `profs` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `publications` +-- +ALTER TABLE `publications` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `ressources` +-- +ALTER TABLE `ressources` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `semestres` +-- +ALTER TABLE `semestres` + ADD PRIMARY KEY (`ID`); + +-- +-- Indexes for table `utilisateurs` +-- +ALTER TABLE `utilisateurs` + ADD PRIMARY KEY (`ID`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `annees` +-- +ALTER TABLE `annees` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + +-- +-- AUTO_INCREMENT for table `annonces` +-- +ALTER TABLE `annonces` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + +-- +-- AUTO_INCREMENT for table `devoirs` +-- +ALTER TABLE `devoirs` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + +-- +-- AUTO_INCREMENT for table `groupes` +-- +ALTER TABLE `groupes` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; + +-- +-- AUTO_INCREMENT for table `profs` +-- +ALTER TABLE `profs` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; + +-- +-- AUTO_INCREMENT for table `publications` +-- +ALTER TABLE `publications` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `ressources` +-- +ALTER TABLE `ressources` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; + +-- +-- AUTO_INCREMENT for table `semestres` +-- +ALTER TABLE `semestres` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + +-- +-- AUTO_INCREMENT for table `utilisateurs` +-- +ALTER TABLE `utilisateurs` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; +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/doc/cahierdescharges.pdf b/doc/cahierdescharges.pdf new file mode 100644 index 0000000..31e9d7a Binary files /dev/null and b/doc/cahierdescharges.pdf differ diff --git a/html/addcas.php b/html/addcas.php new file mode 100644 index 0000000..e9da3c7 --- /dev/null +++ b/html/addcas.php @@ -0,0 +1,45 @@ +prepare("UPDATE utilisateurs SET usercas = :usercas, passcas = :passcas, iv = :iv, verified = 1 WHERE ID = :id"); + + $stmt->bindParam(':usercas', $usercas); + $stmt->bindParam(':passcas', $passcas); + $stmt->bindParam(':iv', $biniv); + $stmt->bindParam(':id', $_SESSION['userdata']['ID']); + $stmt->execute(); + + $_SESSION['usercas'] = $_POST['usercas']; + $_SESSION['passcas'] = $_POST['passcas']; + $_SESSION['userdata']['verified'] = 1; + } else { + $stmt = $pdo->prepare("UPDATE utilisateurs SET usercas = '', passcas = '', verified = 0 WHERE ID = :id"); + $stmt->bindParam(':id', $_SESSION['userdata']['ID']); + $stmt->execute(); + + $_SESSION['usercas'] = ""; + $_SESSION['passcas'] = ""; + $_SESSION['userdata']['verified'] = 0; + } +} + +header("Location: profil.php"); +?> \ No newline at end of file diff --git a/html/admin.php b/html/admin.php new file mode 100644 index 0000000..063919a --- /dev/null +++ b/html/admin.php @@ -0,0 +1,240 @@ +prepare("INSERT INTO devoirs (`prof`, `contenu`, `ressource`, `date`) VALUES (:prof, :contenu, :ressource, :date)"); + $stmt->bindParam(':prof', $_POST['prof']); + $stmt->bindParam(':contenu', $_POST['contenu']); + $stmt->bindParam(':ressource', $_POST['ressource']); + $stmt->bindParam(':date', $_POST['date']); + if ($stmt->execute()) { + + // Récupération de l'ID du devoir ajouté précédemment + $idDevoir = $pdo->lastInsertId(); + + // Ajout de la publication associée au devoir + + foreach($_POST['groupe'] as $groupe) { + $stmt = $pdo->prepare("INSERT INTO publications (`type`, `id_pub`, `groupe`) VALUES (1, :idpub, :groupe)"); + $stmt->bindParam(':idpub', $idDevoir); + $stmt->bindParam(':groupe', $groupe); + if(!$stmt->execute()) { + die("Erreur SQL" . $stmt->errorInfo()[2]); + } + } + + $erreur = "Devoir ajouté"; + $now = getdate(); + $log = "A => " . sprintf("%02d", $now['mday']) . "/" . sprintf("%02d", $now['mon']) . "/" . $now['year'] . " " . sprintf("%02d", $now['hours']) . ":" . sprintf("%02d", $now['minutes']) . ":" . sprintf("%02d", $now['seconds']) . " -> " . $_SESSION['username'] . " a ajouté un devoir (ID ressource : " . $_POST['ressource'] . ")\n"; + addlog($log, $log_dir); + } else { + $erreur = "Erreur : " . $stmt->errorInfo()[2]; + } + } + } else if ($_POST['submit'] == "annonce"){ + //##################### + // ANNONCES + //##################### + if (isset($_POST['message']) && isset($_POST['couleur'])) { + $stmt = $pdo->prepare("INSERT INTO annonces (`emetteur`, `couleur`, `titre`, `message`, `visible`) VALUES (:emetteur, :couleur, :titre, :message, 1)"); + $stmt->bindParam(':emetteur', $_SESSION['userdata']['ID']); + $stmt->bindParam(':couleur', $_POST['couleur']); + $stmt->bindParam(':titre', $_POST['titre']); + $stmt->bindParam(':message', $_POST['message']); + if ($stmt->execute()) { + + // Récupération de l'ID de l'annonce ajoutée précédemment + $idAnnonce = $pdo->lastInsertId(); + + // Ajout de la publication associée à l'annonce + + foreach($_POST['groupe'] as $groupe) { + $stmt = $pdo->prepare("INSERT INTO publications (`type`, `id_pub`, `groupe`) VALUES (2, :idpub, :groupe)"); + $stmt->bindParam(':idpub', $idAnnonce); + $stmt->bindParam(':groupe', $groupe); + if(!$stmt->execute()) { + die("Erreur SQL" . $stmt->errorInfo()[2]); + } + } + + $erreur = "Annonce publiée"; + $now = getdate(); + $log = "A => " . sprintf("%02d", $now['mday']) . "/" . sprintf("%02d", $now['mon']) . "/" . $now['year'] . " " . sprintf("%02d", $now['hours']) . ":" . sprintf("%02d", $now['minutes']) . ":" . sprintf("%02d", $now['seconds']) . " -> " . $_SESSION['username'] . " a ajouté une annonce (" . $_POST['titre'] . ")\n"; + addlog($log, $log_dir); + } else { + $erreur = "Erreur : " . $stmt->errorInfo()[2]; + } + } + } else if ($_POST['submit'] == "popadmin") { + if (isset($_POST['id']) && !empty($_POST['id'])) { + $stmt = $pdo->prepare("UPDATE utilisateurs SET admin = 0 WHERE ID = :adminid"); + $stmt->bindParam(':adminid', $_POST['id']); + $stmt->execute(); + $erreur = "Utilisateur retiré des admins"; + } + } else if ($_POST['submit'] == "addadmin") { + if (isset($_POST['username']) && !empty($_POST['username'])) { + $stmt = $pdo->prepare("UPDATE utilisateurs SET admin = 1 WHERE username = :username"); + $stmt->bindParam(':username', $_POST['username']); + $stmt->execute(); + + if ($stmt->rowCount() > 0) { + $erreur = $_POST['username'] . " a rejoint le groupe des admins"; + } else { + $erreur = "Aucun admin ajouté"; + } + } + } else if ($_POST['submit'] == "deluser") { + if (isset($_POST['id']) && !empty($_POST['id'])) { + $stmt = $pdo->prepare("DELETE FROM utilisateurs WHERE ID = :userid"); + $stmt->bindParam(':userid', $_POST['id']); + $stmt->execute(); + $erreur = "Utilisateur supprimé"; + } + } +} + + +?> + + + + + + <?php echo $title?> + + + + + + + +

Admin

+ + + + "; + } + ?> +
Sessions
" . $session_name . "
+ + + "; + }; + ?> +
Logs
" . current($logs_lines) . "
+ + + + query("SELECT * FROM utilisateurs WHERE admin = 0"); + if ($stmt->rowCount() > 0) { + foreach ($stmt as $user) { + echo ""; + } + } + ?> +
Gestion des utilisateurs
Utilisateurs
" . $user['username'] . "
+ + + + query("SELECT * FROM utilisateurs WHERE admin = 1"); + if ($stmt->rowCount() > 0) { + foreach ($stmt as $user) { + echo ""; + } + } + ?> + + +
Gestion des admins
Admins
" . $user['username']; + if ($user['username'] != $_SESSION['username']) { + echo ""; + } else { + echo ""; + } + echo "
Ajouter un admin
+ + + + query("SELECT * FROM profs"); + $ressources = $pdo->query("SELECT * FROM ressources"); + $groupes = $pdo->query("SELECT * FROM groupes") + ?> + + + + + + + + +
Devoirs
+ +
+ +
+ +
+ + + + query("SELECT * FROM groupes") + ?> + + + + + + + +
Annonces
+ +
+ + + + + + \ No newline at end of file diff --git a/html/colormode.php b/html/colormode.php new file mode 100644 index 0000000..adf0652 --- /dev/null +++ b/html/colormode.php @@ -0,0 +1,18 @@ + diff --git a/html/data_usage.php b/html/data_usage.php new file mode 100644 index 0000000..ad0a199 --- /dev/null +++ b/html/data_usage.php @@ -0,0 +1,44 @@ + + + + + + + Politique des données + + + + + + + "; + nav($_SESSION['config']); + echo ""; + } + ?> +

utilisation des données

+

Toutes les données sensibles (MDP utilisateur, identifiants CAS) sont chiffrées dans la Base de données. Si vous voulez récupérer vos données : club@e59.fr

+ "; + footer(); + echo ""; + } + ?> + + "; + echo ""; + }; + ?> + diff --git a/html/devoirs.php b/html/devoirs.php new file mode 100644 index 0000000..2e87ad2 --- /dev/null +++ b/html/devoirs.php @@ -0,0 +1,72 @@ + + + + + + + <?php echo $title?> + + + + + + + +

Devoirs

+ +prepare("SELECT id_pub FROM publications WHERE groupe = :groupe AND type = 1"); +$stmt->bindParam(':groupe', $_SESSION['userdata']['groupe']); +if(!$stmt->execute()){ + die("Erreur : " . $stmt->errorInfo()[2]); +} +$idPubs = $stmt->fetchAll(PDO::FETCH_COLUMN); + +// Récupération des devoirs correspondants aux id_pub +$devoirs = array(); + +if (!empty($idPubs)) { + $placeholders = implode(',', array_fill(0, count($idPubs), '?')); + + $stmt = $pdo->prepare("SELECT d.date as date, d.contenu as contenu, p.nom as nomProf, r.nom as nomRessource FROM devoirs d JOIN profs p ON d.prof = p.ID JOIN ressources r ON d.ressource = r.ID WHERE d.id IN ($placeholders) ORDER BY d.date ASC"); + if(!$stmt->execute($idPubs)){ + die("Erreur : " . $stmt->errorInfo()[2]); + } + $devoirs = $stmt->fetchAll(PDO::FETCH_ASSOC); +} + +foreach($devoirs as $devoir) { + echo "
"; + echo "
" . $devoir['nomProf'] . " - " . $devoir['nomRessource'] . "
"; + echo "
" . $devoir['date'] . "
"; + echo "
" . $devoir['contenu'] . "
"; + echo "
"; +} + +// Fermeture de la connexion à la base de données +$pdo = null; +?> + + + + + + + \ No newline at end of file diff --git a/html/favicon.ico b/html/favicon.ico new file mode 100644 index 0000000..4f8cca9 Binary files /dev/null and b/html/favicon.ico differ diff --git a/html/img/default_pp.jpg b/html/img/default_pp.jpg new file mode 100644 index 0000000..2a26a89 Binary files /dev/null and b/html/img/default_pp.jpg differ diff --git a/html/img/logo.png b/html/img/logo.png new file mode 100644 index 0000000..b66ea5d Binary files /dev/null and b/html/img/logo.png differ diff --git a/html/img/notehub.png b/html/img/notehub.png new file mode 100644 index 0000000..fc801f8 Binary files /dev/null and b/html/img/notehub.png differ diff --git a/html/img/notehub0.png b/html/img/notehub0.png new file mode 100644 index 0000000..fc801f8 Binary files /dev/null and b/html/img/notehub0.png differ diff --git a/html/img/notehub1.png b/html/img/notehub1.png new file mode 100644 index 0000000..402bda9 Binary files /dev/null and b/html/img/notehub1.png differ diff --git a/html/img/notehub2.png b/html/img/notehub2.png new file mode 100644 index 0000000..fc801f8 Binary files /dev/null and b/html/img/notehub2.png differ diff --git a/html/index.php b/html/index.php new file mode 100644 index 0000000..cf5cab8 --- /dev/null +++ b/html/index.php @@ -0,0 +1,97 @@ + + + + + + + <?php echo $title ?> + + + + + + + +

NoteHub

+ prepare("SELECT id_pub FROM publications WHERE groupe = :groupe AND type = 2"); + $stmt->bindParam(':groupe', $_SESSION['userdata']['groupe']); + if(!$stmt->execute()){ + die("Erreur : " . $stmt->errorInfo()[2]); + } + $idPubs = $stmt->fetchAll(PDO::FETCH_COLUMN); + + // Récupération des devoirs correspondants aux id_pub + $annonces = array(); + + if (!empty($idPubs)) { + $placeholders = implode(',', array_fill(0, count($idPubs), '?')); + //ANNONCES(ID, #IDEMETTEUR, COULEUR, DATE, VISIBILITE, TITRE, MESSAGE) + $stmt = $pdo->prepare("SELECT a.date as date, a.message as message, a.titre as titre, u.username as emetteur, u.verified as verified, u.pp_url as pp_url, a.couleur as couleur, a.visible as visible FROM annonces a JOIN utilisateurs u ON a.emetteur = u.ID WHERE a.id IN ($placeholders) ORDER BY a.date ASC"); + if(!$stmt->execute($idPubs)){ + die("Erreur : " . $stmt->errorInfo()[2]); + } + $annonces = $stmt->fetchAll(PDO::FETCH_ASSOC); + } + + foreach($annonces as $annonce) { + if ($annonce['visible']){ + $pubdate = new DateTime($annonce['date']); + $now = new DateTime("now"); + $interval = $pubdate->diff($now); + if ($interval->days != 0) { + if ($interval->h < 12){ + $age = $interval->days . "j"; + } else { + $age = $interval->days + 1 . "j"; + } + } else if ($interval->h != 0) { + if ($interval->m < 30) { + $age = $interval->h . "h"; + } else { + $age = $interval->h + 1 . "h"; + } + } else if ($interval->i != 0) { + if ($interval->s < 30) { + $age = $interval->i . "m"; + } else { + $age = $interval->i + 1 . "m"; + } + } else { + $age = $interval->h . "s"; + } + echo "
"; + echo "
"; + echo "@" . $annonce['emetteur']; + echo $annonce['verified'] ? $verified : ''; + echo " " . $age . "
"; + echo "
" . $annonce['message'] . "
"; + echo "
"; + } + } + $pdo = null; + ?> + + + + + diff --git a/html/login.php b/html/login.php new file mode 100644 index 0000000..4d76aa1 --- /dev/null +++ b/html/login.php @@ -0,0 +1,104 @@ + 30){ + $error = "Nom d'utilisateur trop long"; + } else { + $stmt = $pdo->query("SELECT * FROM utilisateurs WHERE username = '" . $username . "' AND password = '" . md5($password) . "'"); + if ($stmt->rowCount() > 0) { + $_SESSION['password'] = $password; + $_SESSION['username'] = $username; + foreach($stmt as $user) { + foreach ($user as $key => $value) { + $_SESSION['userdata'][$key] = $value; + } + } + + $iv = hex2bin($_SESSION['userdata']['iv']); + + $usercaschiffre = base64_decode($_SESSION['userdata']['usercas']); + $passcaschiffre = base64_decode($_SESSION['userdata']['passcas']); + + if (isset($iv) && isset($usercaschiffre) && isset($passcaschiffre)) { + $_SESSION['usercas'] = openssl_decrypt($usercaschiffre, 'aes-256-cbc', $password, 0, $iv); + $_SESSION['passcas'] = openssl_decrypt($passcaschiffre, 'aes-256-cbc', $password, 0, $iv); + } else { + $_SESSION['usercas'] = ""; + $_SESSION['passcas'] = ""; + } + + $now = getdate(); + $log = "C => " . sprintf("%02d", $now['mday']) . "/" . sprintf("%02d", $now['mon']) . "/" . $now['year'] . " " . sprintf("%02d", $now['hours']) . ":" . sprintf("%02d", $now['minutes']) . ":" . sprintf("%02d", $now['seconds']) . " -> " . $username . " s'est connecté depuis " . $_SERVER['REMOTE_ADDR'] . " avec la session : " . session_id() . "\n"; + addlog($log, $log_dir); + + $pdo = null; + + if (isset($_GET["page"])) { + header("Location: " . $_GET["page"]); + exit(); + } else { + header("Location: index.php"); + exit(); + } + } else { + $now = getdate(); + $log_data = "F => " . sprintf("%02d", $now['mday']) . "/" . sprintf("%02d", $now['mon']) . "/" . $now['year'] . " " . sprintf("%02d", $now['hours']) . ":" . sprintf("%02d", $now['minutes']) . ":" . sprintf("%02d", $now['seconds']) . " -> " . $username . " a essayé de se connecter depuis " . $_SERVER['REMOTE_ADDR'] . " mauvais mot de passe\n"; + addlog($log_data, $log_dir); + $error = "Nom d'utilisateur ou mot de passe incorrect"; + } + } +} +?> + + + + + + <?php echo $title?> + + + + + + + + + + +

Connexion

+ +
+ + + +
+

Vous n'avez pas encore de compte ? Créer un compte

+ + + + + \ No newline at end of file diff --git a/html/logout.php b/html/logout.php new file mode 100644 index 0000000..2d55c51 --- /dev/null +++ b/html/logout.php @@ -0,0 +1,11 @@ + " . sprintf("%02d", $now['mday']) . "/" . sprintf("%02d", $now['mon']) . "/" . $now['year'] . " " .sprintf("%02d", $now['hours']) . ":" . sprintf("%02d", $now['minutes']) . ":" . sprintf("%02d", $now['seconds']) . " -> " . $_SESSION['username'] . " s'est déconnecté depuis " . $_SERVER['REMOTE_ADDR'] . "\n"; +addlog($log, $log_dir); +session_destroy(); +header('Location: login.php'); +exit(); +?> diff --git a/html/main.js b/html/main.js new file mode 100644 index 0000000..05df383 --- /dev/null +++ b/html/main.js @@ -0,0 +1,308 @@ +function colormode(mode) { + const profiles = { + 0:["#0D1117", "#0D1117", "#161B22", "#171D24", "#ECF6FF", "#E1EAF3", "#BEC6CD", "#BEC6CD", "dark"], + 1:["#EFF3F4", "#F7F9F9", "#FFFFFF", "#EFF1F1", "#0F1419", "#454A4F", "#0F1419", "#ACB3B3", "light"], + 2:["#FF0000", "#FF8800", "#FFFF00", "#88FF00", "#00FF00", "#00FFFF", "#0000FF", "#8800FF", "dark"] + } + var r = document.querySelector('body'); + r.style.setProperty('--nav-bg', profiles[mode][0]); + r.style.setProperty('--table-bg', profiles[mode][1]); + r.style.setProperty('--background', profiles[mode][2]); + r.style.setProperty('--link-hover-bg', profiles[mode][3]); + r.style.setProperty('--text-color', profiles[mode][4]); + r.style.setProperty('--link-color', profiles[mode][5]); + r.style.setProperty('--title-color', profiles[mode][6]); + r.style.setProperty('--table-corder', profiles[mode][7]); + r.style.setProperty('--graphtheme', profiles[mode][8]); +} + +function ressourceChart(ue, name) { + + const moyennes = []; + const labels = []; + const colors = []; + const palette = ["#ca1414", "#ca1414", "#ca1414", "#ca1414", "#ea1818", "#ea1818", "#ea1818", "#ea1818", "#eb6b17", "#ebb117", "#ebe117", "#e5eb17", "#d8eb17", "#cbeb17","#bfeb17", "#9feb17", "#6ceb17", "#2dde15", "#28c513", "#13be7f", "#7013bf"]; + + // Récupération des moyennes et des labels pour chaque ressource + ue = data.relevé.ues[ue] + for (const ressource in ue.ressources) { + var moyenne = ue.ressources[ressource].moyenne + if (moyenne == "~") { + moyenne = "0"; + } + moyennes.push(moyenne); + labels.push([`${data.relevé.ressources[ressource].titre} (${ue.ressources[ressource].coef})`]); + colors.push(palette[Math.round(parseInt(moyenne))]); + } + for (const sae in ue.saes) { + var moyenne = ue.saes[sae].moyenne + if (moyenne == "~") { + moyenne = "0"; + } + moyennes.push(moyenne); + labels.push([`${data.relevé.saes[sae].titre} (${ue.saes[sae].coef})`]); + colors.push(palette[Math.round(parseInt(moyenne))]); + } + + // Options pour le graphe + const options = { + series: [{ + name: "Moyenne", + data: moyennes + },], + chart: { + type: 'bar', + height: 400, + width: 800, + background: getComputedStyle(document.body).getPropertyValue('--background'), + foreColor: getComputedStyle(document.body).getPropertyValue('--text-color') + }, + plotOptions: { + bar: { + horizontal: false, + distributed: true, + borderRadius: 2, + } + }, + legend: { + show: false + }, + colors: colors, + annotations: { + yaxis: [{ + y: 0, + y2: 8, + borderColor: '#b62828', + fillColor: '#b62828', + opacity: 0.2, + },{ + y: 8, + y2: 10, + borderColor: '#deb62f', + fillColor: '#deb62f', + opacity: 0.2, + }] + }, + xaxis: { + categories: labels + }, + yaxis: { + max: 20 + }, + title: { + text: name, + align: 'center', + margin: 10, + offsetX: 0, + offsetY: 0, + floating: false, + style: { + fontSize: '20px', + fontWeight: 'bold', + fontFamily: undefined, + color: getComputedStyle(document.body).getPropertyValue('--title-color') + }, + }, + theme: { + mode: 'dark' + } + }; + options.theme.mode = getComputedStyle(document.body).getPropertyValue('--graphtheme'); + console.log(getComputedStyle(document.body).getPropertyValue('--graphtheme')); + return options; +} + +function uesChart(data, name) { + + const moyennes = []; + const labels = []; + const colors = []; + const palette = ["#ca1414", "#ca1414", "#ca1414", "#ca1414", "#ea1818", "#ea1818", "#ea1818", "#ea1818", "#eb6b17", "#ebb117", "#ebe117", "#e5eb17", "#d8eb17", "#cbeb17","#bfeb17", "#9feb17", "#6ceb17", "#2dde15", "#28c513", "#13be7f", "#7013bf"]; + + + // Récupération des moyennes et des labels pour chaque ressource + for (const ue in data.relevé.ues) { + moyenne = data.relevé.ues[ue].moyenne.value + if (moyenne == "~") { + moyenne = "0" + } + moyennes.push(data.relevé.ues[ue].moyenne.value); + labels.push([`${ue}`]); + colors.push(palette[parseInt(moyenne, 10)]) + } + + // Options pour le graphe + const options = { + series: [{ + name: "Moyenne", + data: moyennes + }], + chart: { + type: "bar", + height: 400, + width: 800, + background: getComputedStyle(document.body).getPropertyValue('--background'), + foreColor: getComputedStyle(document.body).getPropertyValue('--text-color') + }, + plotOptions: { + bar: { + horizontal: false, + distributed: true, + endingShape: 'rounded', + } + }, + legend: { + show: false + }, + colors: colors, + annotations: { + yaxis: [{ + y: 0, + y2: 8, + borderColor: '#b62828', + fillColor: '#b62828', + opacity: 0.2, + },{ + y: 8, + y2: 10, + borderColor: '#deb62f', + fillColor: '#deb62f', + opacity: 0.2, + }] + }, + xaxis: { + categories: labels + }, + yaxis: { + max: 20 + }, + title: { + text: name, + align: 'center', + margin: 10, + offsetX: 0, + offsetY: 0, + floating: false, + style: { + fontSize: '20px', + fontWeight: 'bold', + fontFamily: undefined, + color: getComputedStyle(document.body).getPropertyValue('--title-color') + }, + }, + theme: { + mode: 'dark', + palette: 'palette1', + } + }; + options.theme.mode = getComputedStyle(document.body).getPropertyValue('--graphtheme'); + return options; +} + +function absencesChart(data) { + + const absences = data.relevé.semestre.absences.total; + const absences_injustifie = data.relevé.semestre.absences.injustifie; + const abs_percent = (absences_injustifie/5)*100; + var color; + if (absences <= 1) { + color = "#23A100" + } else if (absences == 2) { + color = "#00FF00" + } else if (absences == 3) { + color = "#FFFF00" + } else if (absences == 4) { + color = "#FF7500" + } else if (absences >= 5) { + color = "#FF0000" + }; + const options = { + chart: { + height: 400, + type: "radialBar", + }, + series: [abs_percent], + colors: [color], + plotOptions: { + radialBar: { + startAngle: -135, + endAngle: 135, + track: { + background: getComputedStyle(document.body).getPropertyValue('--table-bg'), + startAngle: -135, + endAngle: 135, + }, + dataLabels: { + name: { + offsetY: 10, + fontSize: "30px", + show: true, + label: "Absences" + }, + value: { + fontSize: "10px", + show: false, + color: getComputedStyle(document.body).getPropertyValue('--title-color'), + } + } + } + }, + labels: [[`${absences_injustifie}/${absences}`]], + stroke: { + lineCap: "round" + } + }; + + // Options pour le graphe + + return options; +} +function rangChart(data) { + + const rang = parseInt(data.relevé.semestre.rang.value, 10); + const total = data.relevé.semestre.rang.total; + const rang_percent = 100-((rang/total)*100); + const colors = ["#ca1414", "#ca1414", "#ca1414", "#ca1414", "#ea1818", "#ea1818", "#ea1818", "#ea1818", "#eb6b17", "#ebb117", "#ebe117", "#e5eb17", "#d8eb17", "#cbeb17","#bfeb17", "#9feb17", "#6ceb17", "#2dde15", "#28c513", "#13be7f", "#7013bf"]; + var color_pos = Math.round(rang_percent/5); + var color = colors[color_pos]; + const options = { + chart: { + height: 400, + type: "radialBar", + }, + series: [rang_percent], + colors: [color], + plotOptions: { + radialBar: { + startAngle: -135, + endAngle: 135, + track: { + background: getComputedStyle(document.body).getPropertyValue('--table-bg'), + startAngle: -135, + endAngle: 135, + }, + dataLabels: { + name: { + offsetY: 10, + fontSize: "30px", + show: true, + label: "Rang" + }, + value: { + fontSize: "10px", + show: false, + color: getComputedStyle(document.body).getPropertyValue('--title-color'), + } + } + } + }, + labels: [`${rang}/${total}`], + stroke: { + lineCap: "round" + } + }; + + // Options pour le graphe + + return options; +} diff --git a/html/notes.php b/html/notes.php new file mode 100644 index 0000000..68a4b88 --- /dev/null +++ b/html/notes.php @@ -0,0 +1,292 @@ + + + + + + + <?php echo $title;?> + + + + + + + + +

Notes

+ Identifiants CAS non renseignés dans la page profil

"); + } else if (!isset($_SESSION['notedata']) || $_SESSION['notedata'] == 1) { + $_SESSION['notedata'] = authcas($_SESSION['usercas'], $_SESSION['passcas']); + } + if ($_SESSION['notedata'] == 1) { + die("

Erreur d'authentification CAS, vérifiez vos identifiants dans la page profil

"); + } + $data = $_SESSION['notedata']; + ?> + +
+
+
+
+
+
+ = sizeof($data)) { + die("Numéro de semestre invalide"); + } + $sem_data = $data[$sem]; + if (!property_exists($sem_data->relevé, 'semestre')) { + die("L'IUT n'a pas publié de relevé"); + } + $notes = array(); + $michel = array("ressources", "saes"); + $allcolors = array( + 0 => array("#FF4949", "#FFB14A", "#D8FF4A", "#4AFF4A", "#4AFFBA"), + 1 => array("#C90000", "#D06F00", "#CAB000", "#06B800", "#00BF8F") + ); + $colors = $allcolors[$_SESSION['colormode']]; + echo ""; + if ($sem_data->relevé->semestre->notes->value == "~") { + $noteval = ''; + } else if (floatval($sem_data->relevé->semestre->notes->value) == floatval($sem_data->relevé->semestre->notes->max)){ + $noteval = ''; + } else if (floatval($sem_data->relevé->semestre->notes->value) > floatval($sem_data->relevé->semestre->notes->moy)){ + $noteval = ''; + } else if (floatval($sem_data->relevé->semestre->notes->value) == floatval($sem_data->relevé->semestre->notes->moy)){ + $noteval = ''; + } else if (floatval($sem_data->relevé->semestre->notes->value) == floatval($sem_data->relevé->semestre->notes->min)){ + $noteval = ''; + } else if (floatval($sem_data->relevé->semestre->notes->value) < floatval($sem_data->relevé->semestre->notes->moy)){ + $noteval = ''; + } else { + $noteval = ''; + } + + echo "" . $noteval . ""; + + echo "
' . $sem_data->relevé->semestre->notes->value . '' . $sem_data->relevé->semestre->notes->value . '' . $sem_data->relevé->semestre->notes->value . '' . $sem_data->relevé->semestre->notes->value . '' . $sem_data->relevé->semestre->notes->value . '' . $sem_data->relevé->semestre->notes->value . '' . $sem_data->relevé->semestre->notes->value . 'Moyenne Générale" . $sem_data->relevé->semestre->notes->min . " | " . $sem_data->relevé->semestre->notes->moy . " | " . $sem_data->relevé->semestre->notes->max . "
"; + foreach ($michel as $m) { + foreach ($sem_data->relevé->$m as $ressource_key => $ressource) { + echo ""; + echo ""; + echo ""; + foreach($ressource->evaluations as $eval) { + if (!is_null($eval->date)){ + $eval->ressource = $ressource_key; + $notes[] = $eval; + } + if ($eval->note->value == "~") { + $noteval = ''; + } else if (floatval($eval->note->value) == floatval($eval->note->max)){ + $noteval = ''; + } else if (floatval($eval->note->value) > floatval($eval->note->moy)){ + $noteval = ''; + } else if (floatval($eval->note->value) == floatval($eval->note->moy)){ + $noteval = ''; + } else if (floatval($eval->note->value) == floatval($eval->note->min)){ + $noteval = ''; + } else if (floatval($eval->note->value) < floatval($eval->note->moy)){ + $noteval = ''; + } else { + $noteval = ''; + } + echo "" . $noteval . ""; + } + echo "
" . $ressource_key . " - " . $ressource->titre . "
DescriptionCoefNoteMin Moy Max
' . $eval->note->value . '' . $eval->note->value . '' . $eval->note->value . '' . $eval->note->value . '' . $eval->note->value . '' . $eval->note->value . '' . $eval->note->value . '
" . $eval->description . "" . $eval->coef . "" . $eval->note->min . " | " . $eval->note->moy . " | " . $eval->note->max . "
"; + } + } + echo "
"; + echo ""; + echo ""; + echo ""; + function compareByDate($a, $b) { + return strtotime($a->date) - strtotime($b->date); + } + usort($notes, 'compareByDate'); + $notes = array_reverse($notes); + for ($i = 0; $i < sizeof($notes) && $i < 3; $i++) { + $notedate = strtotime($notes[$i]->date); + echo ""; + } + echo "
Dernières notes
EvalDateNote
" . $notes[$i]->ressource . " - " . $notes[$i]->description . "" . date("d/m/Y", $notedate). "" . $notes[$i]->note->value . "
"; + ?> + + + + + diff --git a/html/profil.php b/html/profil.php new file mode 100644 index 0000000..5d2e881 --- /dev/null +++ b/html/profil.php @@ -0,0 +1,125 @@ +prepare("UPDATE utilisateurs SET groupe = :groupe WHERE ID = '" . $_SESSION['userdata']['ID'] ."'"); + $stmt->bindParam(':groupe', $_POST['groupe']); + if($stmt->execute()) { + $_SESSION['userdata']['groupe'] = $_POST['groupe']; + $erreur = "Groupe modifié"; + } else { + $erreur = "Erreur : " . $stmt->errorInfo()[2]; + } +} + +if (isset($_POST['ppurl'])) { + $stmt = $pdo->prepare("UPDATE utilisateurs SET pp_url = :pp_url WHERE ID = '" . $_SESSION['userdata']['ID'] ."'"); + $stmt->bindParam(':pp_url', $_POST['ppurl']); + if($stmt->execute()) { + $_SESSION['userdata']['pp_url'] = $_POST['ppurl']; + $erreur = "PP modifiée"; + } else { + $erreur = "Erreur : " . $stmt->errorInfo()[2]; + } +} + +$username = $_SESSION['username']; +$password = $_SESSION['password']; +?> + + + + + + <?php echo $title ?> + + + + + + + + +

+ @"; + echo $_SESSION['username']; + echo $_SESSION['userdata']['verified'] == 1 ? $verified : "" + ?> +

+ + + + + + + +
Identifiants CAS
+
+ " placeholder="Identifiant CAS" style="grid-column: 1 / 3; grid-row: 1">
" placeholder="Mot de passe CAS" style="grid-column: 1 / 3; grid-row: 2">
+ + + + +
Groupe
+
+ +
+ + + + +
Photo de profil
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/html/register.php b/html/register.php new file mode 100644 index 0000000..710d48f --- /dev/null +++ b/html/register.php @@ -0,0 +1,89 @@ + 30){ + $error = "Nom d'utilisateur trop long"; + } else if ($password != $password2){ + $error = "Les mots de passe ne correspondent pas"; + } else { + $checkuser = $pdo->query("SELECT * FROM utilisateurs WHERE username = '" . $username . "'"); + if ($checkuser->rowCount() == 0) { + $md5password = md5($_POST['password']); + $stmt = $pdo->prepare("INSERT INTO utilisateurs (`username`, `password`, `verified`, `admin`, `groupe`) VALUES (:username, :password, 0, 0, :groupe)"); + $stmt->bindParam(':username', $_POST['username']); + $stmt->bindParam(':password', $md5password); + $stmt->bindValue('groupe', 1); + if($stmt->execute()) { + $now = getdate(); + $log = "C => " . sprintf("%02d", $now['mday']) . "/" . sprintf("%02d", $now['mon']) . "/" . $now['year'] . " " . sprintf("%02d", $now['hours']) . ":" . sprintf("%02d", $now['minutes']) . ":" . sprintf("%02d", $now['seconds']) . " -> " . $username . " a créé un compte depuis " . $_SERVER['REMOTE_ADDR'] . "\n"; + addlog($log, $log_dir); + + $_SESSION['password'] = $password; + $_SESSION['username'] = $username; + + header("Location: logout.php"); + exit(); + } else { + $error = "Erreur : " . $stmt->errorInfo()[2]; + } + + } else { + $error = "Le nom d'utilisateur existe déja"; + } + + } +} +?> + + + + + + <?php echo $title?> + + + + + +

Créer un compte

+
+ query("SELECT * FROM groupes"); + ?> + + + + +
+

Vous avez déja un compte ?Connexion

+ + + + + diff --git a/html/style.css b/html/style.css new file mode 100644 index 0000000..f464f65 --- /dev/null +++ b/html/style.css @@ -0,0 +1,211 @@ +:root{ +--nav-bg: #0D1117; +--table-bg: #0D1117; +--background: #161B22; +--link-hover-bg: #171D24; +--text-color: #ECF6FF; +--link-color: #E1EAF3; +--title-color: #BEC6CD; +--table-border: #BEC6CD; +--graphtheme: 'dark'; +} + +body { + background-color: var(--background); + color: var(--text-color); + font-family: "Open Sans", sans-serif; + font-size: 1.2em; + text-align: center; + margin: 0; +} + +h1 { + margin-top: 160px; + margin-bottom: 100px; + font-size: 4em; +} + +table { + border: 0; + margin: 50px auto 50px auto; + padding: 20px; + border-radius: 10px; + background-color: var(--table-bg); +} + +.post { + border-radius: 10px; + width: 50%; + margin: 50px auto 50px auto; + padding: 10px; + background-color: var(--table-bg); +} + +.post-userinfo { + text-align: left; + padding: 10px; +} + +.post-age { + opacity: 0.8; + font-size: 0.7em; +} + +.post-content { + text-align: left; + padding: 10px; + opacity: 0.9; + line-height: 30px; +} + +.verified-icon { + max-width: 20px; + max-height: 20px; + margin-left: 2px; + color: rgb(0, 151, 29); + user-select: none; + vertical-align: text-bottom; + position: relative; + height: 1.25em; + fill: currentcolor; + display: inline-block; +} + +table th, table td { + padding: 10px; + text-align: left; + border-bottom: 1px solid var(--table-border); + width: 400px; +} +input[type="text"], +input[type="password"] { + background-color: var(--table-bg); + color: var(--text-color); + border: 0; + border-radius: 5px; + font-size: 30px; + outline: none; + padding: 10px; + margin: 20px; +} +input[type="submit"] { + background-color: var(--table-bg); + color: var(--text-colo2); + border: 0; + border-radius: 5px; + font-size: 20px; + cursor: pointer; + outline: none; + padding: 10px; + margin: 20px; +} +input[type="submit"]:hover { + border-bottom: 1px solid var(--table-border); +} +form { + margin: 0 auto; + width: 500px; + display: grid; + align-items: center; +} +.form_link { + background-color: var(--table-bg); + color: var(--text-colo2); + border: 0; + padding: 10px; + margin: 20px; + border-radius: 5px; + font-size: 20px; + cursor: pointer; + outline: none; + text-decoration: none; +} +.form_link:hover { + border-bottom: 1px solid var(--table-border); +} + +nav { + position: fixed; + top: 0; + right: 0; + left: 0; + margin: 0; + padding: 14px; + z-index: 1000; + background-color: var(--nav-bg); +} + +#notehub-icon { + height: 30px; + position: absolute; + left: 20px; +} + +a { + color: var(--link-color); +} + +p { + margin: 30px; + background-color: var(--table-bg); + border-radius: 10px; + padding: 20px; +} + +footer { + margin: 0; + margin-top: 500px; + background-color: var(--nav-bg); + text-align: left; + padding: 30px; +} +footer hr { + margin: 70px 10px 30px 10px; +} + +.navlink { + text-decoration: none; + font-size: 1.2em; + color: var(--fg3); + padding: 10px 14px 10px 14px; + border-radius: 4px; + margin: 5px; +} + +.navlink:hover { + border-bottom: 1px solid var(--table-border); + background-color: var(--link-hover-bg); +} + +@media only screen and (max-device-width : 600px) { + nav { + padding: 20px 0 20px 0; + } + .navlink { + font-size: 1.5em; + padding: 20px 15px 20px 15px; + } + form { + width: 100%; + margin: 0; + } + input[type="text"], + input[type="password"] { + font-size: 2em; + width: 80%; + margin: 40px; + } + input[type="submit"] { + font-size: 2em; + width: 250px; + margin-left: 542px; + margin-top: 40px; + } + footer { + font-size: 0.5em; + margin-top: 800px; + } + .post { + width: 70%; + } +} diff --git a/include/config.php b/include/config.php new file mode 100644 index 0000000..d87e6f0 --- /dev/null +++ b/include/config.php @@ -0,0 +1,12 @@ +' +?> + diff --git a/include/connect.php b/include/connect.php new file mode 100644 index 0000000..b4c5f19 --- /dev/null +++ b/include/connect.php @@ -0,0 +1,11 @@ + PDO::ERRMODE_EXCEPTION); + +try { + $pdo = new PDO($dsn, $username, $dbpass, $options); +} catch (PDOException $e) { + die("Erreur BDD : " . $e->getMessage()); +} +?> \ No newline at end of file diff --git a/include/functions.php b/include/functions.php new file mode 100644 index 0000000..0add1d7 --- /dev/null +++ b/include/functions.php @@ -0,0 +1,92 @@ +loadHTML($req1); + $inputs = $req1_html->getElementsByTagName("input"); + foreach ($inputs as $input) { + if ($input->getAttribute("name") == "execution") { + $execution = $input->getAttribute("value"); + break; + } + } + + curl_setopt($s, CURLOPT_URL, $url1); + curl_setopt($s, CURLOPT_POST, true); + curl_setopt($s, CURLOPT_COOKIEFILE, $username . "-cookies.txt"); + curl_setopt($s, CURLOPT_POSTFIELDS, array ( + "username" => $username, + "password" => $password, + "execution" => $execution, + "_eventId" => "submit", + "geolocalisation" => "" + )); + + $auth = curl_exec($s); + + if (curl_getinfo($s, CURLINFO_HTTP_CODE) != 200) { + return 1; + } + + curl_setopt($s, CURLOPT_URL, $url2); + $semestres = curl_exec($s); + $semestres_data = json_decode($semestres, true); + + $semestres_json = array(); + + foreach ($semestres_data as $sem) { + $id_semestre = $sem['formsemestre_id']; + $url = "https://bulletins.iut-velizy.uvsq.fr/services/data.php?q=relev%C3%A9Etudiant&semestre=" . $id_semestre; + curl_setopt($s, CURLOPT_URL, $url); + $notes_request = curl_exec($s); + array_push($semestres_json, json_decode($notes_request)); + } + curl_setopt($s, CURLOPT_URL, $url3); + curl_exec($s); + curl_close($s); + + return $semestres_json; + } + function footer() { + echo '

A propos

'; + $modes = array("clair", "sombre", "sombre"); + $modes_codes = array("1", "0", "0"); + if(isset($_SESSION['colormode']) && isset($_SESSION['userdata'])) { + echo 'Mode ' . $modes[$_SESSION['colormode']] . '

'; + echo 'Utilisation des données

'; + echo $_SESSION['userdata']['admin'] == 1 ? 'Admin' : ''; + echo "
© 2023 Jan BELLON | Club Réseaux | IUT de Vélizy"; + } else { + echo 'Utilisation des données

'; + echo "
© 2023 Jan BELLON | Club Réseaux | IUT de Vélizy"; + } + } + function nav($pages) { + echo ''; + foreach($pages as $key => $value) { + echo '' . $key . ''; + }; + echo 'Deconnexion'; + // lien vers profil + echo ''; + } + function addlog($log, $log_dir) { + $log_file = fopen($log_dir . "/notehub.log", "a") or die("Log Error"); + fwrite($log_file, $log); + fclose($log_file); + } +?> diff --git a/log/notehub.log b/log/notehub.log new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/log/notehub.log @@ -0,0 +1 @@ +