diff --git a/ensiie-project/src/Controller/arise_button.php b/ensiie-project/src/Controller/arise_button.php new file mode 100644 index 0000000000000000000000000000000000000000..1fe94005db063f1bff420478e830474278297b3e --- /dev/null +++ b/ensiie-project/src/Controller/arise_button.php @@ -0,0 +1,18 @@ +<?php if ($consumer->is_authenticated()) { ?> + <?php if ($has_access && basename($_SERVER['PHP_SELF']) == "index.php") echo '<a href="listing.php" class="label label-default" style="font-size: small; display: inline-block;">Voir les commandes</a>'; ?> + <?php if ($has_access && basename($_SERVER['PHP_SELF']) == "listing.php") echo '<a href="index.php" class="label label-default" style="font-size: small; display: inline-block;">Retour à la page de commande</a>'; ?> + + <p style="float: right;"> + <?php if ($has_access) echo '<a href="README.md" target="blank_" class="small text-muted">Comment mettre à jour la NJV ?</a>'; ?> + <?php if ($has_access) echo '<span class="label label-success" style="font-size: small; display: inline-block;">Admin</span>'; ?> + <span class="label label-primary" style="font-size: small; display: inline-block;"><?php echo $pseudo; ?></span> + <a href="<?php echo $consumer->get_single_logout_uri(OAuthAriseClient::getScriptURL()) ?>" class="label label-danger" style="font-size: small; display: inline-block;"> + Déconnexion de AriseID + </a> + </p> +<?php } else { ?> + <form action="<?php echo basename($_SERVER['PHP_SELF']); ?>" method="POST" style="float: right; margin-bottom: 10px;"> + <button class="btn btn-primary btn-xs" type="submit" name="arise_login">Connexion à AriseID</button> + </form> +<?php } ?> +<div class="clearfix"></div> \ No newline at end of file diff --git a/ensiie-project/src/Controller/connexion_bouton.php b/ensiie-project/src/Controller/connexion_bouton.php new file mode 100644 index 0000000000000000000000000000000000000000..7fa0971665f88f11df1ee521fa2454a4446b0d4a --- /dev/null +++ b/ensiie-project/src/Controller/connexion_bouton.php @@ -0,0 +1,21 @@ +<?php + +if ($utilisateur == NULL) +{?> + <button onclick="window.open('Controller/connexion_form.php');" class="btn btn-primary btn-xs" name="login" style="float: right; margin-bottom: 10px;">Connexion</button> +<?php +} +else +{?> + <p style="float: right;"> + <?php + if ($utilisateur->isAdmin) + {?> + <span class="label label-success" style="font-size: small; display: inline-block;">Admin</span> + <?php + }?> + <span class="label label-primary" style="font-size: small; display: inline-block;"><?php echo $utilisateur->pseudo; ?></span> + <button onclick="window.open('Model/logout.php');" class="btn btn-primary btn-xs" type="submit" name="logout">Déconnexion</button> + </p> +<?php +}?> \ No newline at end of file diff --git a/ensiie-project/src/Controller/connexion_form.php b/ensiie-project/src/Controller/connexion_form.php new file mode 100644 index 0000000000000000000000000000000000000000..f4ecc6c856082c3670bbb8d0f9ebe7b2f9675b58 --- /dev/null +++ b/ensiie-project/src/Controller/connexion_form.php @@ -0,0 +1,15 @@ +<html> + +<head> +<title>Identification</title> +</head> + +<body> +<form action="../Model/login.php" method="post"> +Votre login : <input type="text" name="login"> +<br/> +Votre mot de passe : <input type="password" name="pwd"><br /> +<input type="submit" value="Connexion"> +</form> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Utilisateur.php b/ensiie-project/src/Model/Classes/Utilisateur.php index f994a9e9924ec13b67af51cc36845e16bbcd4de9..b7a3bdda9313124bdd5b80232c31c8bcd9b0d8f4 100644 --- a/ensiie-project/src/Model/Classes/Utilisateur.php +++ b/ensiie-project/src/Model/Classes/Utilisateur.php @@ -47,14 +47,6 @@ class Utilisateur $this->commandes = $commande; } - /** - * Constructeur par defaut - */ - public function Utilisateur() - { - Utilisateur("","","","",FALSE,NULL); - } - /** * @return int */ diff --git a/ensiie-project/src/Model/Utilisateur/set_utilisateur.php b/ensiie-project/src/Model/Utilisateur/set_utilisateur.php new file mode 100644 index 0000000000000000000000000000000000000000..0424e1d031c92697388241ecb2841bbe9eba31fb --- /dev/null +++ b/ensiie-project/src/Model/Utilisateur/set_utilisateur.php @@ -0,0 +1,13 @@ +<?php +// on teste si nos variables sont définies +if (isset($_SESSION['login'])) +{ + //$db_utilisateur = NULL; // Appel à la base pour récupérer l'utilisateur selon son ariseID = $_SESSION['login'] + //$utilisateur = new Utilisateur($db_utilisateur['ariseID'],$db_utilisateur['prenom'],$db_utilisateur['nom'],$db_utilisateur['pseudo'],$db_utilisateur['isAdmin']); + //$utilisateur->setCommandes($db_utilisateur['commandes']); + $utilisateur = NULL; +} +else +{ + $utilisateur = NULL; +} diff --git a/ensiie-project/src/Model/ariseID.php b/ensiie-project/src/Model/ariseID.php new file mode 100644 index 0000000000000000000000000000000000000000..845703f171495a8b47cf153af5460fdd277619e9 --- /dev/null +++ b/ensiie-project/src/Model/ariseID.php @@ -0,0 +1,46 @@ +<?php +require_once("/usr/share/php/ariseid/client/OAuthAriseClient.php"); +require_once("./config.php"); +$consumer = OAuthAriseClient::getInstance($GLOBALS['consumer_key'], $GLOBALS['consumer_secret'], $GLOBALS['consumer_private_key']); + +if (isset($_POST['arise_login'])) + $consumer->authenticate(); + +if (isset($_POST['arise_logout'])) + $consumer->logout(); + +if ($consumer->has_just_authenticated()) { + session_regenerate_id(); + $consumer->session_id_changed(); +} + +if ($consumer->is_authenticated()) { + $results = $consumer->api()->begin()->get_surnom()->get_identifiant()->done(); + + try { + $pseudo = htmlspecialchars($results[0](), ENT_QUOTES, 'UTF-8'); + } + catch(OAuthAPIException $e) { + echo "Erreur : ".$e->getMessage(); + $pseudo = ''; + } + + try { + $identifiant = htmlspecialchars($results[1](), ENT_QUOTES, 'UTF-8'); + } + catch(OAuthAPIException $e) { + echo "Erreur : ".$e->getMessage(); + } + + try { + $assoces = $consumer->api()->begin()->get_assoce_master()->get_assoce_owner()->done(); + $has_access = ( in_array('lanpartiie', $assoces[0]()) || in_array('lanpartiie', $assoces[1]()) ); + } + catch(OAuthAPIException $e) { + echo "Erreur : ".$e->getMessage(); + } + + $has_access = ($has_access || $identifiant == "cocchi2016"); +} +?> + diff --git a/ensiie-project/src/Model/config.example.php b/ensiie-project/src/Model/config.example.php new file mode 100644 index 0000000000000000000000000000000000000000..c1e1e7d0114971e4f7e1930669739e0ab83b9046 --- /dev/null +++ b/ensiie-project/src/Model/config.example.php @@ -0,0 +1,12 @@ +<?php +// Informations sur l'application AriseID +$GLOBALS['consumer_key'] = ''; // Identifiant +$GLOBALS['consumer_secret'] = ''; // Secret partagé +$GLOBALS['consumer_private_key'] = ''; // Clé privée de l'application + +// Informations sur la connexion au serveur SQL +$GLOBALS['SQL_SRVR'] = "mysql.iiens.net"; // Serveur SQL +$GLOBALS['SQL_USER'] = "assoce_lanpartii"; // Identifiant SQL +$GLOBALS['SQL_PSWD'] = ""; // Mot de passe SQL +$GLOBALS['SQL_DTBS'] = "assoce_lanpartiie"; // Table SQL +?> diff --git a/ensiie-project/src/Model/infos_njv.php b/ensiie-project/src/Model/infos_njv.php new file mode 100644 index 0000000000000000000000000000000000000000..0bb4eafe8ebd284223b3d1fa78b3c078a02b33a3 --- /dev/null +++ b/ensiie-project/src/Model/infos_njv.php @@ -0,0 +1,14 @@ +<?php +setlocale(LC_TIME, "fr_FR"); + + +$NJV_NUMERO = 47; // Numéro de la NJV ou ObiLAN en cours +$NJV_TYPE = 'ObiLAN'; // Type de NJV en cours - {ObiLAN, NJV} +$NJV_DATE = strtotime("05/11/2019 08:00:00"); // Date de début de la NJV ou ObiLAN à 2h près (20h = début effectif à 18h) + +$date_fin_premiere_commande = strtotime("-20 hours -1 second", $NJV_DATE); +$date_fin_seconde_commande = strtotime("-1 hours", $NJV_DATE); +$date_fin_seconde_commande_battement = strtotime("-30minutes", $NJV_DATE); +$date_fin_NJV = strtotime("+9 hour", $NJV_DATE); + +?> \ No newline at end of file diff --git a/ensiie-project/src/Model/login.php b/ensiie-project/src/Model/login.php new file mode 100644 index 0000000000000000000000000000000000000000..d48333aa7167a5d65b5261f902ee891e13972bfc --- /dev/null +++ b/ensiie-project/src/Model/login.php @@ -0,0 +1,35 @@ +<?php +// TODO On interroge notre base de données afin de savoir si le visiteur qui se connecte est bien membre du site +$login_valide = "invite"; +$pwd_valide = "abc"; + +// on teste si nos variables sont définies +if (isset($_POST['login']) && isset($_POST['pwd'])) +{ + + // on vérifie les informations du formulaire, à savoir si le pseudo saisi est bien un pseudo autorisé, de même pour le mot de passe + if ($login_valide == $_POST['login'] && $pwd_valide == $_POST['pwd']) + { + // dans ce cas, tout est ok, on peut démarrer notre session + + // on la démarre :) + session_start (); + // on enregistre les paramètres de notre visiteur comme variables de session ($login et $pwd) + $_SESSION['login'] = $_POST['login']; + $_SESSION['pwd'] = $_POST['pwd']; + // on redirige notre visiteur vers une page de notre section membre + header ('location: ../index.php'); + } + else + { + // Le visiteur n'a pas été reconnu comme étant membre de notre site. On utilise alors un petit javascript lui signalant ce fait + echo '<body onLoad="alert(\'Membre non reconnu...\')">'; + // puis on le redirige vers la page d'accueil + echo '<meta http-equiv="refresh" content="0;URL=../index.php">'; + } +} +else +{ + echo 'Les variables du formulaire ne sont pas déclarées.'; +} +?> \ No newline at end of file diff --git a/ensiie-project/src/Model/logout.php b/ensiie-project/src/Model/logout.php new file mode 100644 index 0000000000000000000000000000000000000000..7445c70f92e389ace080cbcac78581c5fc3b749c --- /dev/null +++ b/ensiie-project/src/Model/logout.php @@ -0,0 +1,13 @@ +<?php +// On démarre la session +session_start (); + +// On détruit les variables de notre session +session_unset (); + +// On détruit notre session +session_destroy (); + +// On redirige le visiteur vers la page d'accueil +header ('location: ../index.php'); +?> \ No newline at end of file diff --git a/ensiie-project/src/View/accueil_utilisateur.php b/ensiie-project/src/View/accueil_utilisateur.php new file mode 100644 index 0000000000000000000000000000000000000000..ad1892a5630afb318f962e20e6f5887d5cdd6445 --- /dev/null +++ b/ensiie-project/src/View/accueil_utilisateur.php @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> +<body> +<?php +if ($utilisateur == NULL) +{?> + <div class="alert alert-danger"> + <strong>Veuillez vous connecter</strong> + </div> +<?php +}?> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/View/body_titre.php b/ensiie-project/src/View/body_titre.php new file mode 100644 index 0000000000000000000000000000000000000000..06b5d22795ca5266f1b76377659247d35171db92 --- /dev/null +++ b/ensiie-project/src/View/body_titre.php @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> +<body> + +<div class="container" style="max-width: 900px;"> + <h2 class="text-center"><?php echo $page_title; ?></h2> + <hr> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/View/commande.php b/ensiie-project/src/View/commande.php index c12e6a07128ef8864647a77657726965fced115d..b8ef4733729f463a0f8a71a1ae9d43670a1d785a 100644 --- a/ensiie-project/src/View/commande.php +++ b/ensiie-project/src/View/commande.php @@ -1,3 +1,6 @@ +<!DOCTYPE html> +<html> +<body> <?php foreach( $commande in $utilisateur->commandes){ @@ -8,3 +11,5 @@ foreach( $commande in $utilisateur->commandes){ <?php } ?> +</body> +</html> diff --git a/ensiie-project/src/View/deadline_commande.php b/ensiie-project/src/View/deadline_commande.php new file mode 100644 index 0000000000000000000000000000000000000000..f63717fcdf12aed42c5dae7ba43f872286115162 --- /dev/null +++ b/ensiie-project/src/View/deadline_commande.php @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> +<body> +<?php +if ($date_fin_premiere_commande > time()) +{?> + <div class="alert alert-warning"> + <strong>📅 Les commandes sont ouvertes jusqu'au <?php echo strftime("%A %d/%m à %H:%M:%S", $date_fin_premiere_commande) ?> !</strong> + </div> + +<?php +} +elseif ($date_fin_seconde_commande > time()) +{?> + <div class="alert alert-danger"> + <strong>📅 Les commandes restent ouvertes jusqu'à ce soir, <?php echo date("H", $date_fin_seconde_commande) ?>h dernier délai !</strong> + </div> +<?php +} +elseif ($date_fin_NJV > time()) +{?> + <div class="alert alert-danger"> + <strong>📅 Les commandes sont (normalement) fermées depuis <?php echo date("H", $date_fin_seconde_commande) ?>h. Si vous avez un doute, demandez à un membre de LP.</strong> + </div> +<?php +} +else +{?> + <div class="alert alert-danger"> + <strong>📅 Les commandes sont fermées !</strong> + </div> +<?php +} +?> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/View/footer.php b/ensiie-project/src/View/footer.php index 28d1d22d9615939cf5a097ef1d29c055a566639d..51ea7719acc4c839a7e2ca651123d9ce0f23ee35 100644 --- a/ensiie-project/src/View/footer.php +++ b/ensiie-project/src/View/footer.php @@ -1,2 +1,3 @@ +<!-- </div> --> <img src="http://bde.iiens.net/web/images/logos/lanpartiie.png" style="max-width: 40%; margin: 0 30%;" /> <div class="small text-center text-muted">• Site par JaCoGaJe •</div> \ No newline at end of file diff --git a/ensiie-project/src/View/head.php b/ensiie-project/src/View/head.php new file mode 100644 index 0000000000000000000000000000000000000000..d90ad72feb3cbe00339e6884839c6ecdc8398548 --- /dev/null +++ b/ensiie-project/src/View/head.php @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html> +<head> + <title>LanpartIIE - <?php echo $page_title; ?></title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesome-bootstrap-checkbox/1.0.0/awesome-bootstrap-checkbox.min.css"> + <link rel="icon" type="image/png" href="http://lanpartiie.iiens.net/sith/webroot/img/icons/member.png"> + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> + + <meta http-equiv="Expires" content="Tue, 01 Jan 1995 12:12:12 GMT"> + <meta http-equiv="Pragma" content="no-cache"> + <meta name="theme-color" content="#829A30"> + + <style> + * { outline: 0 !important; } + body { padding: 25px 0; } + .input-group { margin-bottom: 5px; width: 100%; } + .input-group:last-of-type { margin-bottom: 10px; } + .input-group-addon { cursor: default; font-weight: bold; width: 160px; text-align: left; } + textarea { resize: vertical; } + + .abc-checkbox { margin-left: -5px; } + .abc-checkbox input[type=checkbox]:checked + label:after { font-family: 'Glyphicons Halflings'; content: "\e013"; } + .abc-checkbox label:after { padding-left: 0; padding-top: 2px; font-size: 9px; } + .servie-label { color: #666; font-size: 10px; font-weight: bold; } + </style> + +</head> +</html> diff --git a/ensiie-project/src/admin.php b/ensiie-project/src/admin.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ensiie-project/src/index.php b/ensiie-project/src/index.php index d7bae9b3e6454ef8f8e60cfbf065b9ecdc4eebfd..bffaacfbebff309cfff72da3326f3b0fae174643 100644 --- a/ensiie-project/src/index.php +++ b/ensiie-project/src/index.php @@ -1,3 +1,27 @@ <?php +session_start(); + +require_once('Model/Utilisateur/utilisateur.php'); +require_once("Model/Utilisateur/set_utilisateur.php"); +require_once('Model/infos_njv.php'); + +if ($NJV_TYPE == 'ObiLAN') + $page_title = 'Commander pour l\'ObiLAN '.$NJV_NUMERO; +if ($NJV_TYPE == 'NJV') + $page_title = 'Commander pour la NJV '.$NJV_NUMERO; + +include('View/head.php'); + +include('View/body_titre.php'); + +include("Controller/connexion_bouton.php"); + +include('View/accueil_utilisateur.php'); + +if ($utilisateur != NULL) +{ + include('View/deadline_commande.php'); +} + include('View/footer.php'); ?>