[phpMP-CVS] CVS: phpMP/includes admin.php,1.4,1.5
Status: Pre-Alpha
Brought to you by:
heimidal
From: Anthony W. <ant...@us...> - 2003-02-11 21:07:32
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv26429/includes Modified Files: admin.php Log Message: Added user management - having problems with the script not deleting the user when told to do so, but works fine other than that (I think) Index: admin.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/admin.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** admin.php 9 Feb 2003 21:53:51 -0000 1.4 --- admin.php 11 Feb 2003 21:07:29 -0000 1.5 *************** *** 13,17 **** { $this->p_action = $action; ! switch ($action) { --- 13,17 ---- { $this->p_action = $action; ! switch ($action) { *************** *** 19,22 **** --- 19,25 ---- $this->_show_site(); break; + case C_ACTION_USER: + $this->_show_user(); + break; default: break; } *************** *** 84,87 **** --- 87,91 ---- print "<input type=\"checkbox\" name=\"portperms\" value=\"1\" " . $checked . "> Use Portal Permissions?<br>"; print "<input type=\"submit\" name=\"submit_general\" value=\"Submit Configuration\">"; + print "</form>"; } *************** *** 109,113 **** --- 113,218 ---- $DB->query("UPDATE " . DB_CONFIG_TABLE . " SET config_value='" . $portperms . "' WHERE config_key='use_portal_perms'"); } + + // Shows the user selection form + // Author: Anthony White + // Accepts: none. + // Returns: none. + function _show_user() + { + include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); + $DB = new DB; + print "<form method=\"post\" action=\"main.php?parse=" . $this->p_action . "\">"; + print "Select user to edit: <select name=\"userid\">"; + + $query = $DB->query("SELECT * FROM " . DB_USERS_TABLE); + + while ($user = $DB->fetchArray($query)) + { + if ($user[userid] != 1) + { + print "<option value=\"" . $user[userid] . "\">" . $user[username]; + } + } + + print "</select><br>"; + print "<input type=\"submit\" name=\"submit_user\" value=\"Edit User\">"; + print "</form>"; + } + + // Shows user management form + // Author: Anthony White + // Accepts: none. + // Returns: none. + function show_user($userid) + { + if (!$userid || $userid == 1) { print "Invalid User"; return; } + + include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); + $DB = new DB; + + $query = $DB->query("SELECT * FROM " . DB_USERS_TABLE . " WHERE userid=" . $userid); + $user = $DB->fetchArray($query); + + // Print out the form for management + print "<form method=\"post\" action=\"main.php?parse=" . ($this->p_action + 1) . "\">"; + print "Username: <input type=\"text\" name=\"username\" value=\"" . $user[username] . "\"><br>"; + print "Password: <input type=\"password\" name=\"passwd\"> (Leave blank to not change)<br>"; + print "Email: <input type=\"email\" name=\"email\" value=\"" . $user[email] . "\"><br>"; + print "Authentication Level: <select name=\"auth_level\">"; + switch ($user[auth_level]) + { + case AUTH_LVL_MEM: + $sel1 = "SELECTED"; + break; + case AUTH_LVL_CONTRIB: + $sel2 = "SELECTED"; + break; + case AUTH_LVL_MOD: + $sel3 = "SELECTED"; + break; + case AUTH_LVL_ADMIN: + $sel4 = "SELECTED"; + break; + default: break; + } + print "<option value=\"1\" " . $sel1 . ">Standard Member"; + print "<option value=\"2\" " . $sel2 . ">Contributor"; + print "<option value=\"3\" " . $sel3 . ">Moderator"; + print "<option value=\"4\" " . $sel4 . ">Administrator"; + print "</select><br>"; + print "Date Format: <input type=\"text\" name=\"date_format\" value=\"" . $user[date_format] . "\"><br>"; + print "Template: <input type=\"text\" name=\"template\" value=\"" . $user[template] . "\"><br>"; + print "Signature:<br>"; + print "<textarea name=\"signature\" rows=\"5\" cols=\"40\">" . $user[signature] . "</textarea><br>"; + print "<input type=\"checkbox\" name=\"delete\" value=\"delete\"> Delete User? (WARNING: This deletes the user for good)<br>"; + print "<input type=\"submit\" name=\"submit_user_parse\" value=\"Submit User Changes\">"; + print "<input type=\"hidden\" name=\"userid\" value=\"" . $user[userid] . "\">"; + print "</form>"; + } + + // Parse the user management form + // Author: Anthony White + // Accepts: The form variables + // Returns: none. + function parse_user($userid, $username, $passwd, $email, $auth_level, $date_format, $template, $signature, $delete) + { + include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); + $DB = new DB; + + if ($delete == "delete") + { + $DB->query("DELETE FROM " . DB_USERS_TABLE . " WHERE userid='" . $userid . "'"); + return; + } + + if ($passwd != "") + { + $DB->query("UPDATE " . DB_USERS_TABLE . " SET passwd='" . $passwd . "' WHERE userid='" . $userid . "'"); + } + + $DB->query("UPDATE " . DB_USERS_TABLE . " SET username='" . $username . "', email='" . $email . "', auth_level='" . $auth_level . "', date_format='" . $date_format . "', template='" . $template . "', signature='" . $signature . "' WHERE userid='" . $userid . "'"); + } + } |