From a1a96ca29e7e71fd7fb7cd773e084b10f7bf3deb Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 23 Feb 2001 17:53:51 +0000 Subject: - small changes to the watchdog module to make it more conform with other modules - small changes to the account module to make it more conform with other modules - users can be deleted --- admin.php | 2 +- modules/account.module | 158 ++++++++++++++------------------------- modules/watchdog.module | 12 +-- modules/watchdog/watchdog.module | 12 +-- 4 files changed, 70 insertions(+), 114 deletions(-) diff --git a/admin.php b/admin.php index 5281cc9d1..4cc4cd27a 100644 --- a/admin.php +++ b/admin.php @@ -23,7 +23,7 @@ function admin_page($mod) { h1 { font-size: 18pt; font-weight: bold; color: #990000; } h2 { font-family: helvetica, arial; font-size: 18pt; font-weight: bold; } h3 { font-family: helvetica, arial; font-size: 14pt; font-weight: bold; } - th { font-family: helvetica, arial; text-align: center; background-color: #CCCCCC; color: #995555; } + th { font-family: helvetica, arial; text-align: center; vertical-align: top; background-color: #CCCCCC; color: #995555; } td { font-family: helvetica, arial; } diff --git a/modules/account.module b/modules/account.module index 7aeb34ca7..098934992 100644 --- a/modules/account.module +++ b/modules/account.module @@ -75,64 +75,12 @@ function account_search() { } function account_display($order = "username") { - $sort = array("ID" => "id", "fake e-mail address" => "fake_email", "hostname" => "last_host DESC", "last access date" => "last_access DESC", "real e-mail address" => "real_email", "real name" => "name", "rating" => "rating DESC", "status" => "status", "theme" => "theme", "timezone" => "timezone DESC", "username" => "userid"); - $show = array("ID" => "id", "username" => "userid", "$order" => "$sort[$order]", "homepage" => "url"); - $stat = array(0 => "blocked", 1 => "not confirmed", 2 => "open"); - $perm = array(0 => "regular user", 1 => "administrator"); + $result = db_query("SELECT id, userid, last_access FROM users ORDER BY last_access DESC LIMIT 50"); - // Perform query: - $result = db_query("SELECT u.id, u.userid, u.". strtok($sort[$order], " ") .", u.url FROM users u ORDER BY $sort[$order]"); - - // Generate output: $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - - foreach ($show as $key=>$value) { - $output .= " \n"; - } - $output .= " \n"; - $output .= " \n"; - - while ($account = db_fetch_array($result)) { - $output .= " \n"; - foreach ($show as $key=>$value) { - switch($value = strtok($value, " ")) { - case "real_email": - $output .= " \n"; - break; - case "last_access": - $output .= " \n"; - break; - case "status": - $output .= " \n"; - break; - case "timezone": - $output .= " \n"; - break; - case "url": - $output .= " \n"; - break; - case "userid": - $output .= " \n"; - break; - default: - $output .= " \n"; - } - } - $output .= " \n"; - $output .= " \n"; + $output .= " \n"; + while ($account = db_fetch_object($result)) { + $output .= " \n"; } $output .= "
\n"; - $output .= "
\n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
\n"; - $output .= "
$keyoperations
". format_email($account[$value]) ."". format_interval(time() - $account[$value]) ." ago". $stat[$account[$value]] ."". check_output($account[$value] / 3600) ."". format_url($account[$value]) ."". format_username($account[$value]) ."". check_output($account[$value]) ."viewedit
usernamelast accessoperations
". format_username($account->userid) ."". format_date($account->last_access) ."userid\">viewuserid\">edituserid\">delete
\n"; @@ -143,7 +91,7 @@ function account_access($account) { $data = explode(";", $account->access); foreach ($data as $array) { $access = explode(":", $array); - if ($access[0]) $output .= " $access[0]"; + if ($access[0]) $output .= " $access[0]"; } return $output; } @@ -172,10 +120,20 @@ function account_comments($id) { return $output; } +function account_delete($name) { + $result = db_query("SELECT * FROM users WHERE userid = '$name' AND status = 0 AND id > 1"); + if ($account = db_fetch_object($result)) { + db_query("DELETE FROM users WHERE id = $account->id"); + } + else { + print "

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

"; + } +} + function account_edit_save($name, $edit) { foreach ($edit as $key=>$value) if ($key != "access") $query .= "$key = '". addslashes($value) ."', "; - db_query("UPDATE users SET $query last_access = '". time() ."' WHERE userid = '$name'"); - foreach ($edit["access"] as $key=>$value) user_set(user_load($name), "access", $value, 1); + db_query("UPDATE users SET $query access = '' WHERE userid = '$name'"); + if ($edit["access"]) foreach ($edit["access"] as $key=>$value) user_set(user_load($name), "access", $value, 1); watchdog("message", "account: modified user '$name'"); } @@ -196,32 +154,23 @@ function account_edit($name) { foreach ($status as $key=>$value) { $stat .= " \n"; } - $stat = "\n"; module_iterate("access"); $output .= "
\n"; - $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
ID:$account->id
Status:$stat
Access:
Username:$account->userid
Real name:". check_output($account->name) ."
Real e-mail address:". format_email($account->real_email) ."
Fake e-mail address:fake_email\">
URL of homepage:url\">
Last access:". format_date($account->last_access) ." from ". check_output($account->last_host) ."
User rating:". check_output($account->rating) ."
Bio information:
Signature:
Theme:". check_output($account->theme) ."
Timezone:". check_output($account->timezone / 3600) ."
Selected blocks:". check_output(account_blocks($account->id)) ."
Submitted stories:". check_output(account_stories($account->id)) ."
Submitted comments:". check_output(account_comments($account->id)) ."
\n"; - $output .= "userid\">\n"; - $output .= "\n"; + $output .= "ID:
$account->id

\n"; + $output .= "Username:
". check_output($account->userid) ."

\n"; + $output .= "Status:

\n"; + $output .= "Administrator access:

\n"; + $output .= "Real name:
real_name\">

\n"; + $output .= "Real e-mail address:
real_email\">

\n"; + $output .= "Fake e-mail address:
fake_email\">

\n"; + $output .= "URL of homepage:
url\">

\n"; + $output .= "Bio information:

\n"; + $output .= "Signature:

\n"; + $output .= "userid\">\n"; + $output .= "\n"; + $output .= "\n"; $output .= "

\n"; print "$output"; } @@ -233,25 +182,28 @@ function account_view($name) { $result = db_query("SELECT * FROM users WHERE userid = '$name'"); if ($account = db_fetch_object($result)) { + $output .= "
\n"; $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; $output .= "
ID:userid\">$account->id
Status:". $status[$account->status] ."
Access:". check_output(account_access($account)) ."
Username:$account->userid
Real name:". check_output($account->name) ."
Real e-mail address:". format_email($account->real_email) ."
Fake e-mail address:". check_output($account->fake_email) ."
URL of homepage:". format_url($account->url) ."
Last access:". format_date($account->last_access) ." from ". check_output($account->last_host) ."
User rating:". check_output($account->rating) ."
Bio information:". check_output($account->bio) ."
Signature:". check_output($account->signature) ."
Theme:". check_output($account->theme) ."
Timezone:". check_output($account->timezone / 3600) ."
Selected blocks:". check_output(account_blocks($account->id)) ."
Submitted stories:". check_output(account_stories($account->id)) ."
Submitted comments:". check_output(account_comments($account->id)) ."
ID:$account->id
Username:$account->userid
Status:". $status[$account->status] ."
Access:". check_output(account_access($account)) ."
Real name:". check_output($account->name) ."
Real e-mail address:". format_email($account->real_email) ."
Fake e-mail address:". check_output($account->fake_email) ."
URL of homepage:". format_url($account->url) ."
Last access:". format_date($account->last_access) ." from ". check_output($account->last_host) ."
User rating:". check_output($account->rating) ."
Bio information:". check_output($account->bio) ."
Signature:". check_output($account->signature) ."
Theme:". check_output($account->theme) ."
Timezone:". check_output($account->timezone / 3600) ."
Selected blocks:". check_output(account_blocks($account->id)) ."
Submitted stories:". check_output(account_stories($account->id)) ."
Submitted comments:". check_output(account_comments($account->id)) ."
userid\">
\n"; + $output .= "
\n"; print "$output"; } } @@ -279,6 +231,12 @@ function account_admin() { print "overview | search account | help
\n"; switch ($op) { + case "Delete account": + case "delete": + account_delete($name); + account_display(); + break; + case "Edit account": case "edit": account_edit($name); break; @@ -288,6 +246,7 @@ function account_admin() { case "search": account_search(); break; + case "View account": case "view": account_view($name); break; @@ -295,9 +254,6 @@ function account_admin() { account_edit_save($name, $edit); account_view($name); break; - case "Update": - account_display($order); - break; default: account_display(); } diff --git a/modules/watchdog.module b/modules/watchdog.module index f1bb7925f..26714ed20 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -49,12 +49,12 @@ function watchdog_view($id) { if ($watchdog = db_fetch_object($result)) { $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; $output .= "
Level:$watchdog->level
Date:". format_date($watchdog->timestamp, "large") ."
User:". format_username($watchdog->userid) ."
Location:$watchdog->location
Message:$watchdog->message
Hostname:$watchdog->hostname
Level:$watchdog->level
Date:". format_date($watchdog->timestamp, "large") ."
User:". format_username($watchdog->userid) ."
Location:$watchdog->location
Message:$watchdog->message
Hostname:$watchdog->hostname
\n"; print $output; } diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index f1bb7925f..26714ed20 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -49,12 +49,12 @@ function watchdog_view($id) { if ($watchdog = db_fetch_object($result)) { $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; $output .= "
Level:$watchdog->level
Date:". format_date($watchdog->timestamp, "large") ."
User:". format_username($watchdog->userid) ."
Location:$watchdog->location
Message:$watchdog->message
Hostname:$watchdog->hostname
Level:$watchdog->level
Date:". format_date($watchdog->timestamp, "large") ."
User:". format_username($watchdog->userid) ."
Location:$watchdog->location
Message:$watchdog->message
Hostname:$watchdog->hostname
\n"; print $output; } -- cgit v1.2.3