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>';
?>
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', '');
`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', '');