logfin expand
This commit is contained in:
parent
48afc9d770
commit
6b5951eb83
10 changed files with 597 additions and 40 deletions
|
|
@ -433,6 +433,7 @@ function server_content_restart_home($home_id, $options = array())
|
|||
}
|
||||
sleep($delay);
|
||||
}
|
||||
$restart_reason = (isset($options['triggered_by']) && $options['triggered_by'] === 'scheduler') ? 'scheduled_restart' : 'panel_restart';
|
||||
|
||||
$remote_retval = $remote->remote_restart_server(
|
||||
$home_info['home_id'],
|
||||
|
|
@ -450,7 +451,8 @@ function server_content_restart_home($home_id, $options = array())
|
|||
$preStart,
|
||||
$envVars,
|
||||
$server_xml->game_key,
|
||||
(isset($server_xml->console_log) ? $server_xml->console_log : "")
|
||||
(isset($server_xml->console_log) ? $server_xml->console_log : ""),
|
||||
$restart_reason
|
||||
);
|
||||
if ($remote_retval !== 1) {
|
||||
return server_content_result('restart_required', 'Update completed but automatic restart failed.', array(
|
||||
|
|
|
|||
|
|
@ -46,8 +46,20 @@ $install_queries[1] = array(
|
|||
`log_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`date` varchar(20) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`ip` varchar(15) NOT NULL,
|
||||
`message` varchar(250) NOT NULL
|
||||
`ip` varchar(255) NOT NULL,
|
||||
`message` varchar(1000) NOT NULL,
|
||||
`source_type` varchar(20) NOT NULL DEFAULT 'user',
|
||||
`category` varchar(40) NOT NULL DEFAULT 'panel_action',
|
||||
`event_type` varchar(80) DEFAULT NULL,
|
||||
`severity` varchar(20) NOT NULL DEFAULT 'info',
|
||||
`remote_server_id` int(11) DEFAULT NULL,
|
||||
`home_id` int(11) DEFAULT NULL,
|
||||
`event_uuid` varchar(64) DEFAULT NULL,
|
||||
`correlation_id` varchar(64) DEFAULT NULL,
|
||||
`actor` varchar(120) DEFAULT NULL,
|
||||
`metadata_json` text DEFAULT NULL,
|
||||
KEY `idx_logger_event_uuid` (`event_uuid`),
|
||||
KEY `idx_logger_source_category` (`source_type`,`category`,`severity`),
|
||||
KEY `idx_logger_home` (`home_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@ function exec_ogp_module() {
|
|||
$search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
|
||||
$p = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
|
||||
$l = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
|
||||
$filters = array();
|
||||
foreach (array('source_type','category','severity','user_id','remote_server_id','home_id','date_from','date_to') as $filter_key) {
|
||||
if (isset($_GET[$filter_key]) && $_GET[$filter_key] !== '' && $_GET[$filter_key] !== 'all') {
|
||||
$filters[$filter_key] = $_GET[$filter_key];
|
||||
}
|
||||
}
|
||||
$db->ensureLoggerExtendedSchema();
|
||||
|
||||
if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !(isset($_GET['limit']) and !empty($_GET['limit']))){
|
||||
$l = $loggedInUserInfo["users_page_limit"];
|
||||
|
|
@ -36,14 +43,19 @@ function exec_ogp_module() {
|
|||
|
||||
echo "<h2>".get_lang('watch_logger')."</h2>";
|
||||
|
||||
$logs = $db->read_logger($p, $l, $search_field);
|
||||
$logs = $db->read_logger($p, $l, $search_field, $filters);
|
||||
|
||||
if (empty($logs) && !empty($search_field)) {
|
||||
print_failure(get_lang_f('no_results_found', htmlentities($search_field ?? '', ENT_QUOTES, 'UTF-8')));
|
||||
if (empty($logs) && (!empty($search_field) || !empty($filters))) {
|
||||
print_failure(get_lang_f('no_results_found', htmlentities($search_field ?? 'selected filters', ENT_QUOTES, 'UTF-8')));
|
||||
$view->refresh("?m=administration&p=watch_logger", 5);
|
||||
|
||||
return;
|
||||
}
|
||||
$query_params = array_merge(array('m' => 'administration', 'p' => 'watch_logger', 'limit' => $l), $filters);
|
||||
if (!empty($search_field)) {
|
||||
$query_params['search'] = $search_field;
|
||||
}
|
||||
$base_query = http_build_query($query_params);
|
||||
|
||||
?>
|
||||
<!-- Search, Empty Logger, and Paging Options Table -->
|
||||
|
|
@ -53,7 +65,27 @@ function exec_ogp_module() {
|
|||
<form action="home.php" method="GET" style="display: inline;">
|
||||
<input type ="hidden" name="m" value="administration" />
|
||||
<input type ="hidden" name="p" value="watch_logger" />
|
||||
<input name="search" type="text" id="search" value="<?php if(hasValue($search_field)){ echo $search_field; } ?>" />
|
||||
<input name="search" type="text" id="search" value="<?php if(hasValue($search_field)){ echo htmlentities($search_field, ENT_QUOTES, 'UTF-8'); } ?>" />
|
||||
<select name="source_type">
|
||||
<?php foreach (array('all' => 'All sources', 'user' => 'User', 'admin' => 'Admin', 'agent' => 'Agent', 'scheduler' => 'Scheduler') as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php echo (isset($_GET['source_type']) && $_GET['source_type'] === $value) ? 'selected' : ''; ?>><?php echo $label; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<select name="category">
|
||||
<?php foreach (array('all' => 'All categories', 'authentication' => 'Authentication', 'panel_action' => 'Panel actions', 'server_lifecycle' => 'Server lifecycle', 'file_config' => 'File/config changes', 'user_management' => 'User management', 'content_workshop' => 'Content/Workshop', 'errors' => 'Errors') as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php echo (isset($_GET['category']) && $_GET['category'] === $value) ? 'selected' : ''; ?>><?php echo $label; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<select name="severity">
|
||||
<?php foreach (array('all' => 'All severities', 'info' => 'Info', 'notice' => 'Notice', 'warning' => 'Warning', 'error' => 'Error', 'critical' => 'Critical', 'success' => 'Success') as $value => $label) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php echo (isset($_GET['severity']) && $_GET['severity'] === $value) ? 'selected' : ''; ?>><?php echo $label; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input name="user_id" type="number" min="0" placeholder="User ID" value="<?php echo htmlentities($_GET['user_id'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" style="width:70px;" />
|
||||
<input name="remote_server_id" type="number" min="0" placeholder="Agent ID" value="<?php echo htmlentities($_GET['remote_server_id'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" style="width:75px;" />
|
||||
<input name="home_id" type="number" min="0" placeholder="Home ID" value="<?php echo htmlentities($_GET['home_id'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" style="width:75px;" />
|
||||
<input name="date_from" type="date" value="<?php echo htmlentities($_GET['date_from'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" />
|
||||
<input name="date_to" type="date" value="<?php echo htmlentities($_GET['date_to'] ?? '', ENT_QUOTES, 'UTF-8'); ?>" />
|
||||
<input type="submit" value="<?php echo get_lang('search'); ?>" />
|
||||
</form>
|
||||
<form method=POST style="display: inline;">
|
||||
|
|
@ -61,7 +93,7 @@ function exec_ogp_module() {
|
|||
</form>
|
||||
</td>
|
||||
<td style="width: 50%; vertical-align: middle; text-align: right;">
|
||||
<?php echo print_lang('view'); ?> <a href='?m=administration&p=watch_logger&limit=10'>10</a> / <a href='?m=administration&p=watch_logger&limit=20'>20</a> / <a href='?m=administration&p=watch_logger&limit=50'>50</a> / <a href='?m=administration&p=watch_logger&limit=100'>100</a> <?php echo print_lang('per_page'); ?>
|
||||
<?php echo print_lang('view'); ?> <a href='?<?php echo htmlentities(http_build_query(array_merge($query_params, array('limit' => 10))), ENT_QUOTES, 'UTF-8'); ?>'>10</a> / <a href='?<?php echo htmlentities(http_build_query(array_merge($query_params, array('limit' => 20))), ENT_QUOTES, 'UTF-8'); ?>'>20</a> / <a href='?<?php echo htmlentities(http_build_query(array_merge($query_params, array('limit' => 50))), ENT_QUOTES, 'UTF-8'); ?>'>50</a> / <a href='?<?php echo htmlentities(http_build_query(array_merge($query_params, array('limit' => 100))), ENT_QUOTES, 'UTF-8'); ?>'>100</a> <?php echo print_lang('per_page'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -74,6 +106,9 @@ function exec_ogp_module() {
|
|||
<th class="dateFormat-ddmmyyyy"><?php print_lang('when'); ?></th>
|
||||
<th><?php print_lang('who'); ?></th>
|
||||
<th><?php print_lang('where'); ?></th>
|
||||
<th>Type</th>
|
||||
<th>Severity</th>
|
||||
<th>Server</th>
|
||||
<th><?php print_lang('what'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -100,10 +135,23 @@ function exec_ogp_module() {
|
|||
foreach ((array)$logs as $log)
|
||||
{
|
||||
$user = $db->getUserById($log['user_id']);
|
||||
$when = $log['date'];
|
||||
$who = $user['users_login'];
|
||||
$where = $log['ip'];
|
||||
$what = $log['message'];
|
||||
$user = is_array($user) ? $user : array();
|
||||
$when = htmlentities($log['date'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
$who = isset($log['actor']) && $log['actor'] !== '' ? $log['actor'] : ($user['users_login'] ?? 'System');
|
||||
$who = htmlentities($who, ENT_QUOTES, 'UTF-8');
|
||||
$where = htmlentities($log['ip'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
$what = htmlentities($log['message'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
$source = htmlentities(strtoupper($log['source_type'] ?? 'USER'), ENT_QUOTES, 'UTF-8');
|
||||
$category = htmlentities($log['category'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
$severity = htmlentities(strtoupper($log['severity'] ?? 'INFO'), ENT_QUOTES, 'UTF-8');
|
||||
$server_ref = '';
|
||||
if (!empty($log['home_id'])) {
|
||||
$server_ref .= 'Home '.$log['home_id'];
|
||||
}
|
||||
if (!empty($log['remote_server_id'])) {
|
||||
$server_ref .= ($server_ref ? ' / ' : '').'Agent '.$log['remote_server_id'];
|
||||
}
|
||||
$server_ref = htmlentities($server_ref, ENT_QUOTES, 'UTF-8');
|
||||
$log_id = $log['log_id'];
|
||||
// Template
|
||||
echo "<tr class='maintr'>\n".
|
||||
|
|
@ -118,18 +166,30 @@ function exec_ogp_module() {
|
|||
"<td class='collapsible'>$when</td>\n".
|
||||
"<td class='collapsible'>$who</td>\n".
|
||||
"<td class='collapsible'>$where</td>\n".
|
||||
"<td class='collapsible'><span class='note'>$source</span><br />$category</td>\n".
|
||||
"<td class='collapsible'>$severity</td>\n".
|
||||
"<td class='collapsible'>$server_ref</td>\n".
|
||||
"<td class='collapsible'>$what</td>\n".
|
||||
"</tr>\n";
|
||||
|
||||
echo "<tr class='expand-child'>\n".
|
||||
"<td colspan='5' >\n".
|
||||
"<td colspan='8' >\n".
|
||||
"<table>\n";
|
||||
|
||||
$show_values = array( "users_login", "users_lang", "users_role", "users_email", "user_expires");
|
||||
foreach ((array)$user as $key => $value)
|
||||
{
|
||||
if( in_array( $key, $show_values ) )
|
||||
echo "<tr><td>".str_replace("_", "", substr($key,5))."</td><td>$value</td></tr>\n";
|
||||
echo "<tr><td>".htmlentities(str_replace("_", "", substr($key,5)), ENT_QUOTES, 'UTF-8')."</td><td>".htmlentities($value, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if (!empty($log['event_type'])) {
|
||||
echo "<tr><td>event type</td><td>".htmlentities($log['event_type'], ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if (!empty($log['correlation_id'])) {
|
||||
echo "<tr><td>correlation id</td><td>".htmlentities($log['correlation_id'], ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if (!empty($log['metadata_json'])) {
|
||||
echo "<tr><td>details</td><td><pre>".htmlentities($log['metadata_json'], ENT_QUOTES, 'UTF-8')."</pre></td></tr>\n";
|
||||
}
|
||||
echo "</tr>\n".
|
||||
"</td>\n".
|
||||
|
|
@ -139,13 +199,9 @@ function exec_ogp_module() {
|
|||
echo "</tbody>\n";
|
||||
echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
|
||||
echo "</table>\n";
|
||||
$count_logs = $db->get_logger_count($search_field);
|
||||
$count_logs = $db->get_logger_count($search_field, $filters);
|
||||
|
||||
if (isset($_GET['search']) && !empty($_GET['search'])) {
|
||||
$uri = '?m=administration&p=watch_logger&search='.$_GET['search'].'&limit='.$l.'&page=';
|
||||
} else {
|
||||
$uri = '?m=administration&p=watch_logger&limit='.$l.'&page=';
|
||||
}
|
||||
$uri = '?'.$base_query.'&page=';
|
||||
echo paginationPages($count_logs[0]['total'], $p, $l, $uri, 3, 'watchLogger');
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -158,7 +158,8 @@ function build_cron_scheduler_command($panelURL, $token, $game_home, $action) {
|
|||
case "start":
|
||||
return "wget -qO- \"{$panelURL}/ogp_api.php?gamemanager/start&token={$token}&ip={$ip}&port={$port}&mod_key={$mod_key}\" --no-check-certificate > /dev/null 2>&1";
|
||||
case "restart":
|
||||
return "wget -qO- \"{$panelURL}/ogp_api.php?gamemanager/restart&token={$token}&ip={$ip}&port={$port}&mod_key={$mod_key}\" --no-check-certificate > /dev/null 2>&1";
|
||||
$options_json = urlencode(json_encode(array('triggered_by' => 'scheduler')));
|
||||
return "wget -qO- \"{$panelURL}/ogp_api.php?gamemanager/restart&token={$token}&ip={$ip}&port={$port}&mod_key={$mod_key}&options={$options_json}\" --no-check-certificate > /dev/null 2>&1";
|
||||
case "steam_auto_update":
|
||||
return "wget -qO- \"{$panelURL}/ogp_api.php?gamemanager/update&token={$token}&ip={$ip}&port={$port}&mod_key={$mod_key}&type=steam\" --no-check-certificate > /dev/null 2>&1";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue