if (ereg('@', $name) && !eregi('@([0-9a-z](-?[0-9a-z])*\.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t("The Username is not a valid authentication ID.");
if (!eregi('^[[:print:]]+', $name)) return t("The name contains an illegal character.");
$links[] = lm(t("user account"), array("mod" => "user"), "", array("title" => t("Create a user account, request a new password or edit your account settings.")));
$output .= form_textfield(t("Username"), "name", $edit["name"], 20, 64, t("Enter your %s username, or an ID from one of our affiliates: %a.", array("%s" => variable_get("site_name", "local"), "%a" => implode(", ", user_auth_help_links()))));
$body = strtr(variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") .".\n\nYour new %site membership also enables you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
user_mail($edit["mail"], t("drupal user account details for %s", array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
$output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please configure your e-mail settings using the Administration pages.</p><p> Your password is <b>$pass</b>. You may change your password on the next page.</p><p>Please login below.</p>";
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. Your account will have to be approved by the site administrator. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
$output .= "<p>" . t("Note: If you have an account with one of our affiliates (%s), you may ". lm("login now", array("mod" => "user", "op" => "login")) ." instead of registering.", array("%s" => $affiliates)) ."</p>";
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your prefered username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64, t("A password and instructions will be sent to this e-mail address, so make sure it is accurate."));
$output .= form_item(t("Confirm Deletion"), t("You are about to deactivate your own user account. In addition, your e-mail address will be removed from the database."));
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
$output .= form_textfield(t("Homepage"), "homepage", $edit["homepage"], 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\"."));
$output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
$output .= form_select(t("Timezone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your timezone settings will be set appropriate."));
$output .= form_select(t("Language"), "language", $edit["language"], $languages, t("Selecting a different language will change the language of the site."));
$output .= form_textarea(t("Signature"), "signature", $edit["signature"], 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_item(t("Password"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password."));
/*** Administrative features ***********************************************/
function user_conf_options() {
$output .= form_select("Public registrations", "user_register", variable_get("user_register", 1), array("Only site administrators can create new user accounts.", "Visitors can create accounts and no administrator approval is required.", "Visitors can create accounts but administrator approval is required."));
$output .= form_textfield("Password words", "user_password", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"), 55, 256, "A comma separated list of short words that can be concatenated to generate human-readable passwords.");
$output .= form_textfield("Welcome e-mail subject", "user_mail_welcome_subject", variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), 80, 180, "Customize the subject of your welcome e-mail, which is sent to new members upon registering. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto, %date");
$output .= form_textarea("Welcome e-mail body", "user_mail_welcome_body", variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\nYour new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), 70, 10, "Customize the body of the welcome e-mail, which is sent to new members upon registering. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto");
$output .= form_textfield("Forgotten password e-mail subject", "user_mail_pass_subject", variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), 80, 180, "Customize the Subject of your forgotten password e-mail. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto, %date");
$output .= form_textarea("Forgotten password e-mail body", "user_mail_pass_body", variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\nYour new %site membership also enables to you to login to other Drupal powered websites (e.g. http://www.drop.org/) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), 70, 10, "Customize the body of the forgotten password e-mail. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto");
$output .= form_textfield("Role name", "name", $role->name, 32, 64, "The name for this role. Example: 'moderator', 'editorial board', 'site architect'.");
$output .= form_submit("Save role");
$output .= form_submit("Delete role");
$output = form($output);
}
if (!$output) {
/*
** Render role overview:
*/
$result = db_query("SELECT * FROM role ORDER BY name");
else if ($edit["mail"] && db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$account->uid' AND LOWER(mail) = LOWER('%s')", $edit["mail"])) > 0) {
$output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
$output .= form_textfield(t("Homepage"), "homepage", $account->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\"."));
$output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
$output .= form_select(t("Timezone"), "timezone", $account->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate."));
$output .= form_select(t("Language"), "language", $account->language, $languages, t("Selecting a different language will change the language of the site."));
$output .= form_textarea(t("Signature"), "signature", $account->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_item(t("Password"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", t("Enter a new password twice if you want to change the current password for this user or leave it blank if you are happy with the current password."));
$queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY u.uid DESC", "new users"), array("WHERE status = 0 ORDER BY u.uid DESC", "blocked users"));
$result = db_query("SELECT u.uid, u.name, u.timestamp FROM users u LEFT JOIN role r ON u.rid = r.rid ". $queries[$query ? $query : 0][0] ." LIMIT 50");
and other <a href="http://www.drupal.org/">Drupal</a> websites. See <a href="#da">Distributed
Authentication</a> for more information on this innovative feature. The username
and password are kept in your database, where the password is hashed so that
no one can read nor use it. When a username and password needs to be checked
the system goes down the list of registered users until it finds a matching
username, and then hashes the password that was supplied and compares it to
the listed value. If the hashes match, the username and password are correct.
Once a user authenticated session is started, and until that session is over,
the user won't have to re-authenticate. To keep track of the individual sessions,
Drupal relies on <a href="http://www.php.net/manual/en/ref.session.php">PHP's
session support</a>. A visitor accessing your website is assigned an unique
ID, the so-called session ID, which is stored in a cookie. For security's sake,
the cookie does not contain personal information but acts as a key to retrieve
the information stored on your server's side. When a visitor accesses your site,
Drupal will check whether a specific session ID has been sent with the request.
If this is the case, the prior saved environment is recreated.</p>
<p>Authenticated users can select entirely different appearances for the site,
utilizing their own preferences for how the pages are structured, how navigation
lists and other page components are presented and much more. <br />
</p>
<h3>User administration</h3>
<p>Administrators manage user accounts by clicking on the <i>User management</i> link in
their Admin interface. There, you will find several configuration pages and
reports which help you manage your users. The following pages are available:</p>
<h4>Add new user</h4>
<p>If your site is completely private, and doesn't allow registration for
any old web user (see <a href="#settings">settings</a> for this feature), then
you'll need to add new users manually. This web page allows any administrator
to register a new user.</p>
<h4>Access rules<a name="access"></a></h4>
<p>Access rules enable administrators to filter out usernames and e-mail addresses
which are not allowed in Drupal. An administrator creates a 'mask' against which
each new registration is checked. Disallowed names and e-mail addresses are denied
access to the site. Another handy use for this page is to disallow registration
to your site from an untrusted external authentication server. Just add their
server address to the username mask section and you've effectively blocked all
logins from that server.</p>
<p>To do describe access rules you can use the following wild-card characters:</p>
<ul>
<li> % : matches any number of characters, including zero characters.</li>
<li> _ : matches exactly one character.</li>
</ul>
<p><u>Examples:</u></p>
<ul>
<li>E-mail address bans <code>%@hotmail.com</code>, <code>%@altavista.%</code>, <code>%@usa.net</code>, etc. Used to prevent users from using free e-mail accounts, which might be used to cause trouble.</li>
<li>Username bans <code>root</code>, <code>webmaster</code>, <code>admin%</code>, etc. Used to prevent administrator impersonators.</li>
</ul>
<p>If no access rules are provided, access control is turned off and everybody will be able to access your website. The 'allow' rules are processed prior to the 'deny' rules and are thus considered to be stronger.</p>
<h4>User accounts</h4>
<p>This page is quite powerful. It allows an administrator to review any user's
profile. In addition, administrators may block any user, or assign him a <a href="#roles">role</a>,
using this page.</p>
<h4>User roles<a name="roles"></a></h4>
<p>Roles allow you to fine tune the security and administration of drupal. A role
defines a group of users which have certain privileges. Examples of roles
<I>administrator</I> and so on. By default, Drupal comes with two commonly used
roles:
<UL>
<LI>Anonymous user: this role is used for users that don't have a user account
or that are not authenticated.
<LI>Registered user: this role is assigned automatically to authenticated users.
Most users will belong to this user role unless specified otherwise.</LI>
</UL></p>
<p>These common roles will suffice for most sites. However, for a more complex site where you need to give several users different access privileges, you will
need to add a new role by clicking the "add new role" link. Then define what privileges that role will have by clicking the "permission overview" link and checking the appropriate boxes to give that role the permissions you desire.
<p>To attach a specific user to a role, use the "account" section of the drupal Administration. </p>
<p>Note: If you intend for a user to access certain sections of the administration
pages, they must have "access administration page" privileges. </p>
<p>Each role has certain things that its users are allowed to do, and some that
are disallowed. For example, authenticated users may usually post a story but
Anonymous users may not. </p>
<p>Each permission describes a fine-grained logical operation such as <i>access administration pages</i> or <i>add and modify user accounts</i>. You could say a permission represents access granted to a user to perform a set of operations.</p>
<h4>Search account</h4>
<p>Search Account enables an admin to query for any username in the user table
and return users which match that query. For example, one may search for 'br'
and Drupal might return 'brian', 'brad', and 'brenda'.</p>
<h4>Settings<a name="settings"></a></h4>
<p>Administrators may choose to restrict registration to their site. That restriction
may be accomplished on this page. Also, the list of words which may be included
in a system generated password is also listed on this page. Drupal generates
passwords by joining small words from the password list until the new password
is greater than 6 characters.</p>
<h4>Active users - report</h4>
<p>All users sorted by most recent login.</p>
<h4>New users - report</h4>
<p>All users sorted by most recent registration</p>
<h4>Blocked users - report</h4>
<p>All users who have been blocked (status = 0) sorted by most recent registration</p>
<h4>Authenticated users, administrators, etc. - reports</h4>
<p>All <a href="#roles">roles</a> present a report listing their members</p>
<h3>User preferences and profiles</h3>
<p>Drupal comes with a set of user preferences and profile which a user may edit by
clicking on the user account link. Of course, a user must be logged into reach those pages.
There, users will find a page for changing their preferred timezone, language, username, e-mail address, password, theme, signature, homepage, and <a href="#da">distributed authentication</a> names.
Changes made here take effect immediately. Also, administrators may make profile and preferences changes in the Admin Center on behalf of their users.</p>
<p>Module developers are provided several hooks for adding custom fields to the user view/edit pages. These hooks are described in the Developer section of the <A href="http://www.drupal.org">Drupal Handbook</a>. For an example, see the <code>jabber_user()</code> function in <i>/modules/jabber.module</i>.
if ($server !== "blogger.com") return 0; // user did not present a Blogger ID so don't bother trying.
$appkey = "6D4A2D6811A6E1F75148DC1155D33C0C958107BC"; //provided to Drupal by Ev@Blogger
$message = new xmlrpcmsg("blogger.getUsersBlogs", array(new xmlrpcval($appkey, "string"), new xmlrpcval($name, "string"), new xmlrpcval($pass, "string")));
$client = new xmlrpc_client("/api/RPC2", "plant.blogger.com");<br> $result = $client->send($message, 5);
// since Blogger doesn't return properly formed FaultCode, we just search for the string 'fault'
if ($result && !stristr($result->serialize(), "fault")) {
<p>The _page function is not currently used, but it might be in the future. For
now, just copy what you see here, substituting your module name for <i>blogger</i>.</p>
<pre>function blogger_auth_help() {
$site = variable_get("site_name", "this web site");
$html_output = "
<p>You may login to <i>%s</i> using a <b>Blogger ID</b>
and password. A Blogger ID consists of your Blogger username followed by <i>@blogger.com</i>.
So a valid blogger ID is mwlily@blogger.com. If you are a Blogger member, go
ahead and login now.</p><br>
<p>Blogger offers you instant communication power by letting you post
your thoughts to the web whenever the urge strikes.
Blogger will publish to your current web site or help you create one. <a
href=\"http://www.blogger.com/about.pyra\">Learn more about it</a>.";
return sprintf(t($html_output), $site);
}
</pre>
<p>The <i>_auth_help</i> function is prominently linked within Drupal, so you'll
want to write the best possible user help here. You'll want to tell users what
a proper username looks like for your authentication module. Also, you may advertise
a bit about your service at the end. Note that your help text is passed through
a t() function in the last line. This is Drupal's localization function. Translators
may localize your help text just like any other text in Drupal.</p>
<h4>Publishing your module</h4>
<p>Once you've written and tested your authentication module, you'll have to usually
want to share it with the world. The best way to do this is to add the module
to the <a href="http://cvs.drupal.org/viewcvs.cgi/contributions/modules/authentication/Blogger/?cvsroot=contrib">Drupal-Contrib
repository</a>. You'll need to request priveleges in this repository - see <a href="http://cvs.drupal.org/viewcvs.cgi/contributions/README?rev=HEAD&cvsroot=contrib&content-type=text/vnd.viewcvs-markup">README</a>
for the details. Then you'll want to announce your contribution on the <a href="http://www.drop.org/node.php?title=mailing%2Blists">Drupal_devel
and Drupal_support mailing lists</a>. You might also want to post a story on
<a href="http://www.drop.org">Drop.org</a>.<br>
</p>
<?
}
function user_help_devel_userhook() {
?>
<h3><a name="userhook">module_user()</a></h3>
<p>The <b>_user()</b> hook provides to Module Authors a mechanism for inserting text and form fields into the registration page, the user account view/edit pages, and the administer users page. This is useful if you want to add a custom field for your particular community. This is best illustrated by an example called <a href="http://cvs.drupal.org/viewcvs.cgi/contributions/modules/profile/?cvsroot=contrib">profile.module</a> in the Contrib repository. Profile.module is meant to be customized for your needs. Please download it and hack away until it does what you need.</p>
<p>Consider this simpler example from a fictional recipe community web site called Julia's Kitchen. Julia customizes her Drupal powered site by creating a new file called <i>julia.module</i>. That file does the following:
- new members must agree to Julia's Privacy Policy on the reg page.
- members may list their favorite ingredients on their public user profile page</p>
<p>Julia achieves this with the following code. The comments below should help you understand what is going on.</p>
<pre>
function julia_user($type, $edit, &$user) {
switch ($type) {
case "register_form":
$output .= form_item("Privacy Policy", "Julia would never sell your user information. She is just nice old French chef who lives near me in Cambridge, Massachussetts USA.");
<p>Extra credit: use the <a href="http://cvs.drupal.org/viewcvs.cgi/contributions/modules/hotlist/?cvsroot=contrib">hotlist.module</a> to provide Julia users a mechanism for bookmarking their favorite recipes.</p>