Beispiel #1
0
 public function connect()
 {
     if (!$this->initialized) {
         $this->initStream();
     }
     if (socket_connect($this->socket, $this->host, $this->port)) {
         $this->sendStream("/login");
         $rec = $this->recieveStream();
         if (!Util::contains($rec, "!trap") && strlen($rec) > 0) {
             $word = explode(PHP_EOL, $rec);
             if (count($word) > 1) {
                 $split = explode("=ret=", $word[2]);
                 $challange = $split[1];
                 $challanger = $this->challanger($this->username, $this->password, $challange);
                 $this->sendStream($challanger);
                 $res = $this->recieveStream();
                 if (Util::contains($res, "!done") && !Util::contains($res, "!trap")) {
                     $this->login = TRUE;
                 }
             }
         }
         $this->connected = TRUE;
     } else {
         $this->connected = FALSE;
     }
 }
Beispiel #2
0
 public function select($attributeName)
 {
     $name = "";
     if (Util::contains($attributeName, " ")) {
         $token = explode(" ", $attributeName);
         $a = 0;
         while ($a < count($token)) {
             $name = $name . current($token);
             next($token);
             $a++;
         }
     } else {
         $name = $attributeName;
     }
     $this->list->append(new Attribute("select", "proplist", $name));
 }
Beispiel #3
0
 private function createSentence(SentenceUtil $sentence)
 {
     $build = "";
     $sentence = $this->sentenceWrapper($sentence);
     $it = $sentence->getIterator();
     $cmd = "";
     while ($it->valid()) {
         $clause = $it->current()->getClause();
         $name = $it->current()->getName();
         $value = $it->current()->getValue();
         if (Util::contains($clause, "commandPrint")) {
             $build = $build . $value;
             $cmd = "print";
         } else {
             if (Util::contains($clause, "commandReguler")) {
                 $build = $build . $value;
                 $cmd = "reguler";
             } else {
                 if (Util::contains($name, "proplist") || Util::contains($name, "tag")) {
                     $build = $build . "=." . $name . "=" . $value;
                 }
                 if ($clause == "where" && $cmd == "print") {
                     $build = $build . "?" . $name . $value;
                 }
                 if ($clause == "where" && $cmd == "reguler") {
                     $build = $build . $name . $value;
                 }
                 if ($clause == "whereNot" || $clause == "orWhere" || $clause == "orWhereNot" || $clause == "andWhere" || $clause == "andWhereNot") {
                     $build = $build . $name . $value;
                 }
                 if ($clause == "setAttribute") {
                     $build = $build . "=" . $name . "=" . $value;
                 }
             }
         }
         if ($it->valid()) {
             $build = $build . "\n";
         }
         $it->next();
     }
     $this->runDebugger($build);
     return $build;
 }
Beispiel #4
0
 private function run()
 {
     $s = "";
     while (true) {
         $s = $this->con->recieveStream();
         if (Util::contains($s, "!re")) {
             $this->parseRawToList($s);
             $this->runDebugger($s);
             $this->re = TRUE;
         }
         if (Util::contains($s, "!trap")) {
             $this->runDebugger($s);
             $this->trap = TRUE;
             break;
         }
         if (Util::contains($s, "!done")) {
             $this->runDebugger($s);
             $this->done = TRUE;
             break;
         }
     }
 }