Changed check connection method to ajax. Check deleted from login
This commit is contained in:
parent
a23d807baf
commit
50b1fa3c56
|
@ -114,12 +114,6 @@ foreach ($custom_fields as $field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection lost alert.
|
|
||||||
ui_require_css_file('register', 'include/styles/', true);
|
|
||||||
ui_require_javascript_file('connection_check');
|
|
||||||
$conn_title = __('Connection with server has been lost');
|
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
|
||||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
|
||||||
|
|
||||||
// Get the custom icons.
|
// Get the custom icons.
|
||||||
$docs_logo = ui_get_docs_logo();
|
$docs_logo = ui_get_docs_logo();
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Pandora FMS - http://pandorafms.com
|
||||||
|
// ==================================================
|
||||||
|
// Copyright (c) 2005-2011 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; 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.
|
||||||
|
require_once 'functions.php';
|
||||||
|
|
||||||
|
|
||||||
|
if (check_login(false)) {
|
||||||
|
$return = true;
|
||||||
|
} else {
|
||||||
|
$return = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($return);
|
|
@ -29,22 +29,30 @@ function handleConnection() {
|
||||||
var connected;
|
var connected;
|
||||||
var msg = "online";
|
var msg = "online";
|
||||||
|
|
||||||
|
var homeurl = getServerUrl();
|
||||||
|
if (homeurl == null || homeurl == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (navigator.onLine) {
|
if (navigator.onLine) {
|
||||||
isReachable(getServerUrl())
|
$.ajax({
|
||||||
.then(function(online) {
|
url: homeurl + "include/connection_check.php",
|
||||||
if (online) {
|
type: "post",
|
||||||
// handle online status
|
dataType: "json"
|
||||||
connected = true;
|
})
|
||||||
showConnectionMessage(connected, msg);
|
.done(function(response) {
|
||||||
} else {
|
connected = true;
|
||||||
connected = false;
|
showConnectionMessage(connected, msg);
|
||||||
msg = "No connectivity with server";
|
|
||||||
showConnectionMessage(connected, msg);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.fail(function(err) {
|
||||||
connected = false;
|
// If test connection file is not found, do not show message.
|
||||||
msg = err;
|
if (err.status != 404) {
|
||||||
|
connected = false;
|
||||||
|
msg = err;
|
||||||
|
} else {
|
||||||
|
connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
showConnectionMessage(connected, msg);
|
showConnectionMessage(connected, msg);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,38 +63,17 @@ function handleConnection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test server reachibilty and get response.
|
|
||||||
*
|
|
||||||
* @param {String} url
|
|
||||||
*
|
|
||||||
* Return {promise}
|
|
||||||
*/
|
|
||||||
function isReachable(url) {
|
|
||||||
/**
|
|
||||||
* Note: fetch() still "succeeds" for 404s on subdirectories,
|
|
||||||
* which is ok when only testing for domain reachability.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
* https://google.com/noexist does not throw
|
|
||||||
* https://noexist.com/noexist does throw
|
|
||||||
*/
|
|
||||||
return fetch(url, { method: "HEAD", mode: "no-cors" })
|
|
||||||
.then(function(resp) {
|
|
||||||
return resp && (resp.ok || resp.type === "opaque");
|
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
console.warn("[conn test failure]:", error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets server origin url
|
* Gets server origin url
|
||||||
*/
|
*/
|
||||||
function getServerUrl() {
|
function getServerUrl() {
|
||||||
var server_url;
|
var server_url;
|
||||||
|
|
||||||
server_url = window.location.origin;
|
try {
|
||||||
|
server_url = get_php_value("absolute_homeurl");
|
||||||
|
} catch (error) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
return server_url;
|
return server_url;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +86,7 @@ function getServerUrl() {
|
||||||
*/
|
*/
|
||||||
function showConnectionMessage(conn = true, msg = "") {
|
function showConnectionMessage(conn = true, msg = "") {
|
||||||
var data = {};
|
var data = {};
|
||||||
if (conn) {
|
if (conn && closed == false) {
|
||||||
$("div#message_dialog_connection")
|
$("div#message_dialog_connection")
|
||||||
.closest(".ui-dialog-content")
|
.closest(".ui-dialog-content")
|
||||||
.dialog("close");
|
.dialog("close");
|
||||||
|
@ -164,6 +151,7 @@ function infoMessage(data, idMsg) {
|
||||||
},
|
},
|
||||||
close: function(event, ui) {
|
close: function(event, ui) {
|
||||||
$(".ui-widget-overlay").removeClass("error-modal-opened");
|
$(".ui-widget-overlay").removeClass("error-modal-opened");
|
||||||
|
closed = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
|
|
|
@ -1274,6 +1274,7 @@ echo '</div>';
|
||||||
|
|
||||||
// Connection lost alert.
|
// Connection lost alert.
|
||||||
ui_require_javascript_file('connection_check');
|
ui_require_javascript_file('connection_check');
|
||||||
|
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||||
$conn_title = __('Connection with server has been lost');
|
$conn_title = __('Connection with server has been lost');
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
||||||
|
|
|
@ -87,6 +87,7 @@ ui_require_css_file('register', 'include/styles/', true);
|
||||||
$conn_title = __('Connection with server has been lost');
|
$conn_title = __('Connection with server has been lost');
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||||
ui_require_javascript_file('connection_check');
|
ui_require_javascript_file('connection_check');
|
||||||
|
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||||
ui_print_message_dialog(
|
ui_print_message_dialog(
|
||||||
$conn_title,
|
$conn_title,
|
||||||
$conn_text,
|
$conn_text,
|
||||||
|
|
|
@ -66,6 +66,7 @@ ui_require_css_file('register', 'include/styles/', true);
|
||||||
$conn_title = __('Connection with server has been lost');
|
$conn_title = __('Connection with server has been lost');
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||||
ui_require_javascript_file('connection_check');
|
ui_require_javascript_file('connection_check');
|
||||||
|
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
||||||
|
|
||||||
$table = new StdClass;
|
$table = new StdClass;
|
||||||
|
|
|
@ -277,6 +277,7 @@ if ($layers != false) {
|
||||||
$conn_title = __('Connection with server has been lost');
|
$conn_title = __('Connection with server has been lost');
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||||
ui_require_javascript_file('connection_check');
|
ui_require_javascript_file('connection_check');
|
||||||
|
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ $url_css_modal = ui_get_full_url('include/styles/register.css', false, false, fa
|
||||||
echo '<link rel="stylesheet" href="'.$url_css_modal.'" type="text/css" />';
|
echo '<link rel="stylesheet" href="'.$url_css_modal.'" type="text/css" />';
|
||||||
// Connection lost alert.
|
// Connection lost alert.
|
||||||
ui_require_javascript_file('connection_check', 'include/javascript/', true);
|
ui_require_javascript_file('connection_check', 'include/javascript/', true);
|
||||||
|
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||||
$conn_title = __('Connection with server has been lost');
|
$conn_title = __('Connection with server has been lost');
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
||||||
|
|
|
@ -33,6 +33,7 @@ ui_require_css_file('register', 'include/styles/', true);
|
||||||
|
|
||||||
// Connection lost alert.
|
// Connection lost alert.
|
||||||
ui_require_javascript_file('connection_check', 'include/javascript/', true);
|
ui_require_javascript_file('connection_check', 'include/javascript/', true);
|
||||||
|
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
|
||||||
$conn_title = __('Connection with server has been lost');
|
$conn_title = __('Connection with server has been lost');
|
||||||
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
|
||||||
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
|
||||||
|
|
Loading…
Reference in New Issue