Merge pull request #1204 from KombineTech/develop
Fix sendWebHook PHP8 Uncaught TypeError: Cannot access offsetpull/1293/head
commit
085af72e14
|
@ -13,3 +13,4 @@ __MACOSX/
|
||||||
.buildpath
|
.buildpath
|
||||||
.settings/
|
.settings/
|
||||||
/.vscode
|
/.vscode
|
||||||
|
/.vs
|
||||||
|
|
|
@ -1087,7 +1087,7 @@ namespace {
|
||||||
* Send Webhook
|
* Send Webhook
|
||||||
*
|
*
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
* @var array $replacements an array of the replacements
|
* @var array $replacements should be an array of key value as strings where key is the placeholder name to replace in json template with the value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1096,8 +1096,13 @@ namespace {
|
||||||
$error = "";
|
$error = "";
|
||||||
$success = 1;
|
$success = 1;
|
||||||
|
|
||||||
|
$jsonMessage = $this->json;
|
||||||
|
|
||||||
$replacements['#message'] = $this->stripTagsFromMessage($replacements['#message']);
|
$replacements['#message'] = $this->stripTagsFromMessage($replacements['#message']);
|
||||||
$jsonMessage = strtr($this->json, $replacements);
|
|
||||||
|
foreach($replacements as $key => $val) {
|
||||||
|
$jsonMessage = str_replace($key, $val, $jsonMessage);
|
||||||
|
}
|
||||||
|
|
||||||
$curl = curl_init($this->url);
|
$curl = curl_init($this->url);
|
||||||
curl_setopt($curl, CURLOPT_POST, 1);
|
curl_setopt($curl, CURLOPT_POST, 1);
|
||||||
|
|
|
@ -470,7 +470,7 @@ class ConfigController extends AbstractController
|
||||||
$webhook = psm_build_webhook();
|
$webhook = psm_build_webhook();
|
||||||
$webhook->setUrl($user->webhook_url);
|
$webhook->setUrl($user->webhook_url);
|
||||||
$webhook->setJson($user->webhook_json);
|
$webhook->setJson($user->webhook_json);
|
||||||
$message = (psm_get_lang('config', 'test_message'));
|
$message = ['#message' => (psm_get_lang('config', 'test_message'))];
|
||||||
$result = $webhook->sendWebhook($message);
|
$result = $webhook->sendWebhook($message);
|
||||||
if ($result==1) {
|
if ($result==1) {
|
||||||
$this->addMessage(psm_get_lang('config', 'webhook_sent'), 'success');
|
$this->addMessage(psm_get_lang('config', 'webhook_sent'), 'success');
|
||||||
|
|
|
@ -424,10 +424,12 @@ class StatusNotifier
|
||||||
psm_parse_msg($this->status_new, 'email_subject', $this->server);
|
psm_parse_msg($this->status_new, 'email_subject', $this->server);
|
||||||
$mail->Priority = 1;
|
$mail->Priority = 1;
|
||||||
|
|
||||||
|
$publicUrl = PSM_BASE_URL.'/public.php';
|
||||||
|
|
||||||
$body = key_exists('message', $combi) ?
|
$body = key_exists('message', $combi) ?
|
||||||
$combi['message'] :
|
$combi['message'] :
|
||||||
psm_parse_msg($this->status_new, 'email_body', $this->server);
|
psm_parse_msg($this->status_new, 'email_body', $this->server);
|
||||||
if ((bool)psm_get_conf('email_add_url')) $body .= PHP_EOL.PHP_EOL.'<a href="'.PSM_BASE_URL.'">'.PSM_BASE_URL.'</a>';
|
if ((bool)psm_get_conf('email_add_url')) $body .= PHP_EOL.PHP_EOL.'<a href="'.$publicUrl.'">'.$publicUrl.'</a>';
|
||||||
$mail->Body = $body;
|
$mail->Body = $body;
|
||||||
$mail->AltBody = str_replace('<br/>', "\n", $body);
|
$mail->AltBody = str_replace('<br/>', "\n", $body);
|
||||||
|
|
||||||
|
@ -609,6 +611,7 @@ class StatusNotifier
|
||||||
}
|
}
|
||||||
$webhook = psm_build_webhook();
|
$webhook = psm_build_webhook();
|
||||||
|
|
||||||
|
$subject = key_exists('subject', $combi) ? $combi['subject'] : psm_parse_msg($this->status_new, 'email_subject', $this->server);
|
||||||
|
|
||||||
$message = key_exists('message', $combi) ?
|
$message = key_exists('message', $combi) ?
|
||||||
$combi['message'] :
|
$combi['message'] :
|
||||||
|
@ -638,7 +641,8 @@ class StatusNotifier
|
||||||
'#server_label' => $this->server['label'],
|
'#server_label' => $this->server['label'],
|
||||||
'#server_error' => $this->server['error'],
|
'#server_error' => $this->server['error'],
|
||||||
'#server_last_offline_duration' => $this->status_new ? $this->server['last_offline_duration'] : '',
|
'#server_last_offline_duration' => $this->status_new ? $this->server['last_offline_duration'] : '',
|
||||||
'#status' => $this->status_new ? 'online' : 'offline'
|
'#status' => $this->status_new ? 'online' : 'offline',
|
||||||
|
'#subject' => $subject
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<meta name="msapplication-TileImage" content="phpservermon.png">
|
<meta name="msapplication-TileImage" content="phpservermon.png">
|
||||||
<meta name="msapplication-TileColor" content="#424242">
|
<meta name="msapplication-TileColor" content="#424242">
|
||||||
<!-- TODO add base url -->
|
<!-- TODO add base url -->
|
||||||
<!-- <link rel="canonical" href=""> -->
|
<!-- <link rel="canonical" href=""> -->
|
||||||
<meta name="theme-color" content="#424242">
|
<meta name="theme-color" content="#424242">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||||
<link rel="icon" type="image/png" href="favicon.png" />
|
<link rel="icon" type="image/png" href="favicon.png" />
|
||||||
|
@ -24,8 +24,9 @@
|
||||||
<link href="src/templates/default/static/css/bootstrap.min.css" rel="stylesheet">
|
<link href="src/templates/default/static/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="src/templates/default/static/plugin/bootstrap-select/dist/css/bootstrap-select.min.css" rel="stylesheet">
|
<link href="src/templates/default/static/plugin/bootstrap-select/dist/css/bootstrap-select.min.css" rel="stylesheet">
|
||||||
<link href="src/templates/default/static/css/style.min.css" rel="stylesheet">
|
<link href="src/templates/default/static/css/style.min.css" rel="stylesheet">
|
||||||
|
<link href="src/templates/default/static/css/custom.css" rel="stylesheet">
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/*# Used to override main styles for custom layout adjustments and colors. */
|
||||||
|
.container-fluid {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
Loading…
Reference in New Issue