parseUsermask() public static method

public static parseUsermask ( string $mask ) : array
$mask string
return array
Ejemplo n.º 1
0
 /**
  * @TODO DESCR
  * @param array|string $mask
  * @param mixed        $msg
  */
 public function onPart($mask, $msg = null)
 {
     if (is_string($mask)) {
         $mask = IRC::parseUsermask($mask);
     }
     if ($mask['nick'] === $this->irc->nick && $mask['user'] === $this->irc->user) {
         $this->destroy();
     } else {
         unset($this->nicknames[$mask['nick']]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Called when new data received
  * @return void
  */
 public function onRead()
 {
     while (($line = $this->readline()) !== null) {
         if ($line === '') {
             continue;
         }
         if (strlen($line) > 512) {
             Daemon::$process->log('IRCClientConnection error: buffer overflow.');
             $this->finish();
             return;
         }
         $line = binarySubstr($line, 0, -strlen($this->EOL));
         $p = 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] === ':' ? binarySubstr($e[$i++], 1) : null);
         $cmd = $e[$i++];
         $args = [];
         for ($s = min(sizeof($e), 14); $i < $s; ++$i) {
             if ($e[$i][0] === ':') {
                 $args[] = binarySubstr($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 (strlen($this->buf) > 512) {
         Daemon::$process->log('IRCClientConnection error: buffer overflow.');
         $this->finish();
     }
 }
Ejemplo n.º 3
0
 /**
  * @TODO DESCR
  * @param  array|string $mask
  * @return $this
  */
 public function setUsermask($mask)
 {
     if (is_string($mask)) {
         $mask = IRC::parseUsermask($mask);
     }
     $this->setUnverified($mask['unverified'])->setUser($mask['user'])->setNick($mask['nick'])->setHost($mask['host']);
     return $this;
 }