fp = @fsockopen($server, $port, $errno, $errstr,5);
if (!$this->fp) {
die ("ERROR: Can't connect to $server:$port. $errno - $errstr"); //сервер выключен
}
$this->sendLine("\x03\x04{$login}\x0d{$password}\n//nu\n/p\n/exit\n");
//echo "\x03\x04{$login}\x0d{$password}\n//nu\n/p\n/exit\n";
fclose($this->fp);
}
private function sendLine($str) {
fwrite ($this->fp, $str);
while (!feof($this->fp))
{
$this->stream[]= fgets($this->fp, 4086)."\n";
echo current($this->stream);
}
}
public function getUsers() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-4]);
}
public function getGames() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-3]);
}
public function getChannels() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-2]);
}
public function getLatency() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-1]);
}
}
$server="games.podolsk.ru";
$port="6112";
$login='';
$password='';
$bot= new pvpgnBot($server,$port,$login,$password);
echo $bot->getUsers()." users
echo $bot->getGames()." games
";
echo $bot->getChannels()." channels
";
echo $bot->getLatency()." latency
";
?>