-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate the Laravel Queue migration in case you want to use database…
… queues. Provide that as a default in config example. Rewrite system/status page using blade templates because the XHR/Ajax didnt really add anything useful except a delay. Create new route for just displaying phpinfo which we used instead of parsing the output into a table which can be bad for generating errors. Disabled routes /system/DataBaseInfo and /system/phpInfo because they are server side now. Don't do client side sorting of navigation menus (listings) Database upgrade page really didnt need a disclosure control because having it minimised means nothing at all. Move all the system diag functions into App\SystemInformation so they dont live in controllers Migrated the system summary widgets into a blade component based system, provided the "table" widget as an example.
- Loading branch information
Showing
22 changed files
with
433 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
|
||
/** | ||
* This class provides access to information about the system that MunkiReport is running on. | ||
* | ||
* Various methods are extracted from \Compatibility\Kiss\Database AKA munkireport\lib\Database | ||
*/ | ||
class SystemInformation | ||
{ | ||
/** | ||
* Get information about the current database and its configuration. | ||
* Also returns some runtime information about the database if it is connectable. | ||
* | ||
* @return array A hash of information about the database. The keys are i18n codes. | ||
* @throws \PDOException if an unsupported attribute was retrieved from the database, in general this should be caught by testing. | ||
*/ | ||
public static function getDatabaseInformation(): array | ||
{ | ||
$connection = DB::connection(config('database.default')); | ||
|
||
$version = $connection->getPdo()?->getAttribute(\PDO::ATTR_SERVER_VERSION); | ||
$info = $connection->getPdo()?->getAttribute(\PDO::ATTR_SERVER_INFO); | ||
$status = $connection->getPdo()?->getAttribute(\PDO::ATTR_CONNECTION_STATUS); | ||
$client = $connection->getPdo()?->getAttribute(\PDO::ATTR_CLIENT_VERSION); | ||
|
||
try { | ||
$timeout = $connection->getPdo()?->getAttribute(\PDO::ATTR_TIMEOUT); | ||
} catch (\PDOException $e) { | ||
$timeout = null; | ||
} | ||
|
||
$data = [ | ||
'db.driver' => $connection->getDriverName(), | ||
'database' => $connection->getDatabaseName(), | ||
'db.prefix' => $connection->getTablePrefix(), | ||
'version' => $version, | ||
'db.method' => $status, | ||
'db.client.version' => $client, | ||
'db.info' => $info, | ||
'timeout' => $timeout, | ||
]; | ||
|
||
switch ($connection->getDriverName()) { | ||
case 'mysql': | ||
$size = DB::table('information_schema.tables', 't') | ||
->select(DB::raw('SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 ), 2)) AS size')) | ||
->where('table_schema', '=', $connection->getDatabaseName()) | ||
->first()->size; | ||
$data['db.size'] = "{$size} MB"; | ||
break; | ||
case 'sqlite': | ||
$pageSize = DB::select('PRAGMA PAGE_SIZE'); | ||
$pageCount = DB::select('PRAGMA PAGE_COUNT'); | ||
break; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* Get information about the current PHP runtime and its configuration by parsing the HTML output of phpinfo(). | ||
* | ||
* This is not very sustainable and some variables may use php functions in future to avoid the HTML output change | ||
* causing breakage. | ||
* | ||
* @return array PHP information scraped from the phpinfo() output buffer. | ||
*/ | ||
public static function getPhpInformation(): array | ||
{ | ||
ob_start(); | ||
phpinfo(11); | ||
$raw = ob_get_clean(); | ||
$phpinfo = array('phpinfo' => array()); | ||
|
||
// Remove credits | ||
$nocreds = preg_replace('#<h1>PHP Credits.*#s', '', $raw); | ||
if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', $nocreds, $matches, PREG_SET_ORDER)) { | ||
foreach ($matches as $match) { | ||
if (strlen($match[1])) { | ||
$phpinfo[$match[1]] = array(); | ||
} elseif (isset($match[3])) { | ||
$keys1 = array_keys($phpinfo); | ||
$phpinfo[end($keys1)][$match[2]] = isset($match[4]) ? $match[3] . ' ('.$match[4].')' : str_replace(',', ', ', $match[3]); | ||
} else { | ||
$keys1 = array_keys($phpinfo); | ||
$phpinfo[end($keys1)][] = trim(strip_tags($match[2])); | ||
} | ||
} | ||
} | ||
|
||
return $phpinfo; | ||
} | ||
|
||
/** | ||
* Get information about the current PHP runtime and configuration using runtime function calls instead of | ||
* HTML parsing. Should be used in place of getPhpInformation() | ||
* | ||
* @return array | ||
*/ | ||
public static function getPhpInformationByFunc(): array | ||
{ | ||
return [ | ||
'php.version' => phpversion(), | ||
'php.uname' => php_uname(), | ||
'php.loaded_extensions' => get_loaded_extensions(), | ||
'php.ini_loaded_file' => php_ini_loaded_file(), | ||
'php.ini_scanned_files' => php_ini_scanned_files(), | ||
'php.memory_peak_usage' => memory_get_peak_usage(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\View\Components\Widget\Detail; | ||
|
||
use Illuminate\View\Component; | ||
use Compatibility\Kiss\View; | ||
use munkireport\lib\Widgets; | ||
|
||
class Legacy extends Component | ||
{ | ||
/** | ||
* @var string Widget name/template name | ||
*/ | ||
public $name; | ||
|
||
public $data; | ||
|
||
/** | ||
* Create a new component instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(string $name, ?array $data) | ||
{ | ||
$this->name = $name; | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
* | ||
* @return string | ||
*/ | ||
public function render(): string | ||
{ | ||
$obj = new View(); | ||
$widget = app(Widgets::class)->getDetail($this->data); | ||
$output = $obj->viewFetch($widget['file'], $widget['vars'], $widget['path']); | ||
return $output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.