diff --git a/dist/prober.php b/dist/prober.php index 377f59bc..af1b1400 100644 --- a/dist/prober.php +++ b/dist/prober.php @@ -1,9 +1,10 @@ ZH_CN_URL; } return $this->DEFAULT_URL; } } -namespace InnStudio\Prober\Config; class Api { public static $APP_VERSION = '1.1.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'; public static $AUTHOR_NAME = 'INN STUDIO'; public static $CHANGELOG_URL = 'https://raw.githubusercontent.com/kmvan/x-prober/master/CHANGELOG.md'; } +namespace InnStudio\Prober\Benchmark; use InnStudio\Prober\Events\Api as Events; use InnStudio\Prober\Helper\Api as Helper; class Benchmark { public function __construct() { Events::on('init', array($this, 'filter')); } public function filter() { if ( ! Helper::isAction('benchmark')) { return; } $this->display(); } private function getPointsByTime($time) { \error_log($time); return \pow(10, 3) - (int) ($time * \pow(10, 3)); } private function getHashPoints() { $data = 'inn-studio.com'; $hash = array('md5', 'sha512', 'sha256', 'crc32'); $count = \pow(10, 5); $start = \microtime(true); for ($i = 0; $i < $count; ++$i) { foreach ($hash as $v) { \hash($v, $data); } } return $this->getPointsByTime(\microtime(true) - $start); } private function getIntLoopPoints() { $j = 0; $count = \pow(10, 7); $start = \microtime(true); for ($i = 0; $i < $count; ++$i) { ++$j; } return $this->getPointsByTime(\microtime(true) - $start); } private function getFloatLoopPoints() { $j = 1 / 3; $count = \pow(10, 7); $start = \microtime(true); for ($i = 0; $i < $count; ++$i) { ++$j; } return $this->getPointsByTime(\microtime(true) - $start); } private function getIoLoopPoints() { $tmpDir = \sys_get_temp_dir(); if ( ! \is_writable($tmpDir)) { return 0; } $count = \pow(10, 4); $start = \microtime(true); for ($i = 0; $i < $count; ++$i) { $filePath = "{$tmpDir}/innStudioIoBenchmark-{$i}"; \file_put_contents($filePath, $filePath); \unlink($filePath); } return $this->getPointsByTime(\microtime(true) - $start); } private function getPoints() { return array( 'hash' => $this->getHashPoints(), 'intLoop' => $this->getIntLoopPoints(), 'floatLoop' => $this->getFloatLoopPoints(), 'ioLoop' => $this->getIoLoopPoints(), ); } private function display() { \set_time_limit(0); Helper::dieJson(array( 'code' => 0, 'data' => array( 'points' => $this->getPoints(), ), )); } } +namespace InnStudio\Prober\Config; class Api { public static $APP_VERSION = '1.2.0'; 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'; public static $AUTHOR_NAME = 'INN STUDIO'; public static $CHANGELOG_URL = 'https://raw.githubusercontent.com/kmvan/x-prober/master/CHANGELOG.md'; } namespace InnStudio\Prober\Database; use InnStudio\Prober\Events\Api as Events; use InnStudio\Prober\Helper\Api as Helper; use InnStudio\Prober\I18n\Api as I18n; class Database { private $ID = 'database'; public function __construct() { Events::patch('mods', array($this, 'filter'), 500); } public function filter($mods) { $mods[$this->ID] = array( 'title' => I18n::_('Database'), 'tinyTitle' => I18n::_('DB'), 'display' => array($this, 'display'), ); return $mods; } public function display() { ?>
getContent(); ?>
I18n::_('SQLite3'), 'content' => $sqlite3Version, ), array( 'title' => 'sqlite_libversion', 'label' => I18n::_('SQLite'), 'content' => \function_exists('\sqlite_libversion') ? Helper::getIni(0, true) . ' ' . \sqlite_libversion() : Helper::getIni(0, false), ), array( 'title' => 'mysqli_get_client_version', 'label' => I18n::_('MySQLi client'), 'content' => Helper::getIni(0, true) . ' ' . \mysqli_get_client_version(), ), array( 'label' => I18n::_('Mongo'), 'content' => \class_exists('\Mongo') ? \MongoClient::VERSION : Helper::getIni(0, false), ), array( 'label' => I18n::_('MongoDB'), 'content' => \class_exists('\MongoDB') ? Helper::getIni(0, true) : Helper::getIni(0, false), ), array( 'label' => I18n::_('PostgreSQL'), 'content' => \function_exists('\pg_connect') ? Helper::getIni(0, true) : Helper::getIni(0, false), ), array( 'label' => I18n::_('Paradox'), 'content' => \function_exists('\px_new') ? Helper::getIni(0, true) : Helper::getIni(0, false), ), array( 'title' => I18n::_('Microsoft SQL Server Driver for PHP'), 'label' => I18n::_('MS SQL'), 'content' => \function_exists('\sqlsrv_server_info') ? Helper::getIni(0, true) : Helper::getIni(0, false), ), array( 'label' => I18n::_('File Pro'), 'content' => \function_exists('\filepro') ? Helper::getIni(0, true) : Helper::getIni(0, false), ), array( 'label' => I18n::_('MaxDB client'), 'content' => \function_exists('\maxdb_get_client_version') ? \maxdb_get_client_version() : Helper::getIni(0, false), ), array( 'label' => I18n::_('MaxDB server'), 'content' => \function_exists('\maxdb_get_server_version') ? Helper::getIni(0, true) : Helper::getIni(0, false), ), ); $content = ''; foreach ($items as $item) { $title = isset($item['title']) ? "title=\"{$item['title']}\"" : ''; $col = isset($item['col']) ? $item['col'] : '1-3'; $id = isset($item['id']) ? "id=\"{$item['id']}\"" : ''; echo <<
@@ -162,7 +163,7 @@
EOT; } return $content; } private function isOpcEnabled() { $isOpcEnabled = \function_exists('\opcache_get_configuration'); if ($isOpcEnabled) { $isOpcEnabled = \opcache_get_configuration(); $isOpcEnabled = isset($isOpcEnabled['directives']['opcache.enable']) && $isOpcEnabled['directives']['opcache.enable'] === true; } return $isOpcEnabled; } } -namespace InnStudio\Prober\PhpInfo; use InnStudio\Prober\Events\Api as Events; use InnStudio\Prober\Helper\Api as Helper; use InnStudio\Prober\I18n\Api as I18n; class PhpInfo { private $ID = 'phpInfo'; public function __construct() { Events::patch('mods', array($this, 'filter'), 300); } public function filter($mods) { $mods[$this->ID] = array( 'title' => I18n::_('PHP information'), 'tinyTitle' => I18n::_('PHP'), 'display' => array($this, 'display'), ); return $mods; } public function display() { ?>
getContent(); ?>
$this->_('PHP info detail'), 'content' => Helper::getBtn($this->_('Click to check'), '?action=phpInfo'), ), array( 'label' => $this->_('Version'), 'content' => PHP_VERSION, ), array( 'label' => $this->_('SAPI interface'), 'content' => PHP_SAPI, ), array( 'label' => $this->_('Error reporting'), 'title' => 'error_reporting', 'content' => Helper::getErrNameByCode(\ini_get('error_reporting')), ), array( 'label' => $this->_('Max memory limit'), 'title' => 'memory_limit', 'content' => \ini_get('memory_limit'), ), array( 'label' => $this->_('Max POST size'), 'title' => 'post_max_size', 'content' => \ini_get('post_max_size'), ), array( 'label' => $this->_('Max upload size'), 'title' => 'upload_max_filesize', 'content' => \ini_get('upload_max_filesize'), ), array( 'label' => $this->_('Max input variables'), 'title' => 'max_input_vars', 'content' => \ini_get('max_input_vars'), ), array( 'label' => $this->_('Max execution time'), 'title' => 'max_execution_time', 'content' => \ini_get('max_execution_time'), ), array( 'label' => $this->_('Timeout for socket'), 'title' => 'default_socket_timeout', 'content' => \ini_get('default_socket_timeout'), ), array( 'label' => $this->_('Display errors'), 'title' => 'display_errors', 'content' => Helper::getIni('display_errors'), ), array( 'label' => $this->_('Treatment URLs file'), 'title' => 'allow_url_fopen', 'content' => Helper::getIni('allow_url_fopen'), ), array( 'label' => $this->_('SMTP support'), 'title' => 'SMTP', 'content' => Helper::getIni('SMTP') ?: Helper::getIni(0, false), ), array( 'col' => '1-1', 'label' => $this->_('Disabled functions'), 'title' => 'disable_functions', 'content' => \implode(', ', \explode(',', Helper::getIni('disable_functions'))) ?: '-', ), ); $content = ''; foreach ($items as $item) { $title = isset($item['title']) ? "title=\"{$item['title']}\"" : ''; $col = isset($item['col']) ? $item['col'] : '1-3'; $id = isset($item['id']) ? "id=\"{$item['id']}\"" : ''; $content .= <<ID] = array( 'title' => I18n::_('PHP information'), 'tinyTitle' => I18n::_('PHP'), 'display' => array($this, 'display'), ); return $mods; } public function display() { ?>
getContent(); ?>
$this->_('PHP info detail'), 'content' => '👆 ' . Helper::getBtn($this->_('Click to check'), '?action=phpInfo'), ), array( 'label' => $this->_('Version'), 'content' => PHP_VERSION, ), array( 'label' => $this->_('SAPI interface'), 'content' => PHP_SAPI, ), array( 'label' => $this->_('Error reporting'), 'title' => 'error_reporting', 'content' => Helper::getErrNameByCode(\ini_get('error_reporting')), ), array( 'label' => $this->_('Max memory limit'), 'title' => 'memory_limit', 'content' => \ini_get('memory_limit'), ), array( 'label' => $this->_('Max POST size'), 'title' => 'post_max_size', 'content' => \ini_get('post_max_size'), ), array( 'label' => $this->_('Max upload size'), 'title' => 'upload_max_filesize', 'content' => \ini_get('upload_max_filesize'), ), array( 'label' => $this->_('Max input variables'), 'title' => 'max_input_vars', 'content' => \ini_get('max_input_vars'), ), array( 'label' => $this->_('Max execution time'), 'title' => 'max_execution_time', 'content' => \ini_get('max_execution_time'), ), array( 'label' => $this->_('Timeout for socket'), 'title' => 'default_socket_timeout', 'content' => \ini_get('default_socket_timeout'), ), array( 'label' => $this->_('Display errors'), 'title' => 'display_errors', 'content' => Helper::getIni('display_errors'), ), array( 'label' => $this->_('Treatment URLs file'), 'title' => 'allow_url_fopen', 'content' => Helper::getIni('allow_url_fopen'), ), array( 'label' => $this->_('SMTP support'), 'title' => 'SMTP', 'content' => Helper::getIni('SMTP') ?: Helper::getIni(0, false), ), array( 'col' => '1-1', 'label' => $this->_('Disabled functions'), 'title' => 'disable_functions', 'content' => \implode(', ', \explode(',', Helper::getIni('disable_functions'))) ?: '-', ), ); $content = ''; foreach ($items as $item) { $title = isset($item['title']) ? "title=\"{$item['title']}\"" : ''; $col = isset($item['col']) ? $item['col'] : '1-3'; $id = isset($item['id']) ? "id=\"{$item['id']}\"" : ''; $content .= <<
{$item['label']}
@@ -309,6 +310,52 @@ function fillNetworkStats(data) { request(); })(); ID] = array( 'title' => I18n::_('Server Benchmark'), 'tinyTitle' => I18n::_('Benchmark'), 'display' => array($this, 'display'), ); return $mods; } public function display() { ?>

+
getContent(); ?>
I18n::_('My server'), 'content' => '👆 ' . I18n::_('Click to test') . '', ), array( 'label' => '' . I18n::_('Aliyun/ECS/PHP7') . '', 'content' => 3302, ), array( 'label' => '' . I18n::_('Vultr/PHP7') . '', 'content' => 3182, ), array( 'label' => '' . I18n::_('Linode/PHP7') . '', 'content' => 3091, ), array( 'label' => '' . I18n::_('AnyNode/HDD/PHP7') . '', 'content' => 2641, ), array( 'label' => '' . I18n::_('Aliyun/Int/PHP5') . '', 'content' => -7686, ), ); $content = ''; foreach ($items as $item) { $title = isset($item['title']) ? "title=\"{$item['title']}\"" : ''; $col = isset($item['col']) ? $item['col'] : '1-3'; $id = isset($item['id']) ? "id=\"{$item['id']}\"" : ''; echo << +
+
{$item['label']}
+
{$item['content']}
+
+
+EOT; +} } } namespace InnStudio\Prober\ServerInfo; use InnStudio\Prober\Events\Api as Events; use InnStudio\Prober\Helper\Api as Helper; use InnStudio\Prober\I18n\Api as I18n; class ServerInfo { private $ID = 'serverInfo'; public function __construct() { Events::patch('mods', array($this, 'filter'), 200); } public function filter($mods) { $mods[$this->ID] = array( 'title' => I18n::_('Server information'), 'tinyTitle' => I18n::_('Info'), 'display' => array($this, 'display'), ); return $mods; } public function display() { ?>
getContent(); ?>
{$percent}%
@@ -530,6 +577,7 @@ function fillNetworkStats(data) { } } fieldset{ +position: relative; border: 5px solid #eee; border-radius: .5rem; padding: 0; @@ -545,6 +593,14 @@ function fillNetworkStats(data) { color: #fff; margin: 0 auto; } +p{ +margin: 0 0 1rem; +} +.description{ +margin: 0; +padding-left: 1rem; +font-style: italic; +}