Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Antro serverio atvaizdavimas
Parašė Vebster· 2011 Spa. 26 15:10:35
#1
Kaip reikia atvaizduoti du skirtingus veikiančius serverius lentelėje? Tą prasme, kad rodytų kiek pirmam serverį žaidėjų, ir kiek antram serverį žaidėjų. Pvz. cs.serveris.lt:27015 ir cs.serveris.lt:27016. Va kodas:
<?php
$packet = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
function getnextstring(&$data)
{
$temp="";
$counter=0;
while (ord($data[$counter++])!=0) $temp.=$data[$counter-1];
$data=substr($data,strlen($temp)+1);
return $temp;
}
function getnextbytevalue(&$data)
{
$temp=ord($data[0]);
$data=substr($data,1);
return $temp;
}
if(!$live_server = fsockopen("udp://cs.gamebox.lt:27015"))
{
$output = "on";
}
else
{
fwrite($live_server, $packet);
socket_set_timeout($live_server,1,0);
$junk = fread($live_server,5);
$status = socket_get_status($live_server);
$do = 1;
$server_info= "";
while($do)
{
$str_1 = fread($live_server,1);
$server_info .= $str_1;
$status = socket_get_status($live_server);
if($status["unread_bytes"] == 0) {$do = 0;}
}
fclose($live_server);
if (strlen($server_info) > 0)
{
$success = 1;
$junk = getnextstring($server_info);
$servername = getnextstring($server_info);
$map = getnextstring($server_info);
$junk = getnextstring($server_info);
$junk = getnextstring($server_info);
$players = getnextbytevalue($server_info);
$maxplayers = getnextbytevalue($server_info);
}
if ($players != "")
{
$players = $players;
}
else
{
$players = "0";
}
if ($maxplayers != "")
{
$maxplayers = $maxplayers;
}
else
{
$maxplayers = "0";
}
if ($players < $maxplayers)
{
$output = "";
}
else
{
$output = "Full";
}
if ($output != "Full" and $players != "0" or $maxplayers != "0")
{
$output = $output;
}
else
{
$output = "";
}
if ($map != "")
{
$map = $map;
}
else
{
$map = "nera";
}
}
echo'
<table border="1">
<tr>
<th>Serveris</th>
<th>IP adresas</th>
<th>Žaidėjų</th>
<th>Žemėlapis</th>
</tr>
<tr>
<td>Public</td>
<td>cs.gamebox.lt:27015</td>
<td>'.$players.'/'.$maxplayers.'</td>
<td>'.$map.'</td>
</tr>
</table>
';
?>
Redagavo Vebster· 2011 Spa. 26 15:10:46
Parašė MariukasR· 2011 Spa. 26 15:10:41
#2
Mėgink :)
<?php
$packet = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
function getnextstring(&$data)
{
$temp="";
$counter=0;
while (ord($data[$counter++])!=0) $temp.=$data[$counter-1];
$data=substr($data,strlen($temp)+1);
return $temp;
}
function getnextbytevalue(&$data)
{
$temp=ord($data[0]);
$data=substr($data,1);
return $temp;
}
if(!$live_server = fsockopen("udp://cs.gamebox.lt:27015"))
{
$output = "on";
}
else
{
fwrite($live_server, $packet);
socket_set_timeout($live_server,1,0);
$junk = fread($live_server,5);
$status = socket_get_status($live_server);
$do = 1;
$server_info= "";
while($do)
{
$str_1 = fread($live_server,1);
$server_info .= $str_1;
$status = socket_get_status($live_server);
if($status["unread_bytes"] == 0) {$do = 0;}
}
fclose($live_server);
if (strlen($server_info) > 0)
{
$success = 1;
$junk = getnextstring($server_info);
$servername = getnextstring($server_info);
$map = getnextstring($server_info);
$junk = getnextstring($server_info);
$junk = getnextstring($server_info);
$players = getnextbytevalue($server_info);
$maxplayers = getnextbytevalue($server_info);
}
if ($players != "")
{
$players = $players;
}
else
{
$players = "0";
}
if ($maxplayers != "")
{
$maxplayers = $maxplayers;
}
else
{
$maxplayers = "0";
}
if ($players < $maxplayers)
{
$output = "";
}
else
{
$output = "Full";
}
if ($output != "Full" and $players != "0" or $maxplayers != "0")
{
$output = $output;
}
else
{
$output = "";
}
if ($map != "")
{
$map = $map;
}
else
{
$map = "nera";
}
}
echo'
<table border="1">
<tr>
<th>Serveris</th>
<th>IP adresas</th>
<th>Žaidėjų</th>
<th>Žemėlapis</th>
</tr>
<tr>
<td>Public</td>
<td>cs.gamebox.lt:27015</td>
<td>'.$players.'/'.$maxplayers.'</td>
<td>'.$map.'</td>
</tr>
</table>
';
$packet = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
function getnextstring(&$data)
{
$temp="";
$counter=0;
while (ord($data[$counter++])!=0) $temp.=$data[$counter-1];
$data=substr($data,strlen($temp)+1);
return $temp;
}
function getnextbytevalue(&$data)
{
$temp=ord($data[0]);
$data=substr($data,1);
return $temp;
}
if(!$live_server = fsockopen("udp://cs.gamebox.lt:27015"))
{
$output = "on";
}
else
{
fwrite($live_server, $packet);
socket_set_timeout($live_server,1,0);
$junk = fread($live_server,5);
$status = socket_get_status($live_server);
$do = 1;
$server_info= "";
while($do)
{
$str_1 = fread($live_server,1);
$server_info .= $str_1;
$status = socket_get_status($live_server);
if($status["unread_bytes"] == 0) {$do = 0;}
}
fclose($live_server);
if (strlen($server_info) > 0)
{
$success = 1;
$junk = getnextstring($server_info);
$servername = getnextstring($server_info);
$map = getnextstring($server_info);
$junk = getnextstring($server_info);
$junk = getnextstring($server_info);
$players = getnextbytevalue($server_info);
$maxplayers = getnextbytevalue($server_info);
}
if ($players != "")
{
$players = $players;
}
else
{
$players = "0";
}
if ($maxplayers != "")
{
$maxplayers = $maxplayers;
}
else
{
$maxplayers = "0";
}
if ($players < $maxplayers)
{
$output = "";
}
else
{
$output = "Full";
}
if ($output != "Full" and $players != "0" or $maxplayers != "0")
{
$output = $output;
}
else
{
$output = "";
}
if ($map != "")
{
$map = $map;
}
else
{
$map = "nera";
}
}
echo'
<table border="1">
<tr>
<th>Serveris</th>
<th>IP adresas</th>
<th>Žaidėjų</th>
<th>Žemėlapis</th>
</tr>
<tr>
<td>Public</td>
<td>cs.gamebox.lt:27015</td>
<td>'.$players.'/'.$maxplayers.'</td>
<td>'.$map.'</td>
</tr>
</table>
';
?>
Parašė Vebster· 2011 Spa. 26 17:10:41
#3
Neveikia, nes tą pati funkcija viršuje yra, bet man reikia, kad toje pačioje lentelėje būtų serveris.
Redagavo Vebster· 2011 Spa. 26 17:10:55
Parašė mNm.· 2011 Spa. 26 17:10:41
#4
Štai imk. ;)
<?php
echo '
<table border="1">
<tr>
<th>Serveris</th>
<th>IP adresas</th>
<th>Žaideju</th>
<th>Žemelapis</th>
</tr>';
?>
<?php
$packet = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
function getnextstring(&$data)
{
$temp="";
$counter=0;
while (ord($data[$counter++])!=0) $temp.=$data[$counter-1];
$data=substr($data,strlen($temp)+1);
return $temp;
}
function getnextbytevalue(&$data)
{
$temp=ord($data[0]);
$data=substr($data,1);
return $temp;
}
if(!$live_server = fsockopen("udp://cs.gamebox.lt:27015"))
{
$output = "on";
}
else
{
fwrite($live_server, $packet);
socket_set_timeout($live_server,1,0);
$junk = fread($live_server,5);
$status = socket_get_status($live_server);
$do = 1;
$server_info= "";
while($do)
{
$str_1 = fread($live_server,1);
$server_info .= $str_1;
$status = socket_get_status($live_server);
if($status["unread_bytes"] == 0) {$do = 0;}
}
fclose($live_server);
if (strlen($server_info) > 0)
{
$success = 1;
$junk = getnextstring($server_info);
$servername = getnextstring($server_info);
$map = getnextstring($server_info);
$junk = getnextstring($server_info);
$junk = getnextstring($server_info);
$players = getnextbytevalue($server_info);
$maxplayers = getnextbytevalue($server_info);
}
if ($players != "")
{
$players = $players;
}
else
{
$players = "0";
}
if ($maxplayers != "")
{
$maxplayers = $maxplayers;
}
else
{
$maxplayers = "0";
}
if ($players < $maxplayers)
{
$output = "";
}
else
{
$output = "Full";
}
if ($output != "Full" and $players != "0" or $maxplayers != "0")
{
$output = $output;
}
else
{
$output = "";
}
if ($map != "")
{
$map = $map;
}
else
{
$map = "nera";
}
}
echo'
<tr>
<td>Server 1</td>
<td>cs.gamebox.lt:27015</td>
<td>'.$players.'/'.$maxplayers.'</td>
<td>'.$map.'</td>
</tr>
';
?>
<?php
$packet = "\xFF\xFF\xFF\xFFTSource Engine Query\x00";
function getnextstring2(&$data)
{
$temp="";
$counter=0;
while (ord($data[$counter++])!=0) $temp.=$data[$counter-1];
$data=substr($data,strlen($temp)+1);
return $temp;
}
function getnextbytevalue2(&$data)
{
$temp=ord($data[0]);
$data=substr($data,1);
return $temp;
}
if(!$live_server = fsockopen("udp://cs.gamebox.lt:27016"))
{
$output = "on";
}
else
{
fwrite($live_server, $packet);
socket_set_timeout($live_server,1,0);
$junk = fread($live_server,5);
$status = socket_get_status($live_server);
$do = 1;
$server_info= "";
while($do)
{
$str_1 = fread($live_server,1);
$server_info .= $str_1;
$status = socket_get_status($live_server);
if($status["unread_bytes"] == 0) {$do = 0;}
}
fclose($live_server);
if (strlen($server_info) > 0)
{
$success = 1;
$junk = getnextstring2($server_info);
$servername = getnextstring2($server_info);
$map = getnextstring2($server_info);
$junk = getnextstring2($server_info);
$junk = getnextstring2($server_info);
$players = getnextbytevalue2($server_info);
$maxplayers = getnextbytevalue2($server_info);
}
if ($players != "")
{
$players = $players;
}
else
{
$players = "0";
}
if ($maxplayers != "")
{
$maxplayers = $maxplayers;
}
else
{
$maxplayers = "0";
}
if ($players < $maxplayers)
{
$output = "";
}
else
{
$output = "Full";
}
if ($output != "Full" and $players != "0" or $maxplayers != "0")
{
$output = $output;
}
else
{
$output = "";
}
if ($map != "")
{
$map = $map;
}
else
{
$map = "nera";
}
}
echo'
<tr>
<td>Server 2</td>
<td>cs.gamebox.lt:27016</td>
<td>'.$players.'/'.$maxplayers.'</td>
<td>'.$map.'</td>
</tr>
';
?>
<?php echo "</table>"; ?>
Redagavo mNm.· 2011 Spa. 26 17:10:15
Parašė Vebster· 2011 Spa. 26 19:10:31
#5
Ačiū, veikia šitas kodas. :)