mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
minor fixes
This commit is contained in:
parent
e12bcb2ac4
commit
06c7544041
@ -74,7 +74,7 @@ function quickShell()
|
|||||||
config_update_value('ws_port', 8080);
|
config_update_value('ws_port', 8080);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['ws_proxy_url']) === false) {
|
if (empty($config['ws_proxy_url']) === true) {
|
||||||
$ws_url = 'http://'.$config['ws_host'].':'.$config['ws_port'];
|
$ws_url = 'http://'.$config['ws_host'].':'.$config['ws_port'];
|
||||||
} else {
|
} else {
|
||||||
preg_match('/\/\/(.*)/', $config['ws_proxy_url'], $matches);
|
preg_match('/\/\/(.*)/', $config['ws_proxy_url'], $matches);
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Quick shell extra tab (agent view). Gotty based.
|
|
||||||
*
|
|
||||||
* @category Extensions
|
|
||||||
* @package Pandora FMS
|
|
||||||
* @subpackage Quick Shell (gotty)
|
|
||||||
* @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.
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* QuickShell.
|
|
||||||
*/
|
|
||||||
class QuickShell
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes a QuickShell environment.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install QuickShell extension into PandoraFMS
|
|
||||||
*
|
|
||||||
* Registers class into system.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function install()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch an interactive bash session
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function interactiveShell()
|
|
||||||
{
|
|
||||||
file_get_Str();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
// ______ __ _______ _______ _______
|
|
||||||
// | __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __|
|
|
||||||
// | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
||||||
// |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
||||||
//
|
|
||||||
// ============================================================================
|
|
||||||
// Copyright (c) 2007-2018 Artica Soluciones Tecnologicas, http://www.artica.es
|
|
||||||
// This code is NOT free software. This code is NOT licenced under GPL2 licence
|
|
||||||
// You cannnot redistribute it without written permission of copyright holder.
|
|
||||||
// ============================================================================
|
|
||||||
require_once 'include/functions.php';
|
|
||||||
require_once 'include/functions_config.php';
|
|
||||||
require_once 'include/functions_groupview.php';
|
|
||||||
require_once 'include/auth/mysql.php';
|
|
||||||
|
|
||||||
check_login();
|
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
|
||||||
db_pandora_audit(
|
|
||||||
'ACL Violation',
|
|
||||||
'Trying to access Profile Management'
|
|
||||||
);
|
|
||||||
include 'general/noaccess.php';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function confWetty()
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
if (get_parameter('wetty_ip')) {
|
|
||||||
config_update_value('wetty_ip', get_parameter('wetty_ip'));
|
|
||||||
} else {
|
|
||||||
if (!isset($config['wetty_ip'])) {
|
|
||||||
$config['wetty_ip'] = $_SERVER['SERVER_ADDR'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['wetty_ip'] == '127.0.0.1') {
|
|
||||||
config_update_value('wetty_ip', $_SERVER['SERVER_ADDR']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_parameter('wetty_port')) {
|
|
||||||
config_update_value('wetty_port', get_parameter('wetty_port'));
|
|
||||||
} else {
|
|
||||||
if (!isset($config['wetty_port'])) {
|
|
||||||
$config['wetty_port'] = '3000';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$buttons['maps'] = [
|
|
||||||
'active' => false,
|
|
||||||
'text' => '<a href="index.php?login=1&extension_in_menu=gextensions&sec=gextensions&sec2=extensions/wetty">'.html_print_image('images/groups_small/application_osx_terminal.png', true, ['title' => __('Wetty')]).'</a>',
|
|
||||||
];
|
|
||||||
|
|
||||||
ui_print_page_header(__('Wetty'), 'images/extensions.png', false, '', true, $buttons);
|
|
||||||
|
|
||||||
$row = 0;
|
|
||||||
|
|
||||||
echo '<form id="form_setup" action="'.$_SERVER['REQUEST_URI'].'" method="post">';
|
|
||||||
|
|
||||||
$table->width = '100%';
|
|
||||||
$table->class = 'databox data';
|
|
||||||
$table->data = [];
|
|
||||||
$table->head = [];
|
|
||||||
$table->align = [];
|
|
||||||
// $table->align[3] = 'left';
|
|
||||||
$table->style = [];
|
|
||||||
$table->size = [];
|
|
||||||
// $table->size[3] = '10%';
|
|
||||||
$table->style[0] = 'font-weight: bold';
|
|
||||||
|
|
||||||
$table->head[0] = __('Wetty Configuration');
|
|
||||||
$table->head[1] = __('');
|
|
||||||
|
|
||||||
$table->data[$row][0] = __('Wetty ip address connection');
|
|
||||||
$table->data[$row][1] = html_print_input_text('wetty_ip', $config['wetty_ip'], '', 25, 25, true);
|
|
||||||
$row++;
|
|
||||||
|
|
||||||
$table->data[$row][0] = __('Wetty port connection');
|
|
||||||
$table->data[$row][1] = html_print_input_text('wetty_port', $config['wetty_port'], '', 25, 25, true);
|
|
||||||
$row++;
|
|
||||||
|
|
||||||
array_push($table->data, $data);
|
|
||||||
|
|
||||||
html_print_table($table);
|
|
||||||
|
|
||||||
echo '<div class="action-buttons" style="width: '.$table_other->width.'">';
|
|
||||||
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
echo '</form>';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extensions_add_godmode_function('confWetty');
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
// ______ __ _______ _______ _______
|
|
||||||
// | __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __|
|
|
||||||
// | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
||||||
// |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
||||||
//
|
|
||||||
// ============================================================================
|
|
||||||
// Copyright (c) 2007-2018 Artica Soluciones Tecnologicas, http://www.artica.es
|
|
||||||
// This code is NOT free software. This code is NOT licenced under GPL2 licence
|
|
||||||
// You cannnot redistribute it without written permission of copyright holder.
|
|
||||||
// ============================================================================
|
|
||||||
require_once 'include/functions.php';
|
|
||||||
require_once 'include/functions_groupview.php';
|
|
||||||
require_once 'include/auth/mysql.php';
|
|
||||||
|
|
||||||
check_login();
|
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
|
||||||
db_pandora_audit(
|
|
||||||
'ACL Violation',
|
|
||||||
'Trying to access Profile Management'
|
|
||||||
);
|
|
||||||
include 'general/noaccess.php';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function mainWetty()
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
if (!isset($config['wetty_ip'])) {
|
|
||||||
config_update_value('wetty_ip', $_SERVER['SERVER_ADDR']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['wetty_ip'] == '127.0.0.1') {
|
|
||||||
config_update_value('wetty_ip', $_SERVER['SERVER_ADDR']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($config['wetty_port'])) {
|
|
||||||
config_update_value('wetty_port', '3000');
|
|
||||||
}
|
|
||||||
|
|
||||||
$buttons['maps'] = [
|
|
||||||
'active' => false,
|
|
||||||
'text' => '<a href="index.php?login=1&extension_in_menu=gextensions&sec=gextensions&sec2=extensions/wetty_conf">'.html_print_image('images/setup.png', true, ['title' => __('Wetty settings')]).'</a>',
|
|
||||||
];
|
|
||||||
|
|
||||||
ui_print_page_header(__('Wetty'), 'images/extensions.png', false, '', true, $buttons);
|
|
||||||
|
|
||||||
$table->width = '100%';
|
|
||||||
$table->class = 'databox data';
|
|
||||||
$table->data = [];
|
|
||||||
$table->head = [];
|
|
||||||
$table->align = [];
|
|
||||||
// $table->align[3] = 'left';
|
|
||||||
$table->style = [];
|
|
||||||
$table->size = [];
|
|
||||||
// $table->size[3] = '10%';
|
|
||||||
$table->style[0] = 'font-weight: bold';
|
|
||||||
|
|
||||||
$table->head[0] = __('Wetty');
|
|
||||||
|
|
||||||
// $data[0] = '<iframe scrolling="auto" frameborder="0" width="100%" height="600px" src="http://192.168.70.64:3000/"></iframe>';
|
|
||||||
$data[0] = '<iframe scrolling="auto" frameborder="0" width="100%" height="600px" src="http://'.$config['wetty_ip'].':'.$config['wetty_port'].'/"></iframe>';
|
|
||||||
|
|
||||||
// $data[0] .= '<div id="terminal" style="background-color:black;width:100%;height:600px;overflow: hidden;"><div>';
|
|
||||||
array_push($table->data, $data);
|
|
||||||
|
|
||||||
html_print_table($table);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extensions_add_godmode_menu_option(__('Wetty'), 'AW', 'gextensions', null, 'v1');
|
|
||||||
extensions_add_godmode_function('mainWetty');
|
|
@ -1,97 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>WebSocket</title>
|
|
||||||
<style type="text/css">
|
|
||||||
html,
|
|
||||||
body {
|
|
||||||
font: normal 0.9em arial, helvetica;
|
|
||||||
}
|
|
||||||
|
|
||||||
#log {
|
|
||||||
width: 600px;
|
|
||||||
height: 300px;
|
|
||||||
border: 1px solid #7f9db9;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#msg {
|
|
||||||
width: 400px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var socket;
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
var host = "ws://172.16.0.2:8081/echobot"; // SET THIS TO YOUR SERVER
|
|
||||||
try {
|
|
||||||
socket = new WebSocket(host);
|
|
||||||
log("WebSocket - status " + socket.readyState);
|
|
||||||
socket.onopen = function(msg) {
|
|
||||||
log("Welcome - status " + this.readyState);
|
|
||||||
};
|
|
||||||
socket.onmessage = function(msg) {
|
|
||||||
log("Received: " + msg.data);
|
|
||||||
};
|
|
||||||
socket.onclose = function(msg) {
|
|
||||||
log("Disconnected - status " + this.readyState);
|
|
||||||
};
|
|
||||||
} catch (ex) {
|
|
||||||
log(ex);
|
|
||||||
}
|
|
||||||
$("msg").focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function send() {
|
|
||||||
var txt, msg;
|
|
||||||
txt = $("msg");
|
|
||||||
msg = txt.value;
|
|
||||||
if (!msg) {
|
|
||||||
alert("Message can not be empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
txt.value = "";
|
|
||||||
txt.focus();
|
|
||||||
try {
|
|
||||||
socket.send(msg);
|
|
||||||
log("Sent: " + msg);
|
|
||||||
} catch (ex) {
|
|
||||||
log(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function quit() {
|
|
||||||
if (socket != null) {
|
|
||||||
log("Goodbye!");
|
|
||||||
socket.close();
|
|
||||||
socket = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function reconnect() {
|
|
||||||
quit();
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utilities
|
|
||||||
function $(id) {
|
|
||||||
return document.getElementById(id);
|
|
||||||
}
|
|
||||||
function log(msg) {
|
|
||||||
$("log").innerHTML += "<br>" + msg;
|
|
||||||
}
|
|
||||||
function onkey(event) {
|
|
||||||
if (event.keyCode == 13) {
|
|
||||||
send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body onload="init()">
|
|
||||||
<h3>WebSocket v2.00</h3>
|
|
||||||
<div id="log"></div>
|
|
||||||
<input id="msg" type="textbox" onkeypress="onkey(event)" />
|
|
||||||
<button onclick="send()">Send</button>
|
|
||||||
<button onclick="quit()">Quit</button>
|
|
||||||
<button onclick="reconnect()">Reconnect</button>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$host = '127.0.0.1';
|
|
||||||
$port = 8080;
|
|
||||||
|
|
||||||
$r = file_get_contents('http://'.$host.':'.$port.'/js/hterm.js');
|
|
||||||
$r .= file_get_contents('http://'.$host.':'.$port.'/auth_token.js');
|
|
||||||
$gotty = file_get_contents('http://'.$host.':'.$port.'/js/gotty.js');
|
|
||||||
|
|
||||||
|
|
||||||
$url = "var url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws';";
|
|
||||||
$new = "var url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + ':8081' + window.location.pathname;";
|
|
||||||
|
|
||||||
$gotty = str_replace($url, $new, $gotty);
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Quick Shell experiment</title>
|
|
||||||
<style>#terminal {
|
|
||||||
height: 590px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0;
|
|
||||||
max-height: 590px;
|
|
||||||
}
|
|
||||||
#terminal > iframe {
|
|
||||||
position: relative!important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<link rel="icon" type="image/png" href="favicon.png">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Prueba</h1>
|
|
||||||
<div id="terminal"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
<?php echo $r; ?>
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
<?php echo $gotty; ?>
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
||||||
$connect = socket_connect($socket, $host, $port);
|
|
||||||
if (!$connect) {
|
|
||||||
echo 'failed to open target socket redirection';
|
|
||||||
$this->disconnect($user->socket);
|
|
||||||
} else {
|
|
||||||
echo ">> me he conectado al otro lado \n";
|
|
||||||
echo "Enviando petición HTTP HEAD ...\n";
|
|
||||||
|
|
||||||
$out .= 'GET ws://'.$host.':'.$port.'/ws HTTP/1.1'."\r\n";
|
|
||||||
$out .= 'Host: '.$host.':'.$port."\r\n";
|
|
||||||
$out .= 'Connection: Upgrade'."\r\n";
|
|
||||||
$out .= 'Upgrade: websocket'."\r\n";
|
|
||||||
//$out .= 'Sec-WebSocket-Key: tqIu95AAeKFFlrLTsixBAA=='."\r\n";
|
|
||||||
$out .= 'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits'."\r\n";
|
|
||||||
$out .= 'Sec-WebSocket-Protocol: gotty'."\r\n";
|
|
||||||
|
|
||||||
$out .= '{"Arguments":"","AuthToken":""}';
|
|
||||||
|
|
||||||
socket_write($socket, $out);
|
|
||||||
echo "Leyendo respuesta:\n\n";
|
|
||||||
while ($out = socket_read($socket, 2048)) {
|
|
||||||
echo '['.$out.']';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Disconnect.
|
|
||||||
$out = "GET / HTTP/1.1\r\n";
|
|
||||||
$out .= 'Host: '.$host."\r\n";
|
|
||||||
$out .= "Connection: Close\r\n\r\n";
|
|
||||||
|
|
||||||
socket_write($socket, $out);
|
|
||||||
echo ">> Recibiendo respuesta de peticion de cierre:\n";
|
|
||||||
while ($out = socket_read($socket, 2048)) {
|
|
||||||
echo '['.$out.']';
|
|
||||||
}
|
|
||||||
|
|
||||||
socket_close($socket);
|
|
||||||
*/
|
|
Loading…
x
Reference in New Issue
Block a user