-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
45 lines (43 loc) · 1.52 KB
/
index.php
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
<!-- Host -->
<?php
$status = GetServerStatus('yourwebsite.com',yourwebsiteports);
function GetServerStatus($site, $port)
{
$status = array("OFFLINE", "ONLINE");
$fp = @fsockopen($site, $port, $errno, $errstr, 2);
if (!$fp) {
// echo "HOST ".$status[0]."<br>";
$webhookurl = "discordwebhookurlofchannel";
// $msg = "HOST ".$status[0]."";
$msg = "```diff
- HOST ".$status[0]." at ".date("l").", ".date("d F 20y")."```";
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
} else
{
// echo "HOST ".$status[1]."<br>";
$webhookurl = "discordwebhookurlofchannel";
// $msg = "Host ".$status[1]."";
$msg = "```diff
+ Host ".$status[1]." at ".date("l").", ".date("d F 20y")."```";
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
}
}
?>