mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 03:26:20 +05:30
Added a "Health" page for admins/editors.
Added a page for admins/editors to do a quick spot check to make sure their webserver settings are healthy by doing a quick check for PHP version, PHP modules, and critical directories are writable.
This commit is contained in:
parent
cd7778f398
commit
bbeb9b6e3d
5 changed files with 125 additions and 1 deletions
|
|
@ -407,4 +407,15 @@ backtotop = "Back to top"
|
|||
subpages = "Sub pages"
|
||||
getstarted = "Get started"
|
||||
onthispage = "On this page"
|
||||
cache_folder_not_writable = "/cache/ directory is not writable, please update the permissions/ownership to continue."
|
||||
cache_folder_not_writable = "/cache/ directory is not writable, please update the permissions/ownership to continue."
|
||||
health_check = "Health Check"
|
||||
directory_permissions = "Directory Permissions"
|
||||
cache_folder_writable = "/cache/ directory is writable."
|
||||
content_folder_not_writable = "/content/ directory is not writable, please update the permissions/ownership to continue."
|
||||
content_folder_writable = "/content/ directory is writable."
|
||||
users_folder_not_writable = "/config/users/ directory is not writable, please update the permissions/ownership to continue."
|
||||
users_folder_writable = "/config/users/ directory is writable."
|
||||
php_check = "PHP Version"
|
||||
php_version_check_passed = "PHP version meets the minimum requirement."
|
||||
php_version_check_failed = "PHP version does not meet the minimum requirement. Please upgrade your PHP version."
|
||||
php_modules = "PHP Modules"
|
||||
|
|
|
|||
|
|
@ -1674,6 +1674,7 @@ EOF;
|
|||
}
|
||||
if ($role === 'editor' || $role === 'admin') {
|
||||
$toolbar .= '<li class="tb-clearcache"><a href="' . $base . 'admin/clear-cache">' . i18n('Clear_cache') . '</a></li>';
|
||||
$toolbar .= '<li class="tb-health"><a href="' . $base . 'admin/health">' . i18n('health_check') . '</a></li>';
|
||||
}
|
||||
$toolbar .= '<li class="tb-editprofile"><a href="' . $base . 'edit/profile">' . i18n('Edit_profile') . '</a></li>';
|
||||
$toolbar .= '<li class="tb-logout"><a href="' . $base . 'logout">' . i18n('Logout') . '</a></li>';
|
||||
|
|
|
|||
70
system/admin/views/health.html.php
Normal file
70
system/admin/views/health.html.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<?php
|
||||
|
||||
$CSRF = get_csrf();
|
||||
|
||||
echo '<h2>'.i18n('health_check').'</h2><hr>';
|
||||
|
||||
echo '<h3>'.i18n('php_check').'</h3>';
|
||||
|
||||
$requiredPhpVersion = '7.2';
|
||||
if (version_compare(PHP_VERSION, $requiredPhpVersion, '>=')) {
|
||||
echo '<p> ✅ '.i18n('php_version_check_passed').' (Current: '.PHP_VERSION.', Required: '.$requiredPhpVersion.')</p>';
|
||||
} else {
|
||||
echo '<p> ❌ '.i18n('php_version_check_failed').' (Current: '.PHP_VERSION.', Required: '.$requiredPhpVersion.')</p>';
|
||||
}
|
||||
|
||||
echo '<h3>'.i18n('directory_permissions').'</h3>';
|
||||
|
||||
$cachedir = 'cache/';
|
||||
if (!is_writable($cachedir)) {
|
||||
echo '<p> ❌ '.i18n('cache_folder_not_writable').'</p>';
|
||||
} else {
|
||||
echo '<p> ✅ '.i18n('cache_folder_writable').'</p>';
|
||||
}
|
||||
|
||||
$contentdir = 'content/';
|
||||
if (!is_writable($contentdir)) {
|
||||
echo '<p> ❌ '.i18n('content_folder_not_writable').'</p>';
|
||||
} else {
|
||||
echo '<p> ✅ '.i18n('content_folder_writable').'</p>';
|
||||
}
|
||||
|
||||
$usersdir = 'config/users/';
|
||||
if (!is_writable($usersdir)) {
|
||||
echo '<p> ❌ '.i18n('users_folder_not_writable').'</p>';
|
||||
} else {
|
||||
echo '<p> ✅ '.i18n('users_folder_writable').'</p>';
|
||||
}
|
||||
|
||||
echo '<h3>'.i18n('php_modules').'</h3>';
|
||||
|
||||
$requiredChecks = array(
|
||||
'json' => extension_loaded('json'),
|
||||
'mbstring' => extension_loaded('mbstring'),
|
||||
'libxml' => extension_loaded('libxml'),
|
||||
'dom' => extension_loaded('dom') && class_exists('DOMDocument'),
|
||||
'simplexml' => extension_loaded('simplexml') && class_exists('SimpleXMLElement'),
|
||||
'xml' => extension_loaded('xml'),
|
||||
'hash' => extension_loaded('hash'),
|
||||
'session' => extension_loaded('session'),
|
||||
'pcre' => extension_loaded('pcre'),
|
||||
'filter' => extension_loaded('filter'),
|
||||
'ctype' => extension_loaded('ctype'),
|
||||
'openssl' => extension_loaded('openssl'),
|
||||
'zip' => extension_loaded('zip') && class_exists('ZipArchive'),
|
||||
'gd' => extension_loaded('gd') && function_exists('gd_info'),
|
||||
'iconv' => extension_loaded('iconv') && function_exists('iconv'),
|
||||
'intl' => extension_loaded('intl'),
|
||||
'apcu' => extension_loaded('apcu'),
|
||||
'mcrypt' => extension_loaded('mcrypt'),
|
||||
);
|
||||
|
||||
foreach ($requiredChecks as $label => $ok) {
|
||||
if ($ok) {
|
||||
echo '<p> ✅ '.$label.'</p>';
|
||||
} else {
|
||||
echo '<p> ❌ '.$label.'</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +262,13 @@ if (isset($author[0])) {
|
|||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="<?php echo site_url();?>admin/health" class="nav-link">
|
||||
<p>
|
||||
<?php echo i18n('health_check');?>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php if (config('fulltext.search') == 'true') : ?>
|
||||
<li class="nav-item">
|
||||
<a href="<?php echo site_url();?>admin/search" class="nav-link">
|
||||
|
|
|
|||
|
|
@ -2626,6 +2626,41 @@ get('/admin/clear-cache', function () {
|
|||
}
|
||||
});
|
||||
|
||||
// Show health status page
|
||||
get('/admin/health', function () {
|
||||
$user = $_SESSION[site_url()]['user'] ?? null;
|
||||
$role = user('role', $user) ?? null;
|
||||
if (login()) {
|
||||
config('views.root', 'system/admin/views');
|
||||
if ($role === 'editor' || $role === 'admin') {
|
||||
render('health', array(
|
||||
'title' => generate_title('is_default', i18n('Health_check')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_admin-health',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'admin-health',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Health_check')
|
||||
));
|
||||
} else {
|
||||
render('denied', array(
|
||||
'title' => generate_title('is_default', i18n('Denied')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_admin-health',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'denied',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Show Update page
|
||||
get('/admin/update', function () {
|
||||
$user = $_SESSION[site_url()]['user'] ?? null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue