Date: 10/28/99
- Next message: Sascha Schumann: "serialize() (was Re: [PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal)"
- Previous message: carmelo: "[PHPLIB-DEV] cvs commit"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: kk
Date: Thu Oct 28 20:22:33 1999
Added files:
php-lib/php/ct_sql_compat.inc
php-lib/php/registerform.ihtml
Modified files:
php-lib/CHANGES
php-lib/php/local.inc
Log message:
Added a reg mod example to local.inc. To activate, set mode = "reg".
Index: php-lib/CHANGES
diff -u php-lib/CHANGES:1.119 php-lib/CHANGES:1.120
--- php-lib/CHANGES:1.119 Thu Oct 28 13:14:53 1999
+++ php-lib/CHANGES Thu Oct 28 20:22:02 1999
@@ -1,4 +1,7 @@
-$Id: CHANGES,v 1.119 1999/10/28 11:14:53 carmelo Exp $
+$Id: CHANGES,v 1.120 1999/10/28 18:22:02 kk Exp $
+
+28-Oct-1999 kk
+ - reg mode example to local.inc.
28-Oct-1999 cg
- Bug correction on ct_dba
Index: php-lib/php/local.inc
diff -u php-lib/php/local.inc:1.25 php-lib/php/local.inc:1.26
--- php-lib/php/local.inc:1.25 Wed Oct 27 15:17:34 1999
+++ php-lib/php/local.inc Thu Oct 28 20:22:03 1999
@@ -5,7 +5,7 @@
* Copyright (c) 1998,1999 NetUSE GmbH
* Boris Erdmann, Kristian Koehntopp
*
- * $Id: local.inc,v 1.25 1999/10/27 13:17:34 kk Exp $
+ * $Id: local.inc,v 1.26 1999/10/28 18:22:03 kk Exp $
*
*/
@@ -71,6 +71,8 @@
var $lifetime = 15;
+ var $mode = "log"; ## also try "reg"
+
var $database_class = "DB_Example";
var $database_table = "auth_user";
@@ -103,6 +105,64 @@
$uid = $this->db->f("user_id");
$this->auth["perm"] = $this->db->f("perms");
}
+ return $uid;
+ }
+
+ ## show registration form.
+ ## this is a very basic one, you certainly want to
+ ## add columns to that table and this form.
+ function auth_registerform() {
+ global $sess, $auth;
+
+ include("registerform.ihtml");
+ }
+
+ function auth_doregister() {
+ ## Import form variables
+ global $username, $pass1, $pass2;
+
+ ## Save the username for use in registerform.ihtml,
+ ## should registration fail. If you add more fields,
+ ## you will want to save them here, too.
+ $this->auth["uname"] = $username;
+
+ ## Check the passwords for validity.
+ if ($pass1 != $pass2) {
+ $this->auth["error"] = "Password and repeated password do not match. Please try again.";
+ return false;
+ }
+
+ ## See if the user is already present
+ $query = sprintf("select user_id, username, password, perms from %s where username = '%s'",
+ $this->database_table,
+ $username);
+ $this->db->query($query);
+ while($this->db->next_record()) {
+ ## If user is present and password matches, silently log
+ ## the user in.
+ if ($this->db->f("password") == $pass1)
+ return $this->db->f("user_id");
+
+ ## If user is present and password does not match,
+ ## complain and fail.
+ $this->auth["error"] = "This username is already taken. Please choose a different one.";
+ return false;
+ }
+
+ ## password is good and user is new, create a uid
+ ## and a user entry. The new user has no permissions (you
+ ## might want to add some?)
+ $uid = md5(uniqid($this->magic));
+ $query = sprintf("insert into %s ( user_id, username, password ) values ('%s', '%s', '%s')",
+ $this->database_table,
+ $uid,
+ $username,
+ $pass1);
+ $this->db->query($query);
+
+ ## log in that new user. The new user has no permissions.
+ ## If the user should have permissions, you put them
+ ## into $auth->auth["perm"].
return $uid;
}
}
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: Sascha Schumann: "serialize() (was Re: [PHPLIB-DEV] Re: [PHPLIB] phplib - changes proposal)"
- Previous message: carmelo: "[PHPLIB-DEV] cvs commit"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

