return Banana::$page->css;
}
+ /** Return the execution backtrace of the current BananaProtocole
+ */
+ public function backtrace()
+ {
+ if (Banana::$protocole) {
+ return Banana::$protocole->backtrace();
+ }
+ return null;
+ }
+
/**************************************************************************/
/* actions */
/**************************************************************************/
class BananaMBox implements BananaProtocoleInterface
{
private $debug = false;
-
+ private $bt = array();
+
private $_lasterrno = 0;
private $_lasterror = null;
return $file . $mail;
}
+ /** Return the execution backtrace
+ */
+ public function backtrace()
+ {
+ if ($this->debug) {
+ return $this->bt;
+ } else {
+ return null;
+ }
+ }
+
#######
# Filesystem functions
#######
$action .= ' -f ' . $this->getFileName();
$cmd = Banana::$mbox_helper . " $action " . implode(' ', $options) . ' ' . implode(' ', $headers);
if ($this->debug) {
- echo $cmd . '<br />';
$start = microtime(true);
}
exec($cmd, $out, $return);
if ($this->debug) {
- echo ' Execution : ' . (microtime(true) - $start) . 's<br />';
- echo " Retour : $return<br />";
- echo ' Sortie : ' . count($out) . ' ligne(s)<br />';
+ $this->bt[] = array('action' => $cmd, 'time' => (microtime(true) - $start),
+ 'code' => $return, 'response' => count($out));
}
if ($return != 0) {
$this->_lasterrorno = 1;
/** 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;
* @param box STRING boxname
*/
public function filename();
+
+ /** Return the execution backtrace of the protocole
+ * @return array(trace1, trace2, ...)
+ * a trace has the following structure:
+ * array('action' => action, 'time' => microtime, 'code' => return code, 'response' => size of the response)
+ * if no backtrace is available, return null
+ */
+ public function backtrace();
}
// vim:set et sw=4 sts=4 ts=4 enc=utf-8: