[Cstrike-Comunity]->We Are Crowing Every Day!!!
 
AcasaPortalCalendarFAQCautareMembriGrupuriInregistrareConectare
banner3 EvolutionGaming!

Distribuiţi | 
 

 steam server info

In jos 
AutorMesaj
eu149
Fondator
Fondator
avatar

Mesaje : 513
Puncte : 1199
Reputatie : 1
Data de inscriere : 22/04/2011
Varsta : 22
Localizare : dumbrava

MesajSubiect: steam server info   Sam Sept 10, 2011 12:04 pm

Deschidem notepad creem un fisier cu numele
gameserver.class.php in el adaugam :
Cod:
<?
Class gameserver {
var $serverip = "";
var $serverport = "";
var $errors = false;
var $serverinfo = array();


function gameserver($gametype, $serverip, $serverport) {
$this->serverip = $serverip;
$this->serverport = $serverport;

switch($gametype) {
case 'hl':
$serverdata = $this->gethlxserverinfo();
break;
case 'ut':
$serverdata = $this->getutserverinfo();
break;
default:
$this->errors = "Unsupported gametype!";
break;
}
}

function gethlxserverinfo() {
$challenge = substr($this->getserverdata("\xFF\xFF\xFF\xFF\x57"), 5);
$serverinfocmd = "\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00";
$playerinfocmd = "\xFF\xFF\xFF\xFF\x55".$challenge;
$serverrulescmd = "\xFF\xFF\xFF\xFF\x56".$challenge;

$rawserverinfo = $this->getserverdata($serverinfocmd);
$rawplayerinfo = $this->getserverdata($playerinfocmd);
$rawserverrules = $this->getserverdata($serverrulescmd);

if(!$rawserverinfo && !$rawplayerinfo && !$rawserverrules){
$this->errors = "Server is down!";
}

if(!$this->errors){
$datastart = 4;
$this->$serverinfo['type'] = chr($this->getint($rawserverinfo, $datastart, Cool);
switch($this->$serverinfo['type']){
case 'm':
$this->gethl1serverinfo($rawserverinfo);
$this->getplayerinfo($rawplayerinfo);
$this->getserverrules($rawserverrules);
break;
case 'I':
$this->gethl2serverinfo($rawserverinfo);
$this->getplayerinfo($rawplayerinfo);
$this->getserverrules($rawserverrules);
break;
default:
$this->errors = "Unsupported Half-Life querytype!";
break;
}
}
}

function gethl1serverinfo($rawserverinfo) {
$datastart = 5;
$this->serverinfo['gameip'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['hostname'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['map'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['gamedir'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['description']= $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['playercount']= $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['max'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['version'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['dedicated'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['os'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['password'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['idmod'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['urlinfo'] = $this->getstr($rawserverinfo, $datastart, Cool;
$this->serverinfo['urldl'] = $this->getstr($rawserverinfo, $datastart, Cool;
$this->serverinfo['unuserd'] = $this->getstr($rawserverinfo, $datastart, Cool;
$this->serverinfo['modversion'] = $this->getint($rawserverinfo, $datastart, 32);
$this->serverinfo['modsize'] = $this->getint($rawserverinfo, $datastart, 32);
$this->serverinfo['svonly'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['cldll'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['secure'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['botcount'] = $this->getint($rawserverinfo, $datastart, Cool;
}

function gethl2serverinfo($rawserverinfo) {
$datastart = 5;
$this->serverinfo['gameip'] = $this->serverip.":".$this->serverport;
$this->serverinfo['protocol'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['hostname'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['map'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['gamedir'] = $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['description']= $this->getstr($rawserverinfo, $datastart);
$this->serverinfo['appid'] = $this->getint($rawserverinfo, $datastart, 16);
$this->serverinfo['playercount']= $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['max'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['botcount'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['dedicated'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['os'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['password'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['secure'] = $this->getint($rawserverinfo, $datastart, Cool;
$this->serverinfo['gameversion']= $this->getstr($rawserverinfo, $datastart);
}

function getplayerinfo($rawplayerinfo){
$datastart = 5;
$this->serverinfo['playercount'] = $this->getint($rawplayerinfo, $datastart, Cool;

for($teller = 0; $teller < $this->serverinfo['playercount']; $teller++){
$playerindex = $this->getint($rawplayerinfo, $datastart, Cool;
$playername = $this->getstr($rawplayerinfo, $datastart);
$playerfrags = $this->getint($rawplayerinfo, $datastart, 32);
$playertime = $this->getfloat32($rawplayerinfo, $datastart);
if($playertime != 0){
$this->serverinfo['players'][$teller] = array( 'playerindex' => $playerindex,
'playername' => $playername,
'playerfrags' => $playerfrags,
'playertime' => $playertime);
}
}
$this->serverinfo['playercount'] = count($this->serverinfo['players']);
}

function getserverrules($rawserverrules){
$datastart = 5;
$this->serverinfo['rulecount'] = $this->getint($rawserverrules, $datastart, 16);

for($teller = 0; $teller < $this->serverinfo['rulecount']; $teller++){
$rulename = $this->getstr($rawserverrules, $datastart);
$rulevalue = $this->getstr($rawserverrules, $datastart);
if($rulename != ""){
$this->serverinfo['rules'][$teller] = array('rulename' => $rulename,
'rulevalue' => $rulevalue);
}
}
$this->serverinfo['rulecount'] = count($this->serverinfo['rules']);
}

function getint($data, &$datastart, $length){
$value = '';
$datalength = $length / 8;
for($teller = 0; $teller < $datalength; $teller++){
$value += ord($data{$datastart + $teller}) * pow(256, $teller);
}
$datastart = $datastart + $datalength;
return $value;
}

function getstr($data, &$datastart){
$temp = '';
$counter = 0;
while(ord($data[$datastart+$counter++]) != 0)
$temp .= $data[$datastart+$counter-1];
$datastart += strlen($temp) + 1;
return $temp;
}

function getfloat32($data, &$datastart){
$decnumber = $this->getint($data, $datastart, 32);
$binnumber = base_convert($decnumber, 10, 2);
while (strlen($binnumber) < 32)
$binnumber = '0'.$binnumber;

$exp = abs(base_convert(substr($binnumber, 1, Cool, 2, 10)) - 127;

if (substr($binnumber, 0, 1) == 1)
$exp = 0 - $exp;
$mantissa = 1;
$mantadd = 0.5;

for ($counter = 9; $counter < 32; $counter++){
if(substr($binnumber, $counter, 1) == 1)
$mantissa += $mantadd;
$mantadd = $mantadd / 2;
}

$temp = round(pow(2, $exp) * $mantissa);
return $temp;
}

function sortby($sortvalue, $sorttype){
function sortbyplayerfragsasc($a, $b) {
if ($a['playerfrags'] == $b['playerfrags']) return 0;
if ($a['playerfrags'] > $b['playerfrags']) {
return 1;
} else {
return -1;
}
}

function sortbyplayerfragsdesc($a, $b) {
if ($a['playerfrags'] == $b['playerfrags']) return 0;
if ($a['playerfrags'] > $b['playerfrags']) {
return -1;
} else {
return 1;
}
}

function sortbyplayertimeasc($a, $b) {
if ($a['playertime'] == $b['playertime']) return 0;
if ($a['playertime'] > $b['playertime']) {
return 1;
} else {
return -1;
}
}

function sortbyplayertimedesc($a, $b) {
if ($a['playertime'] == $b['playertime']) return 0;
if ($a['playertime'] > $b['playertime']) {
return -1;
} else {
return 1;
}
}

function sortbyplayernameasc($a, $b) {
if ($a['playername'] == $b['playername']) return 0;
if ($a['playername'] > $b['playername']) {
return 1;
} else {
return -1;
}
}

function sortbyplayernamedesc($a, $b) {
if ($a['playername'] == $b['playername']) return 0;
if ($a['playername'] > $b['playername']) {
return -1;
} else {
return 1;
}
}

if($this->serverinfo['playercount'] > 1){
switch($sortvalue){
case 'playername':
if($sorttype == 'asc'){
usort($this->serverinfo['players'], sortbyplayernameasc);
}elseif($sorttype == 'desc'){
usort($this->serverinfo['players'], sortbyplayernamedesc);
}else{
$this->errors = "Unsupported sorttype!";
}
break;
case 'playerfrags':
if($sorttype == 'asc'){
usort($this->serverinfo['players'], sortbyplayerfragsasc);
}elseif($sorttype == 'desc'){
usort($this->serverinfo['players'], sortbyplayerfragsdesc);
}else{
$this->errors = "Unsupported sorttype!";
}
break;
case 'playertime':
if($sorttype == 'asc'){
usort($this->serverinfo['players'], sortbyplayertimeasc);
}elseif($sorttype == 'desc'){
usort($this->serverinfo['players'], sortbyplayertimedesc);
}else{
$this->errors = "Unsupported sorttype!";
}
break;
default:
$this->errors = "Unsupported sorttype!";
break;
}
}
}

function requestinfoarray(){
return $this->serverinfo;
}

function printarray(){
if(!$this->errors){
print("<pre>");
print_r($this->serverinfo);
print("</pre>");
}
}

function errors(){
return $this->errors;
}

function getserverdata($command) {
$serverdata = '';
if(!$socket = fsockopen('udp://'.$this->serverip, $this->serverport)) {
return false;
}else{
socket_set_blocking($socket,1);
socket_set_timeout($socket,5,0);
fwrite($socket,$command,strlen($command));
$timeout = microtime() + 5;
do {
$serverdata.=fgetc($socket);
$serverdatalen++;
$socketstatus=socket_get_status($socket);
if(microtime() > $timeout) {
fclose($cssocket);
return false;
}
} while ($socketstatus["unread_bytes"] );
fclose($socket);
return $serverdata;
}
}
}
?>


mai facem unu cu numele: csinfo.php adaugam :
Cod:
<?php
function playertime($playertime){
$hours = floor($playertime/3600);
$playertime = $playertime-($hours*3600);
$minutes = floor($playertime/60);
$playertime = $playertime-($minutes*60);
$seconds = $playertime;

if($hours == 0){
if($minutes == 0){
return $seconds."s";
}else{
return $minutes."m ".$seconds."s";
}
}else{
return $hours."h ".$minutes."m ".$seconds."s";
}

}
include("./gameserver.class.php");
$gameserver = new gameserver('hl', '213.186.35.79', 27015);
$gameserver->sortby(playerfrags, desc);
$serverinfo = $gameserver->requestinfoarray();
?>
<html>
<head>
<title><? echo $serverinfo['hostname'] ?></title>
</head>
<body bgcolor="#660000" text="#FFFFFF">
<table border="0px" cellpadding="0px" cellspacing="3px" align="center" width="90%">
<tr>
<td align="center" valign="middle" width="100%" height="50px">
<h1><? echo $serverinfo['hostname'] ?></h1>
</td>
</tr>
</table>
<table border="0px" cellpadding="0px" cellspacing="3px" align="center" width="55%">
<tr>
<td align="left" valign="middle" width="100%" height="35px">
<h2>General server info:</h2>
</td>
</tr>
<tr>
<td width="50%" valign="top">
<table border="0px" width="100%">
<tr><td width="35%">Game:</td><td><? echo $serverinfo['description'] ?></td></tr>
<tr><td>Players:</td><td><? echo $serverinfo['playercount']." / ".$serverinfo['max'] ?></td></tr>
<tr><td>Map:</td><td><? echo $serverinfo['map'] ?></td></tr>
<tr><td>Aantal bots:</td><td><? echo $serverinfo['botcount'] ?></td></tr>
<tr><td>Password:</td><td><? $serverinfo['password']==1 ? print("Yes") : print("No"); ?></td></tr>
<tr><td>Dedicated:</td><td><? $serverinfo['dedicated']==100 ? print("Yes") : print("No"); ?></td></tr>
<tr><td>Secure:</td><td><? $serverinfo['secure']==1 ? print("Yes") : print("No"); ?></td></tr>
<tr><td>OS:</td><td><? $serverinfo['os']==108 ? print("Linux") : print("Windows"); ?></td></tr>
<tr><td>Server IP:</td><td><? echo $serverinfo['gameip'] ?></td></tr>
</table>
</td>
<td width="50%" valign="middle">
<table border="0px" width="100%">
<tr><td colspan="2" align="right"><? file_exists("./maps/".$serverinfo['gamedir']."/".$serverinfo['map'].".jpg") ? print("<img src=./maps/".$serverinfo['gamedir']."/".$serverinfo['map'].".jpg />") : print("<img src=./maps/nia.jpg />"); ?></td></tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="middle" width="100%" height="35px">
<h2>Player info:</h2>
</td>
</tr>
<tr>
<td width="100%" valign="top" colspan="2">
<table border="0px" width="100%">
<tr>
<td align="left" width="60%"><b><u>Playername</u></b></td>
<td align="center" width="15%"><b><u>Frags</u></b></td>
<td align="right" width="25%"><b><u>Time on server</u></b></td>
</tr>
<?
for($i = 0; $i < $serverinfo['playercount']; $i++){
$playerline = "<tr>";
$playerline .= "<td align='left'>".htmlspecialchars($serverinfo['players'][$i]['playername'])."</td>";
$playerline .= "<td align='center'>".$serverinfo['players'][$i]['playerfrags']."</td>";
$playerline .= "<td align='right'>".playertime($serverinfo['players'][$i]['playertime'])."</td>";
$playerline .= "</tr>";
echo $playerline;
}
?>
</table>
</td>
</tr>
<tr>
<td align="left" valign="middle" width="100%" height="35px">
<h2>Server rules:</h2>
</td>
</tr>
<tr>
<td width="100%" valign="top" colspan="2">
<table border="0px" width="100%">
<?
for($i = 0; $i < $serverinfo['rulecount']; $i++){
$ruleline = "<tr>";
$ruleline .= "<td align='left'>".$serverinfo['rules'][$i]['rulename']." = ".$serverinfo['rules'][$i]['rulevalue']."</td>";
$ruleline .= "</tr>";
echo $ruleline;
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Sus In jos
Vezi profilul utilizatorului http://cstrike-comunity.the-up.com
dani2153
Admin
avatar

Mesaje : 103
Puncte : 111
Reputatie : 0
Data de inscriere : 16/09/2011
Varsta : 23
Localizare : Bucuresti

MesajSubiect: Re: steam server info   Sam Sept 17, 2011 8:14 pm

-tpc -tpc
Sus In jos
Vezi profilul utilizatorului
 
steam server info
Sus 
Pagina 1 din 1

Permisiunile acestui forum:Nu puteti raspunde la subiectele acestui forum
We Are Crowing Every Day! -> Suntem in crestere in fiecare zi! :: Cstrike # Tutoriale Web :: ..:: Scripturi ::..-
Mergi direct la:  
Forumgratuit.ro | © phpBB | Forum gratuit de suport | Contact | Semnaleaza un abuz | Creeaza-ti propriul blog gratuit