$result = $nntp->authinfo($news["user"],$news["pass"]);
if (!$result) error("nntpauth");
}
-$spool = new spool($nntp,$group,$profile['display'],$profile['lastnews']);
+$spool = new BananaSpool($nntp,$group,$profile['display'],$profile['lastnews']);
if (!$spool) error("nntpspool");
$nntp->group($group);
-$post = new NNTPPost($nntp,$id);
+$post = new BananaPost($nntp,$id);
if (!$post) {
if ($nntp->lasterrorcode == "423") {
$spool->delid($id);
</th>
</tr>
<?php
-foreach ($news['headdisp'] as $nick) {
- if (isset($post->headers[$nick]))
- echo "<tr><td class=\"{$css['bicoltitre']}\">".header_translate($nick)."</td>"
- ."<td>".formatdisplayheader($nick,$post->headers[$nick],$spool)
- ."</td></tr>\n";
-}
+ foreach ($news['headdisp'] as $nick) {
+ if (isset($post->headers[$nick])) {
+ $res = formatdisplayheader($nick,$post->headers[$nick],$spool);
+ if ($res)
+ echo "<tr><td class=\"{$css['bicoltitre']}\">".header_translate($nick)."</td>"
+ ."<td>$res</td></tr>\n";
+ }
+ }
?>
<tr>
<th colspan="2">
/** Class NNTP
* implements some basic functions for NNTP protocol
*/
-class nntp {
+class nntp
+{
/** socket filehandle */
var $ns;
/** debug mode */
* @return STRING
*/
- function gline() {
+ function gline()
+ {
if ($this->debug) {
$line = trim(fgets($this->ns, 1200));
print "NNTP >>>> $line \n";
* @param STRING $_line line to put
*/
- function pline($_line) {
+ function pline($_line)
+ {
if ($this->debug) {
$dline = preg_replace("/\r\n$/", "", $_line);
$dline = preg_replace("/(\r|\n|\r\n)/", "\nNNTP <<<< ", $dline);
* @param $_reader BOOLEAN sends a "MODE READER" at connection if true
*/
- function nntp($_host, $_timeout=120, $_debug=0, $_reader=true) {
+ function nntp($_host, $_timeout=120, $_debug=0, $_reader=true)
+ {
if (preg_match("/([^:]+):([^:]+)/", $_host, $regs)) {
$host = $regs[1];
$port = $regs[2];
* @return BOOLEAN true if authentication was successful
*/
- function authinfo($_user, $_pass) {
+ function authinfo($_user, $_pass)
+ {
$user = preg_replace("/(\r|\n)/", "", $_user);
$pass = preg_replace("/(\r|\n)/", "", $_pass);
$this->pline("AUTHINFO USER $user\r\n");
* @see head
*/
- function article($_msgid="") {
+ function article($_msgid="")
+ {
$msgid = preg_replace("/(\r|\n)/", "", $_msgid);
$this->pline("ARTICLE $msgid\r\n");
$result = $this->gline();
* @return STRING MSGID of article
*/
- function post($_message) {
+ function post($_message)
+ {
if (is_array($_message)) {
$message=join("\n", $_message);
} else {
* @see head
*/
- function body($_msgid="") {
+ function body($_msgid="")
+ {
$msgid = preg_replace("/(\r|\n)/", "", $_msgid);
$this->pline("BODY $msgid\r\n");
$result = $this->gline();
* @see body
*/
- function head($_msgid="") {
+ function head($_msgid="")
+ {
$msgid = preg_replace("/(\r|\n)/", "", $_msgid);
$this->pline("HEAD $msgid\r\n");
$result = $this->gline();
* @return ARRAY array : nb of articles in group, MSGNUM of first article, MSGNUM of last article, and group name
*/
- function group($_group) {
+ function group($_group)
+ {
$group = preg_replace("/(\r|\n)/", "", $_group);
$this->pline("GROUP $group\r\n");
$line = $this->gline();
* @see next
*/
- function last() {
+ function last()
+ {
$this->pline("LAST \r\n");
$line = $this->gline();
if ($line{0}!="2") {
* @see last
*/
- function next() {
+ function next()
+ {
$this->pline("NEXT \r\n");
$line = $this->gline();
if ($line{0}!="2") {
* @see body
*/
- function nntpstat($_msgid) {
+ function nntpstat($_msgid)
+ {
$msgid = preg_replace("/(\r|\n)/", "", $_msgid);
$this->pline("STAT $msgid\r\n");
$line = $this->gline();
* @return BOOLEAN true if posting is allowed lines
*/
- function postok() {
+ function postok()
+ {
return ($this->posting);
}
* @see newgroups
*/
- function liste() {
+ function liste()
+ {
$this->pline("LIST\r\n");
if (substr($this->gline(), 0, 1)!="2") return false;
$result = $this->gline();
* @see liste
*/
- function newgroups($_since, $_distributions="") {
+ function newgroups($_since, $_distributions="")
+ {
#assume $_since is a unix timestamp
$distributions = preg_replace("/(\r|\n)/", "", $_distributions);
$this->pline("NEWGROUPS ".gmdate("ymd His", $_since)
* @return ARRAY MSGID of new articles
*/
- function newnews($_since, $_groups="*", $_distributions="") {
+ function newnews($_since, $_groups="*", $_distributions="")
+ {
$distributions = preg_replace("/(\r|\n)/", "", $_distributions);
$groups = preg_replace("/(\r|\n)/", "", $_groups);
$array = array();
* @return BOOLEAN true if sucessful
*/
- function slave() {
+ function slave()
+ {
$this->pline("SLAVE \r\n");
return (substr($this->gline(), 0, 1)=="2");
}
* @return BOOLEAN
*/
- function ihave($_msgid, $_message=false) {
+ function ihave($_msgid, $_message=false)
+ {
$msgid = preg_replace("/(\r|\n)/", "", $_msgid);
if (is_array($message)) {
$message = join("\n", $_message);
/** closes connection to server
*/
- function quit() {
+ function quit()
+ {
$this->pline("QUIT\r\n");
$this->gline();
fclose($this->ns);
* @return INTEGER timestamp
*/
- function date() {
+ function date()
+ {
$this->pline("DATE \r\n");
$result = $this->gline();
if (preg_match("/^111 (\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/", $result, $r)) {
* @return ARRAY group name => description
*/
- function xgtitle($_pattern="*") {
+ function xgtitle($_pattern="*")
+ {
$pattern = preg_replace("/(\r|\n)/", "", $_pattern);
$this->pline("XGTITLE $pattern \r\n");
if (substr($this->gline(), 0, 1)!="2") return false;
* @return ARRAY MSGNUM => header value
*/
- function xhdr($_hdr, $_range="") {
+ function xhdr($_hdr, $_range="")
+ {
$hdr = preg_replace("/(\r|\n)/", "", $_hdr);
$range = preg_replace("/(\r|\n)/", "", $_range);
$this->pline("XHDR $hdr $range \r\n");
* @return ARRAY MSGNUM => header value
*/
- function xpat($_hdr, $_range, $_pat) {
+ function xpat($_hdr, $_range, $_pat)
+ {
$hdr = preg_replace("/(\r|\n)/", "", $_hdr);
$range = preg_replace("/(\r|\n)/", "", $_range);
$pat = preg_replace("/(\r|\n)/", "", $_pat);
/** class for group lists
*/
-class groups {
- /** group list */
- var $overview;
- /** last update */
- var $date;
-
- /** constructor
- * @param $_nntp RESOURCE handle to NNTP socket
- */
+class BananaGroups {
+ /** group list */
+ var $overview;
+ /** last update */
+ var $date;
- function groups(&$_nntp,$_type=0) {
- global $profile;
- $desc=$_nntp->xgtitle();
- if ($_type==1) {
- $list=$_nntp->newgroups($profile['lastnews']);
- } else {
- $list=$_nntp->liste();
- }
- if (!$list) {
- $this->overview=array();
- return false;
- }
- if (isset($desc)) {
- foreach ($desc as $g=>$d) {
- if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
- or (($_type==1) and in_array($g,array_keys($list)))
- or ($_type==2)) {
- $this->overview[$g][0]=$d;
- $this->overview[$g][1]=$list[$g][0];
+ /** constructor
+ * @param $_nntp RESOURCE handle to NNTP socket
+ */
+
+ function BananaGroups(&$_nntp,$_type=0) {
+ global $profile;
+ $desc=$_nntp->xgtitle();
+ if ($_type==1) {
+ $list=$_nntp->newgroups($profile['lastnews']);
+ } else {
+ $list=$_nntp->liste();
}
- }
- foreach (array_diff(array_keys($list),array_keys($desc)) as $g) {
- if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
- or (($_type==1) and in_array($g,array_keys($list)))
- or ($_type==2)) {
- $this->overview[$g][0]="-";
- $this->overview[$g][1]=$list[$g][0];
+ if (!$list) {
+ $this->overview=array();
+ return false;
}
- }
- } else {
- foreach ($list as $g=>$l) {
- if ((($_type==0) and (!count($profile['subscribe']) and in_array($g,$profile['subscribe'])))
- or (($_type==1) and in_array($g,array_keys($list)))
- or ($_type==2)) {
- $this->overview[$g][0]="-";
- $this->overview[$g][1]=$l[0];
+ if (isset($desc)) {
+ foreach ($desc as $g=>$d) {
+ if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
+ or (($_type==1) and in_array($g,array_keys($list)))
+ or ($_type==2)) {
+ $this->overview[$g][0]=$d;
+ $this->overview[$g][1]=$list[$g][0];
+ }
+ }
+ foreach (array_diff(array_keys($list),array_keys($desc)) as $g) {
+ if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
+ or (($_type==1) and in_array($g,array_keys($list)))
+ or ($_type==2)) {
+ $this->overview[$g][0]="-";
+ $this->overview[$g][1]=$list[$g][0];
+ }
+ }
+ } else {
+ foreach ($list as $g=>$l) {
+ if ((($_type==0) and (!count($profile['subscribe']) and in_array($g,$profile['subscribe'])))
+ or (($_type==1) and in_array($g,array_keys($list)))
+ or ($_type==2)) {
+ $this->overview[$g][0]="-";
+ $this->overview[$g][1]=$l[0];
+ }
+ }
}
- }
+ return true;
}
- return true;
- }
- /** updates overview
- * @param $_nntp RESOURCE handle to NNTP socket
- * @param date INTEGER date of last update
- */
- function update(&$_nntp,$_date) {
- $serverdate = $_nntp->date();
- if (!$serverdate) $serverdate=time();
- $newlist = $_nntp->newgroups($_date);
- if (!$newlist) return false;
- $this->date = $serverdate;
- foreach (array_keys($newlist) as $g) {
- $groupstat = $_nntp->group($g);
- $groupdesc = $_nntp->xgtitle($g);
- $this->overview[$g][0]=($groupdesc?$groupdesc:"-");
- $this->overview[$g][1]=$groupstat[0];
+ /** updates overview
+ * @param $_nntp RESOURCE handle to NNTP socket
+ * @param date INTEGER date of last update
+ */
+ function update(&$_nntp,$_date) {
+ $serverdate = $_nntp->date();
+ if (!$serverdate) $serverdate=time();
+ $newlist = $_nntp->newgroups($_date);
+ if (!$newlist) return false;
+ $this->date = $serverdate;
+ foreach (array_keys($newlist) as $g) {
+ $groupstat = $_nntp->group($g);
+ $groupdesc = $_nntp->xgtitle($g);
+ $this->overview[$g][0]=($groupdesc?$groupdesc:"-");
+ $this->overview[$g][1]=$groupstat[0];
+ }
+ return true;
}
- return true;
- }
}
?>
}
function header_translate($hdr) {
- switch (strtolower($hdr)) {
+ switch ($hdr) {
case 'from': return _b_('De');
case 'subject': return _b_('Sujet');
case 'newsgroups': return _b_('Forums');
- case 'followup': return _b_('Suivi-à');
+ case 'followup-to': return _b_('Suivi-à');
case 'date': return _b_('Date');
case 'organization': return _b_('Organisation');
case 'references': return _b_('Références');
- case 'xface': return _b_('Image');
+ case 'x-face': return _b_('Image');
default:
return $hdr;
}
/** class for posts
*/
-class NNTPPost {
+class BananaPost
+{
var $nb;
/** headers */
var $headers;
* @param $_nntp RESOURCE handle to NNTP socket
* @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
*/
- function NNTPPost(&$_nntp, $_id) {
+ function BananaPost(&$_nntp, $_id)
+ {
$this->nb = $_id;
$this->_header($_nntp);
return false;
}
- $this->nb = $_id;
// parse headers
foreach ($hdrs as $line) {
if (preg_match("/^[\t\r ]+/", $line)) {
}
}
-function spoolcompare($a,$b) { return ($b->date>=$a->date); }
+function spoolCompare($a,$b) { return ($b->date>=$a->date); }
/** Class spoolhead
* class used in thread overviews
*/
-class SpoolHead
+class BananaSpoolHead
{
/** date (timestamp) */
var $date;
* @param $_descunread INTEGER descunread value (0 for a new post)
*/
- function SpoolHead($_date, $_subject, $_from, $_desc=1, $_read=true, $_descunread=0)
+ function BananaSpoolHead($_date, $_subject, $_from, $_desc=1, $_read=true, $_descunread=0)
{
$this->date = $_date;
$this->subject = $_subject;
define("BANANA_SPOOL_VERSION", '0.2');
-class spool
+class BananaSpool
{
var $version;
/** spool */
* @param $_display INTEGER 1 => all posts, 2 => only threads with new posts
* @param $_since INTEGER time stamp (used for read/unread)
*/
- function spool(&$_nntp, $_group, $_display=0, $_since="")
+ function BananaSpool(&$_nntp, $_group, $_display=0, $_since="")
{
global $news;
$this->group = $_group;
}
foreach ($msgids as $id=>$msgid) {
- $msg = new spoolhead($dates[$id], $subjects[$id], $froms[$id]);
+ $msg = new BananaSpoolHead($dates[$id], $subjects[$id], $froms[$id]);
$refs[$id] = str_replace('><', '> <', $refs[$id]);
$msgrefs = preg_split("/[ \t]/", strtr($refs[$id], $this->ids));
$parents = preg_grep('/^\d+$/', $msgrefs);
if ($p = $msg->parent) {
if (empty($this->overview[$p])) {
- $this->overview[$p] = new spoolhead($dates[$p], $subjects[$p], $froms[$p], 1);
+ $this->overview[$p] = new BananaSpoolHead($dates[$p], $subjects[$p], $froms[$p], 1);
}
$this->overview[$p]->children[] = $id;
$result = $nntp->authinfo($news["user"],$news["pass"]);
if (!$result) error("nntpauth");
}
-$groups = new groups($nntp,0);
-if (!count($groups->overview)) $groups=new groups($nntp,2);
+$groups = new BananaGroups($nntp,0);
+if (!count($groups->overview)) $groups = new BananaGroups($nntp,2);
-$newgroups = new groups($nntp,1);
+$newgroups = new BananaGroups($nntp,1);
?>
<h1>
if (isset($group) && isset($id) && isset($_REQUEST['type']) &&
($_REQUEST['type']=='followup')) {
$rq=$nntp->group($group);
- $post = new NNTPPost($nntp,$id);
+ $post = new BananaPost($nntp,$id);
if ($post) {
$subject = (preg_match("/^re:/i",$post->headers['subject'])?"":"Re: ").$post->headers['subject'];
if ($profile['dropsig']) {
}
unset($result);
-$groups = new groups($nntp,2);
+$groups = new BananaGroups($nntp,2);
$list = array_keys($groups->overview);
unset($groups);
foreach ($list as $g) {
print "Generating spool for $g : ";
- $spool = new spool($nntp,$g);
+ $spool = new BananaSpool($nntp,$g);
print "done.\n";
unset($spool);
}
$result = $nntp->authinfo($news["user"],$news["pass"]);
if (!$result) error("nntpauth");
}
-$groups = new groups($nntp,2);
+$groups = new BananaGroups($nntp,2);
?>
<h1>
$result = $nntp->authinfo($news["user"],$news["pass"]);
if (!$result) error("nntpauth");
}
-$spool = new spool($nntp,$group,$profile['display'],
+$spool = new BananaSpool($nntp,$group,$profile['display'],
$profile['lastnews']);
if (!$spool) error("nntpspool");
$max = 50;
case 'cancel':
$mid = array_search($id,$spool->ids);
$nntp->group($group);
- $post = new NNTPPost($nntp,$id);
+ $post = new BananaPost($nntp,$id);
if (checkcancel($post->headers)) {
$message = 'From: '.$profile['name']."\n"
break;
case 'followupok':
$rq=$nntp->group($group);
- $post = new NNTPPost($nntp,$id);
+ $post = new BananaPost($nntp,$id);
if ($post) {
$refs = (isset($post->headers['references'])?
$post->headers['references']." ":"").$post->headers['message-id'];
break;
}
$_SESSION['bananapostok']=false;
- $spool = new spool($nntp,$group,$profile['display'],
+ $spool = new BananaSpool($nntp,$group,$profile['display'],
$profile['lastnews']);
if (!$spool) error("nntpspool");
}