mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
feat: Add system information dashboard to admin panel (#2092)
* feat: Add system information dashboard to admin panel * Update index.php * Update index.php * Update index.php * Update index.tpl * Updated * Update index.php
This commit is contained in:
parent
7c3faa922f
commit
9a4d30c6da
3 changed files with 96 additions and 0 deletions
|
@ -132,6 +132,18 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
||||||
$users_per_day = $total_users;
|
$users_per_day = $total_users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get database version info
|
||||||
|
$database_version = $lang['NOT_AVAILABLE'];
|
||||||
|
$sql = 'SELECT VERSION() as version';
|
||||||
|
$result = DB()->sql_query($sql);
|
||||||
|
$row = DB()->sql_fetchrow($result);
|
||||||
|
if (isset($row['version'])) {
|
||||||
|
$database_version = $row['version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get disk space information
|
||||||
|
$getDiskSpaceInfo = getDiskSpaceInfo();
|
||||||
|
|
||||||
$template->assign_vars([
|
$template->assign_vars([
|
||||||
'NUMBER_OF_POSTS' => commify($total_posts),
|
'NUMBER_OF_POSTS' => commify($total_posts),
|
||||||
'NUMBER_OF_TOPICS' => commify($total_topics),
|
'NUMBER_OF_TOPICS' => commify($total_topics),
|
||||||
|
@ -141,6 +153,13 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
||||||
'TOPICS_PER_DAY' => $topics_per_day,
|
'TOPICS_PER_DAY' => $topics_per_day,
|
||||||
'USERS_PER_DAY' => $users_per_day,
|
'USERS_PER_DAY' => $users_per_day,
|
||||||
'AVATAR_DIR_SIZE' => $avatar_dir_size,
|
'AVATAR_DIR_SIZE' => $avatar_dir_size,
|
||||||
|
// System info
|
||||||
|
'SERVER_OS' => htmlCHR(php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('m')),
|
||||||
|
'SERVER_PHP_VER' => htmlCHR(phpversion()),
|
||||||
|
'SERVER_PHP_MEM_LIMIT' => htmlCHR(ini_get('memory_limit')),
|
||||||
|
'SERVER_PHP_MAX_EXECUTION_TIME' => htmlCHR(ini_get('max_execution_time')),
|
||||||
|
'SERVER_DATABASE_VER' => htmlCHR($database_version),
|
||||||
|
'SERVER_DISK_SPACE_INFO' => htmlCHR(sprintf($lang['ADMIN_SYSTEM_DISK_SPACE_INFO'], $getDiskSpaceInfo['total'], $getDiskSpaceInfo['used'], $getDiskSpaceInfo['free'])),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (isset($_GET['users_online'])) {
|
if (isset($_GET['users_online'])) {
|
||||||
|
@ -225,4 +244,46 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
||||||
print_page('index.tpl', 'admin', 'no_header');
|
print_page('index.tpl', 'admin', 'no_header');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get disk space information
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @return array|string[]
|
||||||
|
*/
|
||||||
|
function getDiskSpaceInfo(string $path = BB_ROOT): array
|
||||||
|
{
|
||||||
|
global $lang;
|
||||||
|
|
||||||
|
$default_values = [
|
||||||
|
'total' => $lang['NOT_AVAILABLE'],
|
||||||
|
'free' => $lang['NOT_AVAILABLE'],
|
||||||
|
'used' => $lang['NOT_AVAILABLE'],
|
||||||
|
'percent_used' => $lang['NOT_AVAILABLE']
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$bytes_total = disk_total_space($path);
|
||||||
|
$bytes_free = disk_free_space($path);
|
||||||
|
|
||||||
|
if ($bytes_total === false || $bytes_free === false) {
|
||||||
|
return $default_values;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes_used = $bytes_total - $bytes_free;
|
||||||
|
$percent_used = ($bytes_total > 0) ? round(($bytes_used / $bytes_total) * 100, 2) : 0;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'total' => humn_size($bytes_total),
|
||||||
|
'free' => humn_size($bytes_free),
|
||||||
|
'used' => humn_size($bytes_used),
|
||||||
|
'percent_used' => $percent_used,
|
||||||
|
'path' => realpath($path)
|
||||||
|
];
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
bb_log("[getDiskSpaceInfo] " . $e->getMessage() . LOG_LF);
|
||||||
|
return $default_values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print_page('index.tpl', 'admin');
|
print_page('index.tpl', 'admin');
|
||||||
|
|
|
@ -1970,6 +1970,16 @@ $lang['DATABASE_SIZE'] = 'Database size';
|
||||||
$lang['GZIP_COMPRESSION'] = 'Gzip compression';
|
$lang['GZIP_COMPRESSION'] = 'Gzip compression';
|
||||||
$lang['NOT_AVAILABLE'] = 'Not available';
|
$lang['NOT_AVAILABLE'] = 'Not available';
|
||||||
|
|
||||||
|
// System information
|
||||||
|
$lang['ADMIN_SYSTEM_INFORMATION'] = 'System information';
|
||||||
|
$lang['ADMIN_SYSTEM_OS'] = 'OS:';
|
||||||
|
$lang['ADMIN_SYSTEM_PHP_VER'] = 'PHP:';
|
||||||
|
$lang['ADMIN_SYSTEM_DATABASE_VER'] = 'Database:';
|
||||||
|
$lang['ADMIN_SYSTEM_PHP_MEM_LIMIT'] = 'Memory limit:';
|
||||||
|
$lang['ADMIN_SYSTEM_DISK_SPACE_INFO_TITLE'] = 'Disk space info:';
|
||||||
|
$lang['ADMIN_SYSTEM_DISK_SPACE_INFO'] = '%s (used: %s | free: %s)';
|
||||||
|
$lang['ADMIN_SYSTEM_PHP_MAX_EXECUTION_TIME'] = 'Max execution time:';
|
||||||
|
|
||||||
// Clear Cache
|
// Clear Cache
|
||||||
$lang['DATASTORE'] = 'Datastore';
|
$lang['DATASTORE'] = 'Datastore';
|
||||||
$lang['CLEAR_CACHE'] = 'Cache';
|
$lang['CLEAR_CACHE'] = 'Cache';
|
||||||
|
|
|
@ -167,6 +167,31 @@
|
||||||
</table>
|
</table>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<table class="forumline">
|
||||||
|
<tr>
|
||||||
|
<th colspan="4">{L_ADMIN_SYSTEM_INFORMATION}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="row1" nowrap="nowrap">{L_ADMIN_SYSTEM_OS}</td>
|
||||||
|
<td class="row2"><b>{SERVER_OS}</b></td>
|
||||||
|
<td class="row1" nowrap="nowrap">{L_ADMIN_SYSTEM_PHP_VER}</td>
|
||||||
|
<td class="row2"><b>{SERVER_PHP_VER}</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="row1" nowrap="nowrap">{L_ADMIN_SYSTEM_DATABASE_VER}</td>
|
||||||
|
<td class="row2"><b>{SERVER_DATABASE_VER}</b></td>
|
||||||
|
<td class="row1" nowrap="nowrap">{L_ADMIN_SYSTEM_PHP_MEM_LIMIT}</td>
|
||||||
|
<td class="row2"><b>{SERVER_PHP_MEM_LIMIT}</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="row1" nowrap="nowrap">{L_ADMIN_SYSTEM_DISK_SPACE_INFO_TITLE}</td>
|
||||||
|
<td class="row2"><b>{SERVER_DISK_SPACE_INFO}</b></td>
|
||||||
|
<td class="row1" nowrap="nowrap">{L_ADMIN_SYSTEM_PHP_MAX_EXECUTION_TIME}</td>
|
||||||
|
<td class="row2"><b>{SERVER_PHP_MAX_EXECUTION_TIME}</b></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<table class="forumline">
|
<table class="forumline">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4">{L_FORUM_STATS}</th>
|
<th colspan="4">{L_FORUM_STATS}</th>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue