function action_message_list()
 {
     $authentification = new Authentification();
     $auth_opt = $authentification->get_auth_opt();
     $model = new Model_Message();
     $data = $model->get_message_list();
     $this->view->generate('view_message.php', 'view_skeleton.php', $data, $auth_opt);
 }
示例#2
0
 public function try_login($email, $password)
 {
     $authentification = new Authentification();
     if ($authentification->login($email, $password)) {
         return true;
     } else {
         return false;
     }
 }
 function action_people()
 {
     $authentification = new Authentification();
     $auth_opt = $authentification->get_auth_opt();
     $model = new Model_People();
     if ($_GET['recieve'] == 1) {
         $data = $model->search_people();
         $options['user_id'] = $_SESSION['user_id'];
         $options['subscribes'] = $model->get_subscribes();
         $this->view->generate('view_people.php', 'view_skeleton.php', $data, $auth_opt, $options);
     } else {
         $this->view->generate('view_people.php', 'view_skeleton.php', $data, $auth_opt, $options);
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         // Si l'utilisateur a l'autorisation de modifier les propriétés,
         // on affiche la version modifiable plutôt que la "vue".
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<ul>';
             $ret .= '<li><label for="Couleur_A">Couleur A : </label><input type="text" id="Couleur_A" name="Couleur_A" value="#000" /></li>';
             $ret .= '<li><label for="Couleur_B">Couleur B : </label><input type="text" id="Couleur_B" name="Couleur_B" value="#eee" /></li>';
             $ret .= '<li><label for="Couleur_C">Couleur C : </label><input type="text" id="Couleur_C" name="Couleur_C" value="#ff6" /></li>';
             $ret .= '<li><label for="Couleur_D">Couleur D : </label><input type="text" id="Couleur_D" name="Couleur_D" value="#fff" /></li>';
             $ret .= '</ul>';
             $ret .= '<p>';
             $ret .= '<input type="submit" value="Appliquer" />';
             $ret .= '</p>';
         } else {
             $ret .= '<ul>';
             $ret .= '<li>Couleur A : ' . Stockage::get_prop($chemin, "Coucleur_A") . '</li>';
             $ret .= '<li>Couleur B : #eee</li>';
             $ret .= '<li>Couleur C : #ff6</li>';
             $ret .= '<li>Couleur D : #fff</li>';
             $ret .= '</ul>';
         }
         return new Page($ret, "Apparence");
     } else {
         if ($vue == "css") {
             // TODO : où mettre ce gen_css... ?
             return Site::gen_css(array("Couleur_A" => Stockage::get_prop($chemin, "Coucleur_A"), "Couleur_B" => Stockage::get_prop($chemin, "Coucleur_B"), "Couleur_C" => Stockage::get_prop($chemin, "Coucleur_C"), "Couleur_D" => Stockage::get_prop($chemin, "Coucleur_D")));
         }
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="contact infos" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
             $ret .= '<p class="contact index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>';
         }
         $ret .= '<div class="contact liste-contacts index">';
         $ret .= '<ul>';
         if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) {
             $ret .= '<li>';
             $ret .= '<div class="titre">';
             $ret .= '<form class="contact nouvelle_page" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<p>';
             $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>';
             $ret .= '<input type="submit" value="Nouveau contact"/>';
             $ret .= '</p>';
             $ret .= '</form>';
             $ret .= '</div>';
             $ret .= '</li>';
         }
         foreach (stockage::liste_enfants($chemin) as $k) {
             $ret .= '<li>' . Modules::vue($k)->contenu . '</li>';
         }
         $ret .= '</ul>';
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="contacts contact edition" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<input type="text" name="prenom" value="' . Stockage::get_prop($chemin, "prenom") . '" />';
             $ret .= '<input type="text" name="nom" value="' . Stockage::get_prop($chemin, "nom") . '" />';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= Stockage::get_prop($chemin, "prenom");
             $ret .= " ";
             $ret .= Stockage::get_prop($chemin, "nom");
             $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "description"));
         }
         if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) {
             $ret .= '<form action="' . $chemin->get_url() . '">';
             $ret .= '<input type="hidden" name="action" value="supprimer"/>';
             $ret .= '<input type="submit" value="Supprimer le contact ' . htmlspecialchars(Stockage::get_prop($chemin, "prenom") . " " . Stockage::get_prop($chemin, "nom")) . '"/>';
             $ret .= '</form>';
         }
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="galerie infos" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
             $ret .= '<p class="galerie index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>';
         }
         $ret .= '<div class="galerie photos index">';
         $ret .= '<ul>';
         foreach (Stockage::liste_enfants($chemin) as $k) {
             $mini = Modules::vue($k, 'miniature');
             $ret .= '<li>';
             $ret .= '<a href="' . $k->get_url() . '">';
             // TODO : escape l'url !
             $ret .= '<span class="miniature">';
             $ret .= $mini->contenu;
             // TODO : escape l'url !
             $ret .= '</span>';
             $ret .= '<span class="titre">';
             $ret .= $mini->titre;
             $ret .= '</span>';
             $ret .= '</a>';
             $ret .= '</li>';
         }
         if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) {
             $ret .= '<li>';
             $ret .= '<div class="miniature">';
             $ret .= '<img alt="nouvelle période" src="' . $chemin->get_url("?vue=image_nouvelle_periode") . '" />';
             $ret .= '</div>';
             $ret .= '<div class="titre">';
             $ret .= '<form class="galerie nouvelle_page" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<p>';
             $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>';
             $ret .= '<input type="submit" value="Nouvelle période"/>';
             $ret .= '</p>';
             $ret .= '</form>';
             $ret .= '</div>';
             $ret .= '</li>';
         }
         $ret .= '</ul>';
         $ret .= '<div class="clearboth"></div>';
         $ret .= '</div>';
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     } else {
         if ($vue == "image_nouvelle_periode") {
             // Houlàlà ça sent le hack pas beau !
             return new Page(Path::combine(Config::get("chemin_base"), "/code/site/nouvelle_image.jpg"), null, "sendfile");
         }
     }
 }
 function action_add_training()
 {
     $authentification = new Authentification();
     $auth_opt = $authentification->get_auth_opt();
     $model = new Model_Training();
     $data = $model->get_all_exercises();
     $options['kos'] = $model->get_all_sports();
     //var_dump($options);
     if ($_GET['recieve'] == 1) {
         $model->add_training();
         $options['result'] = 'Training sucessfully added!';
         $this->view->generate('view_add_training.php', 'view_skeleton.php', $data, $auth_opt, $options);
     } else {
         if ($_GET['recieve'] == 2) {
             $model->add_exercise();
             $options['result'] = 'Exercise sucessfully added!';
             $this->view->generate('view_add_training.php', 'view_skeleton.php', $data, $auth_opt, $options);
         } else {
             $this->view->generate('view_add_training.php', 'view_skeleton.php', $data, $auth_opt, $options);
         }
     }
 }
 function action_index()
 {
     $model = new Model_Main();
     $host = $_SERVER['HTTP_HOST'];
     if ($_GET['logout'] == 1) {
         $authentification = new Authentification();
         $authentification->logout();
     }
     if ($_GET['recieve'] == 1) {
         if ($model->try_login($_POST['email'], $_POST['password'])) {
             $authentification = new Authentification();
             $auth_opt = $authentification->get_auth_opt();
             echo '<script type="text/javascript">location.href = "http://' . $host . '/Feed/feed";</script>';
         } else {
             $options['def_email'] = $_POST['email'];
             $options['result'] = 'Login error!';
             $this->view->generate('view_main_login.php', 'view_skeleton_main.php', $data, $auth_opt, $options);
         }
     } else {
         $this->view->generate('view_main_login.php', 'view_skeleton_main.php');
     }
 }
示例#10
0
 public function login()
 {
     $form = Authentification::$form;
     $id = $user->callLoginProcess(Authentification::$login_user, Authentification::$login_pwd);
     echo '<pre style="font-family: sans-serif; font-size: 1.5rem;display:block; width: 100%; word-wrap: break-word;">';
     var_dump($id);
     echo '</pre>';
     if ($id) {
     } else {
         Tools::throwWarningMessage('wrong identification');
     }
     Authentification::isMemberConnected();
 }
 /**
  * Execute la commande du manager trouvé, attention si la commande a besoin de paramètres, ils seront générés a partir
  * de toutes les données passées en POST et les recherchera par clé, pensez donc a donner le bon nom aux inputs des formulaires
  * pour que la commande trouve bien les variables
  *
  * @param     array params    Tableau de paramètre a passer a la commande
  * @return    json  résultat  rendu par le manager au format json
  */
 public function dispatch($params)
 {
     if ($this->managerFound instanceof Authentification or Authentification::checkUser($this->commandFound['role'], $this->commandFound['strict'])) {
         if (method_exists($this->managerFound, $this->commandFound['method'])) {
             $evalCommand = '$this->managerFound->' . $this->commandFound['method'] . '($params)?>';
             eval($evalCommand);
         } else {
             Response::quickResponse(500, json_encode("La méthode: " . $this->commandFound['method'] . ' n\'est pas présente dans le manager'));
         }
     } else {
         Response::quickResponse(403, json_encode(['message' => 'vous n\'estes pas autorisé a faire cette action']));
     }
 }
 function action_feed()
 {
     $authentification = new Authentification();
     $auth_opt = $authentification->get_auth_opt();
     $model = new Model_Feed();
     if (isset($_GET['delete'])) {
         $model->delete_post($_GET['delete']);
     }
     if (isset($_GET['like_post_id'])) {
         $model->like_post($_GET['like_post_id'], $_SESSION['user_id']);
     }
     if (isset($_GET['recieve_comment'])) {
         $model->add_comment($_GET['recieve_comment']);
     }
     if ($_GET['recieve_post'] == 1) {
         if (isset($_FILES['userfile']['tmp_name'])) {
             $destination = 'images/' . $_FILES['userfile']['name'];
             move_uploaded_file($_FILES['userfile']['tmp_name'], $destination);
         }
         $model->add_post($destination);
     }
     $data = $model->get_posts($_SESSION['user_id']);
     $this->view->generate('view_feed.php', 'view_skeleton.php', $data, $auth_opt);
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="articles infos" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
             $ret .= '<p class="articles index description affichage">' . Stockage::get_prop($chemin, "description") . '</p>';
         }
         $ret .= '<div class="articles liste-articles index">';
         $ret .= '<ul>';
         if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) {
             $ret .= '<li>';
             $ret .= '<div class="titre">';
             $ret .= '<form class="articles nouvelle_page" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<p>';
             $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>';
             $ret .= '<input type="submit" value="Nouvel article"/>';
             $ret .= '</p>';
             $ret .= '</form>';
             $ret .= '</div>';
             $ret .= '</li>';
         }
         foreach (Stockage::liste_enfants($chemin) as $k) {
             // TODO : trier par numéro !
             $mini = Modules::vue($k, 'miniature');
             $ret .= '<li>';
             // TODO : mettre une ancre "#message<numéro>"
             $ret .= '<a href="' . $k->get_url() . '">';
             // TODO : escape l'url !
             $ret .= '<span class="titre">';
             $ret .= $mini->titre;
             $ret .= '</span>';
             $ret .= '<p class="contenu">';
             $ret .= $mini->contenu;
             $ret .= '</p>';
             $ret .= '</a>';
             $ret .= '</li>';
         }
         $ret .= '</ul>';
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     $singleton = new Chemin("/admin/permissions/");
     if ($vue == "normal") {
         $ret = "";
         $ret .= "<h2>Règles de sécurité</h2>";
         $ret .= "<p>La première règle correspondant à une action de l'utilisateur est appliquée. TODO Bla-bla blabla sur le fonctionnement.</p>";
         if (Permissions::vérifier_permission($singleton, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<textarea class="admin permissions regles" cols="200" rows="20">' . Stockage::get_prop($singleton, "regles") . "</textarea>";
             // TODO : html escape chars etc.
         } else {
             $ret .= "<pre><code>" . Stockage::get_prop($singleton, "regles") . "</code></pre>";
             // TODO : html escape chars etc.
         }
         return new Page($ret, "Permissions");
     }
 }
 public static function en_tete($page)
 {
     // TODO : chemin css relatif.
     $racine = new Chemin('/');
     $chemin_css = $racine->get_url('?vue=css');
     $nl = "\n";
     $ret = '';
     $ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . $nl;
     $ret .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">' . $nl;
     $ret .= '	<head>' . $nl;
     $ret .= '		<title>' . $page->titre . '</title>' . $nl;
     $ret .= '		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . $nl;
     $ret .= '		<meta http-equiv="Content-Language" content="fr" />' . $nl;
     $ret .= '		<meta name="keywords" lang="fr" content="motcle1,mocle2" />' . $nl;
     $ret .= '		<meta name="description" content="Description de ma page web." />' . $nl;
     /*$ret .= '		<link href="' . $chemin_css . '" rel="stylesheet" type="text/css" />' . $nl;*/
     $ret .= '		<link href="' . $racine->get_url("test.less") . '" rel="stylesheet/less" type="text/css" />' . $nl;
     $ret .= '		<script src="' . $racine->get_url("less/less.js") . '" type="text/javascript"></script>' . $nl;
     $ret .= '	</head>' . $nl;
     $ret .= '	<body>' . $nl;
     $ret .= '		<h1><a href="' . $racine->get_url() . '">' . Stockage::get_prop($racine, "nom_site") . '</a></h1>' . $nl;
     $ret .= '		<div class="site connexion">' . $nl;
     if (Authentification::est_connecté()) {
         $ret .= '<a href="' . $racine->enfant("admin")->enfant("connexion")->get_url("?action=deconnexion") . '">déconnexion</a>' . $nl;
     } else {
         $ret .= '<a href="' . $racine->enfant("admin")->enfant("connexion")->get_url() . '">connexion</a>' . $nl;
     }
     $ret .= '		</div>' . $nl;
     $ret .= '		<div class="site navigation">' . $nl;
     $ret .= '			<ul>' . $nl;
     $ret .= '				<li><a href="' . $racine->get_url() . '">Accueil</a></li>' . $nl;
     $ret .= '				<li><a href="' . $racine->enfant("galerie")->get_url() . '">Galerie</a></li>' . $nl;
     $ret .= '				<li><a href="' . $racine->enfant("nouveautes")->get_url() . '">Nouveautés</a></li>' . $nl;
     $ret .= '				<li><a href="' . $racine->enfant("equipes")->get_url() . '">Équipes</a></li>' . $nl;
     $ret .= '				<li><a href="' . $racine->enfant("forum")->get_url() . '">Forum</a></li>' . $nl;
     $ret .= '				<li><a href="' . $racine->enfant("liens")->get_url() . '">Liens utiles</a></li>' . $nl;
     $ret .= '				<li><a href="' . $racine->enfant("contact")->get_url() . '">Contact</a></li>' . $nl;
     if (Permissions::vérifier_permission($racine->enfant("admin"), "set_prop", Authentification::get_utilisateur())) {
         $ret .= '<li><a href="' . $racine->enfant("admin")->get_url() . '">Administration</a></li>' . $nl;
     }
     $ret .= '			</ul>' . $nl;
     $ret .= '		</div>' . $nl;
     $ret .= '		<div class="site contenu">' . $nl;
     return $ret;
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="forum message edition" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "message"), "message");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "message"));
         }
         if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) {
             // peut-être afficher le bouton "Supprimer" ??? ou est-ce trop d'options ?
         }
         // Peut-être afficher le bouton "citer" ? ou est-ce trop d'options ?
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         $ret .= '<div class="prochain-evenement">';
         $ret .= '<h2>Prochain évènement</h2>';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form method="post" action="' . $chemin->get_url() . '">';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "prochain_evenement"), "prochain_evenement");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= Stockage::get_prop($chemin, "prochain_evenement");
         }
         $ret .= '</div>';
         $ret .= '<div class="description-site">';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="nom_site infos" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="nom_site" value="' . Stockage::get_prop($chemin, "nom_site") . '" /></h2>';
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= "<h2>" . Stockage::get_prop($chemin, "nom_site") . "</h2>";
         }
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form method="post" action="' . $chemin->get_url() . '">';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= Stockage::get_prop($chemin, "description");
         }
         $ret .= '</div>';
         return new Page($ret, Stockage::get_prop($chemin, "nom_site"));
     } else {
         if ($vue == "css") {
             return new Page(get_css(), "text/css", "raw");
         }
     }
     return new Page('', '');
     // TODO : devrait renvoyer une page d'erreur !
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="articles infos" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
         }
         $ret .= '<div class="nouveautes list index">';
         $ret .= '<ul>';
         /*foreach (Stockage::liste_enfants(new Chemin("/forum")) as $k) {
         		$date = Stockage::get_prop($k, "date_modif");
         		if (Erreur::is_erreur($date)) $date = "0";
         		$date = (int)$date;
         		
         		var_dump($date);
         		}*/
         // TODO : faire dans l'ordre décroissant les 5 dernières nouveautés.
         foreach (Stockage::liste_enfants($chemin) as $n) {
             $k = new Chemin(Stockage::get_prop($n, "chemin"));
             $mini = Modules::vue($k, 'miniature');
             $ret .= '<li>';
             // TODO : mettre une ancre "#message<numéro>"
             $ret .= '<a href="' . $k->get_url() . '">';
             // TODO : escape l'url !
             $ret .= '<span class="titre">';
             $ret .= $mini->titre;
             $ret .= '</span>';
             $ret .= '</a>';
             $ret .= '<p class="contenu">';
             $ret .= $mini->contenu;
             $ret .= '</p>';
             $ret .= '</li>';
         }
         $ret .= '</ul>';
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     }
 }
 public static function vérifier_permission($chemin, $action, $utilisateur = null)
 {
     if ($utilisateur === null) {
         $utilisateur = Authentification::get_utilisateur();
     }
     $groupe = Authentification::get_groupe($utilisateur, true);
     // true => forcer permissions.
     // Parcourt la liste les règles de sécurité (get_regles()), et
     // sélectionne la première pour laquelle $chemin correspond au motif
     // de la règle, $action correspond au motif de la règle, et
     // $utilisateur a comme groupe le groupe de la règle (get_groupe()).
     // Si le champ "autorisation" de la règle est true, on renvoie true,
     // sinon on renvoie false
     foreach (self::get_regles() as $r) {
         if (self::chemin_correspond($chemin, $r["chemin"]) && self::action_correspond($action, $r["action"]) && self::groupe_correspond($groupe, $r["groupe"])) {
             return $r["autorisation"];
         }
     }
     return false;
 }
 public static function action($chemin, $action, $paramètres)
 {
     if ($action == "connexion") {
         if (Authentification::connexion(strtolower($paramètres["utilisateurnom"] . "___" . $paramètres["utilisateurprenom"]), $paramètres["mdp"])) {
             return self::vue($chemin, "connexion réussie");
         } else {
             return self::vue($chemin, "connexion échouée");
         }
     } else {
         if ($action == "deconnexion") {
             Authentification::déconnexion();
             return self::vue($chemin, "déconnexion");
         } else {
             if (isset($paramètres["vue"])) {
                 return self::vue($chemin, $paramètres["vue"]);
             } else {
                 return self::vue($chemin);
             }
         }
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="forum sujet infos" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2 class="forum sujet titre affichage">' . Stockage::get_prop($chemin, "titre") . '</h2>';
         }
         if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) {
             $ret .= '<form action="' . $chemin->get_url() . '">';
             $ret .= '<input type="hidden" name="action" value="supprimer"/>';
             $ret .= '<input type="submit" value="Supprimer le sujet"/>';
             $ret .= '</form>';
         }
         $ret .= '<ul class="forum sujet">';
         foreach (stockage::liste_enfants($chemin) as $k) {
             $ret .= '<li>' . Modules::vue($k)->contenu . '</li>';
         }
         if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) {
             $ret .= '<li>';
             $ret .= '<form class="forum sujet nouvelle_page" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<p>';
             $ret .= '<input type="hidden" name="action" value="nouvelle_page"/>';
             $ret .= '<input type="submit" value="Nouveau message"/>';
             $ret .= '</p>';
             $ret .= '</form>';
             $ret .= '</li>';
         }
         $ret .= '</ul>';
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     } else {
         if ($vue == "miniature") {
             return new Page("Sujet.", Stockage::get_prop($chemin, "titre"));
         }
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     $singleton = new Chemin("/admin/utilisateurs/");
     if ($vue == "normal") {
         $ret = '';
         $ret .= "<h2>Utilisateurs</h2>";
         if (Permissions::vérifier_permission($chemin, "nouvelle_page", Authentification::get_utilisateur())) {
             // afficher le lien "Nouvel utilisateur"
         }
         $ret .= '<table class="utilisateurs index"><thead><th>Nom</th><th>Prénom</th><th>Groupe</th><th>Mot de passe</th><th>Peut se connecter</th><th colspan="2"></th></thead><tbody>';
         $listegroupes = "";
         // Construire la liste des groupes sous forme de menu drop-down.
         foreach (Authentification::liste_utilisateurs() as $u) {
             $ret .= '<tr>' . '<form action="' . $chemin->get_url() . '">' . '<td>' . $u . '</td>' . '<td>' . $u . '</td>' . '<td>' . Authentification::get_groupe($u) . '</td>' . '<td>' . Authentification::get_mot_de_passe($u) . '<input type="submit" value="Générer un nouveau mot de passe"/></td>' . '<td>' . (Authentification::get_peut_se_connecter($u) ? "oui" : "non") . '</td>' . '<td><input type="submit" value="appliquer"/></td>' . '<td><input type="submit" value="supprimer"/></td>' . '</form>' . '</tr>';
             // Le champ mot de passe doit être un lien / bouton "nouveau
             // mot de passe automatique" qui redirige vers
             // $chemin->enfant("$utilisateur") ?action=gen_mdp .
         }
         $ret .= '</tbody></table>';
         return new Page($ret, "Utilisateurs");
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="articles article edition" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "contenu"), "contenu");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
             $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "contenu"));
         }
         if (Permissions::vérifier_permission($chemin, "supprimer", Authentification::get_utilisateur())) {
             // TODO : afficher le bouton "Supprimer".
         }
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     } elseif ($vue == "miniature") {
         $ret = miniature_texte_enrichi(Stockage::get_prop($chemin, "contenu"));
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     }
 }
 public static function vue($chemin, $vue = "normal")
 {
     if ($vue == "normal") {
         $ret = '';
         if (Permissions::vérifier_permission($chemin, "set_prop", Authentification::get_utilisateur())) {
             $ret .= '<form class="galerie infos" enctype="multipart/form-data" method="post" action="' . $chemin->get_url() . '">';
             $ret .= '<h2><input type="text" name="titre" value="' . Stockage::get_prop($chemin, "titre") . '" /></h2>';
             $ret .= '<img alt="' . Stockage::get_prop($chemin, "titre") . '" src="' . $chemin->get_url("?vue=image") . '"/>';
             $ret .= '<p>';
             $ret .= '<input type="file" name="fichier_image" id="fichier_image">';
             $ret .= '</p>';
             $ret .= formulaire_édition_texte_enrichi(Stockage::get_prop($chemin, "description"), "description");
             $ret .= '<p><input type="submit" value="appliquer" /></p>';
             $ret .= '</form>';
         } else {
             $ret .= '<h2>' . Stockage::get_prop($chemin, "titre") . '</h2>';
             $ret .= '<img alt="' . Stockage::get_prop($chemin, "titre") . '" src="' . $chemin->get_url("?vue=image") . '"/>';
             $ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "message"));
         }
         return new Page($ret, Stockage::get_prop($chemin, "titre"));
     } else {
         if ($vue == "miniature" || $vue == "mini") {
             $ret = '<img alt="' . Stockage::get_prop($chemin, "titre") . '" src="' . $chemin->get_url("?vue=image_mini") . '"/>';
             return new Page($ret, Stockage::get_prop($chemin, "titre"));
         } else {
             if ($vue == "image") {
                 return new Page($chemin, "image", "sendprop");
             } else {
                 if ($vue == "image_mini") {
                     return new Page($chemin, "image_mini", "sendprop");
                 }
             }
         }
     }
     return new Page('', '');
     // TODO : devrait renvoyer une page d'erreur !
 }
示例#25
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/classes/class.DataHandling.php';
$fromUri = isset($_GET['originating_uri']) ? $_GET['originating_uri'] : '/profile';
if (Authentification::CheckCredentials()) {
    Redirect('/profile');
}
if (isset($_POST['submit'])) {
    $bool = isset($_SESSION['attempts']);
    $_SESSION['attempts'] = $bool ? $_SESSION['attempts'] + 1 : 1;
    $post = GetPOST();
    $login = $post['login'];
    $pass = $post['pass'];
    try {
        //captcha checking
        if (isset($_SESSION['attempts']) && $_SESSION['attempts'] >= NUMBER_OF_LOGIN_ATTEMPTS) {
            $key_string = isset($_POST['keystring']) ? $_POST['keystring'] : '';
            $bool = isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] === $key_string;
            if ($bool) {
                $_SESSION['attempts'] = NULL;
            } elseif ($_SESSION['attempts'] > NUMBER_OF_LOGIN_ATTEMPTS) {
                $smarty->assign('errorCaptcha', ERROR_CAPTCHA);
                throw new Exception('');
            }
        }
        try {
            (new DataHandling())->validatePassword($pass, ERROR_LOGIN);
            AuthorizedUser::Login($login, $pass);
            $_SESSION['attempts'] = null;
            Redirect('/profile');
        } catch (Exception $e) {
示例#26
0
<?php

session_start();
require 'autoloader.php';
if (!Authentification::checkUser(0)) {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . "/index.php");
    die;
}
function customCompression($input, $compression)
{
    if ($compression) {
        return strtr(base64_encode(addslashes(gzcompress(serialize($input), 9))), '+/=', '-_,');
    } else {
        return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
    }
}
/* REPONSE DU MANAGER */
$managerStatus = isset($_GET['status']) ? $_GET['status'] : null;
$managerTitle = isset($_GET['title']) ? $_GET['title'] : 'Oups!';
$managerMessage = isset($_GET['message']) ? $_GET['message'] : 'Erreur interne!';
// on récupère la liste des médecins si donnée
$medecinsSearch = isset($_GET['medecins']) ? json_decode(customCompression($_GET['medecins'], false), true) : [];
?>

<!DOCTYPE html>
<html>
	<head>
		<title>Gestion des médecins</title>

		<meta charset='utf-8'/>
		<meta name='description' value='Site de test'/>
示例#27
0
<?php

if (!isset($_SESSION)) {
    @session_start();
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/constants.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/settings.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/utils.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/lib/reg_auth.inc';
$request = explode('/', substr($_SERVER['REQUEST_URI'], 1));
$smarty->assign('isLogin', Authentification::CheckCredentials());
示例#28
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once '../../classes/admin.php';
require_once '../../classes/authentification.php';
require_once '../../classes/tasks.php';
$auth = new Authentification();
$admin = new Admin();
$id_connected = $auth->is_connected();
$params = json_decode(file_get_contents('php://input'), true);
if (!$id_connected['admin']) {
    return;
}
switch ($params['action']) {
    //--------------- ADD_USER ------------------
    case 'add_user':
        echo json_encode($auth->add_user($params['login'], "password"));
        if (isset($params['isAdmin']) && $params['isAdmin'] == 'true') {
            $admin->add_admin($params['login']);
        }
        break;
        //--------------- SET_ADMIN ------------------
    //--------------- SET_ADMIN ------------------
    case 'set_admin':
        if ($params['isAdmin'] == 'true') {
            echo json_encode($admin->add_admin($params['login']));
        } else {
            echo json_encode($admin->remove_admin($params['login']));
        }
示例#29
0
文件: back.php 项目: satodev/pf-pvt
<?php

session_write_close();
$auth = new Authentification();
if ($auth->getEnableContent()) {
    echo '<ul class="vertical medium-horizontal menu center">
        <li><a href="?p=back&opt=mailer">Mailer</a></li>
        <li><a href="?p=back&opt=imgs">Image System</a></li>
      </ul>';
    if ($_GET && $_GET['opt']) {
        if ($_GET['opt'] == 'mailer') {
            $mailer = new Mailer();
            $mailer->init();
        }
        if ($_GET['opt'] == 'imgs') {
            $imageManager = new ImageManager();
            // $imageManager->goToFolder('compute');
            // $imageManager->createImageFolder('compute');
            $imageManager->getTreeMap();
            // $imageManager->interfaceTreeFolder();
            $imageManager->interfaceInputUrlBar();
            $imageManager->interfaceAccordion();
            // $imageManager->interfaceImageData();
            // echo '<p id="currentPosition">'.$imageManager->getFolderPosition().'</p>';
            $imageManager->goToFolder();
            // $imageManager->createImageFolder('myfilename');
            $imageManager->interfaceUpload();
        }
    }
}
?>
示例#30
0
<!DOCTYPE html>

<?php 
/*
petite explication : on démarre le systeme de session de php, on inclu notre authentification
, on appelle la fonction que vérifie le login et role de l'utilisateur (voir source pour la doc)
si l'utilisateur est logué, on le redirige vers la page d'accueil de l'outil
*/
session_start();
require 'autoloader.php';
if (isset($_POST['co'])) {
    $Auth = new Authentification();
    $Auth->authentification($_POST['username'], $_POST['password']);
}
if (Authentification::checkUser(0)) {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . "/Dashboard.php");
    die;
}
?>

<html>
	<head>
		<title>Connexion</title>

		<meta charset='utf-8'/>
		<meta name='description' value='Site de test'/>
		<meta name='author' value='{xdrm} & SeekDaSky'/>


		<link rel='stylesheet' href='css/font.css'/>
		<link rel='stylesheet' href='css/login-material.css'/>