Commit 808b6b6c authored by Dries's avatar Dries

- Changed the authentication and login scheme as discussed on the mailing
  list.
- Fixed the export function in book.module (patch my Julian).
- Fixed the comment alignment (comments got truncated).
parent 876536a9
This diff is collapsed.
# MySQL dump 7.1
#
# Host: localhost Database: drop
#--------------------------------------------------------
# Server version 3.22.32
#
# Table structure for table 'access'
#
CREATE TABLE access (
id tinyint(10) DEFAULT '0' NOT NULL auto_increment,
mask varchar(255) DEFAULT '' NOT NULL,
......@@ -7,6 +16,9 @@ CREATE TABLE access (
PRIMARY KEY (id)
);
#
# Table structure for table 'blocks'
#
CREATE TABLE blocks (
name varchar(64) DEFAULT '' NOT NULL,
module varchar(64) DEFAULT '' NOT NULL,
......@@ -18,6 +30,9 @@ CREATE TABLE blocks (
PRIMARY KEY (name)
);
#
# Table structure for table 'blog'
#
CREATE TABLE blog (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -25,6 +40,9 @@ CREATE TABLE blog (
PRIMARY KEY (lid)
);
#
# Table structure for table 'book'
#
CREATE TABLE book (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -37,6 +55,9 @@ CREATE TABLE book (
PRIMARY KEY (lid)
);
#
# Table structure for table 'boxes'
#
CREATE TABLE boxes (
bid tinyint(4) DEFAULT '0' NOT NULL auto_increment,
title varchar(64) DEFAULT '' NOT NULL,
......@@ -49,6 +70,9 @@ CREATE TABLE boxes (
PRIMARY KEY (bid)
);
#
# Table structure for table 'bundle'
#
CREATE TABLE bundle (
bid int(11) DEFAULT '0' NOT NULL auto_increment,
title varchar(255) DEFAULT '' NOT NULL,
......@@ -57,6 +81,9 @@ CREATE TABLE bundle (
PRIMARY KEY (bid)
);
#
# Table structure for table 'cache'
#
CREATE TABLE cache (
url varchar(255) DEFAULT '' NOT NULL,
data text NOT NULL,
......@@ -64,6 +91,9 @@ CREATE TABLE cache (
PRIMARY KEY (url)
);
#
# Table structure for table 'category'
#
CREATE TABLE category (
cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL,
......@@ -78,6 +108,9 @@ CREATE TABLE category (
PRIMARY KEY (cid)
);
#
# Table structure for table 'channel'
#
CREATE TABLE channel (
id int(11) DEFAULT '0' NOT NULL auto_increment,
site varchar(255) DEFAULT '' NOT NULL,
......@@ -91,6 +124,9 @@ CREATE TABLE channel (
PRIMARY KEY (id)
);
#
# Table structure for table 'chatevents'
#
CREATE TABLE chatevents (
id int(11) DEFAULT '0' NOT NULL auto_increment,
body varchar(255) DEFAULT '' NOT NULL,
......@@ -98,6 +134,9 @@ CREATE TABLE chatevents (
PRIMARY KEY (id)
);
#
# Table structure for table 'chatmembers'
#
CREATE TABLE chatmembers (
id int(11) DEFAULT '0' NOT NULL auto_increment,
nick varchar(32) DEFAULT '' NOT NULL,
......@@ -105,6 +144,9 @@ CREATE TABLE chatmembers (
PRIMARY KEY (id)
);
#
# Table structure for table 'collection'
#
CREATE TABLE collection (
cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL,
......@@ -113,6 +155,9 @@ CREATE TABLE collection (
PRIMARY KEY (cid)
);
#
# Table structure for table 'comments'
#
CREATE TABLE comments (
cid int(6) DEFAULT '0' NOT NULL auto_increment,
pid int(6) DEFAULT '0' NOT NULL,
......@@ -130,6 +175,9 @@ CREATE TABLE comments (
KEY lid (lid)
);
#
# Table structure for table 'cvs'
#
CREATE TABLE cvs (
user varchar(32) DEFAULT '' NOT NULL,
files text,
......@@ -138,6 +186,9 @@ CREATE TABLE cvs (
timestamp int(11) DEFAULT '0' NOT NULL
);
#
# Table structure for table 'diaries'
#
CREATE TABLE diaries (
id int(5) DEFAULT '0' NOT NULL auto_increment,
author int(6) DEFAULT '0' NOT NULL,
......@@ -146,6 +197,9 @@ CREATE TABLE diaries (
PRIMARY KEY (id)
);
#
# Table structure for table 'diary'
#
CREATE TABLE diary (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -153,6 +207,9 @@ CREATE TABLE diary (
PRIMARY KEY (lid)
);
#
# Table structure for table 'entry'
#
CREATE TABLE entry (
eid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL,
......@@ -162,6 +219,9 @@ CREATE TABLE entry (
PRIMARY KEY (eid)
);
#
# Table structure for table 'feed'
#
CREATE TABLE feed (
fid int(11) DEFAULT '0' NOT NULL auto_increment,
title varchar(255) DEFAULT '' NOT NULL,
......@@ -177,6 +237,9 @@ CREATE TABLE feed (
PRIMARY KEY (fid)
);
#
# Table structure for table 'file'
#
CREATE TABLE file (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -189,6 +252,9 @@ CREATE TABLE file (
PRIMARY KEY (lid)
);
#
# Table structure for table 'forum'
#
CREATE TABLE forum (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -196,6 +262,9 @@ CREATE TABLE forum (
PRIMARY KEY (lid)
);
#
# Table structure for table 'item'
#
CREATE TABLE item (
iid int(11) DEFAULT '0' NOT NULL auto_increment,
fid int(11) DEFAULT '0' NOT NULL,
......@@ -208,11 +277,17 @@ CREATE TABLE item (
PRIMARY KEY (iid)
);
#
# Table structure for table 'layout'
#
CREATE TABLE layout (
user int(11) DEFAULT '0' NOT NULL,
block varchar(64) DEFAULT '' NOT NULL
);
#
# Table structure for table 'locales'
#
CREATE TABLE locales (
id int(11) DEFAULT '0' NOT NULL auto_increment,
location varchar(128) DEFAULT '' NOT NULL,
......@@ -228,11 +303,17 @@ CREATE TABLE locales (
PRIMARY KEY (id)
);
#
# Table structure for table 'modules'
#
CREATE TABLE modules (
name varchar(64) DEFAULT '' NOT NULL,
PRIMARY KEY (name)
);
#
# Table structure for table 'node'
#
CREATE TABLE node (
nid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
lid int(10) DEFAULT '0' NOT NULL,
......@@ -259,6 +340,9 @@ CREATE TABLE node (
KEY status (status)
);
#
# Table structure for table 'page'
#
CREATE TABLE page (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -268,6 +352,9 @@ CREATE TABLE page (
PRIMARY KEY (lid)
);
#
# Table structure for table 'poll'
#
CREATE TABLE poll (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -277,6 +364,9 @@ CREATE TABLE poll (
PRIMARY KEY (lid)
);
#
# Table structure for table 'poll_choices'
#
CREATE TABLE poll_choices (
chid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -286,6 +376,9 @@ CREATE TABLE poll_choices (
PRIMARY KEY (chid)
);
#
# Table structure for table 'rating'
#
CREATE TABLE rating (
user int(6) DEFAULT '0' NOT NULL,
new int(6) DEFAULT '0' NOT NULL,
......@@ -293,11 +386,17 @@ CREATE TABLE rating (
PRIMARY KEY (user)
);
#
# Table structure for table 'referer'
#
CREATE TABLE referer (
url varchar(255) DEFAULT '' NOT NULL,
timestamp int(11) DEFAULT '0' NOT NULL
);
#
# Table structure for table 'role'
#
CREATE TABLE role (
rid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL,
......@@ -306,17 +405,24 @@ CREATE TABLE role (
PRIMARY KEY (rid)
);
#
# Table structure for table 'site'
#
CREATE TABLE site (
sid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
title varchar(128) DEFAULT '' NOT NULL,
url varchar(255) DEFAULT '' NOT NULL,
name varchar(128) DEFAULT '' NOT NULL,
link varchar(255) DEFAULT '' NOT NULL,
size text NOT NULL,
timestamp int(11) DEFAULT '0' NOT NULL,
UNIQUE title (title),
UNIQUE url (url),
feed varchar(255) DEFAULT '' NOT NULL,
UNIQUE title (name),
UNIQUE url (link),
PRIMARY KEY (sid)
);
#
# Table structure for table 'story'
#
CREATE TABLE story (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
nid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -325,6 +431,9 @@ CREATE TABLE story (
PRIMARY KEY (lid)
);
#
# Table structure for table 'tag'
#
CREATE TABLE tag (
tid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL,
......@@ -334,6 +443,9 @@ CREATE TABLE tag (
PRIMARY KEY (tid)
);
#
# Table structure for table 'topic'
#
CREATE TABLE topic (
tid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
pid int(10) unsigned DEFAULT '0' NOT NULL,
......@@ -343,6 +455,9 @@ CREATE TABLE topic (
PRIMARY KEY (tid)
);
#
# Table structure for table 'users'
#
CREATE TABLE users (
id int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(60) DEFAULT '' NOT NULL,
......@@ -366,15 +481,24 @@ CREATE TABLE users (
rating decimal(8,2),
language char(2) DEFAULT '' NOT NULL,
role varchar(32) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
PRIMARY KEY (id),
UNIQUE name (name),
UNIQUE userid (userid),
UNIQUE real_email (real_email)
);
#
# Table structure for table 'variable'
#
CREATE TABLE variable (
name varchar(32) DEFAULT '' NOT NULL,
value text NOT NULL,
PRIMARY KEY (name)
);
#
# Table structure for table 'watchdog'
#
CREATE TABLE watchdog (
id int(5) DEFAULT '0' NOT NULL auto_increment,
user int(6) DEFAULT '0' NOT NULL,
......
......@@ -10,8 +10,8 @@
$corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low");
class Comment {
function Comment($userid, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) {
$this->userid = $userid;
function Comment($name, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) {
$this->name = $name;
$this->subject = $subject;
$this->comment = $comment;
$this->timestamp = $timestamp;
......@@ -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->userid)) {
$result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->userid, $vote) ."' 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'");
}
}
}
......@@ -52,7 +52,7 @@ function comment_form($edit) {
global $REQUEST_URI, $user;
// name field:
$form .= form_item(t("Your name"), format_username($user->userid, $user->name));
$form .= form_item(t("Your name"), format_name($user->name));
// 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 comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = '$pid'"));
comment_view(new Comment($item->userid, $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 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"));
}
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->userid, 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->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"));
$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->userid ? 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->id', '". 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 .= " ";
}
else if ($user->id && $user->userid != $comment->userid && !field_get($comment->users, $user->userid)) {
else if ($user->id && $user->name != $comment->name && !field_get($comment->users, $user->id)) {
// 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";
......@@ -216,7 +216,7 @@ 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_username($comment->userid, $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->name) ." <SMALL>($comment->score)</SMALL><P>";
}
function comment_thread_min($cid, $threshold) {
......@@ -235,14 +235,33 @@ function comment_thread_min($cid, $threshold) {
function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
global $user;
/*
** We had quite a few browser specific issues with expanded comments below
** the top level getting truncated on the right hand side. A range of
** solutions have been suggested and tried but either the right margins of
** the comments didn't line up as well, or the heavily nested tables made
** for slow rendering and cluttered HTML. This is the best work-around in
** 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");
if ($level > 1) {
print "</td></tr></table>\n";
}
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\">&nbsp;</td><td>\n";
while ($comment = db_fetch_object($result)) {
print "<table width=100%><tr><td><ul>";
comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0));
// print "comment at level $level\n";
comment_thread_max($comment->cid, $mode, $threshold, $level + 1, $dummy + 1);
print "</ul></td></tr></table>";
}
if ($level < 2) {
print "</td></tr></table>\n";
}
}
function comment_render($lid, $cid) {
......@@ -278,7 +297,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_username($comment->userid, $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->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
}
}
print "</TABLE>\n";
......
......@@ -204,9 +204,17 @@ function format_date($timestamp, $type = "medium", $format = "") {
return $date;
}
function format_username($username, $realname="") {
if ($username) return (user_access("administer users") ? "<A HREF=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">". check_output($realname ? $realname : $username) ."</A>" : "<A HREF=\"account.php?op=view&name=". urlencode($username) ."\">". check_output($realname ? $realname : $username) ."</A>");
else return variable_get(anonymous, "Anonymous");
function format_name($username, $realname = "") {
if ($realname) {
watchdog("special", "format_name - FIX ME");
return "<font color=\"red\">FIX ME</font>\n";
}
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 {
return variable_get(anonymous, "Anonymous");
}
}
function format_email($address) {
......
......@@ -16,7 +16,7 @@ function _node_get($conditions) {
}
if ($type) {
return db_query("SELECT n.*, l.*, u.userid, 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.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");
}
}
......
......@@ -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_username($entry[user], $entry[name]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>";
$output .= " <small>$entry[link]". ($entry[user] ? " - ". format_name($entry[user], $entry[name]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>";
$output .= "</p>\n";
}
}
......
......@@ -8,7 +8,7 @@ function links($links, $delimiter = " | ") {
function image($name) {
return "misc/$name";
}
function comment_controls($threshold = 1, $mode = 3, $order = 1) {
global $REQUEST_URI, $user;
$output .= "<DIV ALIGN=\"CENTER\">\n";
......@@ -67,7 +67,7 @@ function theme_account($region, $theme) {
$content .= "<a href=\"account.php?op=logout\">". t("logout") ."</a>\n";
$content .= "</td></tr></table>\n";
$theme->box($user->userid, $content, $region);
$theme->box($user->name, $content, $region);
}
else {
$output .= "<div align=\"center\">\n";
......@@ -109,7 +109,8 @@ function theme_moderation_results($theme, $node, $region) {
foreach (explode(",", $node->users) as $vote) {
if ($vote) {
$data = explode("=", $vote);
$output .= format_username($data[0]) ." voted '$data[1]'.<br />";
$account = user_get($data[0]);
$output .= format_name($account->name) ." voted '$data[1]'.<br />";
}
}
......
......@@ -3,7 +3,7 @@
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(userid) = LOWER('$userid') && passwd = PASSWORD('$passwd') AND status = 2");
$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");
......@@ -19,6 +19,10 @@ function User($userid, $passwd = 0) {
}
}
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);
......@@ -49,7 +53,7 @@ function user_save($account, $array) {
else db_query("INSERT INTO users SET $query last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]'");
// return account:
return user_load(($account->userid ? $account->userid : $array[userid]));
return user_load($array[userid] ? $array[userid] : $account->userid);
}
function user_access($perm) {
......@@ -92,20 +96,4 @@ function user_validate_mail($mail) {
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.");
}
function user_validate($user) {
// Verify username:
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.");
}
?>
\ No newline at end of file
......@@ -50,9 +50,9 @@ function account_conf_options() {
}
function account_search($keys) {
$result = db_query("SELECT * FROM users WHERE userid LIKE '%$keys%' LIMIT 20");
$result = db_query("SELECT * FROM users WHERE name LIKE '%$keys%' LIMIT 20");
while ($account = db_fetch_object($result)) {
$find[$i++] = array("title" => $account->userid, "link" => (user_access("administer users") ? "admin.php?mod=account&op=view&name=". urlencode($account->userid) : "account.php?op=view&name=". urlencode($account->userid)), "user" => $account->userid);
$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;
}
......@@ -97,13 +97,13 @@ function account_ac() {
function account_overview($query = array()) {
$result = db_query("SELECT id, userid, last_access FROM users $query[1] LIMIT 50");
$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_username($account->userid) ."</TD><TD>". format_date($account->last_access) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=view&name=". urlencode($account->userid) ."\">view account</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=edit&name=". urlencode($account->userid) ."\">edit account</A></TD></TR>\n";
$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";
......@@ -135,12 +135,12 @@ function account_comments($id) {
}