/**************************************
electrifiedForum
Version 0.99rc4 - November 20, 2001
Copyright 2001- electrifiedpenguin.com
This is free software, please leave all
copyright notices intact, thanks!
This is the user functions file
MAKE NO CHANGES TO THIS FILE
Customizing options are in the realm files!!!
***************************************/
function login($username,$password)
{
global $config,$forumsess,$autherror,$realm;
if ($config['pass_encrypt'] == "mysql")
$vsql = "username='$username' AND password=PASSWORD('$password')";
else
$vsql = "username='$username' AND password='$password'";
if (db_numrows($config[utable],"username='$username'")==1)
{
if (db_numrows($config[utable],$vsql)==1)
{
$disable = db_getvar($config[utable],"username='$username'","disabled");
if (!$disable)
{
if (!session_is_registered("forumsess"))
session_register("forumsess");
$forumsess[$realm][username] = $username;
if (db_getvar($config[utable],"username='$username'","level")==10)
$forumsess[$realm][admin] = TRUE;
return TRUE;
}
else
{
$autherror = "Account Disabled";
return FALSE;
}
}
else
{
$autherror = "Bad Password";
return FALSE;
}
}
else
{
$autherror = "Bad Username";
return FALSE;
}
}
function verifyuser($username,$password)
{
/*synonymous with login()*/
return login($username,$password);
}
function logout()
{
global $config,$forumsess,$realm;
unset($forumsess[$realm][username]);
if ($forumsess[$realm][admin])
unset($forumsess[$realm][admin]);
if ($forumsess[$realm][verified])
unset($forumsess[$realm][verified]);
}
function saveuser($method)
{
global $config,$forumsess,$realm,$reg,$lang;
if ($config[restrict_new_signups]&& $method == "new")
{
if ($config[restrict_signups_text])
print $config[restrict_signups_text]."
";
else
print "The administrator has disabled new signups.
";
}
else
{
$options = $reg[showemail] + $reg[showicq] + $reg[showaim] + $reg[showyahoo] + $reg[showbirthday] + $reg[showhomepage] + $reg[notification];
$birthday = $reg[year].convert($reg[month]).convert($reg[day]);
if ($method == "new")
{
if (!$reg[email])
$regerror .= "You did not enter an email address.
";
else
{
$existinguser = db_numrows_sql("SELECT * FROM $config[utable] WHERE email='$reg[email]'");
if ($existinguser > 0 && !$config[allow_multiple_accts])
$regerror .= "The email adress you entered has already been used.";
}
if (!$reg[username])
$regerror .= "You did not enter a username.
";
if (!$reg[password])
$regerror .= "You did not enter a password.
";
if ($regerror)
{
print "Registration errors have occured:
$regerror
";
signup_form();
return;
}
$columns = "username,password,location,email,avatar,sig,icq,aim,yahoo,birthday,gender,homepage,options";
if ($config['pass_encrypt'] == "mysql")
$values = "'$reg[username]', PASSWORD('$reg[password]'), '$reg[location]', '$reg[email]', '$reg[avatar]', '$reg[sig]', '$reg[icq]', '$reg[aim]', '$reg[yahoo]', '$birthday', '$reg[gender]', '$reg[homepage]', '$options'";
else
$values = "'$reg[username]', '$reg[password]', '$reg[location]', '$reg[email]', '$reg[avatar]', '$reg[sig]', '$reg[icq]', '$reg[aim]', '$reg[yahoo]', '$birthday', '$reg[gender]', '$reg[homepage]', '$options'";
if (db_insert($config[utable],$columns,$values))
{
if (!session_is_registered("forumsess"))
session_register("forumsess");
$forumsess[$realm]["username"] = $reg[username];
print "Successfully saved your registration!
";
}
else
{
print "There was an $lang[error] with your registration!
";
}
}
elseif ($method == "edit")
{
$columns = array("location","email","avatar","sig","icq","aim","yahoo","gender","birthday","homepage","options");
$values = array($reg[location],$reg[email],$reg[avatar],$reg[sig],$reg[icq],$reg[aim],$reg[yahoo],$reg[gender],$birthday,$reg[homepage],$options);
db_update($config[utable],"username='".$forumsess[$realm][username]."'",$columns,$values);
print "Successfully edited your $lang[profile]!
";
}
else
{
print "An $lang[error] has occured.
";
}
print "";
}
}
function savepass()
{
global $config,$forumsess,$realm,$pass,$lang;
//$row = db_getrow($config[utable],"username='".$forumsess[$realm][username]."'");
//if ($pass[old]==$row[password]){
if ($config['pass_encrypt'] == "mysql")
{
if (db_numrows($config[utable],"username='".$forumsess[$realm][username]."' AND password=PASSWORD('$pass[old]')")==1)
{
//$columns = array("password");
//$values = array("PASSWORD(".$pass['new'].")");
$sql = "UPDATE $config[utable] SET password=PASSWORD('$pass[new]') WHERE username='".$forumsess[$realm][username]."'";
//db_update($config[utable],"username='".$forumsess[$realm][username]."'",$columns,$values);
if (db_do($sql))
print "Successfully saved your new password!
";
else
print "An $lang[error] has occured while attempting to update your password.
";
mainforums();
}
else
{
print "$lang[error] You have entered an incorrect password!
";
passwordform();
}
}
else
{
$row = db_getrow($config[utable],"username='".$forumsess[$realm][username]."'");
if ($pass[old]==$row[password])
{
$columns = array("password");
$values = array($pass['new']);
db_update($config[utable],"username='".$forumsess[$realm][username]."'",$columns,$values);
print "Successfully saved your new password!
";
mainforums();
}
else
{
print "$lang[error] You have entered an incorrect password!
";
passwordform();
}
}
}
function listavatars($currav)
{
global $config;
$avatars = dir_list($config['avatar_dir']);
?>