From cdf5485aee3eb097479926a98a9b94eba528b4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Mon, 27 Jun 2022 18:06:51 +0200 Subject: [PATCH] Updated api checker extension --- pandora_console/extensions/api_checker.php | 128 ++++++++++++++++----- 1 file changed, 98 insertions(+), 30 deletions(-) diff --git a/pandora_console/extensions/api_checker.php b/pandora_console/extensions/api_checker.php index b4af7c77ee..ed2053036e 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -1,43 +1,101 @@ $url, 'result' => $result, ]; - - return $return; } +/** + * Perform API Checker + * + * @return void. + */ function extension_api_checker() { global $config; check_login(); - if (! check_acl($config['id_user'], 0, 'PM')) { + if ((bool) check_acl($config['id_user'], 0, 'PM') === false) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access Profile Management' @@ -85,11 +146,12 @@ function extension_api_checker() $return_type = io_safe_output(get_parameter('return_type', '')); $other = io_safe_output(get_parameter('other', '')); $other_mode = io_safe_output(get_parameter('other_mode', 'url_encode_separator_|')); + $token = get_parameter('token'); - $api_execute = get_parameter('api_execute', 0); + $api_execute = (bool) get_parameter('api_execute', false); $return_call_api = ''; - if ($api_execute) { + if ($api_execute === true) { $return_call_api = api_execute( $url, $ip, @@ -103,7 +165,8 @@ function extension_api_checker() urlencode($id2), $return_type, urlencode($other), - $other_mode + $other_mode, + $token ); } @@ -182,6 +245,11 @@ function extension_api_checker() $row[] = html_print_input_text('other_mode', $other_mode, '', 50, 255, true); $table2->data[] = $row; + $row = []; + $row[] = __('API Token'); + $row[] = html_print_input_text('token', $token, '', 50, 255, true); + $table2->data[] = $row; + $table3 = new stdClass(); $table3->data = []; @@ -214,7 +282,7 @@ function extension_api_checker() echo ''; echo ''; - if ($api_execute) { + if ($api_execute === true) { echo '
'; echo ''.__('Result').''; echo __('URL').'
';