Added ablility to switch Server-Status-Overview page to public mode - without any login.
This commit is contained in:
parent
aad1a1eda7
commit
2d6a7d952f
|
@ -418,6 +418,7 @@ $sm_lang = array(
|
||||||
'log_retention_days' => 'days',
|
'log_retention_days' => 'days',
|
||||||
'user_agent' => 'User Agent',
|
'user_agent' => 'User Agent',
|
||||||
'user_agent_key_note' => 'Custom user agent used by monitor within communication with external services.',
|
'user_agent_key_note' => 'Custom user agent used by monitor within communication with external services.',
|
||||||
|
'public_status' => 'Make Status-Page public?'
|
||||||
),
|
),
|
||||||
'notifications' => array(
|
'notifications' => array(
|
||||||
'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%',
|
'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%',
|
||||||
|
@ -518,6 +519,7 @@ $sm_lang = array(
|
||||||
'error_reset_invalid_link' => 'The reset link you provided is invalid.',
|
'error_reset_invalid_link' => 'The reset link you provided is invalid.',
|
||||||
'success_password_forgot' => 'An email has been sent to you with information how to reset your password.',
|
'success_password_forgot' => 'An email has been sent to you with information how to reset your password.',
|
||||||
'success_password_reset' => 'Your password has been reset successfully. Please login.',
|
'success_password_reset' => 'Your password has been reset successfully. Please login.',
|
||||||
|
'anonymous_username' => 'Anonymous',
|
||||||
),
|
),
|
||||||
'error' => array(
|
'error' => array(
|
||||||
'401_unauthorized' => 'Unauthorized',
|
'401_unauthorized' => 'Unauthorized',
|
||||||
|
|
|
@ -278,8 +278,10 @@ abstract class AbstractController implements ControllerInterface
|
||||||
'label_help' => psm_get_lang('menu', 'help'),
|
'label_help' => psm_get_lang('menu', 'help'),
|
||||||
'label_profile' => psm_get_lang('users', 'profile'),
|
'label_profile' => psm_get_lang('users', 'profile'),
|
||||||
'label_logout' => psm_get_lang('login', 'logout'),
|
'label_logout' => psm_get_lang('login', 'logout'),
|
||||||
|
'label_login' => psm_get_lang('login', 'login'),
|
||||||
'url_profile' => psm_build_url(array('mod' => 'user_profile')),
|
'url_profile' => psm_build_url(array('mod' => 'user_profile')),
|
||||||
'url_logout' => psm_build_url(array('logout' => 1)),
|
'url_logout' => psm_build_url(array('logout' => 1)),
|
||||||
|
'url_login' => psm_build_url(array('mod' => 'user_profile')),
|
||||||
'label_current' => psm_get_lang('system', 'current'),
|
'label_current' => psm_get_lang('system', 'current'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -311,6 +313,11 @@ abstract class AbstractController implements ControllerInterface
|
||||||
psm_get_lang('login', 'welcome_usermenu')
|
psm_get_lang('login', 'welcome_usermenu')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$tpl_data['label_usermenu'] = psm_get_lang('login','anonymous_username');
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl_data['ulvl'] = $ulvl;
|
||||||
return $this->twig->render('main/menu.tpl.html', $tpl_data);
|
return $this->twig->render('main/menu.tpl.html', $tpl_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ class ConfigController extends AbstractController
|
||||||
'log_jabber',
|
'log_jabber',
|
||||||
'show_update',
|
'show_update',
|
||||||
'combine_notifications',
|
'combine_notifications',
|
||||||
|
'public_status',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -641,6 +642,7 @@ class ConfigController extends AbstractController
|
||||||
'label_user_agent' => psm_get_lang('config', 'user_agent'),
|
'label_user_agent' => psm_get_lang('config', 'user_agent'),
|
||||||
'label_user_agent_key_note' => psm_get_lang('config', 'user_agent_key_note'),
|
'label_user_agent_key_note' => psm_get_lang('config', 'user_agent_key_note'),
|
||||||
'label_site_title' => psm_get_lang('config', 'site_title'),
|
'label_site_title' => psm_get_lang('config', 'site_title'),
|
||||||
|
'label_public_status' => psm_get_lang('config','public_status'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,24 @@ abstract class AbstractServerController extends AbstractController
|
||||||
$sql_where = '';
|
$sql_where = '';
|
||||||
|
|
||||||
if ($this->getUser()->getUserLevel() > PSM_USER_ADMIN) {
|
if ($this->getUser()->getUserLevel() > PSM_USER_ADMIN) {
|
||||||
// restrict by user_id
|
if ($this->getUser()->getUserLevel() == PSM_USER_ANONYMOUS && psm_get_conf(public_status) == true) {
|
||||||
$sql_join = "JOIN `" . PSM_DB_PREFIX . "users_servers` AS `us` ON (
|
// restrict by user_id of anonymous User - if configured to do so
|
||||||
`us`.`user_id`={$this->getUser()->getUserId()}
|
$sql_join = "JOIN `" . PSM_DB_PREFIX . "users_servers` AS `us` ON (
|
||||||
|
`us`.`user_id`= 0
|
||||||
AND `us`.`server_id`=`s`.`server_id`
|
AND `us`.`server_id`=`s`.`server_id`
|
||||||
)";
|
)";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// restrict by user_id
|
||||||
|
$sql_join = "JOIN `" . PSM_DB_PREFIX . "users_servers` AS `us` ON (
|
||||||
|
`us`.`user_id`={$this->getUser()->getUserId()}
|
||||||
|
AND `us`.`server_id`=`s`.`server_id`
|
||||||
|
)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($server_id !== null) {
|
if ($server_id !== null) {
|
||||||
$server_id = intval($server_id);
|
$server_id = intval($server_id);
|
||||||
$sql_where = "WHERE `s`.`server_id`={$server_id} ";
|
$sql_where = "WHERE `s`.`server_id`={$server_id} ";
|
||||||
|
|
|
@ -43,6 +43,12 @@ class StatusController extends AbstractServerController
|
||||||
|
|
||||||
$this->setCSRFKey('status');
|
$this->setCSRFKey('status');
|
||||||
$this->setActions(array('index', 'saveLayout'), 'index');
|
$this->setActions(array('index', 'saveLayout'), 'index');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for configuration of public available Status-Page
|
||||||
|
*/
|
||||||
|
if (psm_get_conf('public_status'))
|
||||||
|
$this->setMinUserLevelRequired(PSM_USER_ANONYMOUS,array('index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,10 +98,19 @@ class StatusController extends AbstractServerController
|
||||||
if ($server['last_offline_nice'] != psm_get_lang('system', 'never')) {
|
if ($server['last_offline_nice'] != psm_get_lang('system', 'never')) {
|
||||||
$server['last_offline_duration_nice'] = "(" . $server['last_offline_duration'] . ")";
|
$server['last_offline_duration_nice'] = "(" . $server['last_offline_duration'] . ")";
|
||||||
}
|
}
|
||||||
$server['url_view'] = psm_build_url(
|
|
||||||
array('mod' => 'server', 'action' => 'view', 'id' => $server['server_id'], 'back_to' => 'server_status')
|
|
||||||
);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link Server-Title with detailed Status-Page only when User is NOT Anonymous
|
||||||
|
*/
|
||||||
|
if ($this->getUser()->getUserLevel() != PSM_USER_ANONYMOUS) {
|
||||||
|
$server['url_view'] = psm_build_url(
|
||||||
|
array('mod' => 'server', 'action' => 'view', 'id' => $server['server_id'], 'back_to' => 'server_status')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$server['url_view'] = psm_build_url();
|
||||||
|
}
|
||||||
if ($server['status'] == "off") {
|
if ($server['status'] == "off") {
|
||||||
$layout_data['servers_offline'][] = $server;
|
$layout_data['servers_offline'][] = $server;
|
||||||
} elseif ($server['warning_threshold_counter'] > 0) {
|
} elseif ($server['warning_threshold_counter'] > 0) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ class UserController extends AbstractController
|
||||||
|
|
||||||
$users = $this->db->select(
|
$users = $this->db->select(
|
||||||
PSM_DB_PREFIX . 'users',
|
PSM_DB_PREFIX . 'users',
|
||||||
null,
|
'user_id > 0',
|
||||||
array('user_id', 'user_name', 'level', 'name', 'mobile', 'email'),
|
array('user_id', 'user_name', 'level', 'name', 'mobile', 'email'),
|
||||||
null,
|
null,
|
||||||
array('name')
|
array('name')
|
||||||
|
|
|
@ -435,7 +435,7 @@ class Database
|
||||||
}
|
}
|
||||||
$query = substr($query, 0, -5);
|
$query = substr($query, 0, -5);
|
||||||
} else {
|
} else {
|
||||||
if (strpos($where, '=') === false) {
|
if ((strpos($where, '=') === false ) && (strpos($where, '>') === false) && (strpos($where, '<') === false)) {
|
||||||
// no field given, use primary field
|
// no field given, use primary field
|
||||||
$primary = $this->getPrimary($table);
|
$primary = $this->getPrimary($table);
|
||||||
$query .= " WHERE `{$table}`.`{$primary}`={$this->quote($where)}";
|
$query .= " WHERE `{$table}`.`{$primary}`={$this->quote($where)}";
|
||||||
|
|
|
@ -369,6 +369,9 @@ class Installer
|
||||||
if (version_compare($version_from, '3.6.0', '<')) {
|
if (version_compare($version_from, '3.6.0', '<')) {
|
||||||
$this->upgrade360();
|
$this->upgrade360();
|
||||||
}
|
}
|
||||||
|
if (version_compare($version_from, '3.7.0', '<')) {
|
||||||
|
$this->upgrade370();
|
||||||
|
}
|
||||||
psm_update_conf('version', $version_to);
|
psm_update_conf('version', $version_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,4 +759,22 @@ class Installer
|
||||||
ADD `discord` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `sms`;";
|
ADD `discord` ENUM( 'yes','no' ) NOT NULL DEFAULT 'yes' AFTER `sms`;";
|
||||||
$this->execSQL($queries);
|
$this->execSQL($queries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upgrade for v3.7.0 release
|
||||||
|
* Added support for public Status-Pages
|
||||||
|
*/
|
||||||
|
protected function upgrade370()
|
||||||
|
{
|
||||||
|
$queries = array();
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE
|
||||||
|
('public_status', '0')";
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users`
|
||||||
|
(`user_id`, `user_name`, `password`, `password_reset_hash`, `password_reset_timestamp`, `rememberme_token`, `level`, `name`, `mobile`, `discord`, `pushover_key`, `pushover_device`, `webhook_url`, `webhook_json`, `telegram_id`, `jabber`, `email`)
|
||||||
|
VALUES
|
||||||
|
('0', 'anonymous', 'NO_PASSWORD_REQUIRED', NULL, NULL, NULL, '30', 'Anonymous / Public', '', '', '', '', '', '{\"text\":\"servermon: #message\"}', '', '', '')";
|
||||||
|
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "users` SET `user_id` = '0' WHERE `monitor_users`.`user_id` = 3";
|
||||||
|
$this->execSQL($queries);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</noscript>
|
</noscript>
|
||||||
<noscript><div hidden></noscript>
|
<noscript><div hidden></noscript>
|
||||||
|
{% if ulvl < 30 %}
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
@ -35,4 +36,21 @@
|
||||||
</li>
|
</li>
|
||||||
-->
|
-->
|
||||||
</ul>
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
{{ label_usermenu }}
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="{{ url_login|raw }}">{{ label_login }} </a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<!--
|
||||||
|
<li class="nav-item">
|
||||||
|
<i class="text-white fas fa-universal-access fa-lg nav-link"></i>
|
||||||
|
</li>
|
||||||
|
-->
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
<noscript></div></noscript>
|
<noscript></div></noscript>
|
|
@ -62,6 +62,8 @@
|
||||||
{{ macro.input_field("text", "password_encrypt_key", null, "password_encrypt_key", label_password_encrypt_key, password_encrypt_key, "cab03a766...", "40", "password_encrypt_key_help", label_password_encrypt_key_note) }}
|
{{ macro.input_field("text", "password_encrypt_key", null, "password_encrypt_key", label_password_encrypt_key, password_encrypt_key, "cab03a766...", "40", "password_encrypt_key_help", label_password_encrypt_key_note) }}
|
||||||
<!-- Custom user agent -->
|
<!-- Custom user agent -->
|
||||||
{{ macro.input_field("text", "user_agent", null, "user_agent", label_user_agent, user_agent, "Mozilla/5.0...", "255", "user_agent_key_help", label_user_agent_key_note) }}
|
{{ macro.input_field("text", "user_agent", null, "user_agent", label_user_agent, user_agent, "Mozilla/5.0...", "255", "user_agent_key_help", label_user_agent_key_note) }}
|
||||||
|
<!-- Public Status-Page -->
|
||||||
|
{{ macro.input_checkbox("public_status","public_status[]", label_public_status, public_status_checked) }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<!-- Notification settings -->
|
<!-- Notification settings -->
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
Loading…
Reference in New Issue