-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.php
195 lines (194 loc) · 5.87 KB
/
function.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
function cs_scan($ip,$port){
global $pingtime;
$fp = @fsockopen('udp://'.$ip,$port,$errno,$errstr,1);
if ($config['timeout'] = intval($config['timeout']))
{
@stream_set_timeout($fp, $config['timeout']);
}
else
{
@stream_set_timeout($fp, 0, 500000);
}
@stream_set_blocking($fp, TRUE);
if (!$fp) {
unset($data);
$data['color'] = "st4";
$data['address'] = $ip.":".$port;
$data['gamemod'] = "-";
$data['hostname'] = "-";
$data['mapname'] = "-";
$data['players'] = "0";
$data['maxplayers'] = "0";
$data['password'] = "-";
$data['datatype'] = "-";
$data['version'] = "-";
$data['description'] = "-";
$data['server_type'] = "-";
$data['server_os'] = "-";
$data['server_secure'] = "-";
$data['server_bots'] = "-";
$stopro = 1;
$osv1 = $data['players'];
$osvw1 = $osv1/$stopro;
$osve1 = $osvw1*100;
$data['percent'] = round($osve1);
$data['la'] = "images/la/0.gif";
$data['color'] = "color2";
$data['status'] = 0;
return $data;
}
else {
$pingtime1 = microtime();
$final = false;
fwrite($fp,"\xFF\xFF\xFF\xFFTSource Engine Query\x00");
$buffer = fread($fp,4096);
if (!$buffer) {
fclose($fp);
unset($data);
$data['color'] = "st4";
$data['address'] = $ip.":".$port;
$data['gamemod'] = "-";
$data['hostname'] = "-";
$data['mapname'] = "-";
$data['players'] = "0";
$data['maxplayers'] = "0";
$data['password'] = "-";
$data['datatype'] = "-";
$data['version'] = "-";
$data['description'] = "-";
$data['server_type'] = "-";
$data['server_os'] = "-";
$data['server_secure'] = "-";
$data['server_bots'] = "-";
$stopro = 1;
$osv1 = $data['players'];
$osvw1 = $osv1/$stopro;
$osve1 = $osvw1*100;
$data['percent'] = round($osve1);
$data['la'] = "images/la/0.gif";
$data['color'] = "color2";
$data['status'] = 0;
return $data;
}
$second_packet = $buffer;
if (strlen($second_packet) > 0) {
$reverse_check = dechex(ord($buffer[8]));
if ($reverse_check[0] == "1") {
$tmp = $buffer;
$buffer = $second_packet;
$second_packet = $tmp;
}
$buffer = substr($buffer, 13);
$second_packet = substr($second_packet, 9);
$buffer = trim($buffer.$second_packet);
$buffer = trim(substr($buffer, 4));
if (!trim($buffer)) {
unset($data);
$data['color'] = "st4";
$data['address'] = $ip.":".$port;
$data['gamemod'] = "-";
$data['hostname'] = "-";
$data['mapname'] = "-";
$data['players'] = "0";
$data['maxplayers'] = "0";
$data['password'] = "-";
$data['datatype'] = "-";
$data['version'] = "-";
$data['description'] = "-";
$data['server_type'] = "-";
$data['server_os'] = "-";
$data['server_secure'] = "-";
$data['server_bots'] = "-";
$stopro = 1;
$osv1 = $data['players'];
$osvw1 = $osv1/$stopro;
$osve1 = $osvw1*100;
$data['percent'] = round($osve1);
$data['la'] = "images/la/0.gif";
$data['color'] = "color2";
$data['status'] = 0;
return $data;
}
}
}
fclose($fp);
unset($data);
$tmp = explode("\x00", $buffer);
$place = strlen($tmp[0].$tmp[1].$tmp[2].$tmp[3].$tmp[4]) + 5;
$data['color'] = "st4";
$data['address'] = $ip.":".$port;
$data['gamemod'] = $tmp[3];
$data['hostname'] = $tmp[1];
$data['mapname'] = $tmp[2];
if ($data['mapname'] == "cstrike"){
$data['hostname'] = $tmp[3];
$data['mapname'] = $tmp[1];
}
if ($data['mapname'] == "") {
$data['hostname'] = $tmp[1];
$data['mapname'] = $tmp[2];
}
$data['next'] = 1;
$data['players'] = ord($buffer[$place]);
$data['maxplayers'] = ord($buffer[$place + 1]);
$data['color'] = "";
$stopro = $data['maxplayers']+1;
$osv1 = $data['players'];
$osvw1 = $osv1/$stopro;
$osve1 = $osvw1*100;
$data['percent'] = round($osve1);
$data['status'] = 1;
$data['la'] = "images/la/0.gif";
if(round($osve1)>0 && round($osve1)<21) {
$data['la'] = "images/la/1.gif"; }
if(round($osve1)>20 && round($osve1)<41) {
$data['la'] = "images/la/2.gif"; }
if(round($osve1)>40 && round($osve1)<61) {
$data['la'] = "images/la/3.gif"; }
if(round($osve1)>60 && round($osve1)<81) {
$data['la'] = "images/la/4.gif"; }
if(round($osve1)>80 && round($osve1)<101) {
$data['la'] = "images/la/5.gif"; }
$data['pingtime'] = microtime()-$pingtime1;
$data['password'] = ord($buffer[$place + 5]);
if ($data['password'] = ord($buffer[$place + 5])){
$data['password'] = 'Clan War';
}
else{
$data['password'] = 'Public';
}
$data['datatype'] = $buffer[0]; // m ??? ????? ????
$data['version'] = ord($buffer[$place + 2]); // ??????
$data['description'] = $tmp[4];
$data['server_type'] = $buffer[$place + 3]; // D ???????? ??? L ???????
$data['server_os'] = $buffer[$place + 4]; // W ??? ?????? ??? L ??? ????????
$data['server_secure'] = ord($tmp[14]); // VAC
if ($data['server_secure'] = ord($tmp[14])){
$data['server_secure'] = "????";
}
else{
$data['server_secure'] = "???";
}
$data['server_bots'] = ord($tmp[15]); // ???-?? ?????
if (substr_count($data['hostname'],"banned") == 1) {
$data['hostname'] = "IP Banned";
$data['mapname'] = "-";
$data['password'] = "-";
$data['server_secure'] = "-";
}
if ($data == "Server offline") {
unset($data);
$data['hostname'] = "Server Offline";
$data['mapname'] = "-";
$data['players'] = "0";
$data['maxplayers'] = "0";
}
if($data['players'] > $data['maxplayers']){
$temp=$data['players'];
$data['players']=$data['maxplayers'];
$data['maxplayers']=$temp;
}
return $data;
}
?>