mirror of
https://github.com/kmvan/x-prober.git
synced 2026-08-13 02:11:38 +08:00
fixed disk display error in some OS
adjust code to read easily
This commit is contained in:
+5
-1
@@ -1,7 +1,11 @@
|
||||
# Changelog
|
||||
# Changelog
|
||||
|
||||
All Notable changes to `x-prober` will be documented in this file
|
||||
|
||||
## 1.3.1 - 2018-03-01
|
||||
### Fixed
|
||||
- Fixed disk display error in some OS
|
||||
- Fixed translation
|
||||
|
||||
## 1.3.0 - 2017-12-11
|
||||
### Added
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[](https://wx3.sinaimg.cn/large/686ee05dly1fkvkxkwyhzj21gu0d2my8.jpg)
|
||||
[](https://wx3.sinaimg.cn/large/686ee05dly1fkvkxkwyhzj21gu0d2my8.jpg)
|
||||
|
||||
# 😎 x-prober
|
||||
> This is a prober program for PHP environment. It can show your server information and readable easily. And most important is IT'S LIKE iPhone X!
|
||||
@@ -21,7 +21,8 @@
|
||||
## Compile and Usage
|
||||
- Star and clone.
|
||||
- Check the config ./src/Config/Api.php
|
||||
- Compile: php ./compile.php dev
|
||||
- Compile development: php ./compile.php dev
|
||||
- Compile production: php ./compile.php
|
||||
- Access ./dist/prober.php
|
||||
- Enjoy
|
||||
|
||||
|
||||
Vendored
+75
-43
File diff suppressed because one or more lines are too long
+1
-1
@@ -4,7 +4,7 @@ namespace InnStudio\Prober\Config;
|
||||
|
||||
class Api
|
||||
{
|
||||
public static $APP_VERSION = '1.3.0';
|
||||
public static $APP_VERSION = '1.3.1';
|
||||
public static $APP_NAME = 'X Prober';
|
||||
public static $APP_URL = 'https://github.com/kmvan/x-prober';
|
||||
public static $AUTHOR_URL = 'https://inn-studio.com/prober';
|
||||
|
||||
@@ -97,14 +97,14 @@ class Database
|
||||
$col = isset($item['col']) ? $item['col'] : '1-3';
|
||||
$id = isset($item['id']) ? "id=\"{$item['id']}\"" : '';
|
||||
|
||||
echo <<<EOT
|
||||
echo <<<HTML
|
||||
<div class="poi-g-lg-{$col}">
|
||||
<div class="form-group">
|
||||
<div class="group-label" {$title}>{$item['label']}</div>
|
||||
<div class="group-content" {$id} {$title}>{$item['content']}</div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+41
-10
@@ -36,7 +36,7 @@ class Api
|
||||
$total = (int) $total / \count($server);
|
||||
$cpus['idle'] = 100 - $total;
|
||||
$cpus['user'] = $total;
|
||||
// exec
|
||||
// exec
|
||||
} else {
|
||||
\exec('wmic cpu get LoadPercentage', $p);
|
||||
|
||||
@@ -83,7 +83,9 @@ class Api
|
||||
|
||||
public static function getBtn($tx, $url)
|
||||
{
|
||||
return '<a href="' . $url . '" target="_blank" class="btn">' . $tx . '</a>';
|
||||
return <<<HTML
|
||||
<a href="{$url}" target="_blank" class="btn">{$tx}</a>
|
||||
HTML;
|
||||
}
|
||||
|
||||
public static function getDiskTotalSpace($human = false)
|
||||
@@ -110,7 +112,11 @@ class Api
|
||||
static $space = null;
|
||||
|
||||
if (null === $space) {
|
||||
$space = \disk_free_space('/');
|
||||
try {
|
||||
$space = \disk_free_space('/');
|
||||
} catch (\Exception $e) {
|
||||
$space = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $space) {
|
||||
@@ -215,9 +221,13 @@ class Api
|
||||
}
|
||||
|
||||
if (1 === (int) $ini) {
|
||||
return '<span class="ini-ok">✓</span>';
|
||||
return <<<HTML
|
||||
<span class="ini-ok">✓</span>
|
||||
HTML;
|
||||
} elseif (0 === (int) $ini) {
|
||||
return '<span class="ini-error">×</span>';
|
||||
return <<<HTML
|
||||
<span class="ini-error">×</span>
|
||||
HTML;
|
||||
}
|
||||
|
||||
return $ini;
|
||||
@@ -357,7 +367,10 @@ class Api
|
||||
$html = '';
|
||||
|
||||
foreach ($cpu as $k => $v) {
|
||||
$html .= '<span class="small-group"><span class="item-name">' . $k . '</span> <span class="item-value">' . $v . '</span></span>';
|
||||
$html .= <<<HTML
|
||||
<span class="small-group"><span class="item-name">{$k}</span>
|
||||
<span class="item-value">{$v}</span></span>
|
||||
HTML;
|
||||
}
|
||||
|
||||
return $html;
|
||||
@@ -376,11 +389,29 @@ class Api
|
||||
return I18n::_('Not support on Windows');
|
||||
}
|
||||
|
||||
$avg = \sys_getloadavg();
|
||||
$avg = \sys_getloadavg();
|
||||
$langMin = function ($n) {
|
||||
return \sprintf(I18n::_('%d min:'), $n);
|
||||
};
|
||||
|
||||
$avg[0] = '<span class="small-group"><span class="item-name">' . I18n::_('1 min:') . "</span> {$avg[0]}</span>";
|
||||
$avg[1] = '<span class="small-group"><span class="item-name">' . I18n::_('5 min:') . "</span> {$avg[1]}</span>";
|
||||
$avg[2] = '<span class="small-group"><span class="item-name">' . I18n::_('15 min:') . "</span> {$avg[2]}</span>";
|
||||
$avg[0] = <<<HTML
|
||||
<span class="small-group">
|
||||
<span class="item-name">{$langMin(1)}</span>
|
||||
{$avg[0]}
|
||||
</span>
|
||||
HTML;
|
||||
$avg[1] = <<<HTML
|
||||
<span class="small-group">
|
||||
<span class="item-name">{$langMin(5)}</span>
|
||||
{$avg[1]}
|
||||
</span>
|
||||
HTML;
|
||||
$avg[2] = <<<HTML
|
||||
<span class="small-group">
|
||||
<span class="item-name">{$langMin(15)}</span>
|
||||
{$avg[2]}
|
||||
</span>
|
||||
HTML;
|
||||
|
||||
return \implode('', $avg);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class MyInfo
|
||||
{
|
||||
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
||||
|
||||
return <<<EOT
|
||||
return <<<HTML
|
||||
<div class="form-group">
|
||||
<div class="group-label">{$this->_('My IP')}</div>
|
||||
<div class="group-content">{$this->getClientIp()}</div>
|
||||
@@ -44,7 +44,7 @@ class MyInfo
|
||||
<div class="group-label">{$this->_('My UA')}</div>
|
||||
<div class="group-content">{$ua}</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
|
||||
private function getClientIp()
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ class Nav
|
||||
|
||||
public function filterStyle()
|
||||
{
|
||||
?>
|
||||
echo <<<HTML
|
||||
<style>
|
||||
.nav {
|
||||
position: fixed;
|
||||
@@ -63,12 +63,12 @@ class Nav
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function filterScript()
|
||||
{
|
||||
?>
|
||||
echo <<<HTML
|
||||
<script>
|
||||
(function(){
|
||||
var fieldsets = document.querySelectorAll('fieldset');
|
||||
@@ -92,6 +92,6 @@ for(var i = 0; i < fieldsets.length; i++) {
|
||||
document.body.appendChild(nav);
|
||||
})()
|
||||
</script>
|
||||
<?php
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,16 +63,18 @@ class NetworkStats
|
||||
$txHuman = Helper::formatBytes($item['tx']);
|
||||
$items[] = array(
|
||||
'label' => $ethName,
|
||||
'content' => "<div class=\"network-stats-container\">
|
||||
<div class=\"rx\">
|
||||
<div><span id=\"network-{$ethName}-rx-total\">{$rxHuman}</span></div>
|
||||
<div><span class=\"icon\">▼</span><span id=\"network-{$ethName}-rx-rate\">0</span><span class=\"second\">/s</span></div>
|
||||
</div>
|
||||
<div class=\"tx\">
|
||||
<div><span id=\"network-{$ethName}-tx-total\">{$txHuman}</span></div>
|
||||
<div><span class=\"icon\">▲</span><span id=\"network-{$ethName}-tx-rate\">0</span><span class=\"second\">/s</span></div>
|
||||
</div>
|
||||
</div>",
|
||||
'content' => <<<HTML
|
||||
<div class="network-stats-container">
|
||||
<div class="rx">
|
||||
<div><span id="network-{$ethName}-rx-total">{$rxHuman}</span></div>
|
||||
<div><span class="icon">▼</span><span id="network-{$ethName}-rx-rate">0</span><span class="second">/s</span></div>
|
||||
</div>
|
||||
<div class="tx">
|
||||
<div><span id="network-{$ethName}-tx-total">{$txHuman}</span></div>
|
||||
<div><span class="icon">▲</span><span id="network-{$ethName}-tx-rate">0</span><span class="second">/s</span></div>
|
||||
</div>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,14 +84,14 @@ class NetworkStats
|
||||
$title = isset($item['title']) ? "title=\"{$item['title']}\"" : '';
|
||||
$col = isset($item['col']) ? $item['col'] : '1-1';
|
||||
$id = isset($item['id']) ? "id=\"{$item['id']}\"" : '';
|
||||
$content .= <<<EOT
|
||||
$content .= <<<HTML
|
||||
<div class="poi-g-lg-{$col}">
|
||||
<div class="form-group">
|
||||
<div class="group-label" {$title}>{$item['label']}</div>
|
||||
<div class="group-content" {$title} {$id}>{$item['content']}</div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
@@ -28,11 +28,11 @@ class PhpExtensionInfo
|
||||
|
||||
public function display()
|
||||
{
|
||||
?>
|
||||
echo <<<HTML
|
||||
<div class="row">
|
||||
<?php echo $this->getContent(); ?>
|
||||
{$this->getContent()}
|
||||
</div>
|
||||
<?php
|
||||
HTML;
|
||||
}
|
||||
|
||||
private function getContent()
|
||||
@@ -70,14 +70,14 @@ class PhpExtensionInfo
|
||||
$title = isset($item['title']) ? "title=\"{$item['title']}\"" : '';
|
||||
$col = isset($item['col']) ? $item['col'] : '1-3';
|
||||
$id = isset($item['id']) ? "id=\"{$item['id']}\"" : '';
|
||||
$content .= <<<EOT
|
||||
$content .= <<<HTML
|
||||
<div class="poi-g-lg-{$col}">
|
||||
<div class="form-group">
|
||||
<div class="group-label" {$title}>{$item['label']}</div>
|
||||
<div class="group-content" {$title} {$id}>{$item['content']}</div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
@@ -114,14 +114,14 @@ class PhpInfo
|
||||
$title = isset($item['title']) ? "title=\"{$item['title']}\"" : '';
|
||||
$col = isset($item['col']) ? $item['col'] : '1-3';
|
||||
$id = isset($item['id']) ? "id=\"{$item['id']}\"" : '';
|
||||
$content .= <<<EOT
|
||||
$content .= <<<HTML
|
||||
<div class="poi-g-lg-{$col}">
|
||||
<div class="form-group">
|
||||
<div class="group-label" {$title}>{$item['label']}</div>
|
||||
<div class="group-content" {$title} {$id}>{$item['content']}</div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
@@ -15,7 +15,7 @@ class Script
|
||||
|
||||
public function filter()
|
||||
{
|
||||
?>
|
||||
echo <<<HTML
|
||||
<script>
|
||||
(function () {
|
||||
var xhr = new XMLHttpRequest();
|
||||
@@ -186,6 +186,6 @@ class Script
|
||||
request();
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,13 @@ class ServerBenchmark
|
||||
|
||||
public function display()
|
||||
{
|
||||
?>
|
||||
<p class="description"><?= I18n::_('💡 Hight is better.'); ?></p>
|
||||
$lang = I18n::_('💡 Hight is better.');
|
||||
echo <<<HTML
|
||||
<p class="description">{$lang}</p>
|
||||
<div class="row">
|
||||
<?php echo $this->getContent(); ?>
|
||||
{$this->getContent()}
|
||||
</div>
|
||||
<?php
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function filterJs()
|
||||
@@ -135,14 +136,16 @@ class ServerBenchmark
|
||||
$col = isset($item['col']) ? $item['col'] : '1-3';
|
||||
$id = isset($item['id']) ? "id=\"{$item['id']}\"" : '';
|
||||
|
||||
echo <<<EOT
|
||||
$content .= <<<HTML
|
||||
<div class="poi-g-lg-{$col}">
|
||||
<div class="form-group">
|
||||
<div class="group-label" {$title}>{$item['label']}</div>
|
||||
<div class="group-content" {$id} {$title}>{$item['content']}</div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,21 +45,19 @@ class ServerInfo
|
||||
$hunamUsed = Helper::formatBytes(Helper::getDiskTotalSpace() - Helper::getDiskFreeSpace());
|
||||
$hunamTotal = Helper::getDiskTotalSpace(true);
|
||||
|
||||
return <<<EOT
|
||||
return <<<HTML
|
||||
<div class="progress-container">
|
||||
<div class="percent" id="diskUsagePercent">{$percent}%</div>
|
||||
<div class="number">
|
||||
<span id="diskUsage">
|
||||
{$hunamUsed}
|
||||
/
|
||||
{$hunamTotal}
|
||||
{$hunamUsed} / {$hunamTotal}
|
||||
</span>
|
||||
</div>
|
||||
<div class="progress" id="diskUsageProgress">
|
||||
<div id="diskUsageProgressValue" class="progress-value" style="width: {$percent}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
|
||||
private function getContent()
|
||||
@@ -121,14 +119,14 @@ EOT;
|
||||
$col = isset($item['col']) ? $item['col'] : '1-3';
|
||||
$id = isset($item['id']) ? "id=\"{$item['id']}\"" : '';
|
||||
|
||||
echo <<<EOT
|
||||
echo <<<HTML
|
||||
<div class="poi-g-lg-{$col}">
|
||||
<div class="form-group">
|
||||
<div class="group-label" {$title}>{$item['label']}</div>
|
||||
<div class="group-content" {$id} {$title}>{$item['content']}</div>
|
||||
</div>
|
||||
</div>
|
||||
EOT;
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user