www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

login.php (2538B)


      1 <?php
      2 session_start();
      3 require_once("ressources/strings.inc");
      4 require_once("ressources/locations.inc");
      5 
      6 $msg = null;
      7 
      8 if(isset($_POST['loginid']) && !empty($_POST['loginid']))
      9 	$user =	 SQLite3::escapeString($_POST['loginid']);
     10 if(isset($_POST['loginpswd']) && !empty($_POST['loginpswd']))
     11 	$pswd = md5($_POST['loginpswd']);
     12 
     13 $location = get_location();
     14 
     15 if(isset($_GET['d']) && $_GET['d'] == "true") {
     16 	session_destroy();
     17 	return_to($location, "?showmsg=ok_login_disconnect");
     18 }
     19 
     20 if(isset($user) && isset($pswd))
     21 {
     22 	$SQL_DBNAME = (dirname(__FILE__) . "/db");
     23 
     24 	if (!$db = new SQlite3($SQL_DBNAME))
     25 		die($strings['err_login_dbopen']);
     26 
     27 	if($pswd == ($db->querySingle("SELECT hash_passwd FROM user WHERE login='$user';"))) {
     28 		$_SESSION['userId'] = $user; // Le login se fait aussi dans signup.
     29 		
     30 		return_to($location,"?showmsg=ok_login_connect");
     31 	}
     32 	else
     33 		$msg = $strings['err_login_bad_user_pass'];
     34 }
     35 else if(isset($user) or isset($pswd))
     36 	$msg = $strings['err_login_fill_all'];
     37 
     38 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     39 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
     40 	<head>
     41 		<title>PtiClic sous Android™ - Version Alpha - Se connecter</title>
     42 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     43 		<link rel="stylesheet" href="ressources/simple.css" />
     44 	</head>
     45 	<body>
     46 		<?php include("ressources/menu.inc"); ?>
     47 		<div class="content">
     48 			<h2>Connexion</h2>
     49 			<?php include("ressources/showmsg.inc"); ?>
     50 
     51 			<h3>Vous êtes déjà inscrit&nbsp;? Authentifiez-vous.</h3>
     52 			<?php
     53 				if($msg !== null)
     54 					echo '<p class="message warning">'.htmlspecialchars($msg).'</p>';
     55 			?>
     56 			<form name="loginform" method="POST" action="login.php?return=<?php echo $location; ?>">
     57 				<table>
     58 					<tr>
     59 						<td>
     60 							<label for="loginid"> Identifiant&nbsp;:</label> 
     61 						</td>
     62 						<td>
     63 							<input name="loginid" type="text" /><br />
     64 						</td>
     65 					</tr>
     66 					<tr>
     67 						<td>
     68 							<label for="loginpswd"> Mot de passe&nbsp;: </label>
     69 						</td>
     70 						<td>
     71 							<input name="loginpswd" type="password" />
     72 						</td>
     73 					</tr>
     74 					<tr>
     75 						<td>
     76 						</td>
     77 						<td>
     78 							<input type="submit" name="loginsubmit" value="Valider" />
     79 						</td>
     80 					</tr>
     81 				</table>
     82 			</form>
     83 			<h3>Vous ne disposez pas encore d'un compte&nbsp;? <a href="signup.php?return=<?php echo $location; ?>">Inscrivez-vous</a> dès maintenant !</h3>
     84 		</div>
     85 		<?php include("ressources/footer.inc"); ?>
     86 	</body>
     87 </html>