- Added the new user module!

4.0.x
Dries Buytaert 2001-09-16 11:33:14 +00:00
parent f358893b52
commit 2d1e9126cb
49 changed files with 275 additions and 1505 deletions

View File

@ -1,562 +0,0 @@
<?php
include_once "includes/common.inc";
page_header();
function account_get_user($name) {
return db_fetch_object(db_query("SELECT * FROM users WHERE name = '". check_input($name) ."'"));
}
function account_email_form() {
global $REQUEST_URI;
$output .= "<p>". t("Lost your password? Fill out your username and e-mail address, and your password will be mailed to you.") ."</p>\n";
$output .= form_textfield(t("Username"), "login", $edit[login], 30, 64, t("Enter your full name or username."));
$output .= form_textfield(t("E-mail address"), "email", $edit[email], 30, 64, t("You will be sent a new password."));
$output .= form_submit(t("E-mail new password"));
return form($REQUEST_URI, $output);
}
function account_page() {
global $theme;
$theme->header();
if (variable_get("account_register", 1)) {
$theme->box(t("Create user account"), account_create_form());
}
if (variable_get("account_password", 1)) {
$theme->box(t("E-mail new password"), account_email_form());
}
$theme->footer();
}
function account_create_form($edit = array(), $error = "") {
global $theme, $REQUEST_URI;
if ($error) {
$output .= "<p><font color=\"red\">". t("Failed to create new account") .": ". check_output($error) ."</font></p>\n";
watchdog("account", "failed to create new account: $error");
}
else {
$output .= "<p>". t("Registering allows you to comment, to moderate comments and pending submissions, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."</p><p>". t("To create an account, simply fill out this form an click the 'Create new account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."</p>\n";
}
$output .= form_textfield(t("Username"), "login", $edit[login], 30, 64, t("Enter your full name or username: only letters, numbers and common special characters like spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "email", $edit[email], 30, 64, t("You will be sent instructions on how to validate your account via this e-mail address: make sure it is accurate."));
$output .= form_submit(t("Create new account"));
return form($REQUEST_URI, $output);
}
function account_session_start($userid, $passwd) {
global $user;
if ($userid && $passwd) {
$user = new User($userid, $passwd);
}
if ($user->id) {
if ($rule = user_ban($user->userid, "username")) {
watchdog("account", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'");
}
else if ($rule = user_ban($user->last_host, "hostname")) {
watchdog("account", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'");
}
else {
session_register("user");
watchdog("account", "session opened for '$user->userid'");
}
}
else {
watchdog("account", "failed to login for '$userid': invalid password");
}
}
function account_session_close() {
global $user;
watchdog("account", "session closed for user '$user->userid'");
session_unset();
session_destroy();
unset($user);
}
function account_info_edit($error = 0) {
global $theme, $user;
if ($user->id) {
if ($error) {
$form .= "<p><font color=\"red\">$error</font></p>\n";
}
$form .= form_textfield(t("Username"), "userid", $user->userid, 30, 55, t("Required, a unique name that can be used to log on."));
$form .= form_textfield(t("Name"), "name", $user->name, 30, 55, t("Required, a unique name displayed with your contributions."));
$form .= form_item(t("Real e-mail address"), $user->real_email, t("Required, unique, can not be changed.") ." ". t("Your real e-mail address is never displayed publicly: only needed in case you lose your password."));
$form .= form_textfield(t("Fake e-mail address"), "fake_email", $user->fake_email, 30, 55, t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want."));
$form .= form_textfield(t("Homepage"), "url", $user->url, 30, 55, t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\"."));
$form .= form_textarea(t("Bio"), "bio", $user->bio, 35, 5, t("Optional") .". ". t("Maximal 255 characters.") ." ". t("This biographical information is publicly displayed on your user page.") ."<BR>". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Signature"), "signature", $user->signature, 35, 5, t("Optional") .". ". t("Maximal 255 characters.") ." ". t("This information will be publicly displayed at the end of your comments.") ."<BR>". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_item(t("Password"), "<INPUT TYPE=\"password\" NAME=\"edit[pass1]\" SIZE=\"10\" MAXLENGTH=\"20\"> <INPUT TYPE=\"password\" NAME=\"edit[pass2]\" SIZE=\"10\" MAXLENGTH=\"20\">", 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."));
$form .= form_submit(t("Save user information"));
$theme->header();
$theme->box(t("Edit user information"), form("account.php", $form));
$theme->footer();
}
else {
account_page();
}
}
function account_info_save($edit) {
global $user;
if ($error = user_validate_name($edit[userid])) {
return t("Invalid name") .": $error";
}
else if ($error = user_validate_name($edit[name])) {
return t("Invalid name") .": $error";
}
else if (db_num_rows(db_query("SELECT userid FROM users WHERE id != '$user->id' AND (LOWER(userid) = LOWER('$edit[userid]') OR LOWER(name) = LOWER('$edit[userid]'))")) > 0) {
return t("Invalid username") .": the username '$edit[userid]' is already taken.";
}
else if (db_num_rows(db_query("SELECT name FROM users WHERE id != '$user->id' AND (LOWER(userid) = LOWER('$edit[name]') OR LOWER(name) = LOWER('$edit[name]'))")) > 0) {
return t("Invalid name") .": the name '$edit[name]' is already taken.";
}
else if ($user->id) {
$user = user_save($user, array("userid" => $edit[userid], "name" => $edit[name], "fake_email" => $edit[fake_email], "url" => $edit[url], "bio" => $edit[bio], "signature" => $edit[signature]));
if ($edit[pass1] && $edit[pass1] == $edit[pass2]) $user = user_save($user, array("passwd" => $edit[pass1]));
}
}
function account_settings_edit() {
global $cmodes, $corder, $theme, $themes, $languages, $user;
if ($user->id) {
foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n";
$form .= form_item(t("Theme"), "<SELECT NAME=\"edit[theme]\">$options</SELECT>", t("Selecting a different theme will change the look and feel of the site."));
for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")";
$form .= form_select(t("Timezone"), "timezone", $user->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate."));
$form .= form_select(t("Language"), "language", $user->language, $languages, t("Selecting a different language will change the language of the site."));
$form .= form_select(t("Number of nodes to display"), "nodes", $user->nodes, array(10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The maximum number of nodes that will be displayed on the main page."));
$form .= form_select(t("Comment display mode"), "mode", $user->mode, $cmodes);
$form .= form_select(t("Comment display order"), "sort", $user->sort, $corder);
for ($count = -1; $count < 6; $count++) $threshold[$count] = t("Filter") ." - $count";
$form .= form_select(t("Comment filter"), "threshold", $user->threshold, $threshold, t("Comments that scored less than this threshold setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points."));
$form .= form_submit(t("Save site settings"));
$theme->header();
$theme->box(t("Edit your preferences"), form("account.php", $form));
$theme->footer();
}
else {
account_page();
}
}
function account_settings_save($edit) {
global $user;
if ($user->id) {
$user = user_save($user, array("theme" => $edit[theme], "timezone" => $edit[timezone], "language" => $edit[language], "nodes" => $edit[nodes], "mode" => $edit[mode], "sort" => $edit[sort], "threshold" => $edit[threshold]));
}
}
function account_blocks_edit() {
global $theme, $user;
if ($user->id) {
// construct form:
$result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module");
while ($block = db_fetch_object($result)) {
$entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '". check_input($block->name) ."' AND user = '$user->id'"));
$options .= "<input type=\"checkbox\" name=\"edit[$block->name]\"". ($entry->user ? " checked=\"checked\"" : "") ." /> ". t($block->name) ."<br />\n";
}
$form .= form_item(t("Blocks in side bars"), $options, t("Enable the blocks you would like to see displayed in the side bars."));
$form .= form_submit(t("Save block settings"));
// display form:
$theme->header();
$theme->box(t("Edit your content"), form("account.php", $form));
$theme->footer();
}
else {
account_page();
}
}
function account_blocks_save($edit) {
global $user;
if ($user->id) {
db_query("DELETE FROM layout WHERE user = '$user->id'");
foreach (($edit ? $edit : array()) as $block=>$weight) {
db_query("INSERT INTO layout (user, block) VALUES ('$user->id', '". check_input($block) ."')");
}
}
}
function account_user($name) {
global $user, $theme;
if ($user->id && $user->name == $name) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("Name") .":</B></TD><TD>". check_output($user->name) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("E-mail") .":</B></TD><TD>". format_email($user->fake_email) ."</A></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("Homepage") .":</B></TD><TD>". format_url($user->url) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Bio") .":</B></TD><TD>". check_output($user->bio, 1) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Signature") .":</B></TD><TD>". check_output($user->signature, 1) ."</TD></TR>\n";
$output .= "</TABLE>\n";
// Display account information:
$theme->header();
$theme->box(t("Personal information"), $output);
$theme->footer();
}
elseif ($name && $account = account_get_user($name)) {
$theme->header();
// Display account information:
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("Name") .":</B></TD><TD>". check_output($account->name) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("E-mail") .":</B></TD><TD>". format_email($account->fake_email) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("Homepage") .":</B></TD><TD>". format_url($account->url) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>". t("Bio") .":</B></TD><TD>". check_output($account->bio) ."</TD></TR>\n";
$output .= "</TABLE>\n";
$theme->box(strtr(t("%a's user information"), array("%a" => $name)), $output);
// Display contributions:
if (user_access("access contents")) {
$result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '". node_status("posted") ."' AND n.author = '$account->id' GROUP BY n.nid DESC ORDER BY n.nid DESC LIMIT 25");
while ($node = db_fetch_object($result)) {
$nodes .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$nodes .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Subject") .":</B></TD><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A> (". format_plural($node->count, "comment", "comments") .")</TD></TR>\n";
$nodes .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Type") .":</B></TD><TD>". check_output($node->type) ."</A></TD></TR>\n";
$nodes .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Date") .":</B></TD><TD>". format_date($node->timestamp) ."</TD></TR>\n";
$nodes .= "</TABLE>\n";
$nodes .= "<P>\n";
}
$theme->box(strtr(t("%a's contributions"), array("%a" => $name)), ($nodes ? $nodes : t("Not posted any nodes.")));
}
if (user_access("access comments")) {
$sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.author = '$account->id' GROUP BY n.nid DESC ORDER BY n.nid DESC LIMIT 5");
while ($node = db_fetch_object($sresult)) {
$comments .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." `<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>`:</LI>\n";
$comments .= " <UL>\n";
$cresult = db_query("SELECT * FROM comments WHERE author = '$account->id' AND lid = '$node->nid'");
while ($comment = db_fetch_object($cresult)) {
$comments .= " <LI><A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A> (". t("replies") .": ". comment_num_replies($comment->cid) .", ". t("votes") .": $comment->votes, ". t("score") .": ". comment_score($comment) .")</LI>\n";
}
$comments .= " </UL>\n";
}
$theme->box(strtr(t("%a's comments"), array("%a" => $name)), ($comments ? $comments : t("Not posted any comments.")));
}
$theme->footer();
}
else {
account_page();
}
}
function account_email_submit($edit) {
global $theme;
$result = db_query("SELECT id FROM users WHERE (userid = '". check_input($edit[login]) ."' OR name = '". check_input($edit[login]) ."') AND real_email = '". check_input($edit[email]) ."'");
if ($account = db_fetch_object($result)) {
/*
** Generate a password and a confirmation hash:
*/
$passwd = user_password();
$hash = substr(md5("$edit[login]. ". time() .""), 0, 12);
$status = 1;
/*
** Update the user account in the database:
*/
db_query("UPDATE users SET passwd = PASSWORD('$passwd'), hash = '$hash', status = '$status' WHERE userid = '". check_input($edit[login]) ."'");
/*
** Send out an e-mail with the account details:
*/
$link = path_uri() ."account.php?op=confirm&name=". urlencode($edit[login]) ."&hash=$hash";
$subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
$message = strtr(t("%a,\n\n\nyou requested us to e-mail you a new password for your account at %b. You will need to re-confirm your account or you will not be able to login. To confirm your account updates visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team"), array("%a" => $edit[login], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $passwd));
mail($edit[email], $subject, $message, "From: noreply");
watchdog("account", "new password: `$edit[login]' &lt;$edit[email]&gt;");
$output = t("Your password and further instructions have been sent to your e-mail address.");
}
else {
watchdog("account", "new password: '$edit[login]' and &lt;$edit[email]&gt; do not match");
$output = t("Could not sent password: no match for the specified username and e-mail address.");
}
$theme->header();
$theme->box(t("E-mail new password"), $output);
$theme->footer();
}
function account_create_submit($edit) {
global $theme, $HTTP_HOST, $REQUEST_URI;
if (variable_get("account_register", 1)) {
$theme->header();
if ($error = user_validate_name($edit[login])) {
$theme->box(t("Create user account"), account_create_form($edit, $error));
}
else if ($error = user_validate_mail($edit[email])) {
$theme->box(t("Create user account"), account_create_form($edit, $error));
}
else if ($ban = user_ban($edit[login], "username")) {
$theme->box(t("Create user account"), account_create_form($edit, t("the username '$edit[login]' is banned") .": <i>$ban->reason</i>."));
}
else if ($ban = user_ban($edit[real_email], "e-mail address")) {
$theme->box(t("Create user account"), account_create_form($edit, t("the username '$edit[email]' is banned") .": <i>$ban->reason</i>."));
}
else if (db_num_rows(db_query("SELECT userid FROM users WHERE (LOWER(userid) = LOWER('$edit[login]') OR LOWER(name) = LOWER('$edit[login]'))")) > 0) {
$theme->box(t("Create user account"), account_create_form($edit, t("the username '$edit[login]' is already taken.")));
}
else if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$edit[email]')")) > 0) {
$theme->box(t("Create user account"), account_create_form($edit, t("the e-mail address '$edit[email]' is already in use by another account.")));
}
else {
/*
** Generate a password and a confirmation hash:
*/
$edit[passwd] = user_password();
$edit[hash] = substr(md5("$edit[login]. ". time()), 0, 12);
/*
** Create the new user account in the database:
*/
$user = user_save("", array("userid" => $edit[login], "name" => $edit[login], "real_email" => $edit[email], "passwd" => $edit[passwd], "role" => "authenticated user", "status" => 1, "hash" => $edit[hash]));
/*
** Send out an e-mail with the account details:
*/
$link = path_uri() ."account.php?op=confirm&name=". urlencode($edit[login]) ."&hash=$edit[hash]";
$subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
$message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a bundle and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $edit[login], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $edit[passwd]));
mail($edit[email], $subject, $message, "From: noreply");
watchdog("account", "new account: `$edit[login]' &lt;$edit[email]&gt;");
$theme->box(t("Create user account"), t("Congratulations! Your member account has been successfully created and further instructions on how to confirm your account have been sent to your e-mail address. You have to confirm your account first or you will not be able to login."));
}
$theme->footer();
}
}
function account_create_confirm($name, $hash) {
global $theme;
$result = db_query("SELECT userid, hash, status FROM users WHERE userid = '$name'");
if ($account = db_fetch_object($result)) {
if ($account->status == 1) {
if ($account->hash == $hash) {
db_query("UPDATE users SET status = '2', hash = '' WHERE userid = '$name'");
$output = t("Your account has been successfully confirmed.");
watchdog("account", "$name: account confirmation successful");
}
else {
$output = t("Confirmation failed: invalid confirmation hash.");
watchdog("warning", "$name: invalid confirmation hash");
}
}
else {
$output = t("Confirmation failed: your account has already been confirmed.");
watchdog("warning", "$name: attempt to re-confirm account");
}
}
else {
$output = t("Confirmation failed: non-existing account.");
watchdog("warning", "$name: attempt to confirm non-existing account");
}
$theme->header();
$theme->box(t("Create user account"), $output);
$theme->footer();
}
function account_track_comments() {
global $theme, $user;
$sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.author = '$user->id' GROUP BY n.nid DESC ORDER BY n.nid DESC LIMIT 5");
while ($node = db_fetch_object($sresult)) {
$output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." `<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>`:</LI>\n";
$output .= " <UL>\n";
$cresult = db_query("SELECT * FROM comments WHERE author = '$user->id' AND lid = '$node->nid'");
while ($comment = db_fetch_object($cresult)) {
$output .= " <LI><A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A> (". t("replies") .": ". comment_num_replies($comment->cid) .", ". t("votes") .": $comment->votes, ". t("score") .": ". comment_score($comment) .")</LI>\n";
}
$output .= " </UL>\n";
}
$theme->header();
$theme->box(t("Track your comments"), ($output ? $output : t("You have not posted any comments recently.")));
$theme->footer();
}
function account_track_contributions() {
global $theme, $user;
$result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '". node_status("posted") ."' AND n.author = '$user->id' GROUP BY n.nid DESC ORDER BY n.nid DESC LIMIT 25");
while ($node = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Subject") .":</B></TD><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A> (". format_plural($node->count, "comment", "comments") .")</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Type") .":</B></TD><TD>". check_output($node->type) ."</A></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Date") .":</B></TD><TD>". format_date($node->timestamp) ."</TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<P>\n";
}
$theme->header();
$theme->box(t("Track your contributions"), ($output ? $output : t("You have not posted any nodes.")));
$theme->footer();
}
function account_track_site() {
global $theme, $user;
$period = 259200; // 3 days
$theme->header();
$nresult = db_query("SELECT n.nid, n.title, COUNT(c.cid) AS count FROM comments c LEFT JOIN node n ON n.nid = c.lid WHERE n.status = '". node_status("posted") ."' AND c.timestamp > ". (time() - $period) ." GROUP BY c.lid ORDER BY count DESC");
while ($node = db_fetch_object($nresult)) {
$output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
$cresult = db_query("SELECT c.subject, c.cid, c.pid, u.userid, u.name FROM comments c LEFT JOIN users u ON u.id = c.author WHERE c.lid = $node->nid ORDER BY c.timestamp DESC LIMIT $node->count");
$output .= "<UL>\n";
while ($comment = db_fetch_object($cresult)) {
$output .= " <LI>'<A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>' ". t("by") ." ". format_name($comment->name) ."</LI>\n";
}
$output .= "</UL>\n";
}
$theme->box(t("Recent comments"), ($output ? $output : t("No comments recently.")));
unset($output);
$result = db_query("SELECT n.title, n.nid, n.type, n.status, u.userid, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE ". time() ." - n.timestamp < $period ORDER BY n.timestamp DESC LIMIT 10");
if (db_num_rows($result)) {
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$output .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Status") ."</TH></TR>\n";
while ($node = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node->name) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD></TR>";
}
$output .= "</TABLE>";
}
$theme->box(t("Recent nodes"), ($output ? $output : t("No nodes recently.")));
$theme->footer();
}
switch ($op) {
case t("E-mail new password"):
account_email_submit($edit);
break;
case t("Create new account"):
account_create_submit($edit);
break;
case t("Save user information"):
if ($error = account_info_save($edit)) {
account_info_edit($error);
}
else {
account_user($user->name);
}
break;
case t("Save site settings"):
account_settings_save($edit);
header("Location: account.php?op=info");
break;
case t("Save block settings"):
account_blocks_save($edit);
account_user($user->name);
break;
case "confirm":
account_create_confirm(check_input($name), check_input($hash));
break;
case "login":
account_session_start(check_input($userid), check_input($passwd));
header("Location: account.php?op=info");
break;
case "logout":
account_session_close();
header("Location: account.php?op=info");
break;
case "view":
switch ($type) {
case "information":
account_user($user->name);
break;
case "site":
account_track_site();
break;
case "contributions":
account_track_contributions();
break;
case "comments":
account_track_comments();
break;
default:
account_user(check_input($name));
}
break;
case "edit":
switch ($type) {
case "blocks":
account_blocks_edit();
break;
case "settings":
account_settings_edit();
break;
default:
account_info_edit();
}
break;
default:
account_user($user->name);
}
page_footer();
?>

View File

@ -10,13 +10,13 @@ $cmodes = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 =
$corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low");
class Comment {
function Comment($name, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) {
function Comment($uid, $name, $subject, $comment, $timestamp, $url, $score, $votes, $cid, $lid) {
$this->uid = $uid;
$this->name = $name;
$this->subject = $subject;
$this->comment = $comment;
$this->timestamp = $timestamp;
$this->url = $url;
$this->fake_email = $fake_email;
$this->score = $score;
$this->votes = $votes;
$this->cid = $cid;
@ -27,7 +27,7 @@ class Comment {
function comment_moderate($moderate) {
global $user, $comment_votes;
if ($user->id && $moderate) {
if ($user->uid && $moderate) {
$none = $comment_votes[key($comment_votes)];
foreach ($moderate as $id=>$vote) {
@ -35,8 +35,8 @@ function comment_moderate($moderate) {
$id = check_output($id);
$vote = check_output($vote);
$comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '$id'"));
if ($comment && !field_get($comment->users, $user->id)) {
$result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->id, $vote) ."' WHERE cid = '$id'");
if ($comment && !field_get($comment->users, $user->uid)) {
$result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->uid, $vote) ."' WHERE cid = '$id'");
}
}
}
@ -45,14 +45,14 @@ function comment_moderate($moderate) {
function comment_settings($mode, $order, $threshold) {
global $user;
if ($user->id) $user = user_save($user, array("mode" => $mode, "sort" => $order, "threshold" => $threshold));
if ($user->uid) $user = user_save($user, array("mode" => $mode, "sort" => $order, "threshold" => $threshold));
}
function comment_form($edit) {
global $REQUEST_URI, $user;
// name field:
$form .= form_item(t("Your name"), format_name($user->name));
$form .= form_item(t("Your name"), format_name($user));
// subject field:
$form .= form_textfield(t("Subject"), "subject", $edit[subject], 50, 64);
@ -79,8 +79,8 @@ function comment_reply($pid, $id) {
global $theme;
if ($pid) {
$item = db_fetch_object(db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$pid'"));
comment_view(new Comment($item->name, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment"));
$item = db_fetch_object(db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$pid'"));
comment_view(new Comment($item->uid, $item->name, $item->subject, $item->comment, $item->timestamp, $item->url, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment"));
}
else {
node_view(node_get_object(array("nid" => $id)));
@ -99,7 +99,7 @@ function comment_preview($edit) {
global $REQUEST_URI, $theme, $user;
// Preview comment:
comment_view(new Comment($user->name, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->url), check_preview($user->fake_email), 0, 0, 0, 0), t("reply to this comment"));
comment_view(new Comment($user->uid, $user->name, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->homepage), 0, 0, 0, 0), t("reply to this comment"));
$theme->box(t("Reply"), comment_form($edit));
}
@ -125,7 +125,7 @@ function comment_post($edit) {
watchdog("special", "comment: added '$edit[subject]'");
// add comment to database:
db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->id', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->name ? 1 : 0) ."')");
db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->uid', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->name ? 1 : 0) ."')");
// clear cache:
cache_clear();
@ -150,7 +150,7 @@ function comment_moderation($comment) {
// preview comment:
$output .= "&nbsp;";
}
else if ($user->id && $user->name != $comment->name && !field_get($comment->users, $user->id)) {
else if ($user->uid && $user->name != $comment->name && !field_get($comment->users, $user->uid)) {
// comment hasn't been moderated yet:
foreach ($comment_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
$output .= "<SELECT NAME=\"moderate[$comment->cid]\">$options</SELECT>\n";
@ -181,7 +181,7 @@ function comment_order($order) {
}
function comment_query($lid, $order, $pid = -1) {
$query .= "SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$lid'";
$query .= "SELECT c.*, u.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.lid = '$lid'";
if ($pid >= 0) $query .= " AND pid = '$pid'";
if ($order == 1) $query .= " ORDER BY c.timestamp DESC";
else if ($order == 2) $query .= " ORDER BY c.timestamp";
@ -216,13 +216,13 @@ function comment_view($comment, $folded = 0) {
// display comment:
if ($folded) $theme->comment($comment, $folded);
else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_name($comment->name) ." <SMALL>($comment->score)</SMALL><P>";
else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_name($comment) ." <SMALL>($comment->score)</SMALL><P>";
}
function comment_thread_min($cid, $threshold) {
global $user;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
while ($comment = db_fetch_object($result)) {
print "<ul>";
@ -244,7 +244,7 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
** terms of speed and size.
*/
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
while ($comment = db_fetch_object($result)) {
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\">&nbsp;</td><td>\n";
@ -264,11 +264,11 @@ function comment_render($lid, $cid) {
// Pre-process variables:
$lid = empty($lid) ? 0 : $lid;
$cid = empty($cid) ? 0 : $cid;
$mode = ($user->id) ? $user->mode : variable_get(default_comment_mode, 4);
$order = ($user->id) ? $user->sort : variable_get(default_comment_order, 1);
$threshold = ($user->id) ? $user->threshold : variable_get(default_comment_threshold, 3);
$mode = ($user->uid) ? $user->mode : variable_get(default_comment_mode, 4);
$order = ($user->uid) ? $user->sort : variable_get(default_comment_order, 1);
$threshold = ($user->uid) ? $user->threshold : variable_get(default_comment_threshold, 3);
if ($user->id) {
if ($user->uid) {
// Comment control:
$theme->box(t("Comment control"), $theme->comment_controls($threshold, $mode, $order));
@ -277,7 +277,7 @@ function comment_render($lid, $cid) {
}
if ($cid > 0) {
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE cid = '$cid'");
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE cid = '$cid'");
if ($comment = db_fetch_object($result)) {
comment_view($comment, comment_links($comment));
}
@ -289,7 +289,7 @@ function comment_render($lid, $cid) {
print " <TR><TH>Subject</TH><TH>Author</TH><TH>Date</TH><TH>Score</TH></TR>\n";
while ($comment = db_fetch_object($result)) {
if (comment_visible($comment, $threshold)) {
print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
}
}
print "</TABLE>\n";
@ -316,7 +316,7 @@ function comment_render($lid, $cid) {
}
}
if ($user->id) {
if ($user->uid) {
// Print moderation form:
print " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$lid\">\n";
print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Moderate comments") ."\">\n";

View File

@ -34,7 +34,7 @@ function error_handler($errno, $message, $filename, $line, $variables) {
function watchdog($type, $message) {
global $user;
db_query("INSERT INTO watchdog (user, type, message, location, hostname, timestamp) VALUES ('$user->id', '". check_input($type) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."', '". time() ."')");
db_query("INSERT INTO watchdog (user, type, message, location, hostname, timestamp) VALUES ('$user->uid', '". check_input($type) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."', '". time() ."')");
}
function throttle($type, $rate) {
@ -152,7 +152,7 @@ function cache_clear($interval = 0) {
function cache_get() {
global $user, $REQUEST_URI, $REQUEST_METHOD;
if (!$user->id && $REQUEST_METHOD == "GET") {
if (!$user->uid && $REQUEST_METHOD == "GET") {
if ($cache = db_fetch_object(db_query("SELECT * FROM cache WHERE url = '". check_input($REQUEST_URI) ."'"))) {
cache_clear(variable_get("cache_clear", 30));
}
@ -167,7 +167,7 @@ function cache_get() {
function cache_set() {
global $user, $REQUEST_URI, $REQUEST_METHOD;
if (!$user->id && $REQUEST_METHOD == "GET") {
if (!$user->uid && $REQUEST_METHOD == "GET") {
if ($data = ob_get_contents()) {
db_query("INSERT INTO cache (url, data, timestamp) VALUES('". addslashes($REQUEST_URI) ."', '". addslashes($data) ."', '". time() ."')");
}
@ -220,13 +220,14 @@ function format_date($timestamp, $type = "medium", $format = "") {
return $date;
}
function format_name($username, $realname = "") {
if ($realname) {
watchdog("special", "format_name - FIX ME");
return "<font color=\"red\">FIX ME</font>\n";
function format_name($object) {
if ($object->uid && $object->name) {
return "<a href=\"module.php?mod=user&op=view&id=$object->uid\">$object->name</a>";
}
else if ($username) {
return (user_access("administer users") ? "<a href=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">". $username ."</a>" : "<a href=\"account.php?op=view&name=". urlencode($username) ."\">$username</a>");
else if (!is_object($object)) {
watchdog("error", "format_name(): missing name ($object->name) or uid ($object->uid)");
return "<font color=\"red\">FIX ME</font>";
}
else {
return variable_get(anonymous, "Anonymous");
@ -308,7 +309,6 @@ function link_page() {
$links[] = "<a href=\"index.php\">". t("home") ."</a>";
$links[] = "<a href=\"submit.php\">". t("submit") ."</a>";
$links[] = "<a href=\"account.php\">". t("account") ."</a>";
foreach (module_list() as $name) {
if (module_hook($name, "link")) {
@ -343,8 +343,6 @@ function timer_print() {
}
function page_header() {
global $user;
if (variable_get("dev_timer", 0)) {
timer_start();
}
@ -373,19 +371,16 @@ include_once "includes/$conf.php";
include_once "includes/database.inc";
include_once "includes/variable.inc";
include_once "includes/comment.inc";
include_once "includes/xmlrpc.inc";
include_once "includes/module.inc";
include_once "includes/locale.inc";
include_once "includes/search.inc";
include_once "includes/theme.inc";
include_once "includes/user.inc";
include_once "includes/node.inc";
// initialize configuration variables:
$conf = variable_init();
// initialize user session:
user_init();
// initialize installed modules:
module_init();

View File

@ -4,9 +4,9 @@
# Database settings:
#
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "database";
$db_user = "drop"; // username
$db_pass = "drop"; // password
$db_name = "database"; // database
#
# Comment votes:

View File

@ -2,7 +2,7 @@
function locale_init() {
global $languages, $user;
return ($languages ? (($user->id && $user->language) ? $user->language : key($languages)) : 0);
return ($languages ? (($user->uid && $user->language) ? $user->language : key($languages)) : 0);
}
function t($string) {

View File

@ -16,7 +16,7 @@ function _node_get($conditions) {
}
if ($type) {
return db_query("SELECT n.*, l.*, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE $where ORDER BY n.timestamp DESC");
return db_query("SELECT n.*, l.*, u.uid, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN user u ON n.author = u.uid WHERE $where ORDER BY n.timestamp DESC");
}
}
@ -190,7 +190,7 @@ function node_control($node) {
</SCRIPT>
<?php
if ($user->id) {
if ($user->uid) {
$choices = array("node.php?id=$node->nid" => t("view node"), "submit.php?mod=$node->type" => t("add node"), "submit.php?mod=$node->type&op=update&id=$node->nid" => t("update node"), "node.php?op=history&id=$node->nid" => t("view history"));
}
else {
@ -236,7 +236,7 @@ function node_index($node) {
function node_access($node) {
global $user, $status;
return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access("administer nodes");
return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->uid) || user_access("administer nodes");
}

View File

@ -14,7 +14,7 @@ function search_data($keys, $type) {
foreach ($result as $entry) {
$output .= "<p>\n";
$output .= " <b><u><a href=\"$entry[link]\">$entry[title]</a></u></b><br />";
$output .= " <small>$entry[link]". ($entry[user] ? " - ". format_name($entry[user], $entry[name]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>";
$output .= " <small>$entry[link]". ($entry[user] ? " - $entry[user]" : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>";
$output .= "</p>\n";
}
}

View File

@ -13,9 +13,9 @@ class BaseTheme {
global $REQUEST_URI, $user;
$output .= "<DIV ALIGN=\"CENTER\">\n";
$output .= "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n";
$output .= comment_mode(($user->id ? $user->mode : $mode));
$output .= comment_order(($user->id ? $user->sort : $order));
$output .= comment_threshold(($user->id ? $user->threshold : $threshold));
$output .= comment_mode(($user->uid ? $user->mode : $mode));
$output .= comment_order(($user->uid ? $user->sort : $order));
$output .= comment_threshold(($user->uid ? $user->threshold : $threshold));
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Update settings") ."\">\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Add comment") ."\">\n";
$output .= "</FORM>\n";
@ -40,21 +40,9 @@ function theme_init() {
function theme_account($region, $theme) {
global $user;
if ($user->id) {
if ($user->uid) {
// Display account settings:
$content .= "<table><tr><td nowrap=\"nowrap\">\n";
$content .= "<a href=\"account.php?op=edit&type=information\">". t("your information") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=edit&type=settings\">". t("your settings") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=edit&type=blocks\">". t("your blocks") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=view&type=comments\">". t("your comments") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=view&type=contributions\">". t("your submissions") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=view&type=site\">". strtr(t("your %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
$content .= "<p />\n";
if (user_access("access administration pages")) {
$content .= "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
$content .= "<p />\n";
}
foreach (module_list() as $name) {
if (module_hook($name, "link")) {
@ -62,40 +50,30 @@ function theme_account($region, $theme) {
foreach ($links as $link) $content .= "$link<br />\n";
}
}
if ($link) $content .= "<p />\n";
$content .= "<a href=\"account.php?op=logout\">". t("logout") ."</a>\n";
if (user_access("access administration pages")) {
$content .= "<p />\n";
$content .= "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
}
$content .= "</td></tr></table>\n";
$theme->box($user->name, $content, $region);
}
else {
$output .= "<div align=\"center\">\n";
$output .= " <form action=\"account.php?op=login\" method=\"post\">\n";
$output .= " <b>". t("Username") .":</b><br /><input name=\"userid\" size=\"15\"><p />\n";
$output .= " <b>". t("Password") .":</b><br /><input name=\"passwd\" size=\"15\" TYPE=\"password\"><br />\n";
$output .= " <input type=\"submit\" value=\"". t("Login") ."\"><br />\n";
if (variable_get("account_register", 1)) $output .= " <a href=\"account.php\">". t("REGISTER") ."</a>\n";
$output .= " </form>\n";
$output .= "</div>\n";
$theme->box(t("Login"), $output, $region);
}
}
function theme_blocks($region, $theme) {
global $id, $PHP_SELF, $status, $user;
switch (strrchr($PHP_SELF, "/")) {
case "/node.php":
if ($region != "left") {
if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
if ($user->uid) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
if ($node->status == $status[queued]) theme_moderation_results($theme, $node, $region);
}
break;
case "/index.php":
if ($user->id) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.user = '$user->id'))". (($region == "left" || $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight");
if ($user->uid) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.user = '$user->uid'))". (($region == "left" || $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight");
else $result = db_query("SELECT * FROM blocks WHERE status = 2". (($region == "left" || $region == "right") ? ($region == "left" ? " AND region = 0" : " AND region = 1") : "") ." ORDER BY weight");
while ($block = db_fetch_object($result)) {
$blocks = module_invoke($block->module, "block");
@ -109,8 +87,8 @@ function theme_moderation_results($theme, $node, $region) {
foreach (explode(",", $node->users) as $vote) {
if ($vote) {
$data = explode("=", $vote);
$account = user_get($data[0]);
$output .= format_name($account->name) ." voted '$data[1]'.<br />";
$account = user_load(array("uid" => $data[0]));
$output .= format_name($account) ." voted '$data[1]'.<br />";
}
}

View File

@ -1,99 +0,0 @@
<?php
class User {
function User($userid, $passwd = 0) {
if ($passwd) {
$result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE (LOWER(u.userid) = LOWER('$userid') OR LOWER(u.name) = LOWER('$userid')) AND u.passwd = PASSWORD('$passwd') AND u.status = 2");
if (db_num_rows($result) == 1) {
foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; }
db_query("UPDATE users SET last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]' WHERE id = $this->id");
}
}
else {
$result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE u.userid = '$userid' AND u.status = 2");
if (db_num_rows($result) == 1) {
foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; }
db_query("UPDATE users SET last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]' WHERE id = $this->id");
}
}
}
}
function user_get($uid) {
return db_fetch_object(db_query("SELECT * FROM users WHERE id = '". check_output($uid) ."'"));
}
function user_init() {
global $db_name;
session_name($db_name);
session_start();
}
function user_load($username) {
return new User($username);
}
function user_rehash() {
global $user;
if ($user->id) {
$user = new User($user->userid);
session_register("user");
}
}
function user_save($account, $array) {
// dynamically compose query:
foreach ($array as $key=>$value) {
if ($key == "passwd") $query .= "$key = PASSWORD('". addslashes($value) ."'), ";
else $query .= "$key = '". addslashes($value) ."', ";
}
// update or instert account:
if ($account->id) db_query("UPDATE users SET $query last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]' WHERE id = '$account->id'");
else db_query("INSERT INTO users SET $query last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]'");
// return account:
return user_load($array[userid] ? $array[userid] : $account->userid);
}
function user_access($perm) {
global $user;
if ($user->id == 1) {
return 1;
}
else if ($user->perm) {
return strstr($user->perm, $perm);
}
else {
return db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user' AND perm LIKE '%$perm%'"));
}
}
function user_ban($mask, $type) {
$result = db_query("SELECT * FROM access WHERE type = '$type' AND '$mask' REGEXP mask");
return db_fetch_object($result);
}
function user_password($min_length=6) {
mt_srand((double)microtime() * 1000000);
$words = explode(",", variable_get("account_words", "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"));
while (strlen($password) < $min_length) $password .= trim($words[mt_rand(0, count($words))]);
return $password;
}
function user_validate_name($name) {
if (!$name) return t("you must enter a username.");
if (eregi("^ ", $name)) return t("the username can not begin with a space.");
if (eregi(" \$", $name)) return t("the username can not end with a space.");
if (eregi(" ", $name)) return t("the username can not contain multiple spaces in a row.");
if (eregi("[^a-zA-Z0-9 ]", $name)) return t("the username contains an illegal character.");
if (strlen($name) > 32) return t("the username '$name' is too long: it must be less than 32 characters.");
}
function user_validate_mail($mail) {
if (!$mail) return t("your must enter an e-mail address.");
if (!eregi("^[_+\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $mail)) return t("the e-mail address '$email' is not valid.");
}
?>

View File

@ -1,175 +0,0 @@
<?php
function access_help() {
?>
<H3>Roles</H3>
<P>Users have roles that define what kinds of actions they can take. Roles define classes of users such as <I>anonymous user</I>, <I>authenticated user</I>, <I>moderator</I>, <I>administrator</I> and so on. Every user can have one role.</P>
<P>Roles make it easier for you to manage security. Instead of defining what every single user can do, you can simply set a couple different permissions for different user roles.</P>
<P>Drupal comes with three built-in roles:</P>
<UL>
<LI>Anonymous user: this role is used for users that don't have a user account or that are not authenticated.</LI>
<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>For basic Drupal sites you can get by with <I>anonymous user</I> and <I>authenticated user</I> but for more complex sites where you want other users to be able to perform maintainance or administrative duties, you may want to create your own roles to classify your users into different groups.</P>
<H3>Permissions</H3>
<P>Each Drupal's 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>
<H3>Access control</H3>
<P>Roles tie users to permissions. The combination of roles and permissions represent a way to tie user authorization to the performance of actions, which is how Drupal can determine what users can do.</P>
<?php
}
function access_perm() {
return array("access administration pages", "administer roles and permissions");
}
function access_link($type) {
if ($type == "admin" && user_access("administer roles and permissions")) {
$links[] = "<a href=\"admin.php?mod=access\">roles and permissions</a>";
}
return $links ? $links : array();
}
function access_get_role($rid) {
return db_fetch_array(db_query("SELECT * FROM role WHERE rid = '". check_input($rid) ."'"));
}
function access_get_roles() {
$result = db_query("SELECT * FROM role ORDER BY name");
while ($role = db_fetch_object($result)) {
$roles[$role->name] = $role->name;
}
return $roles;
}
function access_role_form($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Role name", "name", $edit[name], 50, 64, "The name for this role. Example: 'moderator', 'editorial board', 'site architect'.");
$form .= form_submit("Submit");
if ($edit[rid]) {
$form .= form_submit(t("Delete"));
$form .= form_hidden("rid", $edit[rid]);
}
return form($REQUEST_URI, $form);
}
function access_role_save($edit) {
if ($edit[rid] && $edit[name]) {
db_query("UPDATE role SET name = '". check_input($edit[name]) ."' WHERE rid = '$edit[rid]'");
}
else if ($edit[rid]) {
db_query("DELETE FROM role WHERE rid = '". check_input($edit[rid]) ."'");
}
else {
db_query("INSERT INTO role (name) VALUES ('". check_input($edit[name]) ."')");
}
}
function access_role_view() {
$result = db_query("SELECT * FROM role ORDER BY name");
$output .= "<TABLE BORDER=\"1\" CELLSPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>name</TH><TH>operations</TH></TR>\n";
while ($role = db_fetch_object($result)) {
$output .= "<TR><TD>". check_output($role->name) ."</TD><TD><A HREF=\"admin.php?mod=access&op=edit&id=$role->rid\">edit role</A></TD></TR>\n";
}
$output .= "</TABLE>\n";
return $output;
}
function access_perm_form() {
global $REQUEST_URI;
// Compile permission array:
foreach (module_list() as $name) {
if (module_hook($name, "perm")) {
$perms = array_merge($perms, module_invoke($name, "perm"));
}
}
asort($perms);
// Compile role array:
$result = db_query("SELECT * FROM role ORDER BY name");
while ($role = db_fetch_object($result)) $roles[$role->name] = $role->perm;
// Render roles / permission table:
$output .= "<TABLE BORDER=\"1\" CELLSPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>&nbsp;</TH><TH>". implode("</TH><TH>", array_keys($roles)) ."</TH></TR>\n";
foreach ($perms as $perm) {
$output .= " <TR>\n";
$output .= " <TD>". check_output($perm) ."</TD>\n";
foreach ($roles as $name => $value) {
$output .= " <TD ALIGN=\"center\"><INPUT TYPE=\"checkbox\" NAME=\"edit[$name][$perm]\"". (strstr($value, $perm) ? " CHECKED" : "") ."></TD>\n";
}
$output .= " </TR>\n";
}
$output .= "</TABLE>\n";
$output .= form_submit("Save permissions");
return form($REQUEST_URI, $output);
}
function access_perm_save($edit) {
$result = db_query("SELECT * FROM role");
while ($role = db_fetch_object($result)) {
$perm = $edit[$role->name] ? implode(", ", array_keys($edit[$role->name])) : "";
db_query("UPDATE role SET perm = '$perm' WHERE name = '$role->name'");
}
return "permissions have been saved.";
}
function access_init() {
$role = db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user'"));
if (!$role) db_query("INSERT INTO role (name) VALUES ('anonymous user')");
$role = db_fetch_object(db_query("SELECT * FROM role WHERE name = 'authenticated user'"));
if (!$role) db_query("INSERT INTO role (name) VALUES ('authenticated user')");
}
function access_admin() {
global $edit, $op, $id;
if (user_access("administer roles and permissions")) {
print "<SMALL><A HREF=\"admin.php?mod=access&op=add\">add new role</A> | <A HREF=\"admin.php?mod=access&op=role\">role overview</A> | <A HREF=\"admin.php?mod=access&op=perm\">permission overview</A> | <A HREF=\"admin.php?mod=access&op=help\">help</A></SMALL><HR>\n";
access_init();
switch ($op) {
case "add":
print access_role_form();
break;
case "edit":
print access_role_form(access_get_role($id));
break;
case "help":
print access_help();
break;
case "Delete":
$edit[name] = 0;
// fall through:
case "Submit":
print status(access_role_save($edit));
// fall through:
case "role":
print access_role_view();
break;
case "Save permissions":
print status(access_perm_save($edit));
// fall through:
default:
print access_perm_form();
}
}
else {
print message_access();
}
}
?>

View File

@ -1,382 +0,0 @@
<?php
function account_help() {
?>
<P>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.</P>
<P>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!</P>
<P>Check the documentation page for detailed information about user management.</P>
<H3>Regular expressions</H3>
<P>A <I>regular expression</I> (or <I>regexp</I>, or <I>pattern</I>) is a text string that describes some (mathematical) set of strings. A regexp <CODE>R</CODE> "matches" a string <CODE>S</CODE> if <CODE>S</CODE> is in the set of strings described by <CODE>R</CODE>.</P>
<P>Regular expressions are very powerful but often get complicated and nothing in this write-up can change that.
<P>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:</P>
<TABLE BORDER="1">
<TR><TD>^</TD><TD>Matches the beginning of a string.</TD></TR>
<TR><TD>$</TD><TD>Matches the end of a string.</TD></TR>
<TR><TD>.</TD><TD>Matches any character (including newline). For example the regular expression a.c would match the strings abc, adb, axb, but not axxc.<TD></TR>
<TR><TD>a*</TD><TD>Matches any sequence of zero or more a characters.</TD></TR>
<TR><TD>a+</TD><TD>Matches any sequence of one or more a characters.</TD></TR>
<TR><TD>a?</TD><TD>Matches either zero or one a character.</TD></TR>
<TR><TD>ab|cd</TD><TD>Matches either of the sequences "ab" or "cd".</TD></TR>
<TR><TD>(abc)*</TD><TD>Matches zero or more instances of the sequence abc.</TD></TR>
<TR><TD>[abc]</TD><TD>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.</TD></TR>
<TR><TD>{num}</TD><TD>Matches the preceding element num times.</TD></TR>
<TR><TD>{min, max}</TD><TD>Matches the preceding element at least min times, but not more than max times.</TD></TR>
</TABLE>
<P><B>Examples:</B></P>
<TABLE BORDER="1">
<TR><TD>apple</TD><TD>Matches any string that has the text "apple" in it.</TD></TR>
<TR><TD>^apple$</TD><TD>Matches the exact string "apple".</TD></TR>
<TR><TD>^apple</TD><TD>Matches any string that starts with "apple".</TD></TR>
<TR><TD>domain\.com$</TD><TD>Matches any string that ends with "domain.com". Note that you have to escape the dot in domain.com.</TD></TR>
</TABLE>
<?php
}
function account_perm() {
return array("administer users");
}
function account_link($type) {
if ($type == "admin" && user_access("administer users")) {
$links[] = "<a href=\"admin.php?mod=account\">user accounts</a>";
}
return $links ? $links : array();
}
function account_conf_options() {
$output .= form_select(t("Public accounts"), "account_register", variable_get("account_register", 1), array("Disabled", "Enabled"), "If enabled, everyone can create a new user account. If disabled, new user accounts can only be created by site administrators.");
return $output;
}
function account_search($keys) {
$result = db_query("SELECT * FROM users WHERE name LIKE '%$keys%' LIMIT 20");
while ($account = db_fetch_object($result)) {
$find[$i++] = array("title" => $account->name, "link" => (user_access("administer users") ? "admin.php?mod=account&op=view&name=". urlencode($account->name) : "account.php?op=view&name=". urlencode($account->name)), "user" => $account->name);
}
return $find;
}
function account_ac_add($edit) {
db_query("INSERT INTO access (mask, type, reason) VALUES ('". check_input($edit[mask]) ."', '". check_input($edit[type]) ."', '". check_input($edit[reason]) ."')");
}
function account_ac_del($id) {
db_query("DELETE FROM access WHERE id = '$id'");
}
function account_ac_check($edit) {
return "\"$edit[text]\" ". (($rule = user_ban($edit[text], $edit[category])) ? "matched with access rule '$rule->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 .= " <OPTION VALUE=\"$value\">$value</OPTION>\n";
$output .= "<FORM ACTION=\"admin.php?mod=account&op=access\" METHOD=\"post\">\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>mask</TH><TH>type</TH><TH>reason</TH><TH>operations</TH></TR>\n";
while ($rule = db_fetch_object($result)) {
$output .= " <TR><TD>$rule->mask</TD><TD ALIGN=\"center\">$rule->type</TD><TD>". check_output($rule->reason) ."</TD><TD><A HREF=\"admin.php?mod=account&op=delete&id=$rule->id\">delete rule</A></TD></TR>\n";
}
$output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"edit[mask]\"></TD><TD><SELECT NAME=\"edit[type]\">\n$type</SELECT></TD><TD><INPUT TYPE=\"text\" NAME=\"edit[reason]\"></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Add rule\"></TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"4\"><SMALL><I>Use <A HREF=\"admin.php?mod=account&op=help\">regular expressions</A> (regexs) to specify the mask pattern.</I></SMALL></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<BR><BR>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH COLSPAN=\"3\">check access rules</TH></TR>\n";
$output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"edit[text]\"></TD><TD><SELECT NAME=\"edit[category]\">\n$type</SELECT></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Check\"></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "</FORM>\n";
return $output;
}
function account_overview($query = array()) {
$result = db_query("SELECT id, name, last_access FROM users $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>username</TH><TH>last access</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($account = db_fetch_object($result)) {
$output .= " <TR><TD>". format_name($account->name) ."</TD><TD>". format_date($account->last_access) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=view&name=". urlencode($account->name) ."\">view account</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=edit&name=". urlencode($account->name) ."\">edit account</A></TD></TR>\n";
}
$output .= "</TABLE>\n";
return $output;
}
function account_blocks($id) {
$result = db_query("SELECT * FROM layout WHERE user = '$id'");
while ($layout = db_fetch_object($result)) {
$output .= "<LI>$layout->block</LI>\n";
}
return $output;
}
function account_nodes($id) {
$result = db_query("SELECT * FROM node WHERE author = $id ORDER BY timestamp DESC LIMIT 30");
while ($node = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"node.php?id=$node->nid\">$node->title</A> ($node->type)</LI>\n";
}
return $output;
}
function account_comments($id) {
$result = db_query("SELECT * FROM comments WHERE author = '$id' ORDER BY timestamp DESC LIMIT 30");
while ($comment = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject</A></LI>\n";
}
return $output;
}
function account_delete($name) {
$result = db_query("SELECT * FROM users WHERE name = '$name' AND status = 0 AND id > 1");
if ($account = db_fetch_object($result)) {
db_query("DELETE FROM users WHERE id = '$account->id'");
}
else {
return "failed to delete account '". format_name($name) ."': the account must be blocked first.";
}
}
function account_form($account = 0) {
$form .= $account->id ? form_item("ID", $account->id) . form_hidden("id", $account->id) : "";
$form .= form_item(t("Name"), check_output($account->name) ." (". check_output($account->userid) .")");
$form .= form_select(t("Status"), "status", $account->status, array("blocked", "not confirmed", "open"));
$form .= form_select(t("Role"), "role", $account->role, access_get_roles());
$form .= form_textfield(t("Real e-mail address"), "real_email", $account->real_email, 30, 55);
$form .= form_textfield(t("Fake e-mail address"), "fake_email", $account->fake_email, 30, 55);
$form .= form_textfield(t("Homepage"), "url", $account->url, 30, 55);
$form .= form_textarea(t("Bio"), "bio", $account->bio, 35, 5);
$form .= form_textarea(t("Signature"), "signature", $account->signature, 35, 5);
$form .= form_hidden("userid", $account->userid);
$form .= form_hidden("name", $account->name);
if ($account) {
$form .= form_submit("View account");
}
$form .= form_submit("Save account");
return form("admin.php?mod=account", $form);
}
function account_save($edit) {
if ($edit[id]) {
// Updating existing account
foreach ($edit as $key=>$value) {
$query[] = "$key = '". addslashes($value) ."'";
}
db_query("UPDATE users SET ". implode(", ", $query) ." WHERE id = $edit[id]");
watchdog("account", "account: modified user '$edit[name]'");
return $edit[name];
}
else {
if ($error = account_validate($edit)) {
print status($error);
return 0;
}
else {
$edit[passwd] = user_password();
$edit[hash] = substr(md5("$edit[userid]. ". time()), 0, 12);
$user = user_save("", array("name" => $edit[userid], "userid" => $edit[userid], "role" => $edit[role], "real_email" => $edit[real_email], "passwd" => $edit[passwd], "status" => $edit[status], "hash" => $edit[hash]));
$link = path_uri() ."account.php?op=confirm&name=". urlencode($edit[userid]) ."&hash=$edit[hash]";
$subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
$message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a knot and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $edit[userid], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $edit[passwd]));
watchdog("account", "new account: `$edit[userid]' &lt;$edit[real_email]&gt;");
if ($edit[status] == 1) mail($edit[real_email], $subject, $message, "From: noreply");
return $edit[userid];
}
}
}
function account_edit($name) {
$result = db_query("SELECT * FROM users WHERE name = '$name'");
if ($account = db_fetch_object($result)) {
return account_form($account);
}
}
function account_add() {
global $REQUEST_URI;
$form .= form_textfield("Username", "name", "", 30, 55);
$form .= form_textfield("E-mail address", "mail", "", 30, 55);
$form .= form_textfield("Password", "pass", "", 30, 55);
$form .= form_submit("Create account");
return form($REQUEST_URI, $form);
}
function account_create($edit) {
if ($error = user_validate_name($edit[name])) {
return $error;
}
else if ($error = user_validate_mail($edit[mail])) {
return $error;
}
else if (empty($edit[pass])) {
return "password should be non-empty.";
}
else if (db_num_rows(db_query("SELECT userid FROM users WHERE (LOWER(userid) = LOWER('$edit[name]') OR LOWER(name) = LOWER('$edit[name]'))")) > 0) {
return "the username '$edit[name]' is already taken.";
}
else if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$edit[mail]')")) > 0) {
return "the e-mail address '$edit[mail]' is already in use by another account.";
}
else {
$user = user_save("", array("userid" => $edit[name], "name" => $edit[name], "real_email" => $edit[mail], "passwd" => $edit[pass], "role" => "authenticated user", "status" => 2));
}
}
function account_view($name) {
$status = array(0 => "blocked", 1 => "not confirmed", 2 => "open");
$result = db_query("SELECT * FROM users WHERE name = '$name'");
if ($account = db_fetch_object($result)) {
$form .= form_hidden("name", $account->name);
$form .= form_submit("Edit account");
$form .= form_submit("Delete account");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>ID:</TH><TD>$account->id</TD></TR>\n";
$output .= " <TR><TH>Name:</TH><TD>". check_output($account->name) ." (". check_output($account->userid) .")</TD></TR>\n";
$output .= " <TR><TH>Status:</TH><TD>". $status[$account->status] ."</TD></TR>\n";
$output .= " <TR><TH>Role:</TH><TD>". check_output($account->role) ."</TD></TR>\n";
$output .= " <TR><TH>Real e-mail address:</TH><TD>". format_email($account->real_email) ."</TD></TR>\n";
$output .= " <TR><TH>Fake e-mail address:</TH><TD>". check_output($account->fake_email) ."</TD></TR>\n";
$output .= " <TR><TH>Homepage:</TH><TD>". format_url($account->url) ."</TD></TR>\n";
$output .= " <TR><TH>Last access:</TH><TD>". format_date($account->last_access) ." from ". check_output($account->last_host) ."</TD></TR>\n";
$output .= " <TR><TH>User rating:</TH><TD>". check_output($account->rating) ."</TD></TR>\n";
$output .= " <TR><TH>Bio:</TH><TD>". check_output($account->bio) ."</TD></TR>\n";
$output .= " <TR><TH>Signature:</TH><TD>". check_output($account->signature) ."</TD></TR>\n";
$output .= " <TR><TH>Theme:</TH><TD>". check_output($account->theme) ."</TD></TR>\n";
$output .= " <TR><TH>Timezone:</TH><TD>". check_output($account->timezone / 3600) ."</TD></TR>\n";
$output .= " <TR><TH>Selected blocks:</TH><TD>". check_output(account_blocks($account->id)) ."</TD></TR>\n";
$output .= " <TR><TH>Recent nodes:</TH><TD>". check_output(account_nodes($account->id)) ."</TD></TR>\n";
$output .= " <TR><TH>Recent comments:</TH><TD>". check_output(account_comments($account->id)) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">". form("admin.php?mod=account", $form) ."</TD></TR>\n";
$output .= "</TABLE>\n";
return $output;
}
}
function account_query($type = "") {
$queries = array(array("users recently visiting", "ORDER BY last_access DESC"), array("users recently joining", "ORDER BY id DESC"), array("users with pending accounts", "WHERE status = 1 ORDER BY last_access DESC"), array("users with blocked accounts", "WHERE status = 0 ORDER BY last_access DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function account_validate($user) {
if ($error = user_validate_name($user[userid])) return $error;
// Verify e-mail address:
if ($error = user_validate_mail($user[real_email])) return $error;
// Check to see whether the username or e-mail address are banned:
if ($ban = user_ban($user[userid], "username")) return t("the username '$user[userid]' is banned") .": <I>$ban->reason</I>.";
if ($ban = user_ban($user[real_email], "e-mail address")) return t("the e-mail address '$user[real_email]' is banned") .": <I>$ban->reason</I>.";
// Verify whether username and e-mail address are unique:
if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid) = LOWER('$user[userid]')")) > 0) return t("the username '$user[userid]' is already taken.");
if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$user[real_email]')")) > 0) return t("the e-mail address '$user[real_email]' is already in use by another account.");
}
function account_admin() {
global $op, $edit, $id, $mod, $keys, $order, $name, $query;
if (user_access("administer users")) {
print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=add\">add new account</A> | <A HREF=\"admin.php?mod=account&op=listing\">account listings</A> | <A HREF=\"admin.php?mod=account&op=search\">search account</A> | <A HREF=\"admin.php?mod=account\">overview</A> | <A HREF=\"admin.php?mod=account&op=help\">help</A></SMALL><HR>";
$query = $query ? $query : 0;
$name = $name ? $name : $edit[name];
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":
print status(account_ac_del($id));
print account_ac();
break;
case "Delete account":
print status(account_delete($name));
print account_overview(account_query($query));
break;
case "Create account":
if ($error = account_create($edit)) {
print status($error);
print account_add($edit);
}
else {
print account_edit($edit[name]);
}
break;
case "add":
print account_add();
break;
case "Edit account":
case "edit":
print account_edit($name);
break;
case "help":
print account_help();
break;
case "listing":
print node_listing(account_query());
break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
break;
case "Save account":
$name = account_save($edit);
if ($name)
print account_view($name);
else {
foreach ($edit as $key=>$value) {
$account->$key = $value;
}
print account_form($account);
}
break;
case "View account":
case "view":
print account_view($name);
break;
default:
print account_overview(account_query($query));
}
}
else {
print message_access();
}
}
?>

View File

@ -50,7 +50,7 @@ function import_update() {
function import_format_item($item, $feed = 0) {
global $theme, $user;
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$output .= "<a href=\"submit.php?mod=blog&type=import&id=$item->iid\"><img src=\"". $theme->image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /></a> ";
}
@ -602,7 +602,7 @@ function import_page_sources() {
while ($feed = db_fetch_object($result)) {
$output .= format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title);
$output .= "<p><div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div></p>";
$output .= "<div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div><br />";
}
$output .= "<a href=\"module.php?mod=import&op=fd\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a><br />\n";

View File

@ -50,7 +50,7 @@ function import_update() {
function import_format_item($item, $feed = 0) {
global $theme, $user;
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$output .= "<a href=\"submit.php?mod=blog&type=import&id=$item->iid\"><img src=\"". $theme->image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /></a> ";
}
@ -602,7 +602,7 @@ function import_page_sources() {
while ($feed = db_fetch_object($result)) {
$output .= format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title);
$output .= "<p><div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div></p>";
$output .= "<div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div><br />";
}
$output .= "<a href=\"module.php?mod=import&op=fd\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a><br />\n";

View File

@ -26,20 +26,28 @@ function blog_summary($node) {
return $node->body;
}
function blog_feed_user($name = 0, $date = 0) {
function blog_feed_user($uid = 0, $date = 0) {
global $user;
$name = check_input($name ? $name : $user->name);
$date = check_input($date ? $date : time());
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
}
else {
$account = $user;
}
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.name = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15");
if (!$date) {
$date = time();
}
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid WHERE u.uid = '$uid' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
$items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->body);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel("$name's blog", path_uri() ."module.php?mod=blog&op=view&name=". urlencode($name), "$name's blog", $items);
$output .= format_rss_channel("$account->name's blog", path_uri() ."module.php?mod=blog&op=view&id=$account->uid", "$account->name's blog", $items);
$output .= "</rss>\n";
header("Content-Type: text/xml");
@ -49,9 +57,9 @@ function blog_feed_user($name = 0, $date = 0) {
}
function blog_feed_last() {
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 15");
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid ORDER BY b.lid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
$items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&name=". urlencode($blog->name), $blog->body);
$items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=". urlencode($blog->uid), $blog->body);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
@ -65,13 +73,21 @@ function blog_feed_last() {
}
function blog_page_user($name = 0, $date = 0) {
function blog_page_user($uid = 0, $date = 0) {
global $theme, $user;
$name = check_input($name ? $name : $user->name);
$date = check_input($date ? $date : time());
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
}
else {
$account = $user;
}
$result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid WHERE u.name = '$name' AND n.timestamp <= '$date' AND n.timestamp >= '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
if (!$date) {
$date = time();
}
$result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN comments c ON n.nid = c.lid WHERE u.uid = '$account->uid' AND n.timestamp <= '$date' AND n.timestamp >= '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
@ -81,14 +97,14 @@ function blog_page_user($name = 0, $date = 0) {
if ($date != date("dny", $blog->timestamp)) {
$date = date("dny", $blog->timestamp);
$output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&name=". urlencode($name) ."&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>";
$output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>";
}
if ($user->id && $user->name == $name) {
if ($user->uid && $user->name == $name) {
$links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
@ -102,15 +118,15 @@ function blog_page_user($name = 0, $date = 0) {
}
$output .= "</table>";
$output .= "<a href=\"module.php?mod=blog&op=feed&name=". urlencode($name) ."\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n";
$output .= "<a href=\"module.php?mod=blog&op=feed&id=$account->uid\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n";
$theme->box(strtr(t("%a's blog"), array("%a" => $name)), $output, "main");
$theme->box(sprintf(t("%s's blog"), $account->name), $output, "main");
}
function blog_page_last() {
global $theme, $user;
$result = db_query("SELECT n.author, n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
$result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
@ -118,13 +134,13 @@ function blog_page_last() {
$links = array();
$links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->name) ."\">". strtr(t("%a's blog"), array("%a" => $blog->name)) ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\">". sprintf("%s's blog", $blog->name) ."</a>";
if ($blog->author == $user->id) {
if ($blog->uid == $user->uid) {
$links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
@ -148,7 +164,7 @@ function blog_remove($nid) {
$blog = node_get_object(array(nid => $nid, type => "blog"));
if ($blog && $blog->author == $user->id) {
if ($blog && $blog->uid == $user->uid) {
node_save(array(nid => $nid), array(status => $status[dumped]));
node_del(array(type => "blog", nid => $nid));
}
@ -163,7 +179,7 @@ function blog_view($node, $main = 0) {
function blog_form($edit = array()) {
global $REQUEST_URI, $id, $mod, $type, $user, $theme;
if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) {
if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
if ($mod == "node" || $edit[type] == "blog") {
// do nothing
}
@ -217,12 +233,12 @@ function blog_form($edit = array()) {
function blog_save($edit) {
global $status, $user;
if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) {
if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
if ($edit["nid"]) {
node_save($edit, array(title, body, type => "blog"));
}
else {
node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->id, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0));
node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->uid, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0));
}
}
}
@ -230,7 +246,7 @@ function blog_save($edit) {
function blog_edit_history($nid) {
global $user;
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '". check_input($user->id) ."' AND n.nid <= '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15");
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '$user->uid' AND n.nid <= '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15");
$output .= "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width=\"100%\">";
while ($blog = db_fetch_object($result)) {
@ -242,13 +258,13 @@ function blog_edit_history($nid) {
}
function blog_page() {
global $theme, $op, $name, $date;
global $theme, $id, $op, $date;
if (user_access("access blogs")) {
switch ($op) {
case "feed":
if ($name) {
blog_feed_user($name, $date);
if ($id) {
blog_feed_user($id, $date);
}
else {
blog_feed_last();
@ -256,8 +272,8 @@ function blog_page() {
break;
default:
$theme->header();
if ($name) {
blog_page_user($name, $date);
if ($id) {
blog_page_user($id, $date);
}
else {
blog_page_last();
@ -280,7 +296,7 @@ function blog_user() {
switch ($op) {
case "delete":
blog_remove($id);
blog_page_user($user->name, time());
blog_page_user($user->uid, time());
break;
case "edit":
$theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main");
@ -291,7 +307,7 @@ function blog_user() {
break;
case t("Submit"):
blog_save($edit);
blog_page_user($user->name, time());
blog_page_user($user->uid, time());
break;
default:
$theme->box(t("Submit a blog"), blog_form($edit), "main");
@ -309,11 +325,11 @@ function blog_link($type, $node = 0) {
if ($type == "menu" && user_access("post blogs")) {
$links[] = "<a href=\"submit.php?mod=blog\">". t("add blog entry") ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($user->name) ."\">". t("view your blog") ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>";
}
if ($type == "node" && $node->type == "blog") {
$links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>";
}
return $links ? $links : array();
@ -321,11 +337,12 @@ function blog_link($type, $node = 0) {
function blog_block() {
global $name, $date, $user, $mod;
global $user;
$result = db_query("SELECT u.uid, u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN user u ON n.author = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
$result = db_query("SELECT u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
while ($node = db_fetch_object($result)) {
$output .= "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". check_output($node->title) ."</a><br />\n";
$output .= "<a href=\"module.php?mod=blog&op=view&id=$node->nid\">". check_output($node->title) ."</a><br />\n";
}
$block[0]["subject"] = "<a href=\"module.php?mod=blog\">". t("User blogs") ."</a>";
@ -333,23 +350,13 @@ function blog_block() {
$block[0]["info"] = t("User blogs");
$block[0]["link"] = "module.php?mod=blog";
$date = $date ? $date : time();
$name = $name ? $name : $user->name;
if (($mod == "blog") || ($mod == "block")) {
// Only show this block on "blog pages" and in the admin block section.
$calendar = new BlogCalendar($name, $date);
$block[1]["subject"] = "<a href=\"module.php?mod=blog&name=". urlencode($name) ."\">" . t("Browse blog") . "</a>";
$block[1]["content"] = $calendar->display();
$block[1]["info"] = t("Calendar to browse blogs");
}
return $block;
}
function blog_search($keys) {
global $status, $user;
global $status;
$result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($blog = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($blog->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);

View File

@ -26,20 +26,28 @@ function blog_summary($node) {
return $node->body;
}
function blog_feed_user($name = 0, $date = 0) {
function blog_feed_user($uid = 0, $date = 0) {
global $user;
$name = check_input($name ? $name : $user->name);
$date = check_input($date ? $date : time());
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
}
else {
$account = $user;
}
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.name = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15");
if (!$date) {
$date = time();
}
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid WHERE u.uid = '$uid' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
$items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->body);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel("$name's blog", path_uri() ."module.php?mod=blog&op=view&name=". urlencode($name), "$name's blog", $items);
$output .= format_rss_channel("$account->name's blog", path_uri() ."module.php?mod=blog&op=view&id=$account->uid", "$account->name's blog", $items);
$output .= "</rss>\n";
header("Content-Type: text/xml");
@ -49,9 +57,9 @@ function blog_feed_user($name = 0, $date = 0) {
}
function blog_feed_last() {
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 15");
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid ORDER BY b.lid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
$items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&name=". urlencode($blog->name), $blog->body);
$items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=". urlencode($blog->uid), $blog->body);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
@ -65,13 +73,21 @@ function blog_feed_last() {
}
function blog_page_user($name = 0, $date = 0) {
function blog_page_user($uid = 0, $date = 0) {
global $theme, $user;
$name = check_input($name ? $name : $user->name);
$date = check_input($date ? $date : time());
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
}
else {
$account = $user;
}
$result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid WHERE u.name = '$name' AND n.timestamp <= '$date' AND n.timestamp >= '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
if (!$date) {
$date = time();
}
$result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN comments c ON n.nid = c.lid WHERE u.uid = '$account->uid' AND n.timestamp <= '$date' AND n.timestamp >= '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
@ -81,14 +97,14 @@ function blog_page_user($name = 0, $date = 0) {
if ($date != date("dny", $blog->timestamp)) {
$date = date("dny", $blog->timestamp);
$output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&name=". urlencode($name) ."&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>";
$output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>";
}
if ($user->id && $user->name == $name) {
if ($user->uid && $user->name == $name) {
$links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
@ -102,15 +118,15 @@ function blog_page_user($name = 0, $date = 0) {
}
$output .= "</table>";
$output .= "<a href=\"module.php?mod=blog&op=feed&name=". urlencode($name) ."\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n";
$output .= "<a href=\"module.php?mod=blog&op=feed&id=$account->uid\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n";
$theme->box(strtr(t("%a's blog"), array("%a" => $name)), $output, "main");
$theme->box(sprintf(t("%s's blog"), $account->name), $output, "main");
}
function blog_page_last() {
global $theme, $user;
$result = db_query("SELECT n.author, n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
$result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
@ -118,13 +134,13 @@ function blog_page_last() {
$links = array();
$links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->name) ."\">". strtr(t("%a's blog"), array("%a" => $blog->name)) ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\">". sprintf("%s's blog", $blog->name) ."</a>";
if ($blog->author == $user->id) {
if ($blog->uid == $user->uid) {
$links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
@ -148,7 +164,7 @@ function blog_remove($nid) {
$blog = node_get_object(array(nid => $nid, type => "blog"));
if ($blog && $blog->author == $user->id) {
if ($blog && $blog->uid == $user->uid) {
node_save(array(nid => $nid), array(status => $status[dumped]));
node_del(array(type => "blog", nid => $nid));
}
@ -163,7 +179,7 @@ function blog_view($node, $main = 0) {
function blog_form($edit = array()) {
global $REQUEST_URI, $id, $mod, $type, $user, $theme;
if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) {
if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
if ($mod == "node" || $edit[type] == "blog") {
// do nothing
}
@ -217,12 +233,12 @@ function blog_form($edit = array()) {
function blog_save($edit) {
global $status, $user;
if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) {
if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
if ($edit["nid"]) {
node_save($edit, array(title, body, type => "blog"));
}
else {
node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->id, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0));
node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->uid, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0));
}
}
}
@ -230,7 +246,7 @@ function blog_save($edit) {
function blog_edit_history($nid) {
global $user;
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '". check_input($user->id) ."' AND n.nid <= '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15");
$result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '$user->uid' AND n.nid <= '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15");
$output .= "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width=\"100%\">";
while ($blog = db_fetch_object($result)) {
@ -242,13 +258,13 @@ function blog_edit_history($nid) {
}
function blog_page() {
global $theme, $op, $name, $date;
global $theme, $id, $op, $date;
if (user_access("access blogs")) {
switch ($op) {
case "feed":
if ($name) {
blog_feed_user($name, $date);
if ($id) {
blog_feed_user($id, $date);
}
else {
blog_feed_last();
@ -256,8 +272,8 @@ function blog_page() {
break;
default:
$theme->header();
if ($name) {
blog_page_user($name, $date);
if ($id) {
blog_page_user($id, $date);
}
else {
blog_page_last();
@ -280,7 +296,7 @@ function blog_user() {
switch ($op) {
case "delete":
blog_remove($id);
blog_page_user($user->name, time());
blog_page_user($user->uid, time());
break;
case "edit":
$theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main");
@ -291,7 +307,7 @@ function blog_user() {
break;
case t("Submit"):
blog_save($edit);
blog_page_user($user->name, time());
blog_page_user($user->uid, time());
break;
default:
$theme->box(t("Submit a blog"), blog_form($edit), "main");
@ -309,11 +325,11 @@ function blog_link($type, $node = 0) {
if ($type == "menu" && user_access("post blogs")) {
$links[] = "<a href=\"submit.php?mod=blog\">". t("add blog entry") ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($user->name) ."\">". t("view your blog") ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>";
}
if ($type == "node" && $node->type == "blog") {
$links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>";
}
return $links ? $links : array();
@ -321,11 +337,12 @@ function blog_link($type, $node = 0) {
function blog_block() {
global $name, $date, $user, $mod;
global $user;
$result = db_query("SELECT u.uid, u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN user u ON n.author = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
$result = db_query("SELECT u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
while ($node = db_fetch_object($result)) {
$output .= "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". check_output($node->title) ."</a><br />\n";
$output .= "<a href=\"module.php?mod=blog&op=view&id=$node->nid\">". check_output($node->title) ."</a><br />\n";
}
$block[0]["subject"] = "<a href=\"module.php?mod=blog\">". t("User blogs") ."</a>";
@ -333,23 +350,13 @@ function blog_block() {
$block[0]["info"] = t("User blogs");
$block[0]["link"] = "module.php?mod=blog";
$date = $date ? $date : time();
$name = $name ? $name : $user->name;
if (($mod == "blog") || ($mod == "block")) {
// Only show this block on "blog pages" and in the admin block section.
$calendar = new BlogCalendar($name, $date);
$block[1]["subject"] = "<a href=\"module.php?mod=blog&name=". urlencode($name) ."\">" . t("Browse blog") . "</a>";
$block[1]["content"] = $calendar->display();
$block[1]["info"] = t("Calendar to browse blogs");
}
return $block;
}
function blog_search($keys) {
global $status, $user;
global $status;
$result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($blog = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($blog->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);

View File

@ -61,7 +61,7 @@ function book_view($node, $main = 0) {
$output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD></TR>";
$output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
}
if ($node->body) {
@ -83,7 +83,7 @@ function book_view($node, $main = 0) {
function book_search($keys) {
global $status;
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN user u ON n.author = u.uid WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
while ($node = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp);
}
@ -128,7 +128,7 @@ function book_form($edit = array()) {
$form .= book_view(new Book(node_preview($edit)));
}
$form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name)));
$form .= form_item(t("Author"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden(name, $edit[name]);
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
@ -168,7 +168,7 @@ function book_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight));
node_save($edit, array(author => $user->uid, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight));
}
else if (user_access("administer nodes")) {
node_save($edit, array(body, log, parent, title, type => "book", weight));

View File

@ -61,7 +61,7 @@ function book_view($node, $main = 0) {
$output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD></TR>";
$output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
}
if ($node->body) {
@ -83,7 +83,7 @@ function book_view($node, $main = 0) {
function book_search($keys) {
global $status;
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN user u ON n.author = u.uid WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
while ($node = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp);
}
@ -128,7 +128,7 @@ function book_form($edit = array()) {
$form .= book_view(new Book(node_preview($edit)));
}
$form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name)));
$form .= form_item(t("Author"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden(name, $edit[name]);
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
@ -168,7 +168,7 @@ function book_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight));
node_save($edit, array(author => $user->uid, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight));
}
else if (user_access("administer nodes")) {
node_save($edit, array(body, log, parent, title, type => "book", weight));

View File

@ -18,7 +18,7 @@ function box_help() {
</PRE>
<P>If we are however dealing with a registered user, we can customize the message by using:</P>
<PRE>
if ($user->id) {
if ($user->uid) {
return "Welcome $user->name, ... welcome message goes here ...";
}
else {
@ -44,7 +44,6 @@ function box_block() {
$blocks[$i]["subject"] = check_output($block->title);
$blocks[$i]["content"] = ($block->type == 2) ? eval($block->body) : $block->body;
$blocks[$i]["info"] = check_output($block->info);
$blocks[$i]["link"] = check_output($block->link);
$i++;
}
return $blocks;
@ -65,7 +64,6 @@ function box_display() {
$output .= " <TR><TH>Body:</TH><TD>". nl2br(htmlentities($block->body)) ."</TD></TR>\n";
$output .= " <TR><TH>Type:</TH><TD>". $type[$block->type] ."</TD></TR>\n";
$output .= " <TR><TH>Description:</TH><TD>". check_output($block->info) ."</TD></TR>\n";
$output .= " <TR><TH>Link:</TH><TD>". format_url($block->link) ."</TD></TR>\n";
$output .= " <TR><TH>Operations:</TH><TD><A HREF=\"admin.php?mod=box&op=edit&id=$block->bid\">edit</A></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<BR><BR>\n";
@ -76,13 +74,13 @@ function box_display() {
function box_save($edit) {
if ($edit[bid] && $edit[title]) {
db_query("UPDATE boxes SET title = '". check_input($edit[title]) ."', body = '". check_input($edit[body]) ."', info = '". check_input($edit[info]) ."', link = '". check_input($edit[link]) ."', type = '". check_input($edit[type]) ."' WHERE bid = '". check_input($edit[bid]) ."'");
db_query("UPDATE boxes SET title = '". check_input($edit[title]) ."', body = '". check_input($edit[body]) ."', info = '". check_input($edit[info]) ."', type = '". check_input($edit[type]) ."' WHERE bid = '". check_input($edit[bid]) ."'");
}
else if ($edit[bid]) {
db_query("DELETE FROM boxes WHERE bid = '". check_input($edit[bid]) ."'");
}
else {
db_query("INSERT INTO boxes (title, body, info, link, type) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[body]) ."', '". check_input($edit[info]) ."', '". check_input($link) ."', '". check_input($edit[type]) ."')");
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[body]) ."', '". check_input($edit[info]) ."', '". check_input($edit[type]) ."')");
}
}
@ -95,7 +93,6 @@ function box_form($edit = array()) {
$form .= form_textfield("Description", "info", $edit[info], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 70, 10);
$form .= form_select("Type", "type", $edit[type], $type);
$form .= form_textfield("Link", "link", $edit[link], 50, 64);
if ($edit[bid]) {
$form .= form_submit("Delete");

View File

@ -1,8 +1,7 @@
<?php
function comment_search($keys) {
global $user;
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
while ($comment = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
}
@ -24,10 +23,10 @@ function comment_link($type) {
function comment_edit($id) {
global $REQUEST_URI;
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'");
$result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$id'");
$comment = db_fetch_object($result);
$form .= form_item(t("Author"), format_name($comment->name));
$form .= form_item(t("Author"), format_name($comment));
$form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128);
$form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
$form .= form_submit(t("Submit"));
@ -41,12 +40,12 @@ function comment_save($id, $edit) {
}
function comment_overview() {
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50");
$result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON u.uid = c.author ORDER BY timestamp DESC LIMIT 50");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>subject</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($comment = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n";
$output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n";
}
$output .= "</TABLE>\n";

View File

@ -1,8 +1,7 @@
<?php
function comment_search($keys) {
global $user;
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
while ($comment = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
}
@ -24,10 +23,10 @@ function comment_link($type) {
function comment_edit($id) {
global $REQUEST_URI;
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'");
$result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$id'");
$comment = db_fetch_object($result);
$form .= form_item(t("Author"), format_name($comment->name));
$form .= form_item(t("Author"), format_name($comment));
$form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128);
$form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
$form .= form_submit(t("Submit"));
@ -41,12 +40,12 @@ function comment_save($id, $edit) {
}
function comment_overview() {
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50");
$result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON u.uid = c.author ORDER BY timestamp DESC LIMIT 50");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>subject</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($comment = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n";
$output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n";
}
$output .= "</TABLE>\n";

View File

@ -4,7 +4,6 @@ function forum_status() {
return array(dumped, posted);
}
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>";
@ -33,7 +32,7 @@ function forum_form($edit = array()) {
function forum_save($edit) {
global $user, $status;
node_save($edit, array(author => $user->id, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
node_save($edit, array(author => $user->uid, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
}
function forum_num_comments($nid) {

View File

@ -4,7 +4,6 @@ function forum_status() {
return array(dumped, posted);
}
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>";
@ -33,7 +32,7 @@ function forum_form($edit = array()) {
function forum_save($edit) {
global $user, $status;
node_save($edit, array(author => $user->id, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
node_save($edit, array(author => $user->uid, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
}
function forum_num_comments($nid) {

View File

@ -11,7 +11,7 @@ function help_link($type) {
function help_admin() {
foreach (module_list() as $name) {
if (module_hook($name, "help")) {
print "<H2>". ucfirst($name) ." module</H2>";
print "<h2>". ucfirst($name) ." module</h2>";
print module_invoke($name, "help");
}
}

View File

@ -11,7 +11,7 @@ function help_link($type) {
function help_admin() {
foreach (module_list() as $name) {
if (module_hook($name, "help")) {
print "<H2>". ucfirst($name) ." module</H2>";
print "<h2>". ucfirst($name) ." module</h2>";
print module_invoke($name, "help");
}
}

View File

@ -50,7 +50,7 @@ function import_update() {
function import_format_item($item, $feed = 0) {
global $theme, $user;
if ($user->id && user_access("post blogs")) {
if ($user->uid && user_access("post blogs")) {
$output .= "<a href=\"submit.php?mod=blog&type=import&id=$item->iid\"><img src=\"". $theme->image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /></a> ";
}
@ -602,7 +602,7 @@ function import_page_sources() {
while ($feed = db_fetch_object($result)) {
$output .= format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title);
$output .= "<p><div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div></p>";
$output .= "<div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div><br />";
}
$output .= "<a href=\"module.php?mod=import&op=fd\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a><br />\n";

View File

@ -108,7 +108,7 @@ function node_overview($query) {
$color = array("#ffffff", "#e5e5e5");
$query = node_query($query ? $query : 0);
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50");
$result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN user u ON n.author = u.uid $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
@ -117,7 +117,7 @@ function node_overview($query) {
while ($node = db_fetch_object($result)) {
$bg = $color[$i++ % sizeof($color)];
$output .= " <tr bgcolor=\"$bg\"><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">$node->type</td><td>". node_status($node->status) ."</td><td>". check_output($node->attributes) ."</td><td>". format_name($node->name) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
$output .= " <tr bgcolor=\"$bg\"><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">$node->type</td><td>". node_status($node->status) ."</td><td>". check_output($node->attributes) ."</td><td>". format_name($node) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
$output .= " <tr bgcolor=\"$bg\"><td align=\"right\" colspan=\"6\"><small>". implode(", ", node_links($node->nid, $node->type)) ."</small></td>\n";
}
$output .= "</table>\n";
@ -126,7 +126,6 @@ function node_overview($query) {
}
function node_edit_option($id) {
global $user;
$node = node_get_object(array("nid" => $id));
@ -141,7 +140,6 @@ function node_edit_option($id) {
}
function node_edit_attribute($id) {
global $user;
$node = node_get_object(array("nid" => $id));

View File

@ -108,7 +108,7 @@ function node_overview($query) {
$color = array("#ffffff", "#e5e5e5");
$query = node_query($query ? $query : 0);
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50");
$result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN user u ON n.author = u.uid $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
@ -117,7 +117,7 @@ function node_overview($query) {
while ($node = db_fetch_object($result)) {
$bg = $color[$i++ % sizeof($color)];
$output .= " <tr bgcolor=\"$bg\"><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">$node->type</td><td>". node_status($node->status) ."</td><td>". check_output($node->attributes) ."</td><td>". format_name($node->name) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
$output .= " <tr bgcolor=\"$bg\"><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">$node->type</td><td>". node_status($node->status) ."</td><td>". check_output($node->attributes) ."</td><td>". format_name($node) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
$output .= " <tr bgcolor=\"$bg\"><td align=\"right\" colspan=\"6\"><small>". implode(", ", node_links($node->nid, $node->type)) ."</small></td>\n";
}
$output .= "</table>\n";
@ -126,7 +126,6 @@ function node_overview($query) {
}
function node_edit_option($id) {
global $user;
$node = node_get_object(array("nid" => $id));
@ -141,7 +140,6 @@ function node_edit_option($id) {
}
function node_edit_attribute($id) {
global $user;
$node = node_get_object(array("nid" => $id));

View File

@ -73,7 +73,7 @@ function page_form($edit = array()) {
function page_save($edit) {
global $status, $user;
node_save($edit, array(author => $user->id, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
node_save($edit, array(author => $user->uid, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
}
?>

View File

@ -73,7 +73,7 @@ function page_form($edit = array()) {
function page_save($edit) {
global $status, $user;
node_save($edit, array(author => $user->id, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
node_save($edit, array(author => $user->uid, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
}
?>

View File

@ -186,7 +186,7 @@ function poll_form($edit = array(), $nocheck = 0) {
$form .= form_submit(t("Preview")) . "<br><br><br>";
/* Main form */
$form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name)));
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden("name", $edit[name]);
$form .= form_textfield(t("Question"), "title", $edit[title], 50, 127);

View File

@ -186,7 +186,7 @@ function poll_form($edit = array(), $nocheck = 0) {
$form .= form_submit(t("Preview")) . "<br><br><br>";
/* Main form */
$form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name)));
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden("name", $edit[name]);
$form .= form_textfield(t("Question"), "title", $edit[title], 50, 127);

View File

@ -38,10 +38,10 @@ function queue_vote($id, $vote) {
if ($node = node_get_object(array(nid => $id))) {
if (!field_get($node->users, $user->id)) {
if (!field_get($node->users, $user->uid)) {
// Update submission's score- and votes-field:
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->id, $vote) ."' WHERE nid = $id");
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = $id");
$node = node_get_object(array(nid => $id, type => $node->type));
@ -64,13 +64,13 @@ function queue_vote($id, $vote) {
function queue_overview() {
global $status, $theme, $user;
$result = db_query("SELECT n.*, u.name, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'");
$result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN user u ON n.author = u.uid WHERE n.status = '$status[queued]'");
$content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$content .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
while ($node = db_fetch_object($result)) {
if ($user->id == $node->author || field_get($node->users, $user->id)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node->name) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n";
else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node->name) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n";
if ($user->uid == $node->author || field_get($node->users, $user->uid)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n";
else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n";
}
$content .= "</TABLE>\n";
@ -85,7 +85,7 @@ function queue_node($id) {
$node = node_get_object(array(nid => $id));
if ($user->id == $node->author || field_get($node->users, $user->id)) {
if ($user->uid == $node->author || field_get($node->users, $user->uid)) {
header("Location: node.php?id=$node->nid");
}
else {
@ -118,7 +118,7 @@ function queue_node($id) {
function queue_page() {
global $user, $id, $op, $theme, $vote;
if ($user->id && user_access("access submission queue")) {
if ($user->uid && user_access("access submission queue")) {
switch($op) {
case "Vote";
queue_vote(check_input($id), check_input($vote));

View File

@ -29,17 +29,17 @@ function rating_cron() {
if (time() - variable_get("rating_cron_last", 0) > variable_get("rating_cron_time", time())) {
variable_set("rating_cron_last", time());
$r1 = db_query("SELECT id FROM users ORDER BY rating DESC");
$r1 = db_query("SELECT uid FROM user ORDER BY rating DESC");
while ($account = db_fetch_object($r1)) {
db_query("UPDATE users SET rating = '". rating_gravity($account->id) ."' WHERE id = '$account->id'");
$rating[$account->id] = ++$i;
db_query("UPDATE user SET rating = '". rating_gravity($account->uid) ."' WHERE id = '$account->uid'");
$rating[$account->uid] = ++$i;
}
db_query("DELETE FROM rating");
$r2 = db_query("SELECT id FROM users ORDER BY rating DESC");
$r2 = db_query("SELECT uid FROM user ORDER BY rating DESC");
while ($account = db_fetch_object($r2)) {
db_query("INSERT INTO rating (user, new, old) VALUES ('$account->id', '". ++$j ."', '". $rating[$account->id] ."')");
db_query("INSERT INTO rating (user, new, old) VALUES ('$account->uid', '". ++$j ."', '". $rating[$account->uid] ."')");
}
}
}
@ -79,12 +79,12 @@ function rating_gravity($id) {
}
function rating_list($limit) {
$result = db_query("SELECT u.rating, u.name, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit");
$result = db_query("SELECT u.rating, u.name, u.uid, r.* FROM user u LEFT JOIN rating r ON u.uid = r.user ORDER BY u.rating DESC LIMIT $limit");
$output .= "<TABLE CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
while ($account = db_fetch_object($result)) {
$ranking = $account->old - $account->new;
$output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_name($account->name) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>";
$output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_name($account) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>";
}
$output .= "</TABLE>\n";
return $output;

View File

@ -13,7 +13,7 @@ function story_status() {
}
function story_search($keys) {
global $status, $user;
global $status;
$result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($story = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
@ -46,7 +46,7 @@ function story_form($edit = array()) {
story_view(new Story(node_preview($edit)));
}
$form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name)));
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden("name", $edit[name]);
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
$form .= node_attributes_edit("story", $edit);
@ -80,7 +80,7 @@ function story_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->id, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0));
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->uid, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0));
}
else if (user_access("administer nodes")) {
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story"));
@ -88,7 +88,7 @@ function story_save($edit) {
}
function story_user() {
global $edit, $op, $theme, $user;
global $edit, $op, $theme;
switch($op) {
case t("Preview"):

View File

@ -13,7 +13,7 @@ function story_status() {
}
function story_search($keys) {
global $status, $user;
global $status;
$result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($story = db_fetch_object($result)) {
$find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
@ -46,7 +46,7 @@ function story_form($edit = array()) {
story_view(new Story(node_preview($edit)));
}
$form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name)));
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden("name", $edit[name]);
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
$form .= node_attributes_edit("story", $edit);
@ -80,7 +80,7 @@ function story_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->id, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0));
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->uid, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0));
}
else if (user_access("administer nodes")) {
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story"));
@ -88,7 +88,7 @@ function story_save($edit) {
}
function story_user() {
global $edit, $op, $theme, $user;
global $edit, $op, $theme;
switch($op) {
case t("Preview"):

View File

@ -864,7 +864,7 @@ function user_admin_create($edit = array()) {
function user_admin_access($edit = array()) {
global $op, $id, $type, $REQUEST_URI;
$output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a>, <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />";
$output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a> :: <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />";
if ($type != "user") {
$output .= "<h3>E-mail rules</h3>";

View File

@ -864,7 +864,7 @@ function user_admin_create($edit = array()) {
function user_admin_access($edit = array()) {
global $op, $id, $type, $REQUEST_URI;
$output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a>, <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />";
$output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a> :: <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />";
if ($type != "user") {
$output .= "<h3>E-mail rules</h3>";

View File

@ -30,16 +30,16 @@ function watchdog_cron() {
}
function watchdog_overview($type) {
$color = array(account => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C");
$query = array(account => "WHERE type = 'account'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'");
$color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C");
$query = array(user => "WHERE type = 'user'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'");
$result = db_query("SELECT w.*, u.name FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000");
$result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN user u ON w.user = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>date</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
while ($watchdog = db_fetch_object($result)) {
if ($background = $color[$watchdog->type]) {
$output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_name($watchdog->name) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
$output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_name($watchdog) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
}
}
$output .= "</TABLE>\n";
@ -48,13 +48,13 @@ function watchdog_overview($type) {
}
function watchdog_view($id) {
$result = db_query("SELECT l.*, u.name FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'");
$result = db_query("SELECT l.*, u.name, u.uid FROM watchdog l LEFT JOIN user u ON l.user = u.uid WHERE l.id = '$id'");
if ($watchdog = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n";
$output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n";
$output .= " <TR><TH>User:</TH><TD>". format_name($watchdog->name) ."</TD></TR>\n";
$output .= " <TR><TH>User:</TH><TD>". format_name($watchdog) ."</TD></TR>\n";
$output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n";
$output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n";
$output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n";
@ -69,7 +69,7 @@ function watchdog_admin() {
if (user_access("administer watchdog")) {
print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=user\">user messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
switch ($op) {
case "help":

View File

@ -30,16 +30,16 @@ function watchdog_cron() {
}
function watchdog_overview($type) {
$color = array(account => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C");
$query = array(account => "WHERE type = 'account'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'");
$color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C");
$query = array(user => "WHERE type = 'user'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'");
$result = db_query("SELECT w.*, u.name FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000");
$result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN user u ON w.user = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>date</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
while ($watchdog = db_fetch_object($result)) {
if ($background = $color[$watchdog->type]) {
$output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_name($watchdog->name) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
$output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_name($watchdog) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
}
}
$output .= "</TABLE>\n";
@ -48,13 +48,13 @@ function watchdog_overview($type) {
}
function watchdog_view($id) {
$result = db_query("SELECT l.*, u.name FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'");
$result = db_query("SELECT l.*, u.name, u.uid FROM watchdog l LEFT JOIN user u ON l.user = u.uid WHERE l.id = '$id'");
if ($watchdog = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n";
$output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n";
$output .= " <TR><TH>User:</TH><TD>". format_name($watchdog->name) ."</TD></TR>\n";
$output .= " <TR><TH>User:</TH><TD>". format_name($watchdog) ."</TD></TR>\n";
$output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n";
$output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n";
$output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n";
@ -69,7 +69,7 @@ function watchdog_admin() {
if (user_access("administer watchdog")) {
print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=user\">user messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
switch ($op) {
case "help":

View File

@ -77,7 +77,7 @@ function node_failure() {
function node_history($node) {
global $status;
if ($node->status == $status[expired] || $node->status == $status[posted]) {
$output .= "<dt><b>". format_date($node->timestamp) ." by ". format_name($node->name) .":</b></dt><dd>". check_output($node->log, 1) ."<p /></dd>";
$output .= "<dt><b>". format_date($node->timestamp) ." by ". format_name($node) .":</b></dt><dd>". check_output($node->log, 1) ."<p /></dd>";
}
if ($node->pid) {
$output .= node_history(node_get_object(array("nid" => $node->pid)));
@ -88,11 +88,11 @@ function node_history($node) {
$number = ($title ? db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title' AND status = $status[posted]")) : 1);
if ($number > 1) {
$result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = '$title'");
$result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN user u ON n.author = u.uid WHERE n.title = '$title'");
while ($node = db_fetch_object($result)) {
if (node_access($node)) {
$output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_name($node->name) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>";
$output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_name($node) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>";
}
}
@ -110,7 +110,6 @@ elseif ($number) {
$theme->footer();
break;
default:
user_rehash();
node_render($node);
}
}

View File

@ -20,7 +20,7 @@ if (user_access("post content")) {
$output .= form("submit.php", $form, "get");
$theme->box("Submit", $output);
$theme->box(t("Submit"), $output);
}
}
else {

View File

@ -63,7 +63,7 @@
<TD>
<?php
echo strtr(t("by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "small")));
echo strtr(t("by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "small")));
?>
</TD>
@ -120,7 +120,7 @@
echo t("Author") .":";
echo " </TD>";
echo " <TD COLSPAN=\"2\">";
echo format_name($comment->name) ." on ". format_date($comment->timestamp);
echo format_name($comment) ." on ". format_date($comment->timestamp);
echo " </TD>";
echo " </TR>";

View File

@ -65,7 +65,7 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
<body>
<table border="0" cellspacing="3" cellpadding="0" width="100%">
<tr>
<td colspan="2" width="100%"><img src="themes/goofy/images/logo.png" alt=""><br>
<td colspan="2" width="100%"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="left"><img src="themes/goofy/images/logo.png" alt=""></td><td align="right"><img src="themes/goofy/images/drupal.png" alt="Powered by Drupal"></td></tr></table>
<?php $this->linksbar(); ?>
</td>
</tr>
@ -102,7 +102,7 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
function node($node, $main = 0) {
echo "\n<!-- node: \"$node->title\" -->\n";
$title = check_output($node->title);
$subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "large")));
$subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "large")));
$subright = node_index($node);
$body = check_output($node->body, 1) . ($main ? "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links(link_node($node)) . " ]</div>" : "");
print "<script language=\"JavaScript\"><!--\ns(\"". $this->stripbreaks(addslashes($title)) ."\",\"". $this->stripbreaks(addslashes($subleft)) ."\",\"". $this->stripbreaks(addslashes($subright)) ."\",\"". $this->stripbreaks(addslashes($body)) ."\"); // -->\n</script>\n";
@ -112,7 +112,7 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
function comment($comment, $link = "") {
echo "<A NAME=\"$comment->cid\"></A>\n";
$author = "<b>" . format_name($comment->name) . "</b>";
$author = "<b>" . format_name($comment) . "</b>";
if ($comment->name) {
if ($comment->fake_email) $info[] = format_email($comment->fake_email);
if (eregi("http://",$comment->url)) $info[] = format_url($comment->url);

View File

@ -117,7 +117,7 @@
case 12: $how = "Forged"; break;
default: $how = "Sneaked through";
}
echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp), "large")) ."</FONT>";
echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp), "large")) ."</FONT>";
?>
</FONT>
</td>
@ -192,7 +192,7 @@
// Author:
echo " <tr>";
echo " <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_name($comment->name) ."</B> ";
echo " <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_name($comment) ."</B> ";
if ($comment->name) {
// Display extra information line:
if ($comment->fake_email) $info .= format_email($comment->fake_email);

View File

@ -56,7 +56,7 @@
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
print " <tr><td colspan=\"2\"><img src=\"themes/marvin/images/drop.gif\" alt=\"\" /> &nbsp; <b>". check_output($node->title) ."</b></td></tr>\n";
print " <tr valign=\"bottom\"><td colspan=\"2\" bgcolor=\"#000000\" width=\"100%\"><img src=\"themes/marvin/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>\n";
print " <tr><td nowrap=\"nowrap\"><font color=\"#7C7C7C\"><small>". strtr(t("Submitted by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "large"))); ?><?php print "</small></font></td><td align=\"right\" valign=\"top\" nowrap><small>". node_index($node) ."</small></td></tr>\n";
print " <tr><td nowrap=\"nowrap\"><font color=\"#7C7C7C\"><small>". strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "large"))); ?><?php print "</small></font></td><td align=\"right\" valign=\"top\" nowrap><small>". node_index($node) ."</small></td></tr>\n";
print " <tr><td colspan=\"2\">&nbsp;</td></tr>\n";
print " <tr><td colspan=\"2\"><p>". check_output($node->body, 1) ."</p></td></tr>\n";
print " <tr><td colspan=\"2\">&nbsp;</tr></tr>\n";
@ -90,7 +90,7 @@
// Author:
print " <tr>\n";
print " <td align=\"right\" valign=\"top\">". t("Author") .":</td><td>". format_name($comment->name) ."</td>\n";
print " <td align=\"right\" valign=\"top\">". t("Author") .":</td><td>". format_name($comment) ."</td>\n";
print " </tr>\n";
// Date

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -60,7 +60,9 @@
<TD BGCOLOR="<?php print $this->cl80; ?>">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="9" BGCOLOR="<?php print $this->cl80; ?>">
<TR>
<TD COLSPAN="2"><IMG SRC="themes/<?php print $this->themename; ?>/images/logo.gif" ALT="logo"></TD>
<TD COLSPAN="2">
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><IMG SRC="themes/<?php print $this->themename; ?>/images/logo.gif" ALT="logo"></TD></TR></TABLE></TD></TR></TABLE>
</TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="CENTER">
@ -90,7 +92,7 @@
<TR><TD COLSPAN="2" BGCOLOR="<?php echo $this->bgcolor1; ?>" WIDTH="100%"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><FONT COLOR="<?php echo $this->fgcolor1; ?>"><B><?php echo "". check_output($node->title) .""; ?></B></FONT></td><td valign="middle" align="center"><IMG SRC="themes/<?php print $this->themename; ?>/images/icon.gif" valign="middle"></td></tr></table></TD></TR>
<TR BGCOLOR="<?php echo $this->bgcolor2; ?>">
<?php
print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\"><SMALL>" . strtr(t("Submitted by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "large"))) . "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\" NOWRAP><B>". node_index($node) ."</B>";
print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\"><SMALL>" . strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "large"))) . "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\" NOWRAP><B>". node_index($node) ."</B>";
?>
</TD>
</TR>
@ -139,7 +141,7 @@
// Author:
echo " <TR>";
echo " <TD ALIGN=\"right\" VALIGN=\"top\">" . t("Author") . ":</TD><TD><B>" . format_name($comment->name) . "</B> ";
echo " <TD ALIGN=\"right\" VALIGN=\"top\">" . t("Author") . ":</TD><TD><B>" . format_name($node) . "</B> ";
if ($comment->name) {
// Display extra information line:
if ($comment->fake_email) $info .= format_email($comment->fake_email);

View File

@ -134,7 +134,7 @@
<tr>
<td>
<img src="themes/yaroon/images/<?php echo $img; ?>" border="0" />&nbsp;<b style="font-size: 12pt"><?php echo check_output($node->title); ?></b>
<?php echo strtr(t("by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp), "small")); ?>
<?php echo strtr(t("by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp), "small")); ?>
</td>
</tr>
<tr><td bgcolor="<?php echo $color; ?>"><img src="themes/yaroon/images/pixel.gif" width="1" height="1" alt="" border="0" /></td></tr>
@ -172,7 +172,7 @@
<tr>
<td valign="bottom" class="box">
<img src="themes/yaroon/images/square.gif" />&nbsp;<b><?php echo check_output($comment->subject); ?></b>
<font size="-1"><?php echo strtr(t(" by %a on %b"), array("%a" => format_name($comment->name), "%b" => format_date($comment->timestamp), "small")); ?></font>
<font size="-1"><?php echo strtr(t(" by %a on %b"), array("%a" => format_name($comment), "%b" => format_date($comment->timestamp), "small")); ?></font>
</td>
<td align="right"><?php echo comment_moderation($comment); ?></td>
</tr>

View File

@ -21,3 +21,14 @@ UPDATE user SET status = 1 WHERE status = 2;
UPDATE user SET name = userid;
ALTER TABLE user DROP userid;
UPDATE user SET init = mail;
DROP TABLE access;
CREATE TABLE access (
aid tinyint(10) DEFAULT '0' NOT NULL auto_increment,
mask varchar(255) DEFAULT '' NOT NULL,
type varchar(255) DEFAULT '' NOT NULL,
status tinyint(2) DEFAULT '0' NOT NULL,
UNIQUE mask (mask),
PRIMARY KEY (aid)
);