Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Lista OTS serwery
Adriannek
post 30.04.2008, 17:38:09
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 21.10.2007

Ostrzeżenie: (0%)
-----


Witam!
Ten skrypt wyświetla wszystkie serwery i sprawdza ich status a ja chciałby żeby wyświetla tylko te online czy może mi ktoś pomóc?
Kod
<?
mysql_connect('localhost', 'root', 'haslo) or
die (' Niepoprawne połączenie z bazą danych ');
mysql_select_db('1') or die (' Zła baza danych ');

$wynik = mysql_query ("SELECT * FROM `ots`;");


while ($rekord = mysql_fetch_assoc($wynik)) {
$nr = $rekord['nr'];
$name = $rekord['name'];
$ip = $rekord['ip'];
$port = $rekord['port'];
$ver = $rekord['ver'];
$exp = $rekord['exp'];
$type = $rekord['type'];




$ip_serwera = $ip;
$port_serwera = $port;


$info = chr(6).chr(0).chr(255).chr(255).'info';
$sock = @fsockopen($ip_serwera, $port_serwera, $errno, $errstr, 1);



if ($sock)
{
    fwrite($sock, $info);
    $data='';

    while (!feof($sock))
        $data .= fgets($sock, 1024);
    fclose($sock);

    preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);


    preg_match('/uptime="(\d+)"/', $data, $matches);
    $h = floor($matches[1] / 3600);
    $m = floor(($matches[1] - $h*3600) / 60);
     preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);

}
else

    preg_match('/uptime="(\d+)"/', $data, $matches);
$h = floor($matches[1] / 3600);
$m = floor(($matches[1] - $h*3600) / 60);

preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);


print "<tr bgcolor=#99CCFF align=center>";
print "<td> <FONT face=Papyrus size=4> $name </td> <td> <FONT face=Papyrus size=4> $ip </td> <td> <FONT face=Papyrus size=4> $port </td><td><FONT face=Papyrus size=4>  $matches[1] / $matches[2] </td> <td> <FONT face=Papyrus size=4> $h godzin $m minut </td><br>";
print "<td> <FONT face=Papyrus size=4> $ver </td> <td><FONT face=Papyrus size=4> $exp </td> <td> <FONT face=Papyrus size=4> $type </td>";
print "</tr>";
}
print '</table>';
?>

A to baza:
Kod
CREATE TABLE `ots` (
  `id` int(11) NOT NULL auto_increment,
  `ip` varchar(30) NOT NULL,
  `opis` varchar(255) NOT NULL default '',
  `nazwa` varchar(255) character set utf8 NOT NULL,
  `loncze` varchar(20) NOT NULL default '',
  `acc` varchar(50) NOT NULL default '',
  `port` int(4) NOT NULL,
  `client` varchar(10) NOT NULL,
  `exp` varchar(5) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `INDEX` (`ip`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin2 AUTO_INCREMENT=20;

--
-- Zrzut danych tabeli `ots`
--

INSERT INTO `ots` (`id`, `ip`, `opis`, `nazwa`, `loncze`, `acc`, `port`, `client`, `exp`) VALUES
(13, '195.117.153.2', 'gffffffffffffffffffffffffffffffffggggggggggggggggggg', 'Fast OTS', '256KB', 'fdsfdsfdsfdsfsf', 7171, '7.1', '64564'),
(14, '5.91.91.11', '', 'Fajny OTS', '256KB', '', 7171, '7.1', ''),
(15, '72.36.202.227', '', 'vxcvxc', '256KB', '', 7171, '7.1', ''),
(16, 'armia.toproste.pl', '', 'Mega OTS', '256KB', '', 7171, '7.1', ''),
(19, 'mazurskiots.no-ip.biz', 'kjkjhk', 'Fast OTS', '256KB', '', 7171, '7.1', '');
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
batman
post 30.04.2008, 18:26:36
Post #2





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Proszę poprawić temat na zgodny z regulaminem.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
erix
post 30.04.2008, 19:05:48
Post #3





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




W else (ludzie, róbcie klamry, będzie łatwiej) dorzuć przeskakiwanie pętli.


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 17:10