ID)) { return $conf; } $sqlite3Version = class_exists('SQLite3') ? SQLite3::version() : false; $conf[$this->ID] = array( 'sqlite3' => $sqlite3Version ? $sqlite3Version['versionString'] : false, 'sqliteLibversion' => \function_exists('sqlite_libversion') ? sqlite_libversion() : false, 'mysqliClientVersion' => \function_exists('mysqli_get_client_version') ? mysqli_get_client_version() : false, 'mongo' => class_exists('Mongo'), 'mongoDb' => class_exists('MongoDB'), 'postgreSql' => \function_exists('pg_connect'), 'paradox' => \function_exists('px_new'), 'msSql' => \function_exists('sqlsrv_server_info'), 'pdo' => class_exists('PDO') ? implode(',', PDO::getAvailableDrivers()) : false, ); return $conf; }); } } namespace InnStudio\Prober\Components\Database; class DatabaseConstants { protected $ID = 'database'; } namespace InnStudio\Prober\Components\Database; final class Database { public function __construct() { new Conf(); } } namespace InnStudio\Prober\Components\Nodes; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; final class Fetch extends NodesApi { public function __construct() { EventsApi::on('init', function ($action) { switch ($action) { case 'nodes': EventsApi::emit('fetchNodesBefore'); $response = new RestResponse(EventsApi::emit('nodes', array())); $response->json()->end(); case 'node': EventsApi::emit('fetchNodeBefore'); $nodeId = filter_input(\INPUT_GET, 'nodeId', \FILTER_DEFAULT); $response = new RestResponse(); if ( ! $nodeId) { $response->setStatus(StatusCode::$BAD_REQUEST)->json()->end(); } $data = $this->getNodeData($nodeId); if ( ! $data) { $response->setStatus(StatusCode::$NO_CONTENT)->json()->end(); } $response->setData($data)->json()->end(); } return $action; }, 100); } private function getNodeData($nodeId) { foreach ($this->getNodes() as $item) { if ( ! isset($item['id']) || ! isset($item['url']) || $item['id'] !== $nodeId) { continue; } return $this->getRemoteContent("{$item['url']}?action=fetch"); } } private function getRemoteContent($url) { $content = ''; if (\function_exists('curl_init')) { $ch = curl_init(); curl_setopt_array($ch, array( \CURLOPT_URL => $url, \CURLOPT_RETURNTRANSFER => true, )); $content = curl_exec($ch); curl_close($ch); return json_decode($content, true) ?: null; } return json_decode(file_get_contents($url), true) ?: null; } } namespace InnStudio\Prober\Components\Nodes; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends NodesApi { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array( 'items' => $this->getNodes(), ); return $conf; }); } } namespace InnStudio\Prober\Components\Nodes; final class Nodes { public function __construct() { new Conf(); new Fetch(); } } namespace InnStudio\Prober\Components\Nodes; use InnStudio\Prober\Components\Xconfig\XconfigApi; class NodesApi { public $ID = 'nodes'; public function getNodes() { $items = XconfigApi::getNodes(); if ( ! $items || ! \is_array($items)) { return array(); } return array_filter(array_map(function ($item) { if (2 !== \count($item)) { return; } return array( 'id' => $item[0], 'url' => $item[1], ); }, $items)); } } namespace InnStudio\Prober\Components\ServerInfo; class ServerInfoConstants { protected $ID = 'serverInfo'; protected $FEATURE_SERVER_IP = 'serverIp'; } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsDisk; use InnStudio\Prober\Components\Utils\UtilsTime; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Fetch extends ServerInfoConstants { public function __construct() { EventsApi::on('fetch', array($this, 'filter')); EventsApi::on('nodes', array($this, 'filter')); } public function filter(array $items) { if (XconfigApi::isDisabled($this->ID)) { return $items; } $items[$this->ID] = array( 'serverUtcTime' => UtilsTime::getUtcTime(), 'serverTime' => UtilsTime::getTime(), 'serverUptime' => UtilsTime::getUptime(), 'diskUsage' => array( 'value' => UtilsDisk::getTotal() - UtilsDisk::getFree(), 'max' => UtilsDisk::getTotal(), ), ); return $items; } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Utils\UtilsServerIp; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class ServerInitIpv4 extends ServerInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if ('serverIpv4' !== $action) { return $action; } if (XconfigApi::isDisabled($this->ID)) { return $action; } if (XconfigApi::isDisabled($this->FEATURE_SERVER_IP)) { return $action; } $response = new RestResponse(); $response->setData(array( 'ip' => UtilsServerIp::getV4(), ))->json()->end(); }); } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Rest\StatusCode; use InnStudio\Prober\Components\Utils\UtilsLocation; use InnStudio\Prober\Components\Utils\UtilsServerIp; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class ServerLocationIpv4 extends ServerInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if ('serverLocationIpv4' !== $action) { return $action; } if (XconfigApi::isDisabled($this->ID)) { return $action; } if (XconfigApi::isDisabled($this->FEATURE_SERVER_IP)) { return $action; } $response = new RestResponse(); $ip = UtilsServerIp::getV4(); if ( ! $ip) { $response->setStatus(StatusCode::$BAD_REQUEST)->json()->end(); } $response->setData(UtilsLocation::getLocation($ip))->json()->end(); }); } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Utils\UtilsCpu; use InnStudio\Prober\Components\Utils\UtilsDisk; use InnStudio\Prober\Components\Utils\UtilsTime; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class Conf extends ServerInfoConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { if (XconfigApi::isDisabled($this->ID)) { return $conf; } $conf[$this->ID] = array( 'serverName' => $this->getServerInfo('SERVER_NAME'), 'serverUtcTime' => UtilsTime::getUtcTime(), 'serverTime' => UtilsTime::getTime(), 'serverUptime' => UtilsTime::getUptime(), 'serverIp' => XconfigApi::isDisabled('serverIp') ? '-' : $this->getServerInfo('SERVER_ADDR'), 'serverSoftware' => $this->getServerInfo('SERVER_SOFTWARE'), 'phpVersion' => \PHP_VERSION, 'cpuModel' => UtilsCpu::getModel(), 'serverOs' => php_uname(), 'scriptPath' => __FILE__, 'diskUsage' => array( 'value' => UtilsDisk::getTotal() - UtilsDisk::getFree(), 'max' => UtilsDisk::getTotal(), ), ); return $conf; }); } private function getServerInfo($key) { return isset($_SERVER[$key]) ? $_SERVER[$key] : ''; } } namespace InnStudio\Prober\Components\ServerInfo; final class ServerInfo { public function __construct() { new Conf(); new Fetch(); new ServerInitIpv4(); new ServerInitIpv6(); new ServerLocationIpv4(); } } namespace InnStudio\Prober\Components\ServerInfo; use InnStudio\Prober\Components\Events\EventsApi; use InnStudio\Prober\Components\Rest\RestResponse; use InnStudio\Prober\Components\Utils\UtilsServerIp; use InnStudio\Prober\Components\Xconfig\XconfigApi; final class ServerInitIpv6 extends ServerInfoConstants { public function __construct() { EventsApi::on('init', function ($action) { if ('serverIpv6' !== $action) { return $action; } if (XconfigApi::isDisabled($this->ID)) { return $action; } if (XconfigApi::isDisabled($this->FEATURE_SERVER_IP)) { return $action; } $response = new RestResponse(); $response->setData(array( 'ip' => UtilsServerIp::getV6(), ))->json()->end(); }); } } namespace InnStudio\Prober\Components\Bootstrap; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; final class Conf extends BootstrapConstants { public function __construct() { EventsApi::on('conf', function (array $conf) { $conf[$this->ID] = array( 'isDev' => XPROBER_IS_DEV, 'version' => ConfigApi::$APP_VERSION, 'appName' => ConfigApi::$APP_NAME, 'appUrl' => ConfigApi::$APP_URL, 'appConfigUrls' => ConfigApi::$APP_CONFIG_URLS, 'appConfigUrlDev' => ConfigApi::$APP_CONFIG_URL_DEV, 'authorUrl' => ConfigApi::$AUTHOR_URL, 'authorName' => ConfigApi::$AUTHOR_NAME, 'authorization' => isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : '', ); return $conf; }); } } namespace InnStudio\Prober\Components\Bootstrap; use InnStudio\Prober\Components\Config\ConfigApi; use InnStudio\Prober\Components\Events\EventsApi; final class Render { public function __construct() { $appName = ConfigApi::$APP_NAME; $version = ConfigApi::$APP_VERSION; $scriptConf = json_encode(EventsApi::emit('conf', array())); $styleUrl = \defined('XPROBER_IS_DEV') && XPROBER_IS_DEV ? 'app.css' : "?action=style&v={$version}"; $scriptUrl = \defined('XPROBER_IS_DEV') && XPROBER_IS_DEV ? 'app.js' : "?action=script&v={$version}"; echo <<
e||125