From 0291f8f3cd19213b2fda11239d23e520016ad419 Mon Sep 17 00:00:00 2001 From: Hubert Moreau Date: Mon, 15 Aug 2022 10:43:44 +0200 Subject: [PATCH] Add custom header to StatusUpdater --- src/includes/functions.inc.php | 8 +++++++- src/psm/Util/Server/Updater/StatusUpdater.php | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 85e11b3c..158fae23 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -390,6 +390,7 @@ namespace { * @param string|bool $website_password Password website * @param string|null $request_method Request method like GET, POST etc. * @param string|null $post_field POST data + * @param string|null $custom_header HEADER data * @return array cURL result */ function psm_curl_get( @@ -401,7 +402,8 @@ namespace { $website_username = false, $website_password = false, $request_method = null, - $post_field = null + $post_field = null, + $custom_header = null ) { ($timeout === null || $timeout > 0) ? PSM_CURL_TIMEOUT : intval($timeout); @@ -429,6 +431,10 @@ namespace { curl_setopt($ch, CURLOPT_POSTFIELDS, $post_field); } + if (!empty($custom_header)){ + curl_setopt($ch, CURLOPT_HTTPHEADER, array($custom_header)); + } + if ( $website_username !== false && $website_password !== false && diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index e299ae98..5a006166 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -100,7 +100,7 @@ class StatusUpdater 'allow_http_status', 'redirect_check', 'header_name', 'header_value', 'status', 'active', 'warning_threshold', 'warning_threshold_counter', 'ssl_cert_expiry_days', 'ssl_cert_expired_time', 'timeout', 'website_username', - 'website_password', 'last_offline' + 'website_password', 'last_offline', 'custom_header' )); if (empty($this->server)) { return false; @@ -248,7 +248,8 @@ class StatusUpdater psm_password_decrypt($this->server['server_id'] . psm_get_conf('password_encrypt_key'), $this->server['website_password']), $this->server['request_method'], - $this->server['post_field'] + $this->server['post_field'], + $this->server['custom_header'] ); $this->header = $curl_result['exec']; $this->curl_info = $curl_result['info'];