/** debug mode */
private $debug = false;
+ private $bt = array();
/** constructor
* @param $host STRING NNTP host
return $this->lasterrortext;
}
+ public function backtrace()
+ {
+ if ($this->debug) {
+ return $this->bt;
+ } else {
+ return null;
+ }
+ }
+
# Socket functions
/** get a line from server
$array[] = $result;
}
}
+ if ($this->debug && $this->bt) {
+ $this->bt[count($this->bt) - 1]['response'] = count($array);
+ }
return $array;
}
}
if ($this->debug) {
$db_line = preg_replace('/PASS .*/', 'PASS *******', $line);
- echo $db_line;
+ $this->bt[] = array('action' => $db_line, 'time' => microtime(true));
}
return fputs($this->ns, $line, strlen($line));
}
private function checkState($strict = true)
{
$result = $this->getLine();
- if ($this->debug) {
- echo "$result\n";
- }
$this->lastresultcode = substr($result, 0, 3);
$this->lastresulttext = substr($result, 4);
+ if ($this->debug && $this->bt) {
+ $trace =& $this->bt[count($this->bt) - 1];
+ $trace['time'] = microtime(true) - $trace['time'];
+ $trace['code'] = $this->lastresultcode;
+ $trace['message'] = $this->lastresulttext;
+ $trace['response'] = 0;
+ }
$c = $this->lastresultcode{0};
if ($c == '2' || (($c == '1' || $c == '3') && !$strict)) {
return true;