X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fnntpcore.inc.php;h=80322adaa8494b5eb6dc3340b4812db438ffbff6;hb=2b974d09ad89f90c04fe281ef653a34bf6d2c47f;hp=b6170b8a2553ac495c34a8f05c4ec607af469cda;hpb=b4d2fbe0d5aec689ac27f57af2e98fb28c1ad87c;p=banana.git diff --git a/banana/nntpcore.inc.php b/banana/nntpcore.inc.php index b6170b8..80322ad 100644 --- a/banana/nntpcore.inc.php +++ b/banana/nntpcore.inc.php @@ -100,9 +100,10 @@ class BananaNNTPCore /** get a line from server * @return STRING */ - private function getLine() + private function &getLine() { - return rtrim(@fgets($this->ns, 1200), "\r\n"); + $data = rtrim(@fgets($this->ns, 1200), "\r\n"); + return $data; } /** fetch data (and on delimitor) @@ -111,11 +112,13 @@ class BananaNNTPCore private function &fetchResult() { $array = Array(); - while (($result = $this->getLine()) != '.') { - $array[] = $result; + while (($result =& $this->getLine()) != '.') { + $array[] =& $result; } if ($this->debug && $this->bt) { - $this->bt[count($this->bt) - 1]['response'] = count($array); + $trace =& $this->bt[count($this->bt) - 1]; + $trace['response'] = count($array); + $trace['time'] = microtime(true) - $trace['start']; } return $array; } @@ -131,7 +134,7 @@ class BananaNNTPCore } if ($this->debug) { $db_line = preg_replace('/PASS .*/', 'PASS *******', $line); - $this->bt[] = array('action' => $db_line, 'time' => microtime(true)); + $this->bt[] = array('action' => $db_line, 'start' => microtime(true)); } return @fputs($this->ns, $line, strlen($line)); } @@ -172,7 +175,7 @@ class BananaNNTPCore $this->lastresulttext = substr($result, 4); if ($this->debug && $this->bt) { $trace =& $this->bt[count($this->bt) - 1]; - $trace['time'] = microtime(true) - $trace['time']; + $trace['time'] = microtime(true) - $trace['start']; $trace['code'] = $this->lastresultcode; $trace['message'] = $this->lastresulttext; $trace['response'] = 0; @@ -195,7 +198,7 @@ class BananaNNTPCore * @param $pass INTEGER password * @return BOOLEAN true if authentication was successful */ - protected function authinfo($user, $pass) + public function authinfo($user, $pass) { if ($this->execLine("AUTHINFO USER $user", false)) { return $this->execline("AUTHINFO PASS $pass"); @@ -213,7 +216,7 @@ class BananaNNTPCore * @see body * @see head */ - protected function article($msgid = "") + public function article($msgid = "") { if (!$this->execLine("ARTICLE $msgid")) { return false; @@ -226,7 +229,7 @@ class BananaNNTPCore * @param $_message STRING message to post * @return STRING MSGID of article */ - protected function post($message) + public function post($message) { if (!$this->execLine("POST ", false)) { return false; @@ -248,7 +251,7 @@ class BananaNNTPCore * @see article * @see head */ - protected function body($msgid = '') + public function body($msgid = '') { if ($this->execLine("BODY $msgid")) { return false; @@ -263,7 +266,7 @@ class BananaNNTPCore * @see article * @see body */ - protected function head($msgid = '') + public function head($msgid = '') { if (!$this->execLine("HEAD $msgid")) { return false; @@ -275,7 +278,7 @@ class BananaNNTPCore * @param $_group STRING * @return ARRAY array : nb of articles in group, MSGNUM of first article, MSGNUM of last article, and group name */ - protected function group($group) + public function group($group) { if (!$this->execLine("GROUP $group")) { return false; @@ -291,7 +294,7 @@ class BananaNNTPCore * @return STRING MSGID of article * @see next */ - protected function last() + public function last() { if (!$this->execLine("LAST ")) { return false; @@ -307,7 +310,7 @@ class BananaNNTPCore * @see last */ - protected function next() + public function next() { if (!$this->execLine('NEXT ')) { return false; @@ -324,7 +327,7 @@ class BananaNNTPCore * @see article * @see body */ - protected function nntpstat($msgid) + public function nntpstat($msgid) { if (!$this->execLine("STAT $msgid")) { return false; @@ -355,7 +358,7 @@ class BananaNNTPCore * @return ARRAY group name => (MSGNUM of first article, MSGNUM of last article, NNTP flags) * @see newgroups */ - protected function listGroups() + public function listGroups() { if (!$this->execLine('LIST')) { return false; @@ -378,14 +381,14 @@ class BananaNNTPCore * @return ARRAY same format as liste * @see liste */ - protected function newgroups($since, $distributions = '') + public function newgroups($since, $distributions = '') { if (!($since = $this->formatDate($since))) { return false; } if (!$this->execLine("NEWGROUPS $since $distributions")) { return false; - } + } return $this->filterGroups(); } @@ -394,7 +397,7 @@ class BananaNNTPCore * @parma $_groups STRING pattern of intersting groups * @return ARRAY MSGID of new articles */ - protected function newnews($groups = '*', $since = 0, $distributions = '') + public function newnews($groups = '*', $since = 0, $distributions = '') { if (!($since = $this->formatDate($since))) { return false; @@ -408,7 +411,7 @@ class BananaNNTPCore /** Tell the remote server that I am not a user client, but probably another news server * @return BOOLEAN true if sucessful */ - protected function slave() + public function slave() { return $this->execLine("SLAVE "); } @@ -418,7 +421,7 @@ class BananaNNTPCore * @param $_message STRING article * @return BOOLEAN */ - protected function ihave($msgid, $message = false) + public function ihave($msgid, $message = false) { if (!$this->execLine("IHAVE $msgid ")) { return false; @@ -428,7 +431,7 @@ class BananaNNTPCore /** closes connection to server */ - protected function quit() + public function quit() { $this->execLine('QUIT'); fclose($this->ns); @@ -442,7 +445,7 @@ class BananaNNTPCore * @return INTEGER timestamp */ - protected function date() + public function date() { if (!$this->execLine('DATE ', false)) { return false; @@ -458,7 +461,7 @@ class BananaNNTPCore * @return ARRAY group name => description */ - protected function xgtitle($pattern = '*') + public function xgtitle($pattern = '*') { if (!$this->execLine("XGTITLE $pattern ")) { return false; @@ -466,7 +469,7 @@ class BananaNNTPCore $array =& $this->fetchResult(); $groups = array(); foreach ($array as &$result) { - list($group, $desc) = split("[ \t]", $result, 2); + @list($group, $desc) = preg_split('/[ \t]/', $result, 2); $groups[$group] = $desc; } return $groups; @@ -477,7 +480,7 @@ class BananaNNTPCore * @param $_range STRING range of articles * @return ARRAY MSGNUM => header value */ - protected function xhdr($hdr, $first = null, $last = null) + public function xhdr($hdr, $first = null, $last = null) { if (is_null($first) && is_null($last)) { $range = ""; @@ -502,7 +505,7 @@ class BananaNNTPCore * @param $_pat STRING pattern * @return ARRAY MSGNUM => header value */ - protected function xpat($_hdr, $_range, $_pat) + public function xpat($_hdr, $_range, $_pat) { if (!$this->execLine("XPAT $hdr $range $pat")) { return false;