From 4f6a209a2860106ca809828e73c5da9b3401242a Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Wed, 1 Mar 2006 20:52:18 +0000 Subject: [PATCH] =?utf8?q?Possibilit=C3=83=C2=A9=20de=20filtrer=20la=20lis?= =?utf8?q?te=20des=20newsgroups=20=C3=83=C2=A0=20afficher=20=C3=83=C2=A0?= =?utf8?q?=20partir=20d'une=20regexp?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@15 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/NetNNTP.inc.php | 45 +++++++++++++++++++++++++-------------------- banana/banana.inc.php.in | 5 +++++ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/banana/NetNNTP.inc.php b/banana/NetNNTP.inc.php index 13e574a..42bb2a7 100644 --- a/banana/NetNNTP.inc.php +++ b/banana/NetNNTP.inc.php @@ -305,6 +305,29 @@ class nntp return ($this->posting); } + /** retreive the group list + * @return ARRAY group name => (MSGNUM of first article, MSGNUM of last article, NNTP flags) + * @see newgroups, liste + */ + function _grouplist() + { + global $banana; + + if (substr($this->gline(), 0, 1)!="2") { + return false; + } + $result = $this->gline(); + $array = Array(); + while ($result != ".") { + preg_match("/([^ ]+) (\d+) (\d+) (.)/", $result, $regs); + if (!isset($banana->grp_pattern) || preg_match('@'.$banana->grp_pattern.'@', $regs[1])) { + $array[$regs[1]] = array(intval($regs[2]), intval($regs[3]), intval($regs[4])); + } + $result = $this->gline(); + } + return $array; + } + /** gets information about all active newsgroups * @return ARRAY group name => (MSGNUM of first article, MSGNUM of last article, NNTP flags) * @see newgroups @@ -313,15 +336,7 @@ class nntp function liste() { $this->pline("LIST\r\n"); - if (substr($this->gline(), 0, 1)!="2") return false; - $result = $this->gline(); - $array = Array(); - while ($result != ".") { - preg_match("/([^ ]+) (\d+) (\d+) (.)/", $result, $regs); - $array[$regs[1]] = array(intval($regs[2]), intval($regs[3]), intval($regs[4])); - $result = $this->gline(); - } - return $array; + return $this->_grouplist(); } /** get information about recent newsgroups @@ -338,17 +353,7 @@ class nntp $distributions = preg_replace("/(\r|\n)/", "", $_distributions); $this->pline("NEWGROUPS ".gmdate("ymd His", $_since) ." GMT $distributions\r\n"); - if (substr($this->gline(), 0, 1)!="2") { - return false; - } - $result = $this->gline(); - $array = array(); - while ($result != ".") { - preg_match("/([^ ]+) (\d+) (\d+) (.)/", $result, $regs); - $array[$regs[1]] = array(intval($regs[2]), intval($regs[3]), intval($regs[4])); - $result = $this->gline(); - } - return $array; + return $this->_grouplist(); } /** gets a list of new articles diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index c45d717..a1de491 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -21,6 +21,11 @@ class Banana */ var $body_mime = array('text/plain', 'text/html', 'text/richtext'); + /** Regexp for selecting newsgroups to show (if empty, match all newsgroups) + * ex : '^xorg\..*' for xorg.* + */ + var $grp_pattern; + var $tbefore = 5; var $tafter = 5; var $tmax = 50; -- 2.1.4