diff options
author | James Atkinson <thefinn@users.sourceforge.net> | 2001-02-22 06:10:12 +0000 |
---|---|---|
committer | James Atkinson <thefinn@users.sourceforge.net> | 2001-02-22 06:10:12 +0000 |
commit | 8918532a1329157916e539ee84cd711fd3f267bc (patch) | |
tree | 0bfcb465225f44365a137d76a1dd077ea0a7161d /phpBB/functions/auth.php | |
parent | 658df35cd4c176916e7cd0bd766bb8c8e0cc77d1 (diff) | |
download | forums-8918532a1329157916e539ee84cd711fd3f267bc.tar forums-8918532a1329157916e539ee84cd711fd3f267bc.tar.gz forums-8918532a1329157916e539ee84cd711fd3f267bc.tar.bz2 forums-8918532a1329157916e539ee84cd711fd3f267bc.tar.xz forums-8918532a1329157916e539ee84cd711fd3f267bc.zip |
phpBB 2 is started
git-svn-id: file:///svn/phpbb/trunk@13 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/functions/auth.php')
-rw-r--r-- | phpBB/functions/auth.php | 120 |
1 files changed, 119 insertions, 1 deletions
diff --git a/phpBB/functions/auth.php b/phpBB/functions/auth.php index b4278d1182..beacb39262 100644 --- a/phpBB/functions/auth.php +++ b/phpBB/functions/auth.php @@ -1,6 +1,6 @@ <?php /*************************************************************************** - * + * auth.php * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : (C) 2001 The phpBB Group @@ -22,6 +22,124 @@ * ***************************************************************************/ +/* Notes: + * auth() is going to become a very complex function and can take in a LARGE number of arguments. + * The currently included argements should be enough to handle any situation, however, if you need access to another + * the best option would be to create a global variable and access it that way if you can. + * + * auth() returns: + * TRUE if the user authorized + * FALSE if the user is not + */ +function auth($type, + $db, + $user_id = "", + $user_name = "", + $user_pass = "", + $user_level = "", + $session_id = "", + $user_ip = "", + $forum_id = "", + $topic_id = "", + $post_id = "") +{ + switch($type) + { + case 'ip ban': + $sql = "DELETE FROM banlist + WHERE (ban_end < ". mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")).") + AND (ban_end > 0)"; + $db->sql_query($sql); + $sql = "SELECT ban_ip FROM banlist"; + if($result = $db->sql_query($sql)) + { + if($totalrows = $db->sql_numrows()) + { + $iprow = $db->sql_fetchrowset($result); + for($x = 0; $x < $totalrows; $x++) + { + $ip = $iprow[$x]["ban_ip"]; + if($ip[strlen($ip) - 1] == ".") + { + $db_ip = explode(".", $ip); + $this_ip = explode(".", $user_ip); + + for($x = 0; $x < count($db_ip) - 1; $x++) + { + $my_ip .= $this_ip[$x] . "."; + } + + if($my_ip == $ip) + { + return(FALSE); + } + } + else + { + if($ipuser == $ip) + { + return(FALSE); + } + } + } + return(TRUE); + } + else + { + return(TRUE); + } + } + return(TRUE); + break; + case 'username ban': + $sql = "DELETE FROM banlist + WHERE (ban_end < ". mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")).") + AND (ban_end > 0)"; + $db->sql_query($sql); + $sql = "SELECT ban_userid FROM banlist WHERE ban_userid = '$user_id'"; + if($result = $db->sql_query($sql)) + { + if($db->sql_numrows()) + { + return(FALSE); + } + else + { + return(TRUE); + } + } + else + { + return(TRUE); + } + break; + } +} + + +/* + * The following functions are used for getting user information. They are not related directly to auth() + */ +function get_userdata_from_id($userid, $db) +{ + + $sql = "SELECT * FROM users WHERE user_id = $userid"; + if(!$result = $db->sql_query($sql)) + { + $userdata = array("error" => "1"); + return ($userdata); + } + if($db->sql_numrows()) + { + $myrow = $db->sql_fetchrowset($result); + return($myrow[0]); + } + else + { + $userdata = array("error" => "1"); + return ($userdata); + } +} ?> |