diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-12-01 14:44:57 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-12-01 14:44:57 +0000 |
commit | 5ecedf72cfa346269e5e172c968993825b464945 (patch) | |
tree | 457ad20602bb733bc8ed4f19ec9897f105ace23b | |
parent | d95e7d414277e86582ce1121624bac329edebdd7 (diff) | |
download | brdo-5ecedf72cfa346269e5e172c968993825b464945.tar.gz brdo-5ecedf72cfa346269e5e172c968993825b464945.tar.bz2 |
user.module:
- Fixed the session support. Requires a database update.
- Applied a tiny optimization suggested by deekayen.
-rw-r--r-- | modules/user.module | 21 | ||||
-rw-r--r-- | modules/user/user.module | 21 | ||||
-rw-r--r-- | update.php | 5 |
3 files changed, 27 insertions, 20 deletions
diff --git a/modules/user.module b/modules/user.module index b6791ceab..5ac4b8055 100644 --- a/modules/user.module +++ b/modules/user.module @@ -17,13 +17,14 @@ function sess_close() { function sess_read($key) { global $user; $user = user_load(array("sid" => $key, "status" => 1)); - return $user; + + return $user->session; } function sess_write($key, $value) { global $HTTP_SERVER_VARS; - db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."' WHERE sid = '$key'"); + db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', session = '". check_query($value) ."', timestamp = '". time() ."' WHERE sid = '$key'"); } function sess_destroy($key) { @@ -141,11 +142,11 @@ function user_validate_name($name) { */ if (!$name) return t("You must enter a Username."); - if (eregi("^ ", $name)) return t("The Username cannot begin with a space."); - if (eregi(" \$", $name)) return t("The Username cannot end with a space."); - if (eregi(" ", $name)) return t("The Username cannot contain multiple spaces in a row."); - // if (eregi("[^a-zA-Z0-9@-@]", $name)) return t("The Username contains an illegal character."); - if (!eregi('^[a-z0-9]+(@[a-z0-9]+)?$', $name)) t("The name contains an illegal character."); + if (ereg("^ ", $name)) return t("The Username cannot begin with a space."); + if (ereg(" \$", $name)) return t("The Username cannot end with a space."); + if (ereg(" ", $name)) return t("The Username cannot contain multiple spaces in a row."); + // if (ereg("[^a-zA-Z0-9@-@]", $name)) return t("The Username contains an illegal character."); + if (!ereg('^[a-z0-9]+(@[a-z0-9]+)?$', $name)) t("The name contains an illegal character."); if (strlen($name) > 56) return t("The Username '$name' is too long: it must be less than 56 characters."); } @@ -639,13 +640,13 @@ function user_login($edit = array()) { else { if (!$error) { $error = t("Authentication failed."); - } + } if ($server) { watchdog("user", "failed login for '$name@$server': $error"); - } + } else { watchdog("user", "failed login for '$name': $error"); - } + } } } diff --git a/modules/user/user.module b/modules/user/user.module index b6791ceab..5ac4b8055 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -17,13 +17,14 @@ function sess_close() { function sess_read($key) { global $user; $user = user_load(array("sid" => $key, "status" => 1)); - return $user; + + return $user->session; } function sess_write($key, $value) { global $HTTP_SERVER_VARS; - db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."' WHERE sid = '$key'"); + db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', session = '". check_query($value) ."', timestamp = '". time() ."' WHERE sid = '$key'"); } function sess_destroy($key) { @@ -141,11 +142,11 @@ function user_validate_name($name) { */ if (!$name) return t("You must enter a Username."); - if (eregi("^ ", $name)) return t("The Username cannot begin with a space."); - if (eregi(" \$", $name)) return t("The Username cannot end with a space."); - if (eregi(" ", $name)) return t("The Username cannot contain multiple spaces in a row."); - // if (eregi("[^a-zA-Z0-9@-@]", $name)) return t("The Username contains an illegal character."); - if (!eregi('^[a-z0-9]+(@[a-z0-9]+)?$', $name)) t("The name contains an illegal character."); + if (ereg("^ ", $name)) return t("The Username cannot begin with a space."); + if (ereg(" \$", $name)) return t("The Username cannot end with a space."); + if (ereg(" ", $name)) return t("The Username cannot contain multiple spaces in a row."); + // if (ereg("[^a-zA-Z0-9@-@]", $name)) return t("The Username contains an illegal character."); + if (!ereg('^[a-z0-9]+(@[a-z0-9]+)?$', $name)) t("The name contains an illegal character."); if (strlen($name) > 56) return t("The Username '$name' is too long: it must be less than 56 characters."); } @@ -639,13 +640,13 @@ function user_login($edit = array()) { else { if (!$error) { $error = t("Authentication failed."); - } + } if ($server) { watchdog("user", "failed login for '$name@$server': $error"); - } + } else { watchdog("user", "failed login for '$name': $error"); - } + } } } diff --git a/update.php b/update.php index c862f1fdf..80bd9771a 100644 --- a/update.php +++ b/update.php @@ -17,6 +17,7 @@ $mysql_updates = array( "2001-11-02" => "update_8", "2001-11-04" => "update_9", "2001-11-17: distributed authentication" => "update_10", + "2001-12-01" => "update_11", ); // Update functions @@ -236,6 +237,10 @@ function update_10() { update_sql("ALTER TABLE blog DROP body_old;"); } +function update_11() { + update_sql("ALTER TABLE users ADD session TEXT;"); +} + // System functions function update_sql($sql) { global $edit; |