-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
103 lines (101 loc) · 4.5 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<meta http-equiv="refresh" content="60;url=" />
<?php
error_reporting(0);
//=======================================================================
// Create new webhook in your Discord channel settings and copy&paste URL
//=======================================================================
$webhookurl = "channel webhook here";
$jsonIn = file_get_contents('https://discordapp.com/api/guilds/channelidhere/embed.json');
$JSON = json_decode($jsonIn, true);
$membersCount = count($JSON['members']);
$channelCount = count($JSON['channels']);
echo "<h2>Number of Online members:</h2> " . $membersCount;
echo "<br><h2>Number of channels:</h2> " . $channelCount;
//=======================================================================
// Compose message. You can use Markdown
//=======================================================================
//$msg = "Test **message** [https://krasin.in.ua](<URL>)";
//$msg = 'Total Online Members '.$membersCount.' & Channels'.$channelCount.'';
$msg = '```js
Total Online Members '.$membersCount.'```';
$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 );
?>
<?php
error_reporting(0);
//=======================================================================
// Create new webhook in your Discord channel settings and copy&paste URL
//=======================================================================
$webhookurl = "channel webhook here";
//=======================================================================
// Compose message. You can use Markdown
//=======================================================================
//$msg = "Test **message** [https://krasin.in.ua](<URL>)";
//$msg = 'Total Online Members '.$membersCount.' & Channels'.$channelCount.'';
$json_options = [
"http" => [
"method" => "GET",
"header" => "Authorization: Bot token-here"
]
];
$json_context = stream_context_create($json_options);
$json_get = file_get_contents('https://discordapp.com/api/guilds/channelidhere/members?limit=1000', false, $json_context);
$json_decode = json_decode($json_get, true);
echo '<h2>Member Count</h2>';
echo count($json_decode);
$msg = '```js
Total Members '.count($json_decode).'```';
$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 );
?>
<?php
error_reporting(0);
//=======================================================================
// Create new webhook in your Discord channel settings and copy&paste URL
//=======================================================================
$webhookurl = "channel webhook here";
//=======================================================================
// Compose message. You can use Markdown
//=======================================================================
//$msg = "Test **message** [https://krasin.in.ua](<URL>)";
//$msg = 'Total Online Members '.$membersCount.' & Channels'.$channelCount.'';
$json_options = [
"http" => [
"method" => "GET",
"header" => "Authorization: Bot token-here"
]
];
$json_context = stream_context_create($json_options);
$json_getc = file_get_contents('https://discordapp.com/api/guilds/channelidhere/channels?limit=1000', false, $json_context);
$json_decode = json_decode($json_getc, true);
echo '<h2>Channel Count</h2>';
echo count($json_decode);
$msg = '```js
Total Channels '.count($json_decode).'```';
$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 );
?>