-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.php
More file actions
79 lines (62 loc) · 1.44 KB
/
index.php
File metadata and controls
79 lines (62 loc) · 1.44 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
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
<?php
// Load the class
require_once('classes/MurmurQuery.php');
// Set the parameters.
// Note: port, timeout and format options are not necessary if you're going to use the default values.
$settings = array
(
'host' => '31.132.2.124',
'port' => 27814,
'timeout' => 200,
'format' => 'json'
);
// Create new instance
$murmur = new MurmurQuery();
// Load in the settings
$murmur->setup($settings);
// Query the server
$murmur->query();
if($murmur->is_online())
{
echo '<h1>Status</h1>';
echo 'The server is online!';
// Grab the response data.
// This includes a separate channels and users array.
// Also, you get the original response data if you choose to parse it manually.
$status = $murmur->get_status();
// Get the users array
$users = $murmur->get_users();
// Get the channels array
$channels = $murmur->get_channels();
if(count($channels) > 0)
{
echo '<h1>Channels</h1>';
echo '<ul>';
foreach($channels as $channel)
{
echo '<li>'. $channel['name'] .'</li>';
}
echo '</ul>';
}
if(count($users) > 0)
{
echo '<h1>Online Users</h1>';
echo '<ul>';
foreach($users as $user)
{
echo '<li>'. $user['name'] .'</li>';
}
echo '</ul>';
}
// Display the original response data
echo '<h1>Response</h1>';
echo '<pre>';
print_r($status['original']);
echo '</pre>';
}
else
{
echo '<h1>Status</h1>';
echo 'Sorry, the server seems to be offline.';
}
?>