mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Added login/logout file and logic to login a user
git-svn-id: file:///svn/phpbb/trunk@65 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
9bb944225a
commit
83b6163b4b
4 changed files with 141 additions and 79 deletions
|
@ -70,7 +70,7 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user is banned
|
// Check if user is banned
|
||||||
if(!auth("ip ban", $db, "", "", "", "", "", USER_IP, "", "", ""))
|
if(!auth("ip ban", $db, "", USER_IP))
|
||||||
{
|
{
|
||||||
error_die($db, BANNED);
|
error_die($db, BANNED);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ if(isset($HTTP_COOKIE_VARS[$session_cookie]))
|
||||||
$user_logged_in = 1;
|
$user_logged_in = 1;
|
||||||
update_session_time($sessid, $db);
|
update_session_time($sessid, $db);
|
||||||
|
|
||||||
if(!auth("username ban", $db, $userid, "", "", "", "", "", "", "", ""))
|
if(!auth("username ban", $db, $userid))
|
||||||
{
|
{
|
||||||
error_die($db, BANNED);
|
error_die($db, BANNED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,18 +31,9 @@
|
||||||
* TRUE if the user authorized
|
* TRUE if the user authorized
|
||||||
* FALSE if the user is not
|
* FALSE if the user is not
|
||||||
*/
|
*/
|
||||||
function auth($type,
|
function auth($type, $db, $id = "", $user_ip = "")
|
||||||
$db,
|
|
||||||
$user_id = "",
|
|
||||||
$user_name = "",
|
|
||||||
$user_pass = "",
|
|
||||||
$user_level = "",
|
|
||||||
$session_id = "",
|
|
||||||
$user_ip = "",
|
|
||||||
$forum_id = "",
|
|
||||||
$topic_id = "",
|
|
||||||
$post_id = "")
|
|
||||||
{
|
{
|
||||||
|
global $userdata;
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'ip ban':
|
case 'ip ban':
|
||||||
|
@ -53,7 +44,7 @@ function auth($type,
|
||||||
$sql = "SELECT ban_ip FROM ".BANLIST_TABLE;
|
$sql = "SELECT ban_ip FROM ".BANLIST_TABLE;
|
||||||
if($result = $db->sql_query($sql))
|
if($result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
if($totalrows = $db->sql_numrows())
|
if($totalrows = $db->sql_numrows($result))
|
||||||
{
|
{
|
||||||
$iprow = $db->sql_fetchrowset($result);
|
$iprow = $db->sql_fetchrowset($result);
|
||||||
for($x = 0; $x < $totalrows; $x++)
|
for($x = 0; $x < $totalrows; $x++)
|
||||||
|
@ -99,7 +90,7 @@ function auth($type,
|
||||||
$sql = "SELECT ban_userid FROM ".BANLIST_TABLE." WHERE ban_userid = '$user_id'";
|
$sql = "SELECT ban_userid FROM ".BANLIST_TABLE." WHERE ban_userid = '$user_id'";
|
||||||
if($result = $db->sql_query($sql))
|
if($result = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
if($db->sql_numrows())
|
if($db->sql_numrows($result))
|
||||||
{
|
{
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +104,16 @@ function auth($type,
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'login':
|
||||||
|
global $password;
|
||||||
|
if($userdata["user_password"] != md5($password))
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,10 @@ function error_die($db, $error_code = "", $error_msg = "")
|
||||||
break;
|
break;
|
||||||
case NO_POSTS:
|
case NO_POSTS:
|
||||||
$error_msg = "There are no posts in this forum. Click on the 'Post New Topic' link on this page to post one.";
|
$error_msg = "There are no posts in this forum. Click on the 'Post New Topic' link on this page to post one.";
|
||||||
|
break;
|
||||||
|
case LOGIN_FAILED:
|
||||||
|
$error_msg = "Login Failed. You have specified an incorrect username or password, please go back and try again.";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
|
|
57
phpBB/login.php
Normal file
57
phpBB/login.php
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?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);
|
||||||
|
|
||||||
|
if($submit)
|
||||||
|
{
|
||||||
|
$userdata = get_userdata($username, $db);
|
||||||
|
if($userdata["error"])
|
||||||
|
{
|
||||||
|
error_die($db, LOGIN_FAILED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!auth("login", $db))
|
||||||
|
{
|
||||||
|
error_die($db, LOGIN_FAILED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sessid = new_session($userdata[user_id], USER_IP, $session_cookie_time, $db);
|
||||||
|
set_session_cookie($sessid, $session_cookie_time, $session_cookie, "", "", 0);
|
||||||
|
header("Location: index.$phpEx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($logout)
|
||||||
|
{
|
||||||
|
if($user_logged_in)
|
||||||
|
{
|
||||||
|
end_user_session($userdata["user_id"], $db);
|
||||||
|
}
|
||||||
|
header("Location: index.$phpEx");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Reference in a new issue