1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-23 10:01:55 +02:00
Files
php-phpbb/phpBB/login.php
Paul S. Owen 079fc418f9 Compatibility and template updates
git-svn-id: file:///svn/phpbb/trunk@145 89ea8834-ac86-4346-8a33-228a782c2dd0
2001-04-15 14:34:52 +00:00

96 lines
2.6 KiB
PHP

<?php
/***************************************************************************
* login.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id$
*
*
***************************************************************************/
/***************************************************************************
*
* This program 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.
*
*
***************************************************************************/
include('extension.inc');
include('common.'.$phpEx);
//
// Set page ID for session management
//
$userdata = session_pagestart($user_ip, PAGE_LOGIN, $session_length);
init_userprefs($userdata);
//
// End session management
//
if(isset($HTTP_POST_VARS['submit']) || isset($HTTP_GET_VARS['submit']))
{
if($HTTP_POST_VARS['submit'] == "Login" && !$userdata['session_logged_in'])
{
$username = $HTTP_POST_VARS["username"];
$password = $HTTP_POST_VARS["password"];
$sql = "SELECT *
FROM ".USERS_TABLE."
WHERE username = '$username'";
$result = $db->sql_query($sql);
if(!$result)
{
error_die($db, "Error in obtaining userdata : login");
}
$rowresult = $db->sql_fetchrow($result);
if(count($rowresult))
{
if(md5($password) == $rowresult["user_password"])
{
$session_id = session_begin($rowresult["user_id"], $user_ip, PAGE_INDEX, $session_length, 1, $rowresult["user_password"]);
if($session_id)
{
header("Location: index.$phpEx");
}
else
{
error_die($db, "Couldn't start session : login");
}
}
else
{
error_die($db, LOGIN_FAILED);
}
}
else
{
error_die($db, LOGIN_FAILED);
}
}
else if($HTTP_GET_VARS['submit'] == "logout" && $userdata['session_logged_in'])
{
if($userdata['session_logged_in'])
{
session_end($userdata["session_id"], $userdata["user_id"]);
}
header("Location: index.$phpEx");
}
else
{
header("Location: index.$phpEx");
}
}
else
{
header("Location: index.$phpEx");
}
?>