ws php8
This commit is contained in:
parent
28743dcb5d
commit
35184c4eb6
|
@ -33,6 +33,31 @@ require_once $config['homedir'].'/include/functions_agents.php';
|
|||
require_once $config['homedir'].'/godmode/wizards/Wizard.main.php';
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $url Url.
|
||||
* @param array $params Params.
|
||||
*
|
||||
* @return mixed Result
|
||||
*/
|
||||
function curl(string $url, array $params)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||
$get_result = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $get_result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show Quick Shell interface.
|
||||
*
|
||||
|
@ -110,7 +135,7 @@ function quickShell()
|
|||
// No username provided, ask for it.
|
||||
$wiz = new Wizard();
|
||||
|
||||
$test = file_get_contents($ws_url, false, $context);
|
||||
$test = curl($ws_url, []);
|
||||
if ($test === false) {
|
||||
ui_print_error_message(__('WebService engine has not been started, please check documentation.'));
|
||||
$wiz->printForm(
|
||||
|
@ -210,7 +235,7 @@ function quickShell()
|
|||
|
||||
// If rediretion is enabled, we will try to connect using
|
||||
// http:// or https:// endpoint.
|
||||
$test = get_headers($ws_url, null, $context);
|
||||
$test = get_headers($ws_url, false, $context);
|
||||
if ($test === false) {
|
||||
if (empty($wiz) === true) {
|
||||
$wiz = new Wizard();
|
||||
|
|
|
@ -1391,8 +1391,16 @@ function safe_output_accute($string)
|
|||
}
|
||||
|
||||
|
||||
function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $access_attr, $ldap_admin_user, $ldap_admin_pass, $user)
|
||||
{
|
||||
function local_ldap_search(
|
||||
$ldap_host,
|
||||
$ldap_port=389,
|
||||
$ldap_version=3,
|
||||
$dn=null,
|
||||
$access_attr=null,
|
||||
$ldap_admin_user=null,
|
||||
$ldap_admin_pass=null,
|
||||
$user=null
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$filter = '';
|
||||
|
|
|
@ -1269,10 +1269,12 @@ function mysql_db_process_sql_delete($table, $where, $where_join='AND')
|
|||
* @param string $sql
|
||||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function mysql_db_get_all_row_by_steps_sql($new=true, &$result, $sql=null)
|
||||
function mysql_db_get_all_row_by_steps_sql($new, &$result, $sql=null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$new = ($new ?? true);
|
||||
|
||||
if ($config['mysqli'] === true) {
|
||||
if ($new == true) {
|
||||
$result = mysqli_query($config['dbconnection'], $sql);
|
||||
|
|
|
@ -1170,10 +1170,12 @@ function db_get_all_rows_filter($table, $filter=[], $fields=false, $where_join='
|
|||
* @param string $sql
|
||||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function db_get_all_row_by_steps_sql($new=true, &$result, $sql=null)
|
||||
function db_get_all_row_by_steps_sql($new, &$result, $sql=null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$new = ($new ?? true);
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
return mysql_db_get_all_row_by_steps_sql($new, $result, $sql);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
function forecast_projection_graph(
|
||||
$module_id,
|
||||
$period=SECONDS_2MONTHS,
|
||||
$prediction_period,
|
||||
$prediction_period=false,
|
||||
$max_value=false,
|
||||
$min_value=false,
|
||||
$csv=false,
|
||||
|
|
|
@ -2800,7 +2800,7 @@ function graph_agent_status(
|
|||
* @param integer height pie graph height
|
||||
* @param integer id_agent Agent ID
|
||||
*/
|
||||
function graph_event_module($width=300, $height=200, $id_agent)
|
||||
function graph_event_module($width=300, $height=200, $id_agent=null)
|
||||
{
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
@ -2960,9 +2960,9 @@ function graph_sla_slicebar(
|
|||
$sla_min,
|
||||
$sla_max,
|
||||
$date,
|
||||
$daysWeek=null,
|
||||
$time_from=null,
|
||||
$time_to=null,
|
||||
$daysWeek,
|
||||
$time_from,
|
||||
$time_to,
|
||||
$width,
|
||||
$height,
|
||||
$home_url,
|
||||
|
|
|
@ -145,17 +145,31 @@ function integriaims_get_details($details, $detail_index=false)
|
|||
/**
|
||||
* Perform an API call to Integria IMS.
|
||||
*
|
||||
* @param string API host URL.
|
||||
* @param string User name.
|
||||
* @param string User password.
|
||||
* @param string API password.
|
||||
* @param string API Operation.
|
||||
* @param mixed String or array with parameters required by the API function.
|
||||
* @param string|null $api_hostname API host URL.
|
||||
* @param string|null $user User name.
|
||||
* @param string|null $user_pass User password.
|
||||
* @param string|null $api_pass API password.
|
||||
* @param string|null $operation API Operation.
|
||||
* @param mixed $params String or array with parameters required by the API function.
|
||||
* @param mixed $show_credentials_error_msg Show_credentials_error_msg.
|
||||
* @param mixed $return_type Return_type.
|
||||
* @param mixed $token Token.
|
||||
* @param mixed $user_level_conf User_level_conf.
|
||||
*
|
||||
* @return boolean True if API request succeeded, false if API request failed.
|
||||
*/
|
||||
function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api_pass=null, $operation, $params='', $show_credentials_error_msg=false, $return_type='', $token='', $user_level_conf=null)
|
||||
{
|
||||
function integria_api_call(
|
||||
$api_hostname=null,
|
||||
$user=null,
|
||||
$user_pass=null,
|
||||
$api_pass=null,
|
||||
$operation=null,
|
||||
$params='',
|
||||
$show_credentials_error_msg=false,
|
||||
$return_type='',
|
||||
$token='',
|
||||
$user_level_conf=null
|
||||
) {
|
||||
global $config;
|
||||
|
||||
if (is_metaconsole()) {
|
||||
|
|
|
@ -4246,7 +4246,9 @@ function ui_forced_public_url()
|
|||
$exclusions = preg_split("/[\n\s,]+/", io_safe_output($config['public_url_exclusions']));
|
||||
}
|
||||
|
||||
if (in_array($_SERVER['REMOTE_ADDR'], $exclusions)) {
|
||||
if (isset($_SERVER['REMOTE_ADDR']) === true
|
||||
&& in_array($_SERVER['REMOTE_ADDR'], $exclusions)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4353,7 +4355,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me
|
|||
} else {
|
||||
$protocol = 'http';
|
||||
|
||||
if ($_SERVER['SERVER_PORT'] != 80) {
|
||||
if (($_SERVER['SERVER_PORT'] ?? 80) != 80) {
|
||||
$port = $_SERVER['SERVER_PORT'];
|
||||
}
|
||||
}
|
||||
|
@ -4378,10 +4380,10 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me
|
|||
|
||||
$proxy = true;
|
||||
} else {
|
||||
$fullurl = $protocol.'://'.$_SERVER['SERVER_NAME'];
|
||||
$fullurl = $protocol.'://'.($_SERVER['SERVER_NAME'] ?? '');
|
||||
}
|
||||
} else {
|
||||
$fullurl = $protocol.'://'.$_SERVER['SERVER_NAME'];
|
||||
$fullurl = $protocol.'://'.($_SERVER['SERVER_NAME'] ?? '');
|
||||
}
|
||||
|
||||
// Using a different port than the standard.
|
||||
|
|
|
@ -251,8 +251,13 @@ class WSManager extends WebSocketServer
|
|||
}
|
||||
} else {
|
||||
// Failed. Disconnect all.
|
||||
$this->disconnect($user->socket);
|
||||
$this->disconnect($user->redirect->socket);
|
||||
if (isset($user) === true) {
|
||||
$this->disconnect($user->socket);
|
||||
}
|
||||
|
||||
if (isset($user->redirect) === true) {
|
||||
$this->disconnect($user->redirect->socket);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ abstract class WebSocketServer
|
|||
|
||||
$this->sockets['m'] = $this->master;
|
||||
$this->stderr('Listening on: '.$addr.':'.$port);
|
||||
$this->stderr('Master socket: '.$this->master."\n");
|
||||
$this->stderr('Master socket: '.\obhd($this->master)."\n");
|
||||
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ abstract class WebSocketServer
|
|||
continue;
|
||||
} else {
|
||||
$this->connect($client);
|
||||
$this->stderr('Client connected. '.$client);
|
||||
$this->stderr('Client connected. '.\obhd($client));
|
||||
}
|
||||
} else {
|
||||
if (!$socket) {
|
||||
|
@ -569,7 +569,7 @@ abstract class WebSocketServer
|
|||
/**
|
||||
* Disconnect socket from master.
|
||||
*
|
||||
* @param Socket $socket Socket.
|
||||
* @param \Socket $socket Socket.
|
||||
* @param boolean $triggerClosed Also close.
|
||||
* @param integer $sockErrNo Clear error.
|
||||
*
|
||||
|
@ -605,7 +605,7 @@ abstract class WebSocketServer
|
|||
if ($triggerClosed) {
|
||||
$this->closed($user);
|
||||
$this->stderr(
|
||||
'Client disconnected. '.$user->socket
|
||||
'Client disconnected. '.$user->id
|
||||
);
|
||||
socket_close($user->socket);
|
||||
} else {
|
||||
|
|
|
@ -1353,7 +1353,9 @@ $agent_interfaces = agents_get_network_interfaces(
|
|||
['id_agente' => $id_agente]
|
||||
);
|
||||
|
||||
if (is_array($agent_interfaces[$id_agente]['interfaces']) !== true
|
||||
if (isset($agent_interfaces) !== true
|
||||
|| isset($agent_interfaces[$id_agente]) !== true
|
||||
|| is_array($agent_interfaces[$id_agente]['interfaces']) !== true
|
||||
|| is_object($agent_interfaces[$id_agente]['interfaces']) !== true
|
||||
) {
|
||||
$agent_interfaces_count = 0;
|
||||
|
@ -1660,28 +1662,26 @@ if ($tab == 'external_tools') {
|
|||
}
|
||||
|
||||
$onheader = [
|
||||
'manage' => $managetab,
|
||||
'main' => $maintab,
|
||||
'alert' => $alerttab,
|
||||
'interface' => $interfacetab,
|
||||
'inventory' => $inventorytab,
|
||||
'collection' => $collectiontab,
|
||||
'gis' => $gistab,
|
||||
'custom' => $custom_fields,
|
||||
'graphs' => $graphs,
|
||||
'policy' => $policyTab,
|
||||
'ux_console' => $ux_console_tab,
|
||||
'wux_console' => $wux_console_tab,
|
||||
'url_route_analyzer' => $url_route_analyzer_tab,
|
||||
'sap_view' => $saptab,
|
||||
'ncm_view' => $ncm_tab,
|
||||
'external_tools' => $external_tools,
|
||||
'manage' => ($managetab ?? null),
|
||||
'main' => ($maintab ?? null),
|
||||
'alert' => ($alerttab ?? null),
|
||||
'interface' => ($interfacetab ?? null),
|
||||
'inventory' => ($inventorytab ?? null),
|
||||
'collection' => ($collectiontab ?? null),
|
||||
'gis' => ($gistab ?? null),
|
||||
'custom' => ($custom_fields ?? null),
|
||||
'graphs' => ($graphs ?? null),
|
||||
'policy' => ($policyTab ?? null),
|
||||
'ux_console' => ($ux_console_tab ?? null),
|
||||
'wux_console' => ($wux_console_tab ?? null),
|
||||
'url_route_analyzer' => ($url_route_analyzer_tab ?? null),
|
||||
'sap_view' => ($saptab ?? null),
|
||||
'ncm_view' => ($ncm_tab ?? null),
|
||||
'external_tools' => ($external_tools ?? null),
|
||||
'incident' => ($incidenttab ?? null),
|
||||
];
|
||||
|
||||
|
||||
$onheader['incident'] = $incidenttab;
|
||||
|
||||
|
||||
if ($agent['url_address'] != '') {
|
||||
$onheader['url_address'] = $urladdresstab;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ require_once __DIR__.'/vendor/autoload.php';
|
|||
use \PandoraFMS\Websockets\WSManager;
|
||||
|
||||
// Set to true to get full output.
|
||||
$debug = false;
|
||||
$debug = true;
|
||||
|
||||
// 1MB.
|
||||
$bufferSize = 1048576;
|
||||
|
|
Loading…
Reference in New Issue