Fixing a small css issue in the user class.
[elgg.git] / units / admin / admin_main.php
blob2884fbd6e97831e029f37c37835119736d34337e
1 <?php
2 global $USER,$CFG;
3 // Main admin panel screen
5 // Site stats
7 if (logged_on && user_flag_get("admin", $USER->ident)) {
9 $run_result .= "<h2>" . __gettext("Site statistics") . "</h2>";
11 // Number of users of each type
12 $users = count_users();
13 if (!empty($users) && is_array($users)) {
14 $data = '';
15 foreach($users as $user) {
16 $data .= '<h4>' . $user->user_type . ":</h4><p>" . $user->numusers . "</p> ";
19 $run_result .= templates_draw(array(
20 'context' => 'adminTable',
21 'name' => "<h3>" . __gettext("Accounts by type") . "</h3> ",
22 'column1' => '' . $data . '',
23 'column2' => "&nbsp;"
29 // Number of weblog posts
30 $weblog_posts = count_records('weblog_posts');
31 $weblog_comments = count_records('weblog_comments');
32 $weblog_posts_7days = count_records_select('weblog_posts',"posted > ?",array(time() - (86400 * 7)));
33 $weblog_comments_7days = count_records_select('weblog_comments',"posted > ?",array(time() - (86400 * 7)));
34 $run_result .= templates_draw(array(
35 'context' => 'adminTable',
36 'name' => "<h3>" . __gettext("Weblog statistics") . "</h3> ",
37 'column1' => "<h4>" . __gettext("All-time:") . "</h4><p>"
38 . sprintf(__gettext("%u weblog posts, %u comments"),$weblog_posts, $weblog_comments)
39 . "</p><h4>" . __gettext("Last 7 days:") . "</h4><p>"
40 . sprintf(__gettext("%u weblog posts, %u comments"),$weblog_posts_7days, $weblog_comments_7days) . "</p>",
41 'column2' => "&nbsp;"
45 // Number of files
46 $files = get_record_sql('SELECT COUNT(ident) AS numfiles,SUM(size) AS totalsize FROM '.$CFG->prefix.'files');
47 $files_7days = get_record_sql('SELECT COUNT(ident) AS numfiles, SUM(size) AS totalsize FROM '.$CFG->prefix.'files WHERE time_uploaded > ?',array(time() - (86400 * 7)));
48 $run_result .= templates_draw(array(
49 'context' => 'adminTable',
50 'name' => "<h3>" . __gettext("File statistics") . "</h3> ",
51 'column1' => "<h4>" . __gettext("All-time:") . "</h4> <p>" . sprintf(__gettext("%u files (%s bytes)"),$files->numfiles, $files->totalsize)
52 . "</p><h4>" . __gettext("Last 7 days:") . "</h4><p>" . sprintf(__gettext("%u files (%s bytes)"),$files_7days->numfiles, $files_7days->totalsize) . "</p>",
53 'column2' => "&nbsp;"
57 // DB size
58 $totaldbsize = 0;
59 if ($CFG->dbtype == 'mysql') {
60 if ($dbsize = get_records_sql('SHOW TABLE STATUS')) {
61 foreach($dbsize as $atable) {
62 // filter on prefix if we have it.
63 if (!empty($CFG->prefix) && strpos($atable->Name,$CFG->prefix) !== 0) {
64 continue;
66 $totaldbsize += intval($atable->Data_length) + intval($atable->Index_length);
68 $run_result .= templates_draw(array(
69 'context' => 'adminTable',
70 'name' => "<h3>" . __gettext("Database statistics") . "</h3> ",
71 'column1' => "<h4>" . __gettext("Total database size:") . "</h4> <p>" . sprintf(__gettext("%u bytes"),$totaldbsize) . "</p>",
72 'column2' => "&nbsp;"
77 // Users online right now
78 $run_result .= "<h2>" . __gettext("Users online now") . "</h2>";
79 $run_result .= "<p>" . __gettext("The following users have an active session and have performed an action within the past 10 minutes.") . "</p>";
81 if ($users = get_records_select('users',"code != ? AND last_action > ?",array('',time() - 600),'username ASC')) {
82 $run_result .= templates_draw(array(
83 'context' => 'adminTable',
84 'name' => "<h3>" . __gettext("Username") . "</h3>",
85 'column1' => "<h3>" . __gettext("Full name") . "</h3>",
86 'column2' => "<h3>" . __gettext("Email address") . "</h3>"
89 foreach($users as $user) {
90 $run_result .= run("admin:users:panel",$user);
92 } else {
93 $users = array();
96 $run_result .= "<p>" . sprintf(__gettext("%u users in total."),sizeof($users)) . "</p>";