2016-05-09 13:06:30 +02:00
|
|
|
<?php
|
|
|
|
|
2021-09-29 17:03:13 +02:00
|
|
|
// Barivion - http://barivion.com
|
2016-05-09 13:06:30 +02:00
|
|
|
// ==================================================
|
2020-11-27 13:52:35 +01:00
|
|
|
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
2016-05-09 13:06:30 +02:00
|
|
|
// 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.
|
2018-11-21 13:08:58 +01:00
|
|
|
// Don't start a session before this import.
|
|
|
|
// The session is configured and started inside the config process.
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once '../../include/config.php';
|
|
|
|
require_once $config['homedir'].'/include/functions.php';
|
2016-05-09 13:06:30 +02:00
|
|
|
|
|
|
|
check_login();
|
|
|
|
|
|
|
|
$agent_id = (string) get_parameter_get('agent_id');
|
|
|
|
$hostname = (string) get_parameter_get('hostname');
|
|
|
|
$port = (int) get_parameter_get('port');
|
|
|
|
$token = (string) get_parameter_get('token');
|
2016-05-09 16:22:01 +02:00
|
|
|
$expiration = (int) get_parameter_get('expiration');
|
2016-05-09 13:06:30 +02:00
|
|
|
$is_busy = (bool) get_parameter_get('is_busy');
|
|
|
|
$last_connection = (int) get_parameter_get('last_connection');
|
|
|
|
$section = (string) get_parameter_get('section');
|
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
2019-01-30 16:18:44 +01:00
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>eHorus client</title>
|
|
|
|
<link rel="stylesheet" href="../../include/ehorus/css/bootstrap.min.css" type="text/css" />
|
|
|
|
<link rel="stylesheet" href="../../include/ehorus/css/style.css" type="text/css" />
|
|
|
|
<link rel="stylesheet" href="../../include/ehorus/css/xterm.css" type="text/css" />
|
|
|
|
<script type="text/javascript" src="../../include/ehorus/bundle.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="ehorus-client-container"></div>
|
|
|
|
</body>
|
2016-05-09 13:06:30 +02:00
|
|
|
</html>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2019-01-30 16:18:44 +01:00
|
|
|
(function () {
|
|
|
|
var runClient = function (node, props) {
|
|
|
|
props = props || {};
|
|
|
|
var agentID = props.agentID;
|
|
|
|
var protocol = 'wss';
|
|
|
|
var hostname = props.hostname;
|
|
|
|
var port = props.port;
|
|
|
|
var token = props.token;
|
|
|
|
var isBusy = props.isBusy;
|
|
|
|
var lastConnection = props.lastConnection;
|
|
|
|
var section = props.section || 'system';
|
|
|
|
|
|
|
|
var eHorusProps = {
|
|
|
|
url: {
|
|
|
|
protocol: protocol,
|
|
|
|
hostname: hostname,
|
|
|
|
port: port,
|
|
|
|
slashes: true,
|
|
|
|
pathname: '',
|
|
|
|
search: 'auth=' + token
|
|
|
|
},
|
|
|
|
agentID: agentID,
|
|
|
|
agentLastContact: lastConnection,
|
|
|
|
agentIsBusy: isBusy,
|
|
|
|
header: false,
|
|
|
|
section: section
|
|
|
|
}
|
|
|
|
var eHorus = new EHorus(eHorusProps);
|
|
|
|
eHorus.renderIn(node);
|
|
|
|
|
|
|
|
return eHorus;
|
|
|
|
}
|
|
|
|
|
|
|
|
var messageToParent = function (message) {
|
|
|
|
window.parent.postMessage(message, window.location.origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
var handleMessage = function (actionHandlers) {
|
|
|
|
return function (event) {
|
|
|
|
// The message source should be the created in the parent
|
|
|
|
if (event.origin === window.location.origin &&
|
|
|
|
event.source !== window.parent) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (typeof actionHandlers === 'undefined') return;
|
|
|
|
|
|
|
|
if (event.data.action in actionHandlers) {
|
|
|
|
actionHandlers[event.data.action](event.data.payload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = function () {
|
|
|
|
var expiration = <?php echo $expiration; ?>;
|
|
|
|
// Start client
|
|
|
|
var ehorusContainer = document.getElementById('ehorus-client-container');
|
|
|
|
var eHorus = runClient(ehorusContainer, {
|
|
|
|
agentID: '<?php echo $agent_id; ?>',
|
|
|
|
protocol: 'wss',
|
|
|
|
hostname: '<?php echo $hostname; ?>',
|
|
|
|
port: <?php echo $port; ?>,
|
|
|
|
token: '<?php echo $token; ?>',
|
|
|
|
isBusy: <?php echo json_encode($is_busy); ?>,
|
|
|
|
lastConnection: <?php echo $last_connection; ?>,
|
|
|
|
section: '<?php echo $section; ?>'
|
|
|
|
});
|
|
|
|
|
|
|
|
eHorus.remote.onClose(function () {
|
|
|
|
if (expiration && expiration < Date.now() / 1000) {
|
|
|
|
eHorus.remote.close();
|
|
|
|
// Send expired message
|
|
|
|
messageToParent({
|
|
|
|
action: 'expired',
|
|
|
|
payload: {}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Listen for messages
|
|
|
|
var actionHandlers = {
|
|
|
|
change_section: function (payload) {
|
|
|
|
eHorus.changeSection(payload.section);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.addEventListener('message', handleMessage(actionHandlers));
|
|
|
|
|
|
|
|
// Send ready message
|
|
|
|
messageToParent({
|
|
|
|
action: 'ready',
|
|
|
|
payload: {}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})()
|
2016-05-09 13:06:30 +02:00
|
|
|
</script>
|