cvs: php-master-web /manage users.php
| From: | Jim Winstead | Date: | Wed, 17 Oct 2001 22:52:56 +0000 |
| Subject: | cvs: php-master-web /manage users.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-7051@lists.php.net to get a copy of this message | ||
jimw Wed Oct 17 18:52:56 2001 EDT
Modified files:
/php-master-web/manage users.php
Log:
handle username parameter to jump directly to someone's record, add 'approved'
column
Index: php-master-web/manage/users.php
diff -u php-master-web/manage/users.php:1.2 php-master-web/manage/users.php:1.3
--- php-master-web/manage/users.php:1.2 Wed Oct 17 12:18:08 2001
+++ php-master-web/manage/users.php Wed Oct 17 18:52:56 2001
@@ -39,11 +39,18 @@
exit;
}
-mysql_connect("localhost","nobody","")
+@mysql_connect("localhost","nobody","")
or die("unable to connect to database");
-mysql_select_db("php3");
+@mysql_select_db("php3");
+
+if (isset($username) && !isset($id)) {
+ $res = @mysql_query("SELECT userid FROM users WHERE cvsuser='$username' OR
email='$username'");
+ if ($res) $id = mysql_result($res,0);
+}
if (isset($id) && isset($in)) {
+ $approved = $in[approved] ? 1 : 0;
+
if ($error = invalid_input($in)) {
echo "<p class=\"error\">$error</p>";
}
@@ -58,14 +65,16 @@
}
$pass = crypt($in[passwd],substr(md5(time()),0,2));
- $query = "UPDATE users SET
name='$in[name]',email='$in[email]',"
+ $query = "UPDATE users SET"
+ . ($in[name] ? " name='$in[name]'" : "")
+ . ($in[email] ? ",email='$in[email]'," : "")
. ($in[cvsuser] ? "cvsuser='$in[cvsuser]'" : "")
. ($in[passwd] ? ",passwd='$pass]'" : "")
- . " WHERE userid=$id";
+ . ",approved=$approved WHERE userid=$id";
}
else {
if ($in[passwd]) $in[passwd] = crypt($in[passwd],substr(md5(time()),0,2));
- $query = "INSERT INTO users (name,email,cvsuser,passwd) VALUES
('$in[name]','$in[email]','$in[cvsuser]','$in[passwd]')";
+ $query = "INSERT INTO users (name,email,cvsuser,passwd,approved) VALUES
('$in[name]','$in[email]','$in[cvsuser]','$in[passwd]',$approved)";
}
if (!mysql_query($query)) {
@@ -113,6 +122,10 @@
<tr>
<th align="right">Password (again):</th>
<td><input type="password" name="in[passwd2]" value=""
size="20" maxlength="20" /></td>
+</tr>
+<tr>
+ <th align="right">Approved?</th>
+ <td><input type="checkbox" name="approved"<?php echo
$row[approved] ? " checked" : "";?> /></td>
</tr>
<tr>
<td><input type="submit" value="<?php echo $id ? "Change" :
"Add";?>" />