fp = @fsockopen($server, $port, $errno, $errstr, 5);
if (!$this->fp) {
die ("ERROR: Can't connect to $server:$port. $errno - $errstr"); //na?aa? auee??ai
}
// login to server
$cmdline = "\x03\x04{$login}\x0d{$password}\n";
// append commands
foreach ($this->commands as $cmd)
$cmdline .= $cmd . "\n";
$this->sendLine($cmdline);
fclose($this->fp);
}
private function sendLine($str)
{
fwrite ($this->fp, $str);
while (!feof($this->fp))
{
$data = trim( fgets($this->fp, 4086) );
if ( !empty($data) )
$this->stream[] = $data;
}
//print_r($this->stream); # print buffer output
}
public function getUsers() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-5]);
}
public function getGames() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-4]);
}
public function getChannels() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-3]);
}
public function getLatency() {
return preg_replace($this->patterns, "", $this->stream[count($this->stream)-2]);
}
}
$server="server.pvpgn.pro";
$port="6112";
$login='';
$password='';
$bot = new pvpgnBot($server,$port,$login,$password);
echo "$server
";
echo $bot->getUsers()." users
";
echo $bot->getGames()." games
";
echo $bot->getChannels()." channels
";
echo $bot->getLatency()." latency
";