-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverpop.php
170 lines (146 loc) · 5.21 KB
/
serverpop.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/style_servers.css" rel="stylesheet">
<link href="css/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="bootstrap/js/jquery.min.js" type="text/javascript"></script>
<script src="css/notify.min.js"></script>
</head>
<body>
<?php
require __DIR__ . '/PHP-Source-Query-master/SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
// Edit this ->
//define( 'SQ_SERVER_ADDR', 'localhost' );
//define( 'SQ_SERVER_PORT', 27015 );
//define( 'SQ_TIMEOUT', 3 );
//define( 'SQ_ENGINE', SourceQuery::SOURCE );
// Edit this <-
$Timer = MicroTime( true );
$Query = new SourceQuery( );
$Info = Array( );
$Rules = Array( );
$Players = Array( );
include 'servers.php';
try
{
$Query->Connect($ipadd, $portnum);
//$Query->SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound
$Info = $Query->GetInfo( );
$Players = $Query->GetPlayers( );
$Rules = $Query->GetRules( );
}
catch( Exception $e )
{
$Exception = $e;
}
finally
{
$Query->Disconnect( );
}
$Timer = Number_Format( MicroTime( true ) - $Timer, 4, '.', '' );
?>
<div class="container">
<?php if( isset( $Exception ) ): ?>
<div class="panel panel-primary">
<div class="panel-heading">
<?php echo Get_Class( $Exception ); ?> at line
<?php echo $Exception->getLine( ); ?>
</div>
<p><b><?php echo htmlspecialchars( $Exception->getMessage( ) ); ?></b></p>
<p>
<?php echo nl2br( $e->getTraceAsString(), false ); ?>
</p>
</div>
<?php else: ?>
<div class="row">
<div class="col-sm-6">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="info-column">Server Info</th>
<th><span class="label label-<?php echo $Timer > 1.0 ? 'danger' : 'success'; ?>"><?php echo $Timer; ?>s</span></th>
</tr>
</thead>
<tbody>
<?php if( Is_Array( $Info ) ): ?>
<?php foreach( $Info as $InfoKey => $InfoValue ): ?>
<tr>
<td>
<?php echo htmlspecialchars( $InfoKey ); ?>
</td>
<td>
<?php
if( Is_Array( $InfoValue ) )
{
echo "<pre>";
print_r( $InfoValue );
echo "</pre>";
}
else
{
if( $InfoValue === true )
{
echo 'true';
}
else if( $InfoValue === false )
{
echo 'false';
}
else
{
echo htmlspecialchars( $InfoValue );
}
}
?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="2">No information received</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<div class="col-sm-6">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Player <span class="label label-info"><?php echo count( $Players ); ?></span></th>
<th class="frags-column">Frags</th>
<th class="frags-column">Time</th>
</tr>
</thead>
<tbody>
<?php if( !empty( $Players ) ): ?>
<?php foreach( $Players as $Player ): ?>
<tr>
<td>
<?php echo htmlspecialchars( $Player[ 'Name' ] ); ?>
</td>
<td>
<?php echo $Player[ 'Frags' ]; ?>
</td>
<td>
<?php echo $Player[ 'TimeF' ]; ?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="3">No players received</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
</div>
</body>
</html>