Page 1 sur 1

Petit Problème d'autentification

Posté : 14 oct. 2009, 00:11
par samsuffi
bonjour à tous,

Je suis débutant en PHP et j'ai récuperer sur le net la sources d'une gestion de signet bien sympa, qui hélas n'est pls tenu par l'auteur.

mais voilà les source ne prévoi pas de connexion sans autentification, alors que j'aimerai que les utilisateur n'est pas à s'autentifier

serai t'il possible de modifier la source pour que la connexion se fasse automatiquement sur le compte "fav", mot de passe "fav"

Voici la source du fichier index.php

Merci par avance
<?php

/* 
 * This file is part of PHP Bookin
 * Copyright (c) 2005 Patrick Paysant
 *
 * PHP Bookin is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * PHP Bookin is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

define('DEBUG', false) ;
include_once('utils.php') ;

//----------------------------------------------- display
/**
 * connection au serveur MySQL
 *
 * @param string message d'erreur
 * @url string url de retour
 *
 */
function display($msg='') {
	global $_t ;

	header("X-JSON: ({\"code\":400, \"result\":\"index.php?action=late\"})") ;
	
	$lang = getLang() ;
	//$tplFile = getTpl('index', $lang) ;
 
	$tpl = new clsTinyButStrong() ;
	//$tpl->loadTemplate($tplFile) ;
	$tpl->loadTemplate(SYS_TPL.'/index.tpl') ;
	$tpl->mergeField('index', 
			array('error_msg' => $msg, 
			'self' => $_SERVER['PHP_SELF'],
			'signin' => $_t['signin'],
			'login' => $_t['login'],
			'password' => $_t['password'],
			'send' => $_t['send'])) ;
	$tpl->Show() ;
}

//----------------------------------------------- login
/**
 * vérification des codes d'accès
 *
 */
function login() {
	global $_t ;

	$login = addslashes(htmlspecialchars($_POST['login'])) ;
	$password = addslashes(htmlspecialchars($_POST['passwd'])) ;

	if (trim($login) == '') {
		//display("Veuiller entrer votre identifiant") ;
		display($_t['ask_login']) ;
		exit() ;
	}

	if (trim($password) == '') {
		//display("Veuillez entrer votre mot de passe");
		display($_t['ask_password']);
		exit() ;
	}

	$db = sql_connect() ;

	$sql = "select * from ".DB_TABLE_PREFIX."user where login = '".$login."' and " ;
	$sql .= "password = '".$password."' ;" ;

	$result = sql_query($sql, $db) ;
 
	if ($result->numRows() > 1) { // si plusieurs identifiants possibles ( = probleme !)
 		//display ('La base de donnees est sans doute corrompue. Contacter l\'administrateur') ;
 		display ($_t['corrupted_database']) ;
 		exit() ;
 	} // si aucun identifiant (erreur login)
 	elseif ($result->numRows() <= 0) {
 		//display('Mauvais identifiant ou mauvais mot de passe') ;
 		display($_t['bad_login_password']) ;
 		exit() ;
 	} 
 	else { // sinon un identifiant trouve
 		$row = $result->fetchRow(DB_FETCHMODE_ASSOC) ;
 		$id = $row['id'] ;
		$login = $row['login'] ;

 		// démarrage session
 		session_name(SESSION_NAME) ;
 		session_start() ;

 		$_SESSION['s_id_user'] = $id ;
		$_SESSION['s_login'] = $login ;
 		$_SESSION['s_date_death'] = time() + 3600*12 ; // 12 heures

 		header('Location: bookin.php') ;
 	}
}

$act = $_POST['act'] ;
if ($act == '') { $act = "display" ; }

switch ($act) {
 case 'display' : {
 display() ;
 break ;
 }
 case 'bad' : {
 display($_t['bad_login_password']) ;
 break ;
 }
 case 'late' : {
 display($_t['too_late']) ;
 break ;
 }
 case 'login' : {
 login() ;
 break ;
 }
}

# Local Variables:
# mode: C
# End:

?>

Re: Petit Problème d'autentification

Posté : 14 oct. 2009, 08:32
par dunbar
Comme ceci mais je n'en voie pas l'interêt.
$sql = "select * from ".DB_TABLE_PREFIX."user where login = 'fav' and " ;
        $sql .= "password ='fav' ;" ;

Re: Petit Problème d'autentification

Posté : 14 oct. 2009, 22:42
par samsuffi
merci

l'interet est de connecter les utilisteur directement sans passez par la case autentification