Blame | Last modification | View Log | RSS feed
<?php/*login.phpCopyright 2010 Florian SCHMITTAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:1. Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.3. The name of the author may not be used to endorse or promote productsderived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIESOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUTNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OFTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/// Lecture des parametres de l'action// url d'inscription$signupurl = $this->GetParameter('signupurl');// si pas de pas d'url d'inscription renseignée, on utilise ParametresUtilisateurif (empty($signupurl) && $signupurl != "0") {$signupurl = $this->href("", "ParametresUtilisateur", "");}else {if ($this->IsWikiName($signupurl)) {$signupurl = $this->href('', $signupurl);}}// url du profil$profileurl = $this->GetParameter('profileurl');$incomingurl = 'http'.((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'|| $_SERVER['SERVER_PORT'] == 443) ? 's' : '').'://'.(($_SERVER['SERVER_PORT']!='80') ? $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'] :$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']).(($_SERVER['QUERY_STRING']>' ') ? '?'.$_SERVER['QUERY_STRING'] : '');$userpage = $this->GetParameter("userpage");// si pas d'url de page de sortie renseignée, on retourne sur la page couranteif (empty($userpage)) {$userpage = $incomingurl;// si l'url de sortie contient le passage de parametres de déconnexion, on l'effaceif (isset($_REQUEST["action"]) && $_REQUEST["action"] == "logout") {$userpage = str_replace('&action=logout', '', $userpage);}}else {if ($this->IsWikiName($userpage)) {$userpage = $this->href('', $userpage);}}// classes css pour l'action et pour les boutons$class = $this->GetParameter("class");$btnclass = $this->GetParameter("btnclass");// template par défaut$template = $this->GetParameter("template");if (empty($template) || !file_exists('tools/login/presentation/templates/'.$template) ) {$template = "default.tpl.html";}$error = '';$PageMenuUser = '';// on initialise la valeur vide si elle n'existe pasif (!isset($_REQUEST["action"])) $_REQUEST["action"] = '';// cas de la déconnexionif ($_REQUEST["action"] == "logout") {$this->LogoutUser();if($this->config['use_sso']) {require_once('tools/login/libs/identificationsso.class.php');$sso = new identificationSso($this);$sso->deconnecterUtilisateur(str_replace('&action=logout', '', $incomingurl));}$this->SetMessage("Vous êtes maintenant déconnecté !");$this->Redirect(str_replace('&action=logout', '', str_replace('&action=logout', '', $incomingurl)));exit;}// cas de l'identificationif ($_REQUEST["action"] == "login") {// login ssoif($this->config['use_sso']) {// identification.php analyse les cookies, header etc... afin de déterminer la présence d'un jetonrequire_once('tools/login/libs/identificationsso.class.php');$sso = new identificationSso($this);$sso->connecterUtilisateur($_POST["name"], $_POST["password"], $_POST['incomingurl']);} else {// login normal// si l'utilisateur existe, on vérifie son mot de passeif (isset($_POST["name"]) && $existingUser = $this->LoadUser($_POST["name"])) {// si le mot de passe est bon, on créée le cookie et on redirige sur la bonne pageif ($existingUser["password"] == md5($_POST["password"])) {$this->SetUser($existingUser, $_POST["remember"]);// si l'on veut utiliser la page d'accueil correspondant au nom d'utilisateurif ( $userpage=='user' && $this->LoadPage($_POST["name"]) ) {$this->Redirect($this->href('', $_POST["name"], ''));}// on va sur la page d'ou on s'est identifie sinonelse {$this->Redirect($_POST['incomingurl']);}}// on affiche une erreur sur le mot de passe sinonelse {$this->SetMessage("Identification impossible : mauvais mot de passe.");$this->Redirect($_POST['incomingurl']);}}// on affiche une erreur sur le NomWiki sinonelse {$this->SetMessage("Identification impossible : NomWiki non reconnu.");$this->Redirect($_POST['incomingurl']);}}}if($this->config['use_sso']) {require_once('tools/login/libs/identificationsso.class.php');$sso = new identificationSso($this);$sso->recupererIdentiteConnectee();}// cas d'une personne connectée déjàif ($user = $this->GetUser()) {$connected = true;if ($this->LoadPage("PageMenuUser")) {$PageMenuUser .= $this->Format("{{include page=\"PageMenuUser\"}}");}// si pas de pas d'url de profil renseignée, on utilise ParametresUtilisateurif (empty($profileurl)) {$profileurl = $this->href("", "ParametresUtilisateur", "");}elseif ($profileurl=='WikiName') {$profileurl = $this->href("edit", $user['name'], "");}else {if ($this->IsWikiName($profileurl)) {$profileurl = $this->href('', $profileurl);}}}// cas d'une personne non connectéeelse {$connected = false;// si l'authentification passe mais la session n'est pas créée, on a un problème de cookieif ($_REQUEST['action'] == 'checklogged') {$error = 'Vous devez accepter les cookies pour pouvoir vous connecter.';}}// on affiche le templateif (!class_exists('SquelettePhp')) include_once('tools/login/libs/squelettephp.class.php');$squel = new SquelettePhp('tools/login/presentation/templates/'.$template);$squel->set(array("connected" => $connected,"user" => ((isset($user["name"])) ? $user["name"] : ((isset($_POST["name"])) ? $_POST["name"] : '' )),"incomingurl" => $incomingurl,"signupurl" => $signupurl,"profileurl" => $profileurl,"userpage" => $userpage,"PageMenuUser" => $PageMenuUser,"btnclass" => $btnclass,"error" => $error));$output = (!empty($class)) ? '<div class="'.$class.'">'."\n".$squel->analyser()."\n".'</div>'."\n" : $squel->analyser() ;echo $output;?>