Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/serverinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-04-11 17:20:37 +0300
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-04-11 17:49:29 +0300
commitc63e1093f79d2d50f9e7c0e2eb41c40f18625ae8 (patch)
tree7534ae871ad89b7661c49db034d4d0d0a373e6c3
parente2281220b36fc0219826c15f728af812ccb6e91f (diff)
Cleanup
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
-rwxr-xr-xlib/Controller/ApiController.php74
-rwxr-xr-xlib/OperatingSystems/DefaultOs.php109
-rw-r--r--lib/Os.php122
-rw-r--r--templates/settings-admin.php299
4 files changed, 299 insertions, 305 deletions
diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php
index 7d1b2d2..bbd2f31 100755
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -19,11 +19,10 @@
*
*/
-
namespace OCA\ServerInfo\Controller;
-use OCA\ServerInfo\Os;
use OCA\ServerInfo\DatabaseStatistics;
+use OCA\ServerInfo\Os;
use OCA\ServerInfo\PhpStatistics;
use OCA\ServerInfo\SessionStatistics;
use OCA\ServerInfo\ShareStatistics;
@@ -61,7 +60,7 @@ class ApiController extends OCSController {
*
* @param string $appName
* @param IRequest $request
- * @param Os $Os
+ * @param Os $os
* @param SystemStatistics $systemStatistics
* @param StorageStatistics $storageStatistics
* @param PhpStatistics $phpStatistics
@@ -71,23 +70,22 @@ class ApiController extends OCSController {
*/
public function __construct($appName,
IRequest $request,
- Os $Os,
+ Os $os,
SystemStatistics $systemStatistics,
StorageStatistics $storageStatistics,
PhpStatistics $phpStatistics,
DatabaseStatistics $databaseStatistics,
ShareStatistics $shareStatistics,
- SessionStatistics $sessionStatistics
- ) {
+ SessionStatistics $sessionStatistics) {
parent::__construct($appName, $request);
- $this->Os = $Os;
- $this->systemStatistics = $systemStatistics;
- $this->storageStatistics = $storageStatistics;
- $this->phpStatistics = $phpStatistics;
+ $this->os = $os;
+ $this->systemStatistics = $systemStatistics;
+ $this->storageStatistics = $storageStatistics;
+ $this->phpStatistics = $phpStatistics;
$this->databaseStatistics = $databaseStatistics;
- $this->shareStatistics = $shareStatistics;
- $this->sessionStatistics = $sessionStatistics;
+ $this->shareStatistics = $shareStatistics;
+ $this->sessionStatistics = $sessionStatistics;
}
/**
@@ -97,23 +95,19 @@ class ApiController extends OCSController {
*/
public function info() {
- return new DataResponse(
- [
- 'nextcloud' =>
- [
- 'system' => $this->systemStatistics->getSystemStatistics(),
- 'storage' => $this->storageStatistics->getStorageStatistics(),
- 'shares' => $this->shareStatistics->getShareStatistics()
- ],
- 'server' =>
- [
- 'webserver' => $this->getWebserver(),
- 'php' => $this->phpStatistics->getPhpStatistics(),
- 'database' => $this->databaseStatistics->getDatabaseStatistics()
- ],
- 'activeUsers' => $this->sessionStatistics->getSessionStatistics()
- ]
- );
+ return new DataResponse([
+ 'nextcloud' => [
+ 'system' => $this->systemStatistics->getSystemStatistics(),
+ 'storage' => $this->storageStatistics->getStorageStatistics(),
+ 'shares' => $this->shareStatistics->getShareStatistics()
+ ],
+ 'server' => [
+ 'webserver' => $this->getWebserver(),
+ 'php' => $this->phpStatistics->getPhpStatistics(),
+ 'database' => $this->databaseStatistics->getDatabaseStatistics()
+ ],
+ 'activeUsers' => $this->sessionStatistics->getSessionStatistics()
+ ]);
}
@@ -121,21 +115,25 @@ class ApiController extends OCSController {
* @return DataResponse
*/
public function BasicData(): DataResponse {
- $servertime = $this->Os->getTime();
- $uptime = $this->Os->getUptime();
- $timeservers = $this->Os->getTimeServers()[0];
- return new DataResponse(array('servertime'=>$servertime,'uptime'=>$uptime,'timeservers'=>$timeservers));
+ $servertime = $this->os->getTime();
+ $uptime = $this->os->getUptime();
+ $timeservers = $this->os->getTimeServers()[0];
+
+ return new DataResponse([
+ 'servertime' => $servertime,
+ 'uptime' => $uptime,
+ 'timeservers' => $timeservers
+ ]);
}
/**
* @return DataResponse
*/
public function DiskData(): DataResponse {
- $result = $this->Os->getDiskData();
+ $result = $this->os->getDiskData();
return new DataResponse($result);
}
-
/**
* get webserver
*
@@ -145,10 +143,6 @@ class ApiController extends OCSController {
if (isset($_SERVER['SERVER_SOFTWARE'])) {
return $_SERVER['SERVER_SOFTWARE'];
}
-
- return "unknown";
+ return 'unknown';
}
-
-
-
}
diff --git a/lib/OperatingSystems/DefaultOs.php b/lib/OperatingSystems/DefaultOs.php
index 88d4fc3..d695c34 100755
--- a/lib/OperatingSystems/DefaultOs.php
+++ b/lib/OperatingSystems/DefaultOs.php
@@ -19,8 +19,6 @@
*/
namespace OCA\Serverinfo\OperatingSystems;
-
-
/**
* Class Ubuntu
*
@@ -28,10 +26,7 @@ namespace OCA\Serverinfo\OperatingSystems;
*/
class DefaultOs {
- /**
- */
- public function __construct() {
- }
+ public function __construct() {}
/**
* @return bool
@@ -53,12 +48,12 @@ class DefaultOs {
*/
public function getMemory() {
$memory = shell_exec('cat /proc/meminfo | grep -i \'MemTotal\' | cut -f 2 -d ":" | awk \'{$1=$1}1\'');
- $memory = explode(' ',$memory);
- $memory = round($memory[0]/1024);
- if ($memory<1024) {
- $memory = $memory.' MB';
+ $memory = explode(' ', $memory);
+ $memory = round($memory[0] / 1024);
+ if ($memory < 1024) {
+ $memory = $memory . ' MB';
} else {
- $memory = round($memory/1024,1).' GB';
+ $memory = round($memory / 1024, 1) . ' GB';
}
return $memory;
}
@@ -69,8 +64,12 @@ class DefaultOs {
public function getCPUName() {
$cpu = shell_exec('cat /proc/cpuinfo | grep -i \'Model name\' | cut -f 2 -d ":" | awk \'{$1=$1}1\'');
$cores = shell_exec('cat /proc/cpuinfo | grep -i \'cpu cores\' | cut -f 2 -d ":" | awk \'{$1=$1}1\'');
- if ($cores == 1) $cores = ' ('.$cores.' core)'; else $cores = ' ('.$cores.' cores)';
- return $cpu.' '.$cores;
+ if ($cores === 1) {
+ $cores = ' (' . $cores . ' core)';
+ } else {
+ $cores = ' (' . $cores . ' cores)';
+ }
+ return $cpu . ' ' . $cores;
}
/**
@@ -89,13 +88,12 @@ class DefaultOs {
return $uptime;
}
-
/**
- * @return string
- */
+ * @return string
+ */
public function getTimeServers() {
$servers = shell_exec('cat /etc/ntp.conf |grep \'^pool\' | cut -f 2 -d " "');
- $servers.= ' '.shell_exec('cat /etc/systemd/timesyncd.conf |grep \'^NTP=\' | cut -f 2 -d " "');
+ $servers .= ' ' . shell_exec('cat /etc/systemd/timesyncd.conf |grep \'^NTP=\' | cut -f 2 -d " "');
return $servers;
}
@@ -103,13 +101,13 @@ class DefaultOs {
* @return string
*/
public function getNetworkInfo() {
- $result=array();
- $result['hostname'] = \gethostname();
- $dns = shell_exec('cat /etc/resolv.conf |grep -i \'^nameserver\'|head -n1|cut -d \' \' -f2');
- $result['dns'] = $dns;
- $gw = shell_exec('ip route | awk \'/default/ { print $3 }\'');
- $result['gateway'] = $gw;
- return $result;
+ $result = [];
+ $result['hostname'] = \gethostname();
+ $dns = shell_exec('cat /etc/resolv.conf |grep -i \'^nameserver\'|head -n1|cut -d \' \' -f2');
+ $result['dns'] = $dns;
+ $gw = shell_exec('ip route | awk \'/default/ { print $3 }\'');
+ $result['gateway'] = $gw;
+ return $result;
}
/**
@@ -117,28 +115,37 @@ class DefaultOs {
*/
public function getNetworkInterfaces() {
$interfaces = glob('/sys/class/net/*');
- $result=array();
-
- foreach($interfaces as $interface) {
- $iface = array();
- $iface['interface'] = basename($interface);
- $iface['mac'] = shell_exec('ip addr show dev '.$iface['interface'].' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
- $iface['ipv4'] = shell_exec('ip addr show dev '.$iface['interface'].' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
- $iface['ipv6'] = shell_exec('ip -o -6 addr show '.$iface['interface'].' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\'');
- if ($iface['interface']<>'lo') {
- $iface['status'] = shell_exec('cat /sys/class/net/'.$iface['interface'].'/operstate');
- $iface['speed'] = shell_exec('cat /sys/class/net/'.$iface['interface'].'/speed');
- if ($iface['speed'] <> '') $iface['speed'] = $iface['speed'] . 'Mbps'; else $iface['speed'] = 'unknown';
- $duplex = shell_exec('cat /sys/class/net/'.$iface['interface'].'/duplex');
- if ($duplex <> '' ) $iface['duplex'] = 'Duplex: '.$duplex; else $iface['duplex'] = '';
+ $result = [];
+
+ foreach ($interfaces as $interface) {
+ $iface = [];
+ $iface['interface'] = basename($interface);
+ $iface['mac'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
+ $iface['ipv4'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
+ $iface['ipv6'] = shell_exec('ip -o -6 addr show ' . $iface['interface'] . ' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\'');
+ if ($iface['interface'] !== 'lo') {
+ $iface['status'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/operstate');
+ $iface['speed'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/speed');
+ if ($iface['speed'] !== '') {
+ $iface['speed'] = $iface['speed'] . 'Mbps';
} else {
- $iface['status'] = 'up';
$iface['speed'] = 'unknown';
- $iface['duplex'] = '';
}
- $result[] = $iface;
+ $duplex = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/duplex');
+ if ($duplex !== '') {
+ $iface['duplex'] = 'Duplex: ' . $duplex;
+ } else {
+ $iface['duplex'] = '';
+ }
+ } else {
+ $iface['status'] = 'up';
+ $iface['speed'] = 'unknown';
+ $iface['duplex'] = '';
+ }
+ $result[] = $iface;
}
+
return $result;
}
@@ -146,20 +153,20 @@ class DefaultOs {
* @return array
*/
public function getDiskInfo() {
- $blacklist = array('','Type','tmpfs','devtmpfs');
-
- $data = shell_exec('df -T');
+ $blacklist = ['', 'Type', 'tmpfs', 'devtmpfs'];
+ $data = shell_exec('df -T');
$lines = preg_split('/[\r\n]+/', $data);
+
foreach ($lines as $line) {
$entry = preg_split('/\s+/', trim($line));
- if(isset($entry[1]) and !in_array($entry[1],$blacklist)) {
- $items = array();
- $items['device'] = $entry[0];
- $items['fs'] = $entry[1];
- $items['used'] = $entry[3];
+ if (isset($entry[1]) && !in_array($entry[1], $blacklist)) {
+ $items = [];
+ $items['device'] = $entry[0];
+ $items['fs'] = $entry[1];
+ $items['used'] = $entry[3];
$items['available'] = $entry[4];
- $items['percent'] = $entry[5];
- $items['mount'] = $entry[6];
+ $items['percent'] = $entry[5];
+ $items['mount'] = $entry[6];
$result[] = $items;
}
}
diff --git a/lib/Os.php b/lib/Os.php
index b11c7d0..52a6c64 100644
--- a/lib/Os.php
+++ b/lib/Os.php
@@ -21,13 +21,12 @@
namespace OCA\ServerInfo;
use bantu\IniGetWrapper\IniGetWrapper;
+use OCA\ServerInfo\OperatingSystems\DefaultOs;
use OCP\AppFramework\Http;
-use OCP\AppFramework\Http\DataResponse;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
-use OCA\ServerInfo\OperatingSystems\DefaultOs;
class Os {
@@ -61,58 +60,24 @@ class Os {
* @param IniGetWrapper $phpIni
* @param IL10N $l
*/
- public function __construct(IClientService $clientService, IConfig $config, IDBConnection $connection, IniGetWrapper $phpIni, IL10N $l) {
+ public function __construct(IClientService $clientService,
+ IConfig $config,
+ IDBConnection $connection,
+ IniGetWrapper $phpIni,
+ IL10N $l) {
$this->clientService = $clientService;
- $this->config = $config;
- $this->connection = $connection;
- $this->phpIni = $phpIni;
- $this->l = $l;
-
- $detectedOs = $this -> detectOs();
- switch ($detectedOs) {
- case 'ubuntu':
- $this->backend = new DefaultOs();
- break;
- default:
- $this->backend = new DefaultOs();
- break;
- }
- }
-
-
- /**
- * @return string
- */
- public function detectOs(): string {
- $release = shell_exec('cat /etc/*-release');
- if(stripos($release,'ubuntu')) {
- $os = shell_exec('lsb_release -r -s');
- $os = 'Ubuntu '.$os;
- $this->osname = $os;
- return('ubuntu');
- } elseif(stripos($release,'debian')) {
- $this->osname = 'Debian';
- return('debian');
- } elseif(stripos($release,'suse')) {
- $this->osname = 'Suse';
- return('suse');
- } elseif(stripos($release,'fedora')) {
- $this->osname = 'Fedora';
- return('fedora');
- } elseif(stripos($release,'centos')) {
- $this->osname = 'CentOS';
- return('centos');
- } else {
- return('unknown');
- }
+ $this->config = $config;
+ $this->connection = $connection;
+ $this->phpIni = $phpIni;
+ $this->l = $l;
+ $this->backend = new DefaultOs();
}
-
/**
* @return bool
*/
public function supported() {
- $data = $this -> backend -> supported();
+ $data = $this->backend->supported();
return $data;
}
@@ -120,7 +85,7 @@ class Os {
* @return string
*/
public function getHostname() {
- $data = $this -> backend -> getHostname();
+ $data = $this->backend->getHostname();
return $data;
}
@@ -128,7 +93,7 @@ class Os {
* @return string
*/
public function getOSName() {
- $data = $this -> osname;
+ $data = $this->osname;
return $data;
}
@@ -136,7 +101,7 @@ class Os {
* @return string
*/
public function getMemory() {
- $data = $this -> backend -> getMemory();
+ $data = $this->backend->getMemory();
return $data;
}
@@ -144,7 +109,7 @@ class Os {
* @return string
*/
public function getCPUName() {
- $data = $this -> backend -> getCPUName();
+ $data = $this->backend->getCPUName();
return $data;
}
@@ -152,7 +117,7 @@ class Os {
* @return string
*/
public function getTime() {
- $data = $this -> backend -> getTime();
+ $data = $this->backend->getTime();
return $data;
}
@@ -160,7 +125,7 @@ class Os {
* @return string
*/
public function getUptime() {
- $data = $this -> backend -> getUptime();
+ $data = $this->backend->getUptime();
return $data;
}
@@ -168,62 +133,35 @@ class Os {
* @return string
*/
public function getTimeServers() {
- $data = $this -> backend -> getTimeServers();
- return explode("\n",$data);
+ $data = $this->backend->getTimeServers();
+ return explode("\n", $data);
}
/**
* @return string
*/
public function getDiskInfo() {
- $data = $this -> backend -> getDiskInfo();
-/*
- // debug data
- $data = array();
-
- $item['device'] = 'device1';
- $item['fs'] = 'ext';
- $item['used'] = 1000000;
- $item['available'] = 2000000;
- $item['percent'] = '30%';
- $item['mount'] = '/data';
- $data[] = $item;
-
- $item['device'] = 'device2';
- $item['fs'] = 'ext';
- $item['used'] = 2000000;
- $item['available'] = 1000000;
- $item['percent'] = '10%';
- $item['mount'] = '/data222';
- $data[] = $item;
-
-
- $item['device'] = 'device3';
- $item['fs'] = 'ext4';
- $item['used'] = 10000000;
- $item['available'] = 50000000;
- $item['percent'] = '90%';
- $item['mount'] = '/data3';
- $data[] = $item;
-*/
+ $data = $this->backend->getDiskInfo();
return $data;
}
-
/**
* @return string
*/
public function getDiskData() {
- $disks = $this -> backend -> getDiskInfo();
+ $disks = $this->backend->getDiskInfo();
$data = array();
$i = 0;
- foreach($disks as $disk){
- $data[$i] = array(round(($disk['used'])/1024/1024,1),round($disk['available']/1024/1024,1));
+ foreach ($disks as $disk) {
+ $data[$i] = [
+ round(($disk['used']) / 1024 / 1024, 1),
+ round($disk['available'] / 1024 / 1024, 1)
+ ];
$i++;
}
// debug data
-// $data = array('0'=>array(1,2),'1'=>array(4,5),'2'=>array(3,1));
+ // $data = array('0'=>array(1,2),'1'=>array(4,5),'2'=>array(3,1));
return $data;
}
@@ -232,7 +170,7 @@ class Os {
* @return string
*/
public function getNetworkInfo() {
- $data = $this -> backend -> getNetworkInfo();
+ $data = $this->backend->getNetworkInfo();
return $data;
}
@@ -240,7 +178,7 @@ class Os {
* @return string
*/
public function getNetworkInterfaces() {
- $data = $this -> backend -> getNetworkInterfaces();
+ $data = $this->backend->getNetworkInterfaces();
return $data;
}
diff --git a/templates/settings-admin.php b/templates/settings-admin.php
index 0f46fd2..52b4b99 100644
--- a/templates/settings-admin.php
+++ b/templates/settings-admin.php
@@ -19,7 +19,6 @@
*
*/
-
script('serverinfo', 'script');
script('serverinfo', 'smoothie');
script('serverinfo', 'Chart.min');
@@ -27,99 +26,111 @@ script('serverinfo', 'Chart.min');
style('serverinfo', 'style');
function FormatBytes($byte) {
- $unim = array('B','KB','MB','GB','TB','PB');
+ $unim = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$count = 1;
- while ($byte>=1024) {
+ while ($byte >= 1024) {
$count++;
- $byte = $byte/1024;
+ $byte = $byte / 1024;
}
- return number_format($byte,2,'.','.').' '.$unim[$count];
+ return number_format($byte, 2, '.', '.') . ' ' . $unim[$count];
}
?>
-<div class="section"><h2><?php echo('<img class="infoicon" src="'.image_path('serverinfo', 'server.svg').'">'); p($_['hostname']); ?></h2>
+<!-- SERVER INFOS -->
+<div class="section">
+ <h2>
+ <img class="infoicon" src="<?php p(image_path('serverinfo', 'server.svg'));?>">
+ <?php p($_['hostname']);?>
+ </h2>
<p>
- <?php p($l->t('Operating System').': '); ?>
- <span class="info"><?php p($_['osname']); ?></span>
- </p><p>
- <?php p($l->t('CPU').': '); ?>
- <span class="info"><?php p($_['cpu']); ?></span>
- </p><p>
- <?php p($l->t('Memory').': '); ?>
- <span class="info"><?php p($_['memory']); ?></span>
- </p><p>
- <?php p($l->t('Server time').': '); ?>
+ <?php p($l->t('Operating System'));?>:
+ <span class="info"><?php p($_['osname']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('CPU'));?>:
+ <span class="info"><?php p($_['cpu']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('Memory'));?>:
+ <span class="info"><?php p($_['memory']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('Server time'));?>:
<span class="info" id="servertime"></span>
- </p><p>
- <?php p($l->t('Uptime').': '); ?>
+ </p>
+ <p>
+ <?php p($l->t('Uptime'));?>:
<span class="info" id="uptime"></span>
- </p><p>
- <?php p($l->t('Time Servers').': '); ?>
+ </p>
+ <p>
+ <?php p($l->t('Time Servers'));?>:
<span class="info" id="timeservers"></span>
</p>
-
-
<div class="wrapper">
- <div id="one">
+ <div id="one">
<div class="infobox" id="cpuSection">
<h2><?php p($l->t('Load'));?></h2>
<canvas id="cpuloadcanvas" width="100" height="150"></canvas>
</div>
<p><em id="cpuFooterInfo"></em></p>
-
</div>
- <div id="two">
+ <div id="two">
<div class="infobox">
<h2><?php p($l->t('Memory'));?></h2>
<canvas id="memorycanvas" width="300" height="150"></canvas>
</div>
<p><span class="rambox" id="rambox">&nbsp;&nbsp;</span>&nbsp;&nbsp;<em id="memFooterInfo"></em></p>
<p><span class="swapbox" id="swapbox">&nbsp;&nbsp;</span>&nbsp;&nbsp;<em id="swapFooterInfo"></em></p>
-
-
</div>
+
</div>
+</div>
+<!-- DISK STATUS -->
+<div class="section">
+ <h2>
+ <img class="infoicon" src="<?php p(image_path('serverinfo', 'hdd-o.svg'));?>">
+ <?php p($l->t('Disk'));?>
+ </h2>
+ <p>
+ <?php foreach ($_['diskinfo'] as $disk) {?>
+ <div class="infobox">
+ <div class="diskchart-container">
+ <canvas id="DiskChart" class="DiskChart" width="50" height="50"></canvas>
+ </div>
+
+ <h3><?php p(basename($disk['device']));?></h3>
+ <p>
+ <?php p($l->t('Mount'));?> :
+ <span class="info"><?php p($disk['mount']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('Filesystem'));?> :
+ <span class="info"><?php p($disk['fs']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('Size'));?> :
+ <span class="info"><?php p(FormatBytes($disk['used'] + $disk['available']));?></span>
+ </p>
+ <p>
+ <?php p($l->t('Available'));?> :
+ <span class="info"><?php p(FormatBytes($disk['available']));?></span>
+ </p>
+ <p>
+ <?php p($l->t('Used'));?> :
+ <span class="info"><?php p($disk['percent']);?></span>
+ </p>
+ </div>
-</div>
+ <?php }?>
-<div class="section"><h2><?php echo('<img class="infoicon" src="'.image_path('serverinfo', 'hdd-o.svg').'">'); p($l->t('Disk')); ?></h2>
- <p>
- <?php
- foreach ($_['diskinfo'] as $disk) {
-
- echo('<div class="infobox">');
-
- echo('<div class="diskchart-container">');
- echo('<canvas id="DiskChart" class="DiskChart" width="50" height="50"></canvas>');
- echo('</div>');
-
- echo('<h3>'.basename($disk['device']).'</h3>');
- echo('<p>');
- p($l->t('Mount').': ');
- echo('<span class="info">'.$disk['mount'].'</span>');
- echo('</p><p>');
- p($l->t('Filesystem').': ');
- echo('<span class="info">'.$disk['fs'].'</span>');
- echo('</p><p>');
- p($l->t('Size').': ');
- echo('<span class="info">'.FormatBytes($disk['used']+$disk['available']).'</span>');
- echo('</p><p>');
- p($l->t('Available').': ');
- echo('<span class="info">'.FormatBytes($disk['available']).'</span>');
- echo('</p><p>');
- p($l->t('Used').': ');
- echo('<span class="info">'.$disk['percent'].'</span>');
- echo('</p></div>');
- }
- ?>
- <div class="smallinfo"> <?php p($l->t('You will get a notification once one of your disks is nearly full.')); ?></div>
+ <div class="smallinfo"> <?php p($l->t('You will get a notification once one of your disks is nearly full.'));?></div>
<p><?php p($l->t('Files:'));?> <em id="numFilesStorage"><?php p($_['storage']['num_files']);?></em></p>
<p><?php p($l->t('Storages:'));?> <em id="numFilesStorages"><?php p($_['storage']['num_storages']);?></em></p>
@@ -127,98 +138,142 @@ function FormatBytes($byte) {
</p>
</div>
-<div class="section"><h2><?php echo('<img class="infoicon" src="'.image_path('serverinfo', 'sort.svg').'">'); p($l->t('Network')); ?></h2>
+<!-- NETWORK -->
+<div class="section">
+ <h2>
+ <img class="infoicon" src="<?php p(image_path('serverinfo', 'sort.svg'));?>">
+ <?php p($l->t('Network'));?>
+ </h2>
<p>
-
<p>
- <?php p($l->t('Hostname').': '); ?>
- <span class="info"><?php p($_['networkinfo']['hostname']); ?></span>
- </p><p>
- <?php p($l->t('DNS').': '); ?>
- <span class="info"><?php p($_['networkinfo']['dns']); ?></span>
- </p><p>
- <?php p($l->t('Gateway').': '); ?>
- <span class="info"><?php p($_['networkinfo']['gateway']); ?></span>
- </p><p>
+ <?php p($l->t('Hostname'));?>:
+ <span class="info"><?php p($_['networkinfo']['hostname']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('DNS'));?>:
+ <span class="info"><?php p($_['networkinfo']['dns']);?></span>
+ </p>
+ <p>
+ <?php p($l->t('Gateway'));?>:
+ <span class="info"><?php p($_['networkinfo']['gateway']);?></span>
+ </p>
+ <p>
+ <?php foreach ($_['networkinterfaces'] as $interface) {?>
+ <div class="infobox">
+ <h3><?php p($interface['interface'])?></h3>
+ <p>
+ <?php p($l->t('Status'));?>:
+ <span class="info"><?php p($interface['status'])?></span>
+ </p>
+ <p>
+ <?php p($l->t('Speed'));?>:
+ <span class="info"><?php p($interface['speed'] . ' ' . $interface['duplex'])?></span>
+ </p>
+ <?php if (!empty($interface['mac'])) {?>
+ <p>
+ <?php p($l->t('MAC'));?>:
+ <span class="info"><?php p($interface['mac'])?></span>
+ </p>
+ <?php }?>
+ <p>
+ <?php p($l->t('IPv4'));?>:
+ <span class="info"><?php p($interface['ipv4'])?></span>
+ </p>
+ <p>
+ <?php p($l->t('IPv6'));?>:
+ <span class="info"><?php p($interface['ipv6'])?></span>
+ </p>
+ </div>
-<?php
+ <?php }?>
- foreach ($_['networkinterfaces'] as $interface) {
- echo('<div class="infobox">');
- echo('<h3>'.$interface['interface'].'</h3>');
- echo('<p>');
- p($l->t('Status').': ');
- echo('<span class="info">'.$interface['status'].'</span>');
- echo('</p><p>');
- p($l->t('Speed').': ');
- echo('<span class="info">'.$interface['speed'].' '.$interface['duplex'].'</span>');
- echo('</p><p>');
-
- if(!empty($interface['mac'])) {
- p($l->t('MAC').': ');
- echo('<span class="info">'.$interface['mac'].'</span>');
- echo('</p><p>');
- }
- p($l->t('IPv4').': ');
- echo('<span class="info">'.$interface['ipv4'].'</span>');
- echo('</p><p>');
- p($l->t('IPv6').': ');
- echo('<span class="info">'.$interface['ipv6'].'</span>');
- echo('</p></div>');
- }
-
- ?>
</p>
</div>
-
+<!-- ACTIVE USERS -->
<div class="section" id="activeUsersSection">
<div class="infobox">
- <h2><?php p($l->t('Active users'));?></h2>
- <br>
- <div class="chart-container">'
- <canvas width="400" height="250" data-users="<?php p(json_encode($_['activeUsers'])) ?>" class="barchart" id="activeuserscanvas"></canvas>
+ <h2><?php p($l->t('Active users'));?></h2>
+ <br>
+ <div class="chart-container">
+ <canvas width="400" height="250" data-users="<?php p(json_encode($_['activeUsers']))?>" class="barchart" id="activeuserscanvas"></canvas>
+ </div>
+ <p>
+ <?php p($l->t('Total users:'));?>
+ <em id="numUsersStorage"><?php p($_['storage']['num_users']);?></em>
+ </p>
</div>
- <p><?php p($l->t('Total users:'));?> <em id="numUsersStorage"><?php p($_['storage']['num_users']);?></em></p>
-</div>
</div>
+
+<!-- SHARES -->
<div class="section" id="sharesSection">
-<div class="infobox">
- <h2><?php p($l->t('Shares'));?></h2>
- <br>
- <div class="chart-container">'
- <canvas data-shares="<?php p(json_encode($_['shares'])) ?>" class="barchart" id="sharecanvas"></canvas>
-</div>
-</div>
+ <div class="infobox">
+ <h2><?php p($l->t('Shares'));?></h2>
+ <br>
+ <div class="chart-container">
+ <canvas data-shares="<?php p(json_encode($_['shares']))?>" class="barchart" id="sharecanvas"></canvas>
+ </div>
+ </div>
</div>
-
-<div class="section" id="phpSection"><h2><?php echo('<img class="infoicon" src="'.image_path('serverinfo', 'hdd-o.svg').'">'); p($l->t('PHP')); ?></h2>
+<!-- PHPINFO -->
+<div class="section" id="phpSection">
+ <h2>
+ <img class="infoicon" src="<?php p(image_path('serverinfo', 'hdd-o.svg'));?>">
+ <?php p($l->t('PHP'));?>
+ </h2>
<div class="infobox">
- <p><?php p($l->t('Version:'));?> <em id="phpVersion"><?php p($_['php']['version']);?></em></p>
- <p><?php p($l->t('Memory Limit:'));?> <em id="phpMemLimit"><?php p($_['php']['memory_limit']);?></em></p>
- <p><?php p($l->t('Max Execution Time:'));?> <em id="phpMaxExecTime"><?php p($_['php']['max_execution_time']);?></em></p>
- <p><?php p($l->t('Upload max size:'));?> <em id="phpUploadMaxSize"><?php p($_['php']['upload_max_filesize']);?></em></p>
+ <p>
+ <?php p($l->t('Version:'));?>
+ <em id="phpVersion"><?php p($_['php']['version']);?></em>
+ </p>
+ <p>
+ <?php p($l->t('Memory Limit:'));?>
+ <em id="phpMemLimit"><?php p($_['php']['memory_limit']);?></em>
+ </p>
+ <p>
+ <?php p($l->t('Max Execution Time:'));?>
+ <em id="phpMaxExecTime"><?php p($_['php']['max_execution_time']);?></em>
+ </p>
+ <p>
+ <?php p($l->t('Upload max size:'));?>
+ <em id="phpUploadMaxSize"><?php p($_['php']['upload_max_filesize']);?></em>
+ </p>
</div>
</div>
-<div class="section" id="databaseSection"><h2><?php echo('<img class="infoicon" src="'.image_path('serverinfo', 'hdd-o.svg').'">'); p($l->t('Database')); ?></h2>
+<!-- DATABASE -->
+<div class="section" id="databaseSection">
+ <h2>
+ <img class="infoicon" src="<?php p(image_path('serverinfo', 'hdd-o.svg'));?>">
+ <?php p($l->t('Database'));?>
+ </h2>
<div class="infobox">
- <p><?php p($l->t('Type:'));?> <em id="databaseType"><?php p($_['database']['type']);?></em></p>
- <p><?php p($l->t('Version:'));?> <em id="databaseVersion"><?php p($_['database']['version']);?></em></p>
- <p><?php p($l->t('Size:'));?> <em id="databaseSize"><?php p($_['database']['size']);?></em></p>
+ <p>
+ <?php p($l->t('Type:'));?>
+ <em id="databaseType"><?php p($_['database']['type']);?></em>
+ </p>
+ <p>
+ <?php p($l->t('Version:'));?>
+ <em id="databaseVersion"><?php p($_['database']['version']);?></em>
+ </p>
+ <p>
+ <?php p($l->t('Size:'));?>
+ <em id="databaseSize"><?php p($_['database']['size']);?></em>
+ </p>
</div>
</div>
+<!-- OCS ENDPOINT -->
<div class="section" id="ocsEndPoint">
<h2><?php p($l->t('External monitoring tool'));?></h2>
<p>
- <?php p($l->t('You can connect an external monitoring tool by using this end point:')); ?>
+ <?php p($l->t('You can connect an external monitoring tool by using this end point:'));?>
</p>
<div>
<input type="text" readonly="readonly" id="monitoring-endpoint-url" value="<?php echo p($_['ocs']); ?>" />
<a class="clipboardButton icon icon-clippy" data-clipboard-target="#monitoring-endpoint-url"></a>
- <span class="icon-info svg" title="" data-original-title="<?php p($l->t('Did you know?')); ?> <?php p($l->t('Appending "?format=json" at the end of the URL gives you the result in JSON format!')); ?>"></span>
+ <span class="icon-info svg" title="" data-original-title="<?php p($l->t('Did you know?'));?> <?php p($l->t('Appending "?format=json" at the end of the URL gives you the result in JSON format!'));?>"></span>
</div>
</div>