Commit f66120de authored by Dries's avatar Dries
Browse files

Updates:
 * Various small changes to account.php including a SQL table movement:
   'testusers' -> 'users'.  As a result, user.class.php and article.php
   needed patching as well.  Hopefully I didn't break anyting.  ;o)
parent 44a566c8
<?
include "config.inc";
include "functions.inc";
include "database.inc";
function dbsave($dbase, $data, $id=0) {
foreach ($data as $key=>$value) {
......@@ -61,7 +60,7 @@ function newUser($user = "", $error="") {
$theme->footer();
}
function validateUser($user) {
include "ban.class.php";
include "ban.inc";
### Verify username and e-mail address:
$user[userid] = trim($user[userid]);
......@@ -75,8 +74,8 @@ function validateUser($user) {
### Verify whether username and e-mail address are unique:
dbconnect();
if (mysql_num_rows(mysql_query("SELECT userid FROM testusers WHERE LOWER(userid)=LOWER('$user[userid]')")) > 0) $rval = "the specified username is already taken.";
if (mysql_num_rows(mysql_query("SELECT email FROM testusers WHERE LOWER(email)=LOWER('$user[email]')")) > 0) $rval = "the specified e-mail address is already registered.";
if (mysql_num_rows(mysql_query("SELECT userid FROM users WHERE LOWER(userid)=LOWER('$user[userid]')")) > 0) $rval = "the specified username is already taken.";
if (mysql_num_rows(mysql_query("SELECT email FROM users WHERE LOWER(email)=LOWER('$user[email]')")) > 0) $rval = "the specified e-mail address is already registered.";
return($rval);
}
function makePassword($min_length=6) {
......@@ -107,7 +106,7 @@ function makePassword($min_length=6) {
else {
include('theme.inc');
$new[passwd] = makePassword();
dbsave("testusers", $new);
dbsave("users", $new);
$theme->header();
if ($system == 1) {
print("Your password is: <B>$new[passwd]</B><BR>");
......@@ -211,7 +210,7 @@ function makePassword($min_length=6) {
$data[ublock] = $edit[ublock];
$data[ublockon] = $edit[ublockon];
if ($edit[pass1] == $edit[pass2] && !empty($edit[pass1])) { $data[passwd] = $edit[pass1]; }
dbsave("testusers", $data, $user->id);
dbsave("users", $data, $user->id);
$user->update();
}
showUser();
......@@ -224,7 +223,7 @@ function makePassword($min_length=6) {
$data[uorder] = $edit[uorder];
$data[thold] = $edit[thold];
$data[signature] = $edit[signature];
dbsave("testusers", $data, $user->id);
dbsave("users", $data, $user->id);
$user->update();
}
showUser();
......
......@@ -8,7 +8,7 @@
dbconnect();
if ($save) {
mysql_query("UPDATE testusers SET umode='$mode', uorder='$order', thold='$thold' where id='$user->id'");
mysql_query("UPDATE users SET umode='$mode', uorder='$order', thold='$thold' where id='$user->id'");
$user->update();
}
......
......@@ -6,14 +6,14 @@
class User {
function User($userid, $passwd="") {
dbconnect();
$result = mysql_query("SELECT * FROM testusers WHERE LOWER(userid)=LOWER('$userid') && passwd=PASSWORD('$passwd') && STATUS=0") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
$result = mysql_query("SELECT * FROM users WHERE LOWER(userid)=LOWER('$userid') && passwd=PASSWORD('$passwd') && STATUS=0") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
if (mysql_num_rows($result) == 1) {
foreach (mysql_fetch_array($result) as $key=>$value) { $this->$key = $value; }
}
}
function update() {
dbconnect();
$result = mysql_query("SELECT * FROM testusers WHERE id=$this->id") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
$result = mysql_query("SELECT * FROM users WHERE id=$this->id") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
if (mysql_num_rows($result) == 1) {
foreach (mysql_fetch_array($result) as $key=>$value) { $this->$key = $value; }
}
......@@ -23,7 +23,7 @@ function valid($access=0) {
$this->last_access = time();
$this->last_host = (!empty($GLOBALS[REMOTE_HOST]) ? $GLOBALS[REMOTE_HOST] : $GLOBALS[REMOTE_ADDR] );
dbconnect();
mysql_query("UPDATE testusers SET last_access='$this->last_access',last_host='$this->last_host' WHERE id=$this->id") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
mysql_query("UPDATE users SET last_access='$this->last_access',last_host='$this->last_host' WHERE id=$this->id") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
if ($this->access & $access || $access == 0) return 1;
}
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment