and i edited a bit.. but have some issues.
when the server is online works without any problem but when offline.. at server information show the online text and the offline text too...
so the server is offline, however the online text too shows...
how can i fixt it..
here is the code:
Spoiler
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
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
<?php //Step 1: Gather the variables $svip="81.183.100.212"; $svport="36963"; $parts = Explode('/', $_SERVER["PHP_SELF"]); $pagename = $parts[count($parts) - 1]; if (empty($svport)) { 	$svport=36963; } if (!empty($_POST['server_ip'])) { 	if (empty($_POST['server_port'])) { 	header("Location: $pagename?ip=".$_POST['server_ip']."&port=36963"); 	} else { 	header("Location: $pagename?ip=".$_POST['server_ip']."&port=".$_POST['server_port']); 	} 	exit; } //Step 2: Prepare the form if (empty($svip)) { 	?> 	<form name="form_server" action="<?php echo $pagename;?>" method="post"> 	<table border="0"> 	<tr><td>Server IP</td><td><input type="text" name="server_ip"/></td></tr> 	<tr><td>Server Port</td><td><input type="text" name="server_port"/></td></tr> 	<tr><td>OK</td><td><input type="submit" value="Submit" /></td></tr> 	</form> 	<?php 	exit; } //Step 3: Prepare the functions function server_info($ip,$port) { 	$fp = @fsockopen("udp://".$ip, $port, $errno, $errstr); 	fwrite($fp, chr(1).chr(0).chr(251).chr(2)); 	return fread($fp,2048); } function server_players($ip,$port) { 	$fp = @fsockopen("udp://".$ip, $port, $errno, $errstr); 	fwrite($fp, chr(1).chr(0).chr(251).chr(5)); 	return fread($fp,2048); } function strToHex($string) { $hex=''; for ($i=0; $i < strlen($string); $i++) { 		if (strlen(dechex(ord($string[$i])))==1) { 			$hex .= "0".dechex(ord($string[$i])); 		} else { 			$hex .= dechex(ord($string[$i])); 		} } return $hex; } function hexToStr($hex) { $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2) { $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string; } //Step 4: Gather raw data from udp return, strip the header. $v_temp=substr(strToHex(server_info($svip,$svport)),8); if ($v_temp=="") { 	?> <center><font color="red"><b>OFFLINE</b></font></center> <?php else ?> <center><img src="cs2d.png" alt="cs2d icon" height="16" width="16" /><a href="cs2d://server1-cs2dh.co.cc:36963">Join</a></center> <center><font color="green"><b>ONLINE</b></font></center> <?php 	exit; } //Step 5: Gather has_password,has_fow,has_ff,has_lua, change them to text $v_mixed=hexdec(substr($v_temp,0,2)); $v_values=""; while($v_mixed!=1) { 	if ($v_mixed % 2==true) { 		$v_values=$v_values."1"; 	} else { 		$v_values=$v_values."0"; 	} 	$v_mixed=intval($v_mixed/2); } for ($i=1; $i==8-strlen($v_values); $i++) { 	$v_values="0".$v_values; } $password=substr($v_values,1,1); $fow=substr($v_values,3,1); $ff=substr($v_values,4,1); $lua=substr($v_values,7,1); $us=substr($v_values,2,1); if ($password=="1") { 	$password="Jelszóval védett"; } else { 	$password="Nincs Jelszó"; } if ($fow=="1") { 	$fow="Be"; } else { 	$fow="Ki"; } if ($ff=="1") { 	$ff="Be"; } else { 	$ff="Ki"; } if ($lua=="1") { 	$lua="Van"; } else { 	$lua="Nincs Script"; } if ($us=="1") { 	$us="Igen"; } else { 	$us="Nem, Mindenki"; } //Step 6: Gather sv_name,sv_map,create the length $svname=utf8_encode(hexToStr(substr($v_temp,4,hexdec(substr($v_temp,2,2))*2))); $namelen=strlen(hexToStr(substr($v_temp,4,hexdec(substr($v_temp,2,2))*2))); $svmap=hexToStr(substr($v_temp,6+$namelen*2,hexdec(substr($v_temp,4+$namelen*2,2))*2)); //Step 7: Get Gamemode if (strlen($v_temp)-$namelen*2-strlen($svmap)*2-4==8) { 	$gamemode="Standard"; } else { 	$gamemodes=array("Death Match","Team Death Match","Construction","Zombie"); 	$gamemode=$gamemodes[intval(substr($v_temp,-4,2))-1]; } //Step 8: Get Player+PlayerMax+Bots if (strlen($v_temp)-strlen($namelen)*2-strlen($svmap)*2-4==8) { $players=hexdec(substr($v_temp,-6,2)); $maxplayers=hexdec(substr($v_temp,-4,2)); $bots=hexdec(substr($v_temp,-2,2)); } else { if ($gamemode=="Standard") { $players=hexdec(substr($v_temp,-6,2)); $maxplayers=hexdec(substr($v_temp,-4,2)); } else { $players=hexdec(substr($v_temp,-8,2)); $maxplayers=hexdec(substr($v_temp,-6,2)); } $bots=hexdec(substr($v_temp,-2,2)); } if ($bots==1) {$name_bots="bot";} else {$name_bots="bot";} //Step 9: Output the data to html echo '<table border="0">'; echo "<tr><td><font color=white>Név</font></td><td><font color=white>$svname</font></td></tr>"; echo "<tr><td><font color=white>IP</font></td><td><font color=white>$svip:$svport</font></td></tr>"; echo "<tr><td><font color=white>Pálya</font></td><td><font color=white>$svmap</font></td></tr>"; echo "<tr><td><font color=white>Slot</font></td><td><font color=white>$players/$maxplayers ($bots $name_bots)</font></td></tr>"; ?>
edited 1×, last 04.07.12 12:04:14 pm