From 805107cd2202ddee66c4743e43804a3069508f29 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 2 Apr 2001 15:54:37 +0000 Subject: Commiting my work of last Sunday: - removed ban.inc and ban.module and integrated it in account.module under the name "access control" --> the ban code was not really up to standard so this has now been dealt with. This refactoring and reintegration cuts down the code size with 100 lines too. :-) (The ban.module code was really old and it showed.) - added node.module and made the other modules reuse some of this code --> cut down the code size of modules by at least 100 lines and adds stability. - added a status() function to admin.php to display a conform status message where appropriate. See admin.php for usage. - removed $theme->control() and made comments.inc handle this itself wrapped in a $theme->box(). No need to clutter the themes with such complexity --> updated all themes already. :-) - some small visual changes to some administration pages to be more consistent across different modules. --- modules/account.module | 115 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 19 deletions(-) (limited to 'modules/account.module') diff --git a/modules/account.module b/modules/account.module index 71671cbd3..5fd8f85ad 100644 --- a/modules/account.module +++ b/modules/account.module @@ -6,9 +6,33 @@ $module = array("help" => "account_help", function account_help() { ?> -

The account-module is responsible for maintaining the user database. It automatically handles tasks like registration, authentication, access rights, password retrieval, user settings and much more.

+

The account-module is responsible for maintaining the user database. It automatically handles tasks like registration, authentication, access control, password retrieval, user settings and much more.

The required administration can be accomplished through the "account" interface of the administration section. From here administrators can get a quick overview of all registered users and view/edit specific accounts using the links provided. Some useful operations include blocking specific accounts (e.g. a troublesome user) and giving/taking administration permissions. Note that you should only give these permissions to people you trust!

Check the documentation page for detailed information about user management.

+

Regular expressions

+

A regular expression (or regexp, or pattern) is a text string that describes some (mathematical) set of strings. A regexp R "matches" a string S if S is in the set of strings described by R.

+

Regular expressions are very powerful but often get complicated and nothing in this write-up can change that. +

A complete explanation of regular expressions is beyond the scope of this help system. A regular expression may use any of the following special characters/constructs:

+ + + + + + + + + + + + +
^Matches the beginning of a string.
$Matches the end of a string.
.Matches any character (including newline). For example the regular expression a.c would match the strings abc, adb, axb, but not axxc.
a*Matches any sequence of zero or more a characters.
a+Matches any sequence of one or more a characters.
a?Matches either zero or one a character.
ab|cdMatches either of the sequences "ab" or "cd".
(abc)*Matches zero or more instances of the sequence abc.
[abc]Matches any one of the characters between the brackets: a, b or c. Ranges of characters can specified by using a hyphen. For example, the regular expression [0-9] means match any digit. Multiple ranges can be specified as well. The regular expression [A-Za-z] means match any upper or lower case letter. To match any character except those in the range, the complement range, use the caret as the first character after the opening bracket. For example, the expression [^269A-Z] will match any characters except 2, 6, 9, and upper case letters.
{num}Matches the preceding element num times.
{min, max}Matches the preceding element at least min times, but not more than max times.
+

Examples:

+ + + + + +
appleMatches any string that has the text "apple" in it.
^apple$Matches the exact string "apple".
^appleMatches any string that starts with "apple".
domain\.com$Matches any string that ends with "@domain.com". Note that you have to escape the dot in domain.com.
mask'" : "did not match any of the existing access rules") ."."; +} + +function account_ac() { + $access = array("e-mail address", "hostname", "username"); + + $result = db_query("SELECT * FROM access"); + + foreach ($access as $value) $type .= " \n"; + + $output .= "
\n"; + $output .= "\n"; + $output .= " \n"; + while ($rule = db_fetch_object($result)) { + $output .= " \n"; + } + $output .= " \n"; + $output .= " \n"; + $output .= "
masktypereasonoparations
$rule->mask$rule->type". check_output($rule->reason) ."id\">delete rule
Use regular expressions (regexs) to specify the mask pattern.
\n"; + $output .= "

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
check access rules
\n"; + $output .= "
\n"; + + return $output; +} + +function account_overview() { $result = db_query("SELECT id, userid, last_access FROM users ORDER BY last_access DESC LIMIT 50"); $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($account = db_fetch_object($result)) { - $output .= " \n"; + $output .= " \n"; } $output .= "
usernamelast accessoperations
usernamelast accessoperations
". format_username($account->userid) ."". format_date($account->last_access) ."userid\">viewuserid\">edituserid\">delete
". format_username($account->userid) ."". format_date($account->last_access) ."userid\">view accountuserid\">edit account
\n"; - print $output; + return $output; } function account_access($account) { @@ -80,7 +142,7 @@ function account_delete($name) { db_query("DELETE FROM users WHERE id = '$account->id'"); } else { - print "

Failed to delete account '". format_username($name) ."': the account must be blocked first.

"; + return "failed to delete account '". format_username($name) ."': the account must be blocked first."; } } @@ -126,7 +188,7 @@ function account_edit($name) { $output .= "\n"; $output .= "\n"; $output .= "\n"; - print "$output"; + return $output; } } @@ -158,41 +220,56 @@ function account_view($name) { $output .= " userid\">\n"; $output .= "\n"; $output .= "\n"; - print "$output"; + return $output; } } function account_admin() { - global $op, $edit, $order, $name; + global $op, $edit, $id, $order, $name; - print "overview | search account | help
\n"; + print " access control | search account | overview | help
\n"; switch ($op) { + case "access": + print account_ac(); + break; + case "Add rule": + print status(account_ac_add($edit)); + print account_ac(); + break; + case "Check": + print status(account_ac_check($edit)); + print account_ac(); + break; + case "delete rule": + print status(account_ac_del($id)); + print account_ac(); + break; case "Delete account": case "delete": - account_delete(check_input($name)); - account_display(); + print status(account_delete(check_input($name))); + print account_overview(); break; case "Edit account": case "edit": - account_edit(check_input($name)); + print account_edit(check_input($name)); break; case "help": - account_help(); + print account_help(); break; case "search": - account_search(); + print account_search(); break; case "View account": case "view": - account_view($name); + print account_view($name); break; case "Save account": - account_edit_save(check_input($name), $edit); - account_view(check_input($name)); + print status(account_edit_save(check_input($name), $edit)); + print account_view(check_input($name)); break; default: - account_display(); + print account_overview(); } } -- cgit v1.2.3