<?php
/*laczysz sie, wybierasz baze*/
if(isset($_GET['id'])) //jesli istnieje zmienna $_GET czyli ?id= {
$id = intval($_GET['id']); //przypisanie + filtracja int /*pobierasz rekordy , czyli tworzysz zapytanie SQL z warunkiem WHERE */
$sql = mysql_query("SELECT id,ip,port,nazwa,client,loncze,acc,opis FROM ots WHERE id = '$id' ");
echo "<strong>".$rekord['nazwa']."</strong><br>";//wyswietlasz rekordy o podanym ID echo "<strong>".$rekord['ip']."</strong><br>"; echo "<strong>".$rekord['acc']."</strong><br>"; echo "<strong>".$rekord['port']."</strong><br>"; echo "<strong>".$rekord['client']."</strong><br>"; echo "<strong>".$rekord['loncze']."</strong><br><hr />"; echo '<left>Opis Serwera: </left><br>'; echo "<strong>".$rekord['opis']."</strong><br><hr />";
echo 'Status Serwera:<br>';
}
?>
Ten skrypt wyświetla szczegóły rekordów po danym id i chce żeby też sprawdzał status serwera i zapisywał największa ilość graczy online,
czy ktoś mógł by mi to przerobić?
A tutaj daje 2 skrypty na status serwera:
<?php
//========================================================
// Author: DeathfireD with help on regex from
// epimeth, weedpacket, and bradgrafelman
// Date: June 30, 2006
//
// Desc: Tutorial on how to get OTserv info using regex
// (preg_match)
//========================================================
//server packet that needs to be sent to get info
$info = chr(6).chr(0).chr(255).chr(255).'info';
//making socket connection to an ip and port 7171
$sock = @fsockopen(armia
.toproste
.pl
, 7171
, $errno, $errstr, 1
);
//show source request
if($_REQUEST['action']=='source'){
}
else{
if ($sock)
{
//writes the info gotten by sending the server packet.
$data='';
{
$data .= fgets($sock, 1024
); }
//players online and max (ex. Players online: 24 / 100)
preg_match('/players online="(d+)" max="(d+)"/', $data, $matches); echo '<p>Status:<b><font color="#00FF00"> Online</font></b>'; echo '<br />Players online: '.$matches[1].' / '.$matches[2
];
//Monster total (ex. Monsters: 23456)
preg_match('/monsters total="(d+)"/', $data, $matches); print '<br />Monsters: '.$matches[1].'';
//Uptime (Uptime: 23h 12m)
$h = floor($matches[1
] / 3600
); $m = floor(($matches[1
] - $h*3600
) / 60
);
echo '<br />Uptime: '.$h.'h '.$m.'m'.'</p>'; <li><a href="info.php?act=onlinelist">Online List</a></li>
</ul>';
}
else
{
echo '<p>Server Status:<b><font color="#FF0000"> Offline</font></b></p>'; }
}
?>
<?php
$info = chr(6).chr(0).chr(255).chr(255).'info';
$sock = @fsockopen($ip, $port, $errno, $errstr, 1
);
if ($sock)
{
$data='';
$data .= fgets($sock, 1024
);
preg_match('/players online="(d+)" max="(d+)" peak="(d+)"/', $data, $matches); print '<div style="font-size: 13; font-weight: bold; color: green">ONLINE</div>'; print '<div style="font-size: 11; font-weight: normal; color: white">Graczy: '; print $matches[1] . '/' . $matches[2
];
$h = floor($matches[1
] / 3600
); $m = floor(($matches[1
] - $h*3600
) / 60
);
print "<br>Uptime: $h " . ($h==1?
'godzina' : ($h==2||$h==3||$h==4?
'godziny' : 'godzin')); print " $m " . ($m==1?
'minuta' : ($m==12||$m==13||$m==14?
'minut' : ($m%10
==2||$m%10
==3||$m%10
==4?
'minuty' : 'minut'))) . '</div>'; }
else
print '<div style="font-size: 13; font-weight: bold; color: red">OFFLINE</div>'; ?>
Pozdrawiam