diff --git a/admin.php b/admin.php index aa3c3ed71c3..b20e98efdc1 100644 --- a/admin.php +++ b/admin.php @@ -1,7 +1,7 @@ id || $user->id > 4) exit(); +if (!$user->id || ($user->permissions != 1 && $user->id > 1)) exit(); include "includes/admin.inc"; include "includes/cron.inc"; diff --git a/includes/function.inc b/includes/function.inc index 90a1179db6e..dc013683e86 100644 --- a/includes/function.inc +++ b/includes/function.inc @@ -62,15 +62,15 @@ function format_plural($count, $singular, $plural) { } function format_interval($timestamp) { - if ($timestamp > 86400) { + if ($timestamp >= 86400) { $output .= format_plural(floor($timestamp / 86400), "day ", "days "); $timestamp = $timestamp % 86400; } - if ($timestamp > 3600) { + if ($timestamp >= 3600) { $output .= format_plural(floor($timestamp / 3600), "hour ", "hours "); $timestamp = $timestamp % 3600; } - if ($timestamp > 60) { + if ($timestamp >= 60) { $output .= floor($timestamp / 60) ." min "; $timestamp = $timestamp % 60; } diff --git a/includes/user.inc b/includes/user.inc index 75bd5cfaf05..7d04c785f80 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -15,7 +15,7 @@ function user_save($data, $id = 0) { foreach ($data as $key=>$value) { if ($key == "passwd") $query .= "$key = PASSWORD('". addslashes($value) ."'), "; - else $query .= "$key='". addslashes($value) ."', "; + else $query .= "$key = '". addslashes($value) ."', "; } if (empty($id)) { diff --git a/modules/account.module b/modules/account.module index 11f69fb16a5..45652d1027f 100644 --- a/modules/account.module +++ b/modules/account.module @@ -8,17 +8,18 @@ function account_cron() { } function account_display($order = "username") { - $sort = array("ID" => "id", "fake e-mail address" => "fake_email", "homepage" => "url", "hostname" => "last_host", "last access date" => "last_access", "real e-mail address" => "real_email", "real name" => "name", "status" => "status", "theme" => "theme", "timezone" => "timezone", "username" => "userid"); - $show = array("ID" => "id", "username" => "userid", "$order" => "$sort[$order]", "status" => "status"); + $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", "permissions" => "permissions", "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"); // Perform query: - $result = db_query("SELECT u.id, u.userid, u.$sort[$order], u.status FROM users u ORDER BY $sort[$order]"); + $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"; $output .= " \n"; while ($account = db_fetch_array($result)) { $output .= " \n"; foreach ($show as $key=>$value) { - switch($value) { + switch($value = strtok($value, " ")) { case "real_email": $output .= " \n"; break; case "last_access": - $output .= " \n"; + $output .= " \n"; break; case "status": $output .= " \n"; break; + case "permissions": + $output .= " \n"; + break; case "timezone": $output .= " \n"; break; @@ -62,7 +67,7 @@ function account_display($order = "username") { $output .= " \n"; } } - $output .= " \n"; + $output .= " \n"; $output .= " \n"; } $output .= "
\n"; + $output .= " \n"; $output .= "
\n"; $output .= "
$keyoperationsoperations
". format_email($account[$value]) ."". format_date($account[$value]) ."". format_interval(time() - $account[$value]) ." ago". $stat[$account[$value]] ."". $perm[$account[$value]] ."". format_data($account[$value] / 3600) ."". format_data($account[$value]) ."viewviewedit
\n"; @@ -86,8 +91,60 @@ function account_comments($id) { return $output; } +function account_save($name, $edit) { + foreach ($edit as $key=>$value) { + $query .= "$key = '". addslashes($value) ."', "; + } + db_query("UPDATE users SET $query last_access = '". time() ."' WHERE userid = '$name'"); + + watchdog("message", "account: modified user '$name'"); +} + +function account_edit($name) { + $status = array(0 => "blocked", 1 => "not confirmed", 2 => "open"); + $permissions = array(0 => "regular user", 1 => "administrator"); + + $result = db_query("SELECT * FROM users WHERE userid = '$name'"); + + if ($account = db_fetch_object($result)) { + foreach ($status as $key=>$value) { + $stat .= " \n"; + } + $stat = "\n"; + + foreach ($permissions as $key=>$value) { + $perm .= " \n"; + } + $perm = "\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
Username:$account->userid
Real name:". format_data($account->name) ."
Real e-mail address:". format_email($account->real_email) ."
Fake e-mail address:fake_email\">
URL of homepage:url\">
Permissions:$perm
Last access:". format_date($account->last_access) ." from $account->last_host
Bio information:
Signature:
Theme:". format_data($account->theme) ."
Timezone:". format_data($account->timezone / 3600) ."
Submitted stories:". format_data(account_stories($account->id)) ."
Submitted comments:". format_data(account_comments($account->id)) ."
\n"; + $output .= "userid\">\n"; + $output .= "\n"; + $output .= "\n"; + print "$output"; + } +} + function account_view($name) { $status = array(0 => "blocked", 1 => "not confirmed", 2 => "open"); + $permissions = array(0 => "regular user", 1 => "administrator"); $result = db_query("SELECT * FROM users WHERE userid = '$name'"); @@ -100,6 +157,7 @@ function account_view($name) { $output .= " Real e-mail address:". format_email($account->real_email) ."\n"; $output .= " Fake e-mail address:". format_data($account->fake_email) ."\n"; $output .= " URL of homepage:". format_url($account->url) ."\n"; + $output .= " Permissions:". $permissions[$account->permissions] ."\n"; $output .= " Last access:". format_date($account->last_access) ." from $account->last_host\n"; $output .= " Bio information:". format_data($account->bio) ."\n"; $output .= " Signature:". format_data($account->signature) ."\n"; @@ -113,12 +171,19 @@ function account_view($name) { } function account_admin() { - global $op, $name, $order; + global $op, $edit, $order, $name; switch ($op) { + case "edit": + account_edit($name); + break; case "view": account_view($name); break; + case "Save account": + account_save($name, $edit); + account_view($name); + break; case "Update": account_display($order); break; diff --git a/modules/backend.class b/modules/backend.class index b564344d563..35bcfeb0ea8 100644 --- a/modules/backend.class +++ b/modules/backend.class @@ -16,7 +16,7 @@ class backend { // Contains the parsed rdf/rss/xml file: var $headlines = array(); // latest headlines - function backend($id, $site, $url, $file, $contact, $timout = 1800) { + function backend($id, $site, $url, $file, $contact, $timout = 3600) { // Get channel info: $result = db_query("SELECT * FROM channel WHERE id = '$id' OR site = '$site'"); diff --git a/modules/backend.module b/modules/backend.module index 43a2211a6ef..9c3b2bdcc61 100644 --- a/modules/backend.module +++ b/modules/backend.module @@ -44,7 +44,10 @@ function backend_page() { } function backend_cron() { - // update backends + $result = db_query("SELECT * FROM channel"); + while ($channel = db_fetch_object($result)) { + $backend = new Backend($channel->id); + } } function backend_admin_main() { diff --git a/modules/ban.module b/modules/ban.module index df7bb5aef67..35bbbb45f8e 100644 --- a/modules/ban.module +++ b/modules/ban.module @@ -32,7 +32,7 @@ function ban_display($category = "") { $output .= "
\n"; $output .= " \n"; $output .= " \n"; diff --git a/modules/comment.module b/modules/comment.module index d7de2460aaa..be7c9a00b01 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -34,7 +34,7 @@ function comment_edit($id) { function comment_save($id, $subject, $comment) { db_query("UPDATE comments SET subject = '". check_input($subject) ."', comment = '". check_input($comment) ."' WHERE cid = $id"); - watchdog("message", "modified comment `$subject'."); + watchdog("message", "comment: modified `$subject'"); } function comment_display($order = "date") { diff --git a/modules/comment/comment.module b/modules/comment/comment.module index d7de2460aaa..be7c9a00b01 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -34,7 +34,7 @@ function comment_edit($id) { function comment_save($id, $subject, $comment) { db_query("UPDATE comments SET subject = '". check_input($subject) ."', comment = '". check_input($comment) ."' WHERE cid = $id"); - watchdog("message", "modified comment `$subject'."); + watchdog("message", "comment: modified `$subject'"); } function comment_display($order = "date") { diff --git a/modules/cron.module b/modules/cron.module index b242388dbed..f0f091a9ded 100644 --- a/modules/cron.module +++ b/modules/cron.module @@ -9,27 +9,43 @@ function cron_reset($name) { cron_delete($name); } +function cron_save($edit) { + foreach ($edit as $key=>$value) { + db_query("UPDATE cron SET scheduled = '$value' WHERE module = '$key'"); + } +} + function cron_display() { + $intervals = array(300, 900, 1800, 3600, 7200, 10800, 21600, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200); + // Perform query: $result = db_query("SELECT * FROM cron"); // Generate output: + $output .= "\n"; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($cron = db_fetch_object($result)) { - $output .= " \n"; + foreach ($intervals as $value) $period .= "\n"; + $output .= " \n"; + unset($period); } $output .= "
moduleintervallast exectionoperations
moduleperiodlast executionoperations
". check_output($cron->module) ."every ". format_interval($cron->scheduled) ."". format_interval(time() - $cron->timestamp) ." agoexecutemodule\">reset
". check_output($cron->module) ."". format_interval(time() - $cron->timestamp) ." agoexecutemodule\">reset
\n"; + $output .= "\n"; + $output .= "
\n"; print $output; } function cron_admin() { - global $op, $name; + global $op, $edit, $name; switch($op) { case "reset": cron_reset($name); break; + case "Save crons": + cron_save($edit); + break; } cron_display(); diff --git a/modules/diary.module b/modules/diary.module index 92c97d5f37b..31da9fe0de3 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -218,7 +218,7 @@ function diary_admin_edit($id) { function diary_admin_save($id, $text) { db_query("UPDATE diaries SET text = '". check_input($text) ."' WHERE id = $id"); - watchdog("message", "modified diary entry #$id."); + watchdog("message", "diary: modified entry #$id."); } function diary_admin_display($order = "date") { diff --git a/modules/story.module b/modules/story.module index 172cdfdcb2d..42707168c85 100644 --- a/modules/story.module +++ b/modules/story.module @@ -63,7 +63,7 @@ function story_edit($id) { function story_save($id, $subject, $abstract, $updates, $article, $category, $status) { db_query("UPDATE stories SET subject = '". check_input($subject) ."', abstract = '". check_input($abstract) ."', updates = '". check_input($updates) ."', article = '". check_input($article) ."', category = '". check_input($category) ."', status = '$status' WHERE id = $id"); - watchdog("message", "modified story `$subject'."); + watchdog("message", "story: modified `$subject'"); } function story_display($order = "date") { diff --git a/modules/story/story.module b/modules/story/story.module index 172cdfdcb2d..42707168c85 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -63,7 +63,7 @@ function story_edit($id) { function story_save($id, $subject, $abstract, $updates, $article, $category, $status) { db_query("UPDATE stories SET subject = '". check_input($subject) ."', abstract = '". check_input($abstract) ."', updates = '". check_input($updates) ."', article = '". check_input($article) ."', category = '". check_input($category) ."', status = '$status' WHERE id = $id"); - watchdog("message", "modified story `$subject'."); + watchdog("message", "story: modified `$subject'"); } function story_display($order = "date") {