All pastes #67618 Raw Edit

Something

public text v1 · immutable
#67618 ·published 2006-06-20 10:29 UTC
rendered paste body
<?
  private function parseIrcRaw($raw) {  
    if (substr($raw, 0, 4) == "PING") {
      $this->ircWrite("PONG ".substr($raw, 5));
      return;
    }
    //:BB[Lappy]!BB_AtWork_@netadmin PRIVMSG #rip :bot bot bot bot botty!
    if (!preg_match("/^:([^!]+)!([^@]+)@(\S+) PRIVMSG (\S+) :(.*)$/", $raw, $m))
      return;

    array_shift($m);
    list($nick, $ident, $host, $chan, $text) = $m;
    if ($nick == "BB[Lappy]") {
      if (substr($text, 0, 1) == "!") {
        if (substr($text, 1) == "reload") {
          $this->ioe->reload(array($this, "reloaded"));
          return;
        }
      } 
    }
    if ($chan == $this->chan) {
      if ($this->captureMode == false && substr($text, 0, 3) == "<?=") {
        if (($i = strpos($text, "?>")) !== false) {
          $this->phpEval = trim("echo ".substr($text,3,$i-3));
          if (substr($this->phpEval,-1) != ";") $this->phpEval .= ";";
          $this->phpeRun($this->phpEval);
          $this->phpEval = "";
        } else {
          $this->phpEval = trim("echo ".substr($text,3));
          if (substr($this->phpEval,-1) != ";") $this->phpEval .= ";";
          $this->captureMode = true;
        }
      } else if ($this->captureMode == false && substr($text, 0, 2) == "<?") {
        if (substr($text, 0, 5) == "<?php") $len = 5;
        else $len = 2;
        if (!$this->phpe) $this->createPhpe();
        if (($i = strpos($text, "?>")) !== false) {
          $this->phpEval = substr($text,$len,$i-$len);
          $this->phpeRun($this->phpEval);
          $this->phpEval = "";
        } else {
          $this->phpEval = substr($text,$len);
          $this->captureMode = true;
        }
      } else if ($this->captureMode == true) {
        if (($i = strpos($text, "?>")) !== false) {
          $this->phpEval .= substr($text,0,$i);
          $this->captureMode = false;
          $this->phpeRun($this->phpEval);
          $this->phpEval = "";
        } else {
          $this->phpEval .= $text."\n";
        }          
      }
    }
  }
?>