Merge branch 'develop' of https://192.168.50.5:8081/artica/pandorafms into develop
This commit is contained in:
commit
428c678a05
|
@ -1,16 +1,32 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Global & session manageme
|
||||
/**
|
||||
* Generate charts with given parameters.
|
||||
*
|
||||
* @category ChartGenerator.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
require_once 'config.php';
|
||||
|
||||
require_once __DIR__.'/config.php';
|
||||
|
@ -26,6 +42,29 @@ require_once $config['homedir'].'/include/functions_agents.php';
|
|||
require_once $config['homedir'].'/include/functions_tags.php';
|
||||
|
||||
|
||||
/**
|
||||
* Echo to stdout a PhantomJS callback call.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function echoPhantomCallback()
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('document').ready(function () {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
var status = window.callPhantom({ status: "loaded" });
|
||||
} catch (error) {
|
||||
console.log("CALLBACK ERROR", error.message)
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
// Initialize session.
|
||||
global $config;
|
||||
|
||||
|
@ -48,17 +87,7 @@ if (check_login(false) === false) {
|
|||
</head>
|
||||
<body>
|
||||
<h1>Access is not granted</h1>
|
||||
<script type="text/javascript">
|
||||
$('document').ready(function () {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
var status = window.callPhantom({ status: "loaded" });
|
||||
} catch (error) {
|
||||
console.log("CALLBACK ERROR", error.message)
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
<?php echoPhantomCallback(); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -76,11 +105,18 @@ if ($config['metaconsole'] && !empty($server_id)) {
|
|||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
// Error connecting.
|
||||
if (metaconsole_connect($server) !== NOERR) {
|
||||
echo '<html>';
|
||||
echo '<body>';
|
||||
ui_print_error_message(__('There was a problem connecting with the node'));
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
?>
|
||||
<html>
|
||||
<body>
|
||||
<?php
|
||||
ui_print_error_message(
|
||||
__('There was a problem connecting with the node')
|
||||
);
|
||||
echoPhantomCallback();
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -125,16 +161,18 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
|
|||
<body bgcolor="#ffffff" style='background:#ffffff;'>
|
||||
<?php
|
||||
$params['only_image'] = false;
|
||||
$params['width'] = (int) $_REQUEST['viewport_width'];
|
||||
$params['menu'] = false;
|
||||
$params['width'] = (int) $_REQUEST['viewport_width'];
|
||||
$params['menu'] = false;
|
||||
|
||||
if ((!isset($params['width']) || ($params['width'] <= 0))) {
|
||||
if ((isset($params['width']) === false
|
||||
|| ($params['width'] <= 0))
|
||||
) {
|
||||
$params['width'] = 650;
|
||||
}
|
||||
|
||||
$params_combined = json_decode($_REQUEST['data_combined'], true);
|
||||
$module_list = json_decode($_REQUEST['data_module_list'], true);
|
||||
$type_graph_pdf = $_REQUEST['type_graph_pdf'];
|
||||
$module_list = json_decode($_REQUEST['data_module_list'], true);
|
||||
$type_graph_pdf = $_REQUEST['type_graph_pdf'];
|
||||
|
||||
echo '<div>';
|
||||
switch ($type_graph_pdf) {
|
||||
|
@ -253,20 +291,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
|
|||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echoPhantomCallback();
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('document').ready(function () {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
var status = window.callPhantom({ status: "loaded" });
|
||||
} catch (error) {
|
||||
console.log("CALLBACK ERROR", error.message)
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -161,7 +161,7 @@ function pandora_session_gc($max_lifetime=300)
|
|||
if (isset($config['session_timeout'])) {
|
||||
$session_timeout = $config['session_timeout'];
|
||||
} else {
|
||||
// if $config doesn`t work ...
|
||||
// If $config doesn`t work ...
|
||||
$session_timeout = db_get_value(
|
||||
'value',
|
||||
'tconfig',
|
||||
|
@ -170,9 +170,9 @@ function pandora_session_gc($max_lifetime=300)
|
|||
);
|
||||
}
|
||||
|
||||
if (!empty($session_timeout)) {
|
||||
if (empty($session_timeout) === false) {
|
||||
if ($session_timeout == -1) {
|
||||
// The session expires in 10 years
|
||||
// The session expires in 10 years.
|
||||
$session_timeout = 315576000;
|
||||
} else {
|
||||
$session_timeout *= 60;
|
||||
|
@ -191,15 +191,14 @@ function pandora_session_gc($max_lifetime=300)
|
|||
);
|
||||
|
||||
// Deleting cron and empty sessions.
|
||||
$sql = "DELETE FROM tsessions_php WHERE
|
||||
data IS NULL OR id_session REGEXP '^cron-'";
|
||||
$sql = 'DELETE FROM tsessions_php WHERE data IS NULL';
|
||||
db_process_sql($sql);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
// FIXME: SAML should work with pandora session handlers
|
||||
// TODO: SAML should work with pandora session handlers.
|
||||
if (db_get_value('value', 'tconfig', 'token', 'auth') != 'saml') {
|
||||
$result_handler = session_set_save_handler(
|
||||
'pandora_session_open',
|
||||
|
|
|
@ -50,6 +50,29 @@ if (type_graph_pdf == "combined") {
|
|||
|
||||
var page = require("webpage").create();
|
||||
|
||||
page.onResourceError = function(resourceError) {
|
||||
console.log(
|
||||
"Unable to load resource (#" +
|
||||
resourceError.id +
|
||||
"URL:" +
|
||||
resourceError.url +
|
||||
")"
|
||||
);
|
||||
console.log(
|
||||
"Error code: " +
|
||||
resourceError.errorCode +
|
||||
". Description: " +
|
||||
resourceError.errorString
|
||||
);
|
||||
phantom.exit(1);
|
||||
};
|
||||
|
||||
// Not supposed to be prompted messages.
|
||||
page.onPrompt = function() {
|
||||
console.log("Prompt message detected.");
|
||||
phantom.exit(1);
|
||||
};
|
||||
|
||||
page.viewportSize = {
|
||||
width: viewport_width,
|
||||
height: viewport_height
|
||||
|
@ -84,3 +107,21 @@ page.open(url, "POST", post_data, function(status) {
|
|||
phantom.exit();
|
||||
}
|
||||
});
|
||||
|
||||
phantom.onError = function(msg, trace) {
|
||||
var msgStack = ["PHANTOM ERROR: " + msg];
|
||||
if (trace && trace.length) {
|
||||
msgStack.push("TRACE:");
|
||||
trace.forEach(function(t) {
|
||||
msgStack.push(
|
||||
" -> " +
|
||||
(t.file || t.sourceURL) +
|
||||
": " +
|
||||
t.line +
|
||||
(t.function ? " (in function " + t.function + ")" : "")
|
||||
);
|
||||
});
|
||||
}
|
||||
console.log(msgStack.join("\n"));
|
||||
phantom.exit(1);
|
||||
};
|
||||
|
|
|
@ -3258,7 +3258,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$$) {
|
|||
'custom_id' => $custom_id,
|
||||
'url_address' => $url_address,
|
||||
'timezone_offset' => $timezone_offset,
|
||||
'alias' => $alias,
|
||||
'alias' => safe_input($alias),
|
||||
'update_module_count' => 1, # Force to replicate in metaconsole
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue