Update 26 files

- /bdd/notehub.sql
- /doc/cahierdescharges.pdf
- /html/notes.php
- /html/profil.php
- /html/register.php
- /html/style.css
- /html/addcas.php
- /html/admin.php
- /html/colormode.php
- /html/data_usage.php
- /html/devoirs.php
- /html/favicon.ico
- /html/index.php
- /html/login.php
- /html/logout.php
- /html/main.js
- /html/img/notehub1.png
- /html/img/notehub2.png
- /html/img/default_pp.jpg
- /html/img/logo.png
- /html/img/notehub.png
- /html/img/notehub0.png
- /include/connect.php
- /include/functions.php
- /include/config.php
- /log/notehub.log
This commit is contained in:
Jan BELLON 2024-03-02 23:55:59 +00:00 committed by jan
parent 9d00db619d
commit b18f8b32a1
26 changed files with 2098 additions and 0 deletions

326
bdd/notehub.sql Normal file
View File

@ -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 */;

BIN
doc/cahierdescharges.pdf Normal file

Binary file not shown.

45
html/addcas.php Normal file
View File

@ -0,0 +1,45 @@
<?php
session_start();
if (!isset($_SESSION['userdata'])) {
die("Casse toi de là !!");
}
include '../include/config.php';
include '../include/connect.php';
if (isset($_POST['usercas']) && isset($_POST['passcas']) && isset($_POST['submit'])) {
if (!empty($_POST['usercas']) && !empty($_POST['passcas'])) {
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$passcaschiffre = openssl_encrypt($_POST['passcas'], 'aes-256-cbc', $_SESSION['password'], 0, $iv);
$usercaschiffre = openssl_encrypt($_POST['usercas'], 'aes-256-cbc', $_SESSION['password'], 0, $iv);
$usercas = base64_encode($usercaschiffre);
$passcas = base64_encode($passcaschiffre);
$biniv = bin2hex($iv);
$stmt = $pdo->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");
?>

240
html/admin.php Normal file
View File

@ -0,0 +1,240 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include '../include/config.php';
include '../include/functions.php';
session_start();
if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
header("Location: login.php");
exit();
}
if ($_SESSION['userdata']['admin'] != 1) {
http_response_code(403);
exit();
}
include '../include/connect.php';
if (isset($_POST['submit'])) {
if ($_POST['submit'] == "devoir"){
//#####################
// DEVOIRS
//#####################
if (isset($_POST['prof']) && isset($_POST['ressource']) && isset($_POST['contenu']) && isset($_POST['date'])) {
$stmt = $pdo->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é";
}
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title?></title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
</head>
<body>
<nav>
<?php nav($pages);?>
</nav>
<h1>Admin</h1>
<?php echo isset($erreur) ? $erreur : "" ?>
<table>
<tr><th>Sessions</th></tr>
<?php
foreach (array_slice(scandir(ini_get("session.save_path")), 2) as $session_name) {
echo "<tr><td>" . $session_name . "</td></tr>";
}
?>
</table>
<table>
<tr><th>Logs</th></tr>
<?php
$logs = file($log_dir . "/notehub.log", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$logs_lines = array_slice($logs, -10);
for (end($logs_lines); key($logs_lines)!==null; prev($logs_lines)) {
echo "<tr><td>" . current($logs_lines) . "</td></tr>";
};
?>
</table>
<table>
<tr><th>Gestion des utilisateurs</th></tr>
<tr><th>Utilisateurs</th></tr>
<?php
$stmt = $pdo->query("SELECT * FROM utilisateurs WHERE admin = 0");
if ($stmt->rowCount() > 0) {
foreach ($stmt as $user) {
echo "<tr><form action='' method='post'><td>" . $user['username'] . "<input type='hidden' value='" . $user['ID'] . "' name='id'><button type='submit' name='submit' value='deluser' style='float:right'>Supprimer</button></td></form></tr>";
}
}
?>
</table>
<table>
<tr><th>Gestion des admins</th></tr>
<tr><th>Admins</th></tr>
<?php
$stmt = $pdo->query("SELECT * FROM utilisateurs WHERE admin = 1");
if ($stmt->rowCount() > 0) {
foreach ($stmt as $user) {
echo "<tr><form action='' method='post'><td>" . $user['username'];
if ($user['username'] != $_SESSION['username']) {
echo "<input type='hidden' name='id' value='" . $user['ID'] . "'><button type='submit' name='submit' value='popadmin'>Virer</button>";
} else {
echo "<button type='submit' name='submit' value='none' style='float:right' disabled>Cet utilisateur</button>";
}
echo "</td></form></tr>";
}
}
?>
<tr><th>Ajouter un admin</th></tr>
<tr><form action="" method="post"><td><input type='text' name='username' placeholder='username' style='font-size: 20px;'><button type="submit" name="submit" value="addadmin">Valider</button></td></form></tr>
</table>
<table>
<form action="" method="post">
<?php
$profs = $pdo->query("SELECT * FROM profs");
$ressources = $pdo->query("SELECT * FROM ressources");
$groupes = $pdo->query("SELECT * FROM groupes")
?>
<tr><th colspan="3">Devoirs</th></tr>
<tr><th>
<select name="prof">
<?php if ($profs->rowCount() > 0) { foreach($profs as $prof) { echo "<option value='" . $prof['ID'] . "'>" . $prof['nom'] . "</option>"; }}?>
</select>
</th></tr>
<tr><th>
<select name="ressource">
<?php if ($ressources->rowCount() > 0) { foreach($ressources as $ressource) { echo "<option value='" . $ressource['ID'] . "'>R " . $ressource['code'] . " - " . $ressource['nom'] . "</option>"; }}?>
</select>
</th></tr>
<tr><th>
<select name="groupe[]" multiple>
<?php if ($groupes->rowCount() > 0) { foreach($groupes as $groupe) { echo "<option value='" . $groupe['ID'] . "'>" . $groupe['nom'] . "</option>"; }}?>
</select>
</th></tr>
<tr><th><input type="date" name="date"></th></tr>
<tr><th><input type="text" name="contenu" placeholder="contenu"/></th></tr>
<tr><th><button type="submit" name="submit" value="devoir">Valider</button></th></tr>
</form>
</table>
<table>
<form action="" method="post">
<?php
$groupes = $pdo->query("SELECT * FROM groupes")
?>
<tr><th colspan="3">Annonces</th></tr>
<tr><th>
<select name="groupe[]" multiple>
<?php if ($groupes->rowCount() > 0) { foreach($groupes as $groupe) { echo "<option value='" . $groupe['ID'] . "'>" . $groupe['nom'] . "</option>"; }}?>
</select>
</th></tr>
<tr><th><input type="text" name="titre" placeholder="titre"/></th></tr>
<tr><th><input type="text" name="message" placeholder="message"/></th></tr>
<tr><th><input type="color" name="couleur"/></th></tr>
<tr><th><button type="submit" name="submit" value="annonce">Valider</button></th></tr>
</form>
</table>
<footer><?php footer()?></footer>
</body>
<script src="main.js"></script>
<script>colormode(<?php echo $_SESSION['colormode']?>)</script>
</html>
<?php $pdo = null; ?>

18
html/colormode.php Normal file
View File

@ -0,0 +1,18 @@
<?php
session_start();
if (!isset($_SESSION['colormode']) || !isset($_GET['source'])) {
http_response_code(403);
exit();
}
if (!isset($_GET['mode'])) {
header("Location: " . $_GET['source']);
exit();
}
if (in_array($_GET['mode'], [0,1,2])){
$_SESSION['colormode'] = $_GET['mode'];
header("Location: " . $_GET['source']);
} else {
http_response_code(403);
exit();
}
?>

44
html/data_usage.php Normal file
View File

@ -0,0 +1,44 @@
<?php
session_start();
if (isset($_SESSION['status'])) {
$loggedin = 1;
}
include '../include/config.php';
include '../include/functions.php';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Politique des données</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
</head>
<body>
<?php
if ($loggedin) {
echo "<nav>";
nav($_SESSION['config']);
echo "</nav>";
}
?>
<h1>utilisation des données</h1>
<p style="text-align: left;">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 : <a href="mailto:club@e59.fr">club@e59.fr</a></p>
<?php
if ($loggedin) {
echo "<footer>";
footer();
echo "</footer>";
}
?>
</body>
<?php
if ($loggedin) {
echo "<script src='main.js'></script>";
echo "<script>colormode(" . $_SESSION['colormode'] . ")</script>";
};
?>
</html>

72
html/devoirs.php Normal file
View File

@ -0,0 +1,72 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
header("Location: login.php?page=" . $_SERVER['REQUEST_URI']);
exit();
}
include '../include/config.php';
include '../include/functions.php';
include '../include/connect.php';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title?></title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
</head>
<body>
<nav>
<?php nav($pages)?>
</nav>
<h1>Devoirs</h1>
<?php
// Affichage des devoirs
$stmt = $pdo->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 "<div class='post' style='border: 1px solid white'>";
echo "<div class='post-userinfo'>" . $devoir['nomProf'] . " - " . $devoir['nomRessource'] . "</div>";
echo "<div class='post-age'>" . $devoir['date'] . "</div>";
echo "<div class='post-content'>" . $devoir['contenu'] . "</div>";
echo "</div>";
}
// Fermeture de la connexion à la base de données
$pdo = null;
?>
<footer><?php footer()?></footer>
</body>
<script src="main.js"></script>
<script>colormode(<?php echo $_SESSION['colormode']?>)</script>
</html>

BIN
html/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

BIN
html/img/default_pp.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
html/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
html/img/notehub.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

BIN
html/img/notehub0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

BIN
html/img/notehub1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
html/img/notehub2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

97
html/index.php Normal file
View File

@ -0,0 +1,97 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
header("Location: login.php");
exit();
}
include '../include/config.php';
include '../include/connect.php';
include '../include/functions.php';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title ?></title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
</head>
<body>
<nav>
<?php nav($pages)?>
</nav>
<h1>NoteHub</h1>
<?php
$stmt = $pdo->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 "<div class='post' style='border: 1px solid " . $annonce['couleur'] . ";'>";
echo "<div class='post-userinfo'>";
echo "<img src='";
echo $_SESSION['userdata']['pp_url'] != NULL ? $_SESSION['userdata']['pp_url'] : "img/default_pp.jpg";
echo "' height='50px' width='50px' style='margin-right: 10px; border-radius: 25px'/><span style='position:absolute;'>@" . $annonce['emetteur'];
echo $annonce['verified'] ? $verified : '';
echo " <span style='font-size: 0.8em; opacity: 0.8;'>" . $age . "</span></div>";
echo "<div class='post-content'>" . $annonce['message'] . "</div>";
echo "</div>";
}
}
$pdo = null;
?>
<footer><?php footer()?></footer>
</body>
<script src='main.js'></script>
<script>colormode(<?php echo $_SESSION['colormode']?>)</script>
</html>

104
html/login.php Normal file
View File

@ -0,0 +1,104 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
header("Location: index.php");
exit();
}
$error = "";
if (!isset($_SESSION['colormode'])) {
$_SESSION['colormode'] = 0;
}
include '../include/config.php';
include '../include/functions.php';
include '../include/connect.php';
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['submit'])) {
$username = htmlspecialchars($_POST['username'], ENT_QUOTES, 'UTF-8');
$password = htmlspecialchars($_POST['password'], ENT_QUOTES, 'UTF-8');
if (empty($username) || empty($password) || $_POST['submit'] != "valider") {
$error = "Les champs ne doivent pas être vides";
} else if (strlen($username) > 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";
}
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title?></title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<meta property="og:image" content="https://notehub2.e59.fr/img/notehub.png"/>
<meta property="og:description" content="<?php echo $description;?>"/>
<meta property="og:url" content="https://notehub2.e59.fr/"/>
<meta property="og:title" content="<?php echo $title;?>"/>
<meta name="theme-color" data-react-helmet="true" content="#000000"/>
</head>
<body>
<h1>Connexion</h1>
<?php echo $error; ?>
<form action="" method="post">
<input type="text" placeholder="Identifiant" name="username" style="grid-column: 1 / 3; grid-row: 1" required>
<input type="password" placeholder="Mot de passe" name="password" style="grid-column: 1 / 3; grid-row: 2" required>
<input type="submit" value="valider" name="submit" style="grid-column: 2; grid-row: 3">
</form>
<p>Vous n'avez pas encore de compte ? <a href="register.php" class="form_link" style="grid-column: 1; grid-row: 3">Créer un compte</a></p>
<footer><?php footer()?></footer>
</body>
<script src="main.js"></script>
<script>colormode(<?php echo $_SESSION['colormode']?>)</script>
</html>

11
html/logout.php Normal file
View File

@ -0,0 +1,11 @@
<?php
session_start();
include '../include/config.php';
include '../include/functions.php';
$now = getdate();
$log = "D => " . 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();
?>

308
html/main.js Normal file
View File

@ -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;
}

292
html/notes.php Normal file
View File

@ -0,0 +1,292 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
header("Location: login.php?page=" . $_SERVER['REQUEST_URI']);
exit();
}
include '../include/config.php';
include '../include/connect.php';
include '../include/functions.php';
$userdata = $_SESSION['userdata'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title;?></title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.js"></script>
</head>
<style>
#sem_links {
position: fixed;
top: 30px;
right: 20px;
display: block;
z-index: 1200;
}
#sem_links a {
position: relative;
margin: 10px;
text-decoration: none;
padding: 10px;
background-color: var(--table-bg);
border-radius: 10px;
}
#sem_links a:hover {
background-color: var(--link-hover-bg);
}
.rname {
border-bottom: 0;
color: var(--title-color);
}
.apexcharts-xaxis-label {
fill: var(--text-color);
}
.apexcharts-canvas {
margin: 0 auto 0 auto;
}
.chart {
margin: 0 auto 0 auto;
}
#circhart {
display: flex;
margin: 100px;
}
#chart1 {
//margin-top: 500px;
}
/*
#abschart {
position: absolute;
right: 100px;
top: 150px;
z-index: 500;
}
#retchart {
position: absolute;
left: 100px;
top: 150px;
z-index: 500;
}*/
@media screen and (min-width: 1800px) {
#circhart {
width: 800px;
margin-left: 800px;
}
#charts {
display:grid;
grid-gap: 0;
margin: 20px;
}
#chart1 {
grid-column: 1;
grid-row: 1;
//margin-top: 400px;
}
#chart2 {
grid-column: 2;
grid-row: 1;
//margin-top: 400px;
}
#chart3 {
grid-column: 1;
grid-row: 2;
}
#chart4 {
grid-column: 2;
grid-row: 2;
}
/*#abschart {
right: 80px;
top: 100px;
}
#retchart {
right: -40px;
top: 100px;
}*/
#lastgrades {
position: absolute;
top: 25px;
left: 20px;
font-size: 0.8em;
width: 500px;
}
#lastgrades td, #lastgrades th{
width: 50px;
}
.notecol {
width: 50px;
}
}
</style>
<body>
<nav>
<?php nav($pages)?>
</nav>
<h1>Notes</h1>
<?php
if ($_SESSION['userdata']['verified'] == 0) {
die("<p>Identifiants CAS non renseignés dans la page <a href='profil.php'>profil</a></p></body></html>");
} else if (!isset($_SESSION['notedata']) || $_SESSION['notedata'] == 1) {
$_SESSION['notedata'] = authcas($_SESSION['usercas'], $_SESSION['passcas']);
}
if ($_SESSION['notedata'] == 1) {
die("<p>Erreur d'authentification CAS, vérifiez vos identifiants dans la page <a href='profil.php'>profil</a></p></body></html>");
}
$data = $_SESSION['notedata'];
?>
<div id="sem_links">
<?php
for ($i = 0; $i < sizeof($data); $i++) {
if (property_exists($data[$i]->relevé, 'semestre')) {
echo '<a href="notes.php?sem_id=' . $i .'">' . $data[$i]->relevé->semestre->annee_universitaire . ' Semestre ' . $data[$i]->relevé->semestre->numero . '</a><br><br>';
}
}
?>
</div>
<div id="circhart">
<div id="abschart" class="chart"></div>
<div id="retchart" class="chart"></div>
</div>
<div id="charts"></div>
<hr/>
<?php
if (!isset($_GET['sem_id'])) {
$sem = 0;
} else {
$sem = intval($_GET['sem_id']);
}
if ($sem >= 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 "<table>";
if ($sem_data->relevé->semestre->notes->value == "~") {
$noteval = '<td style="color: #888888">' . $sem_data->relevé->semestre->notes->value . '</td>';
} else if (floatval($sem_data->relevé->semestre->notes->value) == floatval($sem_data->relevé->semestre->notes->max)){
$noteval = '<td style="color: ' . $colors[4] . '">' . $sem_data->relevé->semestre->notes->value . '</td>';
} else if (floatval($sem_data->relevé->semestre->notes->value) > floatval($sem_data->relevé->semestre->notes->moy)){
$noteval = '<td style="color: ' . $colors[3] . '">' . $sem_data->relevé->semestre->notes->value . '</td>';
} else if (floatval($sem_data->relevé->semestre->notes->value) == floatval($sem_data->relevé->semestre->notes->moy)){
$noteval = '<td style="color: ' . $colors[2] . '">' . $sem_data->relevé->semestre->notes->value . '</td>';
} else if (floatval($sem_data->relevé->semestre->notes->value) == floatval($sem_data->relevé->semestre->notes->min)){
$noteval = '<td style="color: ' . $colors[0] . '">' . $sem_data->relevé->semestre->notes->value . '</td>';
} else if (floatval($sem_data->relevé->semestre->notes->value) < floatval($sem_data->relevé->semestre->notes->moy)){
$noteval = '<td style="color: ' . $colors[1] . '">' . $sem_data->relevé->semestre->notes->value . '</td>';
} else {
$noteval = '<td>' . $sem_data->relevé->semestre->notes->value . '</td>';
}
echo "<td>Moyenne Générale</td>" . $noteval . "<td><span style='color: " . $colors[0] . "'>" . $sem_data->relevé->semestre->notes->min . "</span> | <span style='color: " . $colors[2] . "'>" . $sem_data->relevé->semestre->notes->moy . "</span> | <span style='color: " . $colors[4] . "'>" . $sem_data->relevé->semestre->notes->max . "</span></td></tr>";
echo "</table>";
foreach ($michel as $m) {
foreach ($sem_data->relevé->$m as $ressource_key => $ressource) {
echo "<table>";
echo "<tr><th class='rname' colspan='3'>" . $ressource_key . " - " . $ressource->titre . "</th></tr>";
echo "<tr><th>Description</th><th>Coef</th><th>Note</th><th>Min Moy Max</th></tr>";
foreach($ressource->evaluations as $eval) {
if (!is_null($eval->date)){
$eval->ressource = $ressource_key;
$notes[] = $eval;
}
if ($eval->note->value == "~") {
$noteval = '<td style="color: #888888">' . $eval->note->value . '</td>';
} else if (floatval($eval->note->value) == floatval($eval->note->max)){
$noteval = '<td style="color: ' . $colors[4] . '">' . $eval->note->value . '</td>';
} else if (floatval($eval->note->value) > floatval($eval->note->moy)){
$noteval = '<td style="color: ' . $colors[3] . '">' . $eval->note->value . '</td>';
} else if (floatval($eval->note->value) == floatval($eval->note->moy)){
$noteval = '<td style="color: ' . $colors[2] . '">' . $eval->note->value . '</td>';
} else if (floatval($eval->note->value) == floatval($eval->note->min)){
$noteval = '<td style="color: ' . $colors[0] . '">' . $eval->note->value . '</td>';
} else if (floatval($eval->note->value) < floatval($eval->note->moy)){
$noteval = '<td style="color: ' . $colors[1] . '">' . $eval->note->value . '</td>';
} else {
$noteval = '<td>' . $eval->note->value . '</td>';
}
echo "<tr><td>" . $eval->description . "</td><td>" . $eval->coef . "</td>" . $noteval . "<td><span style='color: " . $colors[0] . "'>" . $eval->note->min . "</span> | <span style='color: " . $colors[2] . "'>" . $eval->note->moy . "</span> | <span style='color: " . $colors[4] . "'>" . $eval->note->max . "</span></td></tr>";
}
echo "</table>";
}
}
echo "<hr>";
echo "<table id='lastgrades'>";
echo "<tr><th class='rname' colspan='3'>Dernières notes</th></tr>";
echo "<tr><th>Eval</th><th>Date</th><th class='notecol'>Note</th></tr>";
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 "<tr><td>" . $notes[$i]->ressource . " - " . $notes[$i]->description . "</td><td>" . date("d/m/Y", $notedate). "</td><td class='notecol'>" . $notes[$i]->note->value . "</td></tr>";
}
echo "</table>";
?>
<footer><?php footer()?></footer>
</body>
<script src="main.js"></script>
<script>
colormode(<?php echo $_SESSION['colormode'];?>);
const data = <?php echo json_encode($data[$_GET['sem_id']]);?>;
console.log(data);
// Récupération des données pour chaque UE
// Création des graphes
var i = 1;
const container = document.getElementById("charts");
const template = document.createElement("div");
const charts = []
for (const ue in data.relevé.ues) {
const graph = template.cloneNode(true);
graph.setAttribute("id", `chart${i}`);
container.appendChild(graph);
const chart = new ApexCharts(document.querySelector(`#chart${i}`), ressourceChart(ue, `UE${i}`));
chart.render();
i += 1;
}
const graph = template.cloneNode(true);
graph.setAttribute("id", `chart${i}`);
container.appendChild(graph);
const ueschart = new ApexCharts(document.querySelector(`#chart${i}`), uesChart(data, "Moyennes UES"));
ueschart.render();
const abschart = new ApexCharts(document.querySelector("#abschart"), absencesChart(data));
const rangchart = new ApexCharts(document.querySelector("#retchart"), rangChart(data));
abschart.render();
rangchart.render();
</script>
</html>

125
html/profil.php Normal file
View File

@ -0,0 +1,125 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
header("Location: login.php?page=" . $_SERVER['REQUEST_URI']);
exit();
}
include '../include/config.php';
include '../include/functions.php';
include '../include/connect.php';
if (isset($_POST['groupe']) && !empty($_POST['groupe'])) {
$stmt = $pdo->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'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title ?></title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<style>
.verified-icon {
max-width: 80px;
max-height: 80px;
margin-left: 10px;
color: rgb(0, 151, 29);
user-select: none;
vertical-align: text-bottom;
position: relative;
height: 1.25em;
fill: currentcolor;
display: inline-block;
}
</style>
</head>
<body>
<nav>
<?php nav($pages);?>
</nav>
<h1>
<?php
echo "<img src='";
echo $_SESSION['userdata']['pp_url'] != NULL ? $_SESSION['userdata']['pp_url'] : "img/default_pp.jpg";
echo "' height='100px' width='100px' style='margin-right: 100px; border-radius: 50px'/>@";
echo $_SESSION['username'];
echo $_SESSION['userdata']['verified'] == 1 ? $verified : ""
?>
</h1>
<?php echo isset($erreur) ? $erreur : "" ?>
<table>
<tr><th colspan="2">Identifiants CAS</th></tr>
<tr><td>
<form action="addcas.php" method="post">
<input type="text" name="usercas" value="<?php echo isset($_SESSION['usercas']) ? $_SESSION['usercas'] : "";?>" placeholder="Identifiant CAS" style="grid-column: 1 / 3; grid-row: 1"></input></td><td></td></tr>
<tr><td><input type="password" name="passcas" value="<?php echo isset($_SESSION['passcas']) ? $_SESSION['passcas'] : "";?>" placeholder="Mot de passe CAS" style="grid-column: 1 / 3; grid-row: 2"></input></td>
<td><input type="submit" name="submit" value="Valider" style="grid-column: 2; grid-row: 3"></td></tr>
</form>
</table>
<table>
<tr><th colspan="2">Groupe</th></tr>
<tr><td>
<form action="" method="post">
<select name="groupe">
<?php
$stmt = $pdo->query("SELECT * FROM groupes");
if ($stmt->rowCount() > 0) {
foreach($stmt as $groupe) {
if ($groupe['ID'] == $_SESSION['userdata']['groupe']) {
echo "<option value='" . $groupe['ID'] . "' selected='selected'>". $groupe['nom'] . "</option>";
} else {
echo "<option value='" . $groupe['ID'] . "'>". $groupe['nom'] . "</option>";
}
}
}
?>
</select>
</td><td><input type="submit" value="Valider"></input></td></tr>
</form>
</table>
<table>
<tr><th colspan="2">Photo de profil</th></tr>
<tr><td>
<form action="" method="post">
<input type="text" value="<?php echo isset($_SESSION['userdata']['pp_url']) ? $_SESSION['userdata']['pp_url'] : ''; ?>" placeholder="URL de l'image" name="ppurl"></input>
</td><td><input type="submit" value="Valider"></input>
</form></td></tr>
</table>
<footer><?php footer() ?></footer>
</body>
<script src="main.js"></script>
<script>colormode(<?php echo $_SESSION['colormode']?>)</script>
</html>

89
html/register.php Normal file
View File

@ -0,0 +1,89 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include '../include/config.php';
session_start();
if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
header("Location: index.php");
exit();
}
include '../include/functions.php';
include '../include/connect.php';
$error = "";
if (!isset($_SESSION['colormode'])) {
$_SESSION['colormode'] = 0;
}
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['submit'])) {
$username = htmlspecialchars($_POST['username'], ENT_QUOTES, 'UTF-8');
$password = htmlspecialchars($_POST['password'], ENT_QUOTES, 'UTF-8');
$password2 = htmlspecialchars($_POST['password2'], ENT_QUOTES, 'UTF-8');
if (is_null($username) || is_null($password) || $_POST['submit'] != "valider") {
$error = "Les champs ne doivent pas être vides";
} else if (strlen($username) > 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";
}
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?php echo $title?></title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.min.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
</head>
<body>
<h1>Créer un compte</h1>
<form action="" method="post">
<?php
$groupes = $pdo->query("SELECT * FROM groupes");
?>
<input type="text" placeholder="Identifiant" name="username" style="grid-column: 1 / 3; grid-row: 1" required>
<input type="password" placeholder="Mot de passe" name="password" style="grid-column: 1 / 3; grid-row: 2" required>
<input type="password" placeholder="Confirmer mot de passe" name="password2" style="grid-column: 1 / 3; grid-row: 3" required>
<input type="submit" value="valider" name="submit" style="grid-column: 2; grid-row: 5">
</form>
<p>Vous avez déja un compte ?<a href="login.php" style="grid-column: 1; grid-row: 4" class="form_link">Connexion</a></p>
<footer><?php footer()?></footer>
</body>
<script src="main.js"></script>
<script>colormode(<?php echo $_SESSION['colormode']?>)</script>
</html>

211
html/style.css Normal file
View File

@ -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%;
}
}

12
include/config.php Normal file
View File

@ -0,0 +1,12 @@
<?php
$hostname = "notehub";
$description = "Plateforme de visualisation des notes de BUT R&T";
$title = "NoteHub";
$pages = array();
$pages['Notes'] = "notes.php?sem_id=0";
$pages['Devoirs'] = "devoirs.php";
$log_dir = "../log";
$dbpass = "";
$verified = '<svg viewBox="0 0 22 22" aria-label="Compte certifié" role="img" data-testid="icon-verified" class="verified-icon"><g><path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z"></path></g></svg>'
?>

11
include/connect.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$dsn = "mysql:host=127.0.0.1;dbname=notehub";
$username = "root";
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
try {
$pdo = new PDO($dsn, $username, $dbpass, $options);
} catch (PDOException $e) {
die("Erreur BDD : " . $e->getMessage());
}
?>

92
include/functions.php Normal file
View File

@ -0,0 +1,92 @@
<?php
function authcas($username, $password) {
$s = curl_init();
$url1 = "https://cas2.uvsq.fr/cas/login?service=https://bulletins.iut-velizy.uvsq.fr/services/doAuth.php";
$url2 = "https://bulletins.iut-velizy.uvsq.fr/services/data.php?q=semestresEtudiant";
$url3 = "https://bulletins.iut-velizy.uvsq.fr/logout.php";
curl_setopt($s, CURLOPT_URL, $url1);
curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
curl_setopt($s, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($s, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($s, CURLOPT_COOKIEJAR, $username . "-cookies.txt");
$req1 = curl_exec($s);
$req1_html = new DOMDocument();
@$req1_html->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 '<h2>A propos</h2>';
$modes = array("clair", "sombre", "sombre");
$modes_codes = array("1", "0", "0");
if(isset($_SESSION['colormode']) && isset($_SESSION['userdata'])) {
echo '<a href="colormode.php?mode=' . $modes_codes[$_SESSION['colormode']] . '&source=' . $_SERVER['REQUEST_URI'] . '">Mode ' . $modes[$_SESSION['colormode']] . '</a><br><br>';
echo '<a href="data_usage.php">Utilisation des données</a><br><br>';
echo $_SESSION['userdata']['admin'] == 1 ? '<a href="admin.php">Admin</a>' : '';
echo "<hr>&copy; 2023 Jan BELLON | Club Réseaux | IUT de Vélizy";
} else {
echo '<a href="data_usage.php">Utilisation des données</a><br><br>';
echo "<hr>&copy; 2023 Jan BELLON | Club Réseaux | IUT de Vélizy";
}
}
function nav($pages) {
echo '<a href="index.php"><img src="./img/notehub' . $_SESSION['colormode'] . '.png" id="notehub-icon"/></a>';
foreach($pages as $key => $value) {
echo '<a href="' . $value . '" class="navlink">' . $key . '</a>';
};
echo '<a href="logout.php" class="navlink" style="color: #FE2424">Deconnexion</a>';
// lien vers profil
echo '<a href="profil.php"><img src="';
echo $_SESSION['userdata']['pp_url'] != NULL ? $_SESSION['userdata']['pp_url'] : 'img/default_pp.jpg';
echo '" height="50px" width="50px" style="border-radius: 25px; position:absolute; right: 20px; top: 5px"/></a>';
}
function addlog($log, $log_dir) {
$log_file = fopen($log_dir . "/notehub.log", "a") or die("Log Error");
fwrite($log_file, $log);
fclose($log_file);
}
?>

1
log/notehub.log Normal file
View File

@ -0,0 +1 @@