public function onRead()
{
while (($line = $this->readline()) !== null) {
if ($line === '') {
continue;
}
if (mb_orig_strlen($line) > 512) {
Daemon::$process->log('IRCClientConnection error: buffer overflow.');
$this->finish();
return;
}
$line = mb_orig_substr($line, 0, -mb_orig_strlen($this->EOL));
$p = mb_orig_strpos($line, ' :', 1);
$max = $p !== false ? substr_count($line, " ", 0, $p + 1) + 1 : 18;
$e = explode(" ", $line, $max);
$i = 0;
$from = IRC::parseUsermask($e[$i][0] === ':' ? mb_orig_substr($e[$i++], 1) : null);
$cmd = $e[$i++];
$args = [];
for ($s = min(sizeof($e), 14); $i < $s; ++$i) {
if ($e[$i][0] === ':') {
$args[] = mb_orig_substr($e[$i], 1);
break;
}
$args[] = $e[$i];
}
if (ctype_digit($cmd)) {
$code = (int) $cmd;
$cmd = isset(IRC::$codes[$code]) ? IRC::$codes[$code] : $code;
}
$this->lastLine = $line;
$this->onCommand($from, $cmd, $args);
}
if (mb_orig_strlen($this->buf) > 512) {
Daemon::$process->log('IRCClientConnection error: buffer overflow.');
$this->finish();
}
}