61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
//Cette page permet aux utilisateurs de se connecter ou de se deconnecter
|
|
include('config.php');
|
|
if(isset($_SESSION['username']))
|
|
{
|
|
unset($_SESSION['username'], $_SESSION['userid']);
|
|
setcookie('username', '', time()-100);
|
|
setcookie('password', '', time()-100);
|
|
}
|
|
else
|
|
{
|
|
$ousername = '';
|
|
if(isset($_POST['username'], $_POST['password']))
|
|
{
|
|
if(get_magic_quotes_gpc())
|
|
{
|
|
$ousername = stripslashes($_POST['username']);
|
|
$username = mysql_real_escape_string(stripslashes($_POST['username']));
|
|
$password = stripslashes($_POST['password']);
|
|
}
|
|
else
|
|
{
|
|
$username = mysql_real_escape_string($_POST['username']);
|
|
$password = $_POST['password'];
|
|
}
|
|
$req = mysql_query('select password,id from users where username="'.$username.'"');
|
|
$dn = mysql_fetch_array($req);
|
|
if($dn['password']==$password and mysql_num_rows($req)>0)
|
|
{
|
|
$form = false;
|
|
$_SESSION['username'] = $_POST['username'];
|
|
$_SESSION['userid'] = $dn['id'];
|
|
if(isset($_POST['memorize']) and $_POST['memorize']=='yes')
|
|
{
|
|
$one_year = time()+(60*60*24*365);
|
|
setcookie('username', $_POST['username'], $one_year);
|
|
setcookie('password', sha1($password), $one_year);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$form = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$form = true;
|
|
}
|
|
if($form)
|
|
{
|
|
if(isset($message))
|
|
{
|
|
echo '<div class="message">'.$message.'</div>';
|
|
}
|
|
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
|
|
$nb_new_pm = $nb_new_pm['nb_new_pm'];
|
|
}
|
|
}
|
|
|
|
echo '<script language="Javascript">document.location.replace("forum.php");</script>';
|
|
?>
|