-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebhook.php
More file actions
54 lines (49 loc) · 1.61 KB
/
webhook.php
File metadata and controls
54 lines (49 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
$telegrambot = "123456789:SCR8NwQtqFoD3dPSmu99z8um8vN8jfQNYps";
$telegramchatid = "12345678";
$timezone = 2; // 2 for UTC+2
include("functions/telegram.php");
if(isset($_POST['payload']))
{
$data = json_decode($_POST['payload'], true);
if(empty($data['domain_id']))
{
$server_id = $data['server_id'];
$notification_id = $data['notification_id'];
$alert_id = $data['alert_id'];
$server_name = $data['server_name'];
$metric = $data['metric'];
$status = $data['status'];
$value = $data['value'];
$subject = $data['subject'];
$threshold = $data['threshold'];
$start_time = date('Y-m-d H:i:s', $data['start_time']+($timezone*3600));
$time = date('Y-m-d H:i:s', $data['time']+($timezone*3600));
if($status == "open")
{
telegram($subject."\n".$start_time."\nView server statistics on https://nixstats.com/server/".$server_id);
}
else
{
telegram($subject."\n".$time."\nView server statistics on https://nixstats.com/server/".$server_id);
}
}
else
{
$domain_id = $data['domain_id'];
$notification_id = $data['notification_id'];
$name = $data['name'];
$status = strtoupper($data['status']);
$subject = $data['subject'];
$start_time = date('Y-m-d H:i:s', $data['start_time']+($timezone*3600));
$end_time = date('Y-m-d H:i:s', $data['end_time']+($timezone*3600));
if($status == "OPEN")
{
telegram($status." - ".$name." ".$subject."\n".$start_time."\nView domain statistics on https://nixstats.com/domain/".$domain_id);
}
else
{
telegram($status." - ".$name." ".$subject."\n".$end_time."\nView domain statistics on https://nixstats.com/domain/".$domain_id);
}
}
}