phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] nntp ./admin.php ./index.php ./preferences.php ... [V


From: Dave Hall
Subject: [Phpgroupware-cvs] nntp ./admin.php ./index.php ./preferences.php ... [Version-0_9_16-branch]
Date: Thu, 15 Dec 2005 14:06:42 +0000

CVSROOT:        /cvsroot/phpgroupware
Module name:    nntp
Branch:         Version-0_9_16-branch
Changes by:     Dave Hall <address@hidden>      05/12/15 14:06:42

Modified files:
        .              : admin.php index.php preferences.php 
                         read_article.php viewgroup.php 
        inc            : class.mail.inc.php class.nntp.inc.php 
                         functions.inc.php 

Log message:
        globals, cleanups and some bug removal

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/admin.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.25.2.1&tr2=1.25.2.1.2.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/index.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.38.2.1&tr2=1.38.2.1.2.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/preferences.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.36&tr2=1.36.4.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/read_article.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.26&tr2=1.26.4.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/viewgroup.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.23&tr2=1.23.4.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/inc/class.mail.inc.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.6.2.3&tr2=1.6.2.3.2.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/inc/class.nntp.inc.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.7.2.2&tr2=1.7.2.2.2.1&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/nntp/inc/functions.inc.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.27&tr2=1.27.4.1&r1=text&r2=text

Patches:
Index: nntp/admin.php
diff -u /dev/null nntp/admin.php:1.25.2.1.2.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/admin.php      Thu Dec 15 14:06:41 2005
@@ -0,0 +1,260 @@
+<?php
+       
/**************************************************************************\
+       * phpGroupWare module (NNTP)                                            
   *
+       * http://www.phpgroupware.org                                           
   *
+       * Written by Mark Peters <address@hidden>                             *
+       * --------------------------------------------                          
   *
+       *  This program is free software; you can redistribute it and/or modify 
it *
+       *  under the terms of the GNU General Public License as published by 
the   *
+       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
+       *  option) any later version.                                           
   *
+       
\**************************************************************************/
+
+       /* $Id: admin.php,v 1.25.2.1.2.1 2005/12/15 14:06:41 skwashd Exp $ */
+
+       if ( (isset($_POST['submit']) && $_POST['submit']) 
+               && (isset($_POST['nntplist']) && $_POST['nntplist']) )
+       {
+               $phpgw_flags = Array(
+                               'currentapp'                                    
=>      'nntp',
+                               'admin_header'                                  
=>      True,
+                               'enable_nextmatchs_class'       =>      True,
+                               'noheader'                                      
        =>      True,
+                               'nonavbar'                                      
        =>      True
+                               );
+       }
+       else
+       {
+               $phpgw_flags = Array(
+                               'currentapp'                                    
=>      'nntp',
+                               'admin_header'                                  
=>      True,
+                               'enable_nextmatchs_class'       =>      True
+                               );
+       }
+
+       $GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
+       include('../header.inc.php');
+
+       function get_tg()
+       {
+               $GLOBALS['phpgw']->db->query('SELECT count(con) FROM 
newsgroups');
+               $GLOBALS['phpgw']->db->next_record();
+               $tg = $GLOBALS['phpgw']->db->f(0);
+               if($tg == 0)
+               {
+                       @set_time_limit(0);
+                       $GLOBALS['nntp']->load_table();
+                       return get_tg();
+               }
+               else
+               {
+                       return $tg;
+               }
+       }
+
+       if( (!isset($_REQUEST['submit']) || !$_REQUEST['submit']) && 
(!isset($_REQUEST['nntplist']) || !$_REQUEST['nntplist']) )
+       {
+               if ( !isset($_REQUEST['tg']) || !$_REQUEST['tg'] )
+               {
+                       $tg = intval(get_tg());
+               }
+               else
+               {
+                       $tg = intval($_REQUEST['tg']);
+               }
+
+               //$phpgw->common->phpgw_header();
+               //echo parse_navbar();
+
+               $max = 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']);
+
+               $urlname = '/nntp/admin.php';
+
+               $p =& $GLOBALS['phpgw']->template;
+               $p->set_root( $GLOBALS['phpgw']->common->get_tpl_dir('nntp') );
+               
+               $p->set_file('nntp_form', 'nntp.tpl');
+
+               $p->set_block('nntp_form','nntp','nntp');
+               $p->set_block('nntp_form','nntp_list','nntp_list');
+
+               if ( !isset($_REQUEST['start']) || !$_REQUEST['start'] )
+               {
+                       $start = 0;
+               }
+               else
+               {
+                       $start = (int) $_REQUEST['start'];
+               }
+
+               if (!isset($_REQUEST['query_result']) || 
!$_REQUEST['query_result'] )
+               {
+                       $query_result = 0;
+               }
+               else
+               {
+                       $query_result = (int) $_REQUEST['query_result'];
+               }
+
+               if ( !isset($_REQUEST['order']) || !$_REQUEST['order'] )
+               {
+                       $order = 1;
+               }
+               else
+               {
+                       $order = (int) $_REQUEST['order'];
+               }
+
+               $sort = 'ASC';
+
+               $orderby = '';
+               if ( $order > 0 && $order < 4 ) //see below
+               {
+                       $sort = isset($_REQUEST['sort']) && $_REQUEST['sort'] 
== 'DESC' ? 'DESC' : 'ASC';
+
+                       switch ($order)
+                       {
+                               case 1:
+                                       $orderby = ' ORDER BY con '.$sort;
+                                       break;
+                               case 2:
+                                       $orderby = ' ORDER BY name '.$sort;
+                                       break;
+                               case 3:
+                                       $orderby = ' ORDER BY active '.$sort;
+                                       break;
+                       }
+               }
+
+               $query_result = get_var('query_result', array('POST'), 0);
+               if ( (isset($_REQUEST['search']) && $_REQUEST['search']) || 
(isset($_REQUEST['next']) && $_REQUEST['next']) )
+               {
+                       if (isset($_REQUEST['next']) && $_REQUEST['next'])
+                       {
+                               $query_result++;
+                       }
+
+                       $GLOBALS['phpgw']->db->limit_query("SELECT con FROM 
newsgroups WHERE name LIKE '%" 
+                                       . 
$GLOBALS['phpgw']->db->db_addslashes($_REQUEST['query']) . "%'$orderby ",
+                               $query_result, __LINE__, __FILE__);
+                       $GLOBALS['phpgw']->db->next_record();
+                       $start = (int)$GLOBALS['phpgw']->db->f('con') - 1;
+                       if($start < 0)
+                       {
+                               $start = 0;
+                       }
+               }
+
+               $common_hidden_vars = "<input type=\"hidden\" name=\"start\" 
value=\"{$start}\" />\n"
+                                       . '<input type="hidden" name="stop" 
value="' . ($start + $max) . "\">\n"
+                                       . "<input type=\"hidden\" name=\"tg\" 
value=\"{$tg}\">";
+
+               if (isset($query_result) && $query_result)
+               {
+                       $common_hidden_vars .= "<input type=\"hidden\" 
name=\"query_result\" value=\"{$query_result}\" />\n";
+               }
+
+
+               $extra_parms = array();
+               $extra_parms['tg'] = $tg;
+
+               if( $sortorder )
+               {
+                       $extra_parms['sortorder'] = $sortorder;
+               }
+               if( $order )
+               {
+                       $extra_parms['order'] = $order;
+               }
+
+               $var = array
+                       (
+                               'search_value'          =>      
get_var('query', array('POST'), ''),
+                               'search'                =>      lang('search'),
+                               'next'                  =>      lang('next'),
+                               'nml'                   =>      
$GLOBALS['phpgw']->nextmatchs->left($urlname,intval($start),intval($tg),$extra_parms),
+                               'nmr'                   =>      
$GLOBALS['phpgw']->nextmatchs->right($urlname,intval($start),intval($tg),$extra_parms),
+                               'title'                 =>      
lang('Newsgroups'),
+                               'action_url'            =>      
$GLOBALS['phpgw']->link('/nntp/admin.php'),
+                               'common_hidden_vars'    =>      
$common_hidden_vars,
+                               'th_bg'                 =>      
$GLOBALS['phpgw_info']['theme']['th_bg'],
+                               'th_font'               =>      
$GLOBALS['phpgw_info']['theme']['font'],
+                               'sort_con'              =>      
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 1, $order, $urlname,' # 
','&tg='.$tg),
+                               'sort_group'            =>      
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 2, $order, 
$urlname,lang('Group'),'&tg='.$tg),
+                               'sort_active'           =>      
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 3, $order, 
$urlname,lang('Active'),'&tg='.$tg)
+                           );
+
+               $p->set_var($var);
+
+               if ($max <= $tg - $start)
+               {
+                       $totaltodisplay = $max;
+               }
+               else
+               {
+                       $totaltodisplay = ($tg - $start) - 1;
+               }
+
+               $GLOBALS['phpgw']->db->limit_query('SELECT con, name, active 
FROM newsgroups'.$orderby,$start);
+
+               for ( $i = 0; $i < $totaltodisplay; $i++)
+               {
+                       $GLOBALS['phpgw']->db->next_record();
+                       $tr_color = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+                       $con = $GLOBALS['phpgw']->db->f('con');
+
+                       $name = $GLOBALS['phpgw']->db->f('name');
+                       if (!$name)
+                       {
+                               $name  = '&nbsp;';
+                       }
+                       $group_name = $name;
+
+                       $active = $GLOBALS['phpgw']->db->f('active');
+                       if ($active == 'Y')
+                       {
+                               $checked = ' checked="checked"';
+                       }
+                       else
+                       {
+                               $checked = '';
+                       }
+                       $active_var = "<input type=\"checkbox\" 
name=\"nntplist[]\" value=\"{$con}\" {$checked} />";
+
+                       $p->set_var(array
+                               (
+                                       'tr_color'      =>      $tr_color,
+                                       'con'           =>      $con,
+                                       'group'         =>      $group_name,
+                                       'active'        =>      $active_var
+                               ));
+
+                       $p->parse('rows','nntp_list',True);
+               }
+               $var = array
+                       (
+                               'lang_update'   =>      lang('update'),
+                               'checkmark'     =>      
$GLOBALS['phpgw']->common->get_image_path('email').'/check'
+                       );
+
+               $p->set_var($var);
+
+               $p->pparse('out', 'nntp');
+
+               $GLOBALS['phpgw']->common->phpgw_footer();
+       }
+       else
+       {
+               $GLOBALS['phpgw']->db->lock('newsgroups');
+
+               $GLOBALS['phpgw']->db->query('UPDATE newsgroups SET 
active=\'N\' WHERE con>= ' . intval($_REQUEST['start']) . ' AND con<= ' . 
intval($_REQUEST['stop']), __LINE__, __FILE__ );
+
+               for ( $i = 0; $i < count($_POST['nntplist']); ++$i)
+               {
+                       $GLOBALS['phpgw']->db->query('UPDATE newsgroups SET 
active=\'Y\' WHERE con=' . intval($_POST['nntplist'][$i]) , __LINE__, __FILE__ 
);
+               }
+               $GLOBALS['phpgw']->db->unlock();
+
+               $GLOBALS['phpgw']->redirect_link('/nntp/admin.php', 
array('start' => $_REQUEST['start'], 'tg' => $_REQUEST['tg']) );
+       }
+?>
Index: nntp/inc/class.mail.inc.php
diff -u /dev/null nntp/inc/class.mail.inc.php:1.6.2.3.2.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/inc/class.mail.inc.php Thu Dec 15 14:06:42 2005
@@ -0,0 +1,1014 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare app (NNTP)                                               *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+       /*
+       // description
+       (i)nternal/
+       (e)xternal
+       function name
+       
------------------------------------------------------------------------------
+       // Initializer Can't have contructors in base classes
+       * E function init($type='')
+
+       // Set error codes
+       * I function set_error($code,$msg,$desc)
+
+       // Open port to server
+       * E function open_port($server,$port,$timeout)
+
+       // Read port and return response
+       * I function read_port()
+
+       // Write to port
+       * I function write_port($str)
+
+       // write to port and evaluate response for expected result
+       * I function msg2socket($str,$expected_response,$response)
+
+       // Open mailbox
+       * E function mail_open($server,$port,$user,$pass)
+
+       // Only valid for NNTP
+       * E function mode_reader()
+
+       // Return number of messages for associated mailbox
+       * E function mail_num_msg()
+
+       // Returns first message for associated mailbox (NNTP only)
+       * E function mail_first_msg()
+
+       // Returns last message for associated mailbox (NNTP only)
+       * E function mail_last_msg()
+
+       // Splits the line of text and saves the $key, $value to the structure
+       * I function create_header($line,&$header)
+
+       // Read an overview of the information in the headers of the given 
msgnum
+       // into an array
+       * E function mail_fetch_overview($msgnum)
+
+       // Build address structure
+       * I function build_address_structure($key)
+
+       // Read the header of the message and populate the msg structure
+       * E function mail_header($msgnum)
+
+       // An alias for mail_header
+       * E function mail_headerinfo($msgnum)
+
+       // Read the message body
+       * E function mail_body($msgnum)
+
+       // An alias for mail_body
+       * E function mail_fetchtext($msgnum)
+
+       // Determines if message is uu encoded and decodes
+       * I function is_uu_encoded($body)
+
+       // Determines the boundary for mime encoded messages
+       * I function parse_boundary($header)
+
+       // Determines how many mime attachments
+       * I function how_many_mime_attchs($body)
+
+       // Determines if message is mime encoded
+       * I function is_mime_encoded($body)
+
+       // Determines the content type of mime encoded parts
+       * I function get_content_type($header,$struct)
+
+       // Determines the encoding type of mime encoded parts
+       * I function get_encoding_type($header,$struct)
+
+       // Build the $struct type from the specified header and body
+       * I function build_mime_structure($header,$struct)
+
+       // This splits the body of the mime message into the sub-parts
+       * I function split_mime_msg_parts($body,$boundary,$part,&$sub_header,
+       &$sub_body)
+
+       // Slowly being built...
+       //
+       // Still need to write the routine to split the uuencoded branch...
+       //
+       // I really need to study up on the layout of the structure...
+       //
+       // This will call mail_body(), if not previously called, and populate
+       // the structure from the stream of text
+       * E function mail_fetchstructure($msgnum)
+       */
+
+       class parameter
+       {
+               var $attribute;
+               var $value;
+       }
+
+       class struct
+       {
+               var $encoding;
+               var $type;
+               var $subtype;
+               var $ifsubtype;
+               var $parameters;
+               var $ifparameters;
+               var $description;
+               var $ifdescription;
+               var $disposition;
+               var $ifdisposition;
+               var $id;
+               var $ifid;
+               var $lines;
+               var $bytes;
+       }
+
+       class address
+       {
+               var $personal;
+               var $mailbox;
+               var $host;
+               var $adl;
+       }
+
+       class msg
+       {
+               var $from;
+               var $fromaddress;
+               var $to;
+               var $toaddress;
+               var $cc;
+               var $ccaddress;
+               var $bcc;
+               var $bccaddress;
+               var $reply_to;
+               var $reply_toaddress;
+               var $sender;
+               var $senderaddress;
+               var $return_path;
+               var $return_pathaddress;
+               var $udate;
+               var $subject;
+               var $lines;
+       }
+
+       CreateObject('phpgwapi.network');
+
+       class mail extends network
+       {
+               var $decode;
+               var $type;
+               var $header=array();
+               var $msg;
+               var $struct;
+               var $body;
+               var $mailbox;
+               var $numparts;
+
+               var $sparts;
+               var $hsub=array();
+               var $bsub=array();
+
+               function mail($type='')
+               {
+                       $this->errorset = 0;
+                       if ($type == '')
+                       {
+                               return $this->set_error('Programming error',
+                                       'Improper Intiailization',
+                                       'Please consult manual for instructions 
on use of MAIL.INC.PHP');
+                       }
+                       else
+                       {
+                               $this->network(True);
+                               $this->decode = CreateObject('nntp.decode');
+                               $this->type = $type;
+                               return 1;
+                       }
+               }
+
+               function mode_reader()
+               {
+                       return $this->msg2socket('mode 
reader',"^20[01]",$response);
+               }
+
+               function mail_open($server,$port,$user='',$pass='')
+               {
+                       if (!$this->open_port($server,$port,15))
+                       {
+                               return 0;
+                       }
+                       $this->read_port();
+
+                       if ($user <> '' && $pass <> '')
+                       {
+                               if (!$this->msg2socket('authinfo user 
'.$user,"^381",$response))
+                               {
+                                       return 0;
+                               }
+                               if (!$this->msg2socket('authinfo pass 
'.$pass,"^281",$response))
+                               {
+                                       return 0;
+                               }
+                       }
+                       if (!$this->mode_reader())
+                       {
+                               return 0;
+                       }
+                       if(isset($this->mailbox) && $this->mailbox)
+                       {
+                               return $this->msg2socket('group 
'.$this->mailbox,"^211",$response);
+                       }
+                       else
+                       {
+                               return 1;
+                       }
+               }
+
+               function mail_num_msg()
+               {
+                       $str = 'group '.$this->mailbox;
+                       $expected_response = "^211";
+
+                       if 
(!$this->msg2socket($str,$expected_response,$response))
+                       {
+                               return 0;
+                       }
+
+                       $temp_array = explode(' ',$response);
+
+                       return $temp_array[1];
+               }
+
+               function mail_first_msg()
+               {
+                       if ($this->type == 'nntp')
+                       {
+                               if (!$this->msg2socket('group 
'.$this->mailbox,"^211",$response))
+                               {
+                                       return 0;
+                               }
+                               $temp_array = array();
+                               $temp_array = explode(' ',$response);
+
+                               return $temp_array[2];
+                       }
+               }
+
+               function mail_last_msg()
+               {
+                       if ($this->type == 'nntp')
+                       {
+                               if (!$this->msg2socket('group 
'.$this->mailbox,"^211",$response))
+                               {
+                                       return 0;
+                               }
+                               $temp_array = array();
+                               $temp_array = explode(' ',$response);
+
+                               return $temp_array[3];
+                       }
+               }
+
+               function create_header($line,&$header,$line2='')
+               {
+                       $thead = explode(':',$line);
+                       $key = trim($thead[0]);
+                       switch(count($thead))
+                       {
+                               case 1:
+                                       $value = TRUE;
+                                       break;
+                               case 2:
+                                       $value = trim($thead[1]);
+                                       break;
+                               default: 
+                                       $thead[0] = '';
+                                       $value = '';
+                                       for($i=1,$j=count($thead);$i<$j;$i++)
+                                       {
+                                               $value .= $thead[$i].':';
+                                       }
+                                       //      $value = 
trim($value.$thead[$j++]);
+                                       //      $value = trim($value);
+                                       break;
+                       }
+                       $header[$key] = $value;
+                       if (ereg("^multipart/mixed;",$value))
+                       {
+                               if (! ereg('boundary',$header[$key]))
+                               {
+                                       if ($line2 == 'True') $line2 = 
$this->read_port();
+                                       {
+                                               $header[$key] .= chop($line2);
+                                       }
+                               }
+                       }
+                       //    echo 'Header['.$key.'] = 
'.$header[$key].'<br>'."\n";
+               }
+
+               function mail_fetch_overview($msgnum)
+               {
+                       switch (strtolower($this->type))
+                       {
+                               case 'pop':
+                                       $str = 'top '.$msgnum;
+                                       $expected_response = "^+OK";
+                                       break;
+                               case 'nntp':
+                                       $str = 'HEAD '.$msgnum;
+                                       $expected_response = "^221";
+                                       break;
+                       }
+
+                       if 
(!$this->msg2socket($str,$expected_response,$response))
+                       {
+                               return 0;
+                       }
+
+                       while ($line = $this->read_port())
+                       {
+                               if (chop($line) == '.' || chop($line) == '')
+                               {
+                                       break;
+                               }
+                               
$this->create_header($line,$this->header,'True');
+                       }
+                       if ($this->type == 'pop')
+                       {
+                               $lines = 0;
+                               while (chop($this->read_port()) <> '.')
+                               {
+                                       $lines++;
+                               }
+                               $this->header['Lines'] = $lines;
+                       }
+                       return 1;
+               }
+
+               function build_address_structure($key)
+               {
+                       $address = array(new address);
+                       // Build Address to Structure
+                       $temp_array = explode(';',$this->header[$key]);
+                       for ($i=0;$i<count($temp_array);$i++)
+                       {
+                               
$this->decode->decode_author($temp_array[$i],$email,$name);
+                               $temp = explode('@',$email);
+                               $address[$i]->personal = 
$this->decode->decode_header($name);
+                               $address[$i]->mailbox = $temp[0];
+                               if (count($temp) == 2)
+                               {
+                                       $address[$i]->host = $temp[1];
+                               }
+                               $address[$i]->adl = $email;
+                       }
+                       return $address;
+               }
+
+               function convert_date($msg_date)
+               {
+                       // if date is of type "Sat, 15 Jul 2000 20:50:22 +0200"
+                       // strip to "15 Jul 2000 20:50:22 +0200"
+                       $comma_pos = strpos($msg_date,',');
+                       if($comma_pos)
+                       {
+                               $msg_date = substr($msg_date,$comma_pos+1);
+                       }
+
+//                     echo 'NNTP: class.mail.inc.php: convert_date = 
'.$msg_date.'<br>'."\n";
+                       
+                       // This may need to be a reference to the different 
months in native tongue....
+                       $month= array(
+                               'Jan' => 1,
+                               'Feb' => 2,
+                               'Mar' => 3,
+                               'Apr' => 4,
+                               'May' => 5,
+                               'Jun' => 6,
+                               'Jul' => 7,
+                               'Aug' => 8,
+                               'Sep' => 9,
+                               'Oct' => 10,
+                               'Nov' => 11,
+                               'Dec' => 12
+                       );
+                       $dta = array();
+                       $ta = array();
+
+                       // Convert "15 Jul 2000 20:50:22 +0200" to unixtime
+                       $dta = explode(' ',$msg_date);
+                       $ta = explode(':',$dta[4]);
+
+                       if(substr($dta[5],0,3) <> 'GMT')
+                       {
+                               $tzoffset = substr($dta[5],0,1);
+                               $tzhours = intval(substr($dta[5],1,2));
+                               $tzmins = intval(substr($dta[5],3,2));
+                               switch ($tzoffset)
+                               {
+                                       case '+':
+                                               (int)$ta[0] += $tzhours;
+                                               (int)$ta[1] += $tzmins;
+                                               break;
+                                       case '-':
+                                               (int)$ta[0] -= $tzhours;
+                                               (int)$ta[1] -= $tzmins;
+                                               break;
+                               }
+                       }
+                       //echo 'NNTP: class.mail.inc.php: Date = ('.$dta[1].') 
('.$month[$dta[2]].') ('.$dta[3].') TIME: 
('.$ta[0].':'.$ta[1].':'.$ta[2].')<br>'."\n";
+                       return 
mktime($ta[0],$ta[1],$ta[2],$month[$dta[2]],$dta[1],$dta[3]);
+               }
+
+               function mail_header($msgnum)
+               {
+                       $this->msg = new msg;
+                       $this->mail_fetch_overview($msgnum);
+
+                       // From:
+                       $this->msg->from = array(new address);
+                       $this->msg->from = 
$this->build_address_structure('From');
+                       $this->msg->fromaddress = $this->header['From'];
+
+                       // To:
+                       $this->msg->to = array(new address);
+                       if (strtolower($this->type) == 'nntp')
+                       {
+                               $temp = 
explode(',',$this->header['Newsgroups']);
+                               $to = array(new address);
+                               for($i=0;$i<count($temp);$i++)
+                               {
+                                       $to[$i]->mailbox = '';
+                                       $to[$i]->host = '';
+                                       $to[$i]->personal = $temp[$i];
+                                       $to[$i]->adl = $temp[$i];
+                               }
+                               $this->msg->to = $to;
+                       }
+                       else
+                       {
+                               $this->msg->to = 
$this->build_address_structure('To');
+                               $this->msg->toaddress = $this->header['To'];
+                       }
+
+                       // Cc:
+                       $this->msg->cc = array(new address);
+                       if(isset($this->header['Cc']))
+                       {
+                               $this->msg->cc[] = 
$this->build_address_structure('Cc');
+                               $this->msg->ccaddress = $this->header['Cc'];
+                       }
+
+                       // Bcc:
+                       $this->msg->bcc = array(new address);
+                       if(isset($this->header['bcc']))
+                       {
+                               $this->msg->bcc = 
$this->build_address_structure('bcc');
+                               $this->msg->bccaddress = $this->header['bcc'];
+                       }
+
+                       // Reply-To:
+                       $this->msg->reply_to = array(new address);
+                       if(isset($this->header['Reply-To']))
+                       {
+                               $this->msg->reply_to = 
$this->build_address_structure('Reply-To');
+                               $this->msg->reply_toaddress = 
$this->header['Reply-To'];
+                       }
+
+                       // Sender:
+                       $this->msg->sender = array(new address);
+                       if(isset($this->header['Sender']))
+                       {
+                               $this->msg->sender = 
$this->build_address_structure('Sender');
+                               $this->msg->senderaddress = 
$this->header['Sender'];
+                       }
+
+                       // Return-Path:
+                       $this->msg->return_path = array(new address);
+                       if(isset($this->header['Return-Path']))
+                       {
+                               $this->msg->return_path = 
$this->build_address_structure('Return-Path');
+                               $this->msg->return_pathaddress = 
$this->header['Return-Path'];
+                       }
+
+                       // UDate
+                       $this->msg->udate = 
$this->convert_date($this->header['Date']);
+
+                       // Subject
+                       $this->msg->subject = 
$this->decode->phpGW_quoted_printable_decode($this->header['Subject']);
+
+                       // Lines
+                       // This represents the number of lines contained in the 
body
+                       $this->msg->lines = $this->header['Lines'];
+               }
+
+               function mail_headerinfo($msgnum)
+               {
+                       $this->mail_header($msgnum);
+               }
+
+               function mail_body($msgnum)
+               {
+                       switch (strtolower($this->type))
+                       {
+                               case 'pop':
+                                       $str = 'retr '.$msgnum;
+                                       $expected_response = "^+OK";
+                                       break;
+                               case 'nntp':
+                                       $str = 'BODY '.$msgnum;
+                                       $expected_response = "^222";
+                                       break;
+                       }
+
+                       if 
(!$this->msg2socket($str,$expected_response,$response))
+                       {
+                               return 0;
+                       }
+
+                       if (strtolower($this->type) == 'pop')
+                       {
+                               while (chop($this->read_port()) <> '')
+                               {
+                               }
+                       }
+                       $retval = '';
+                       while ($line = $this->read_port())
+                       {
+                               $end = chop($line);
+                               if ($end == '.')
+                               {
+                                       if($retval == '')
+                                       {
+                                               $retval = 'Body Not 
Found!'."\n";
+                                       }
+                                       break;
+                               }
+                               $retval .= $line . "\n";
+                       }
+                       $this->body = $retval;
+               }
+
+               function mail_fetchtext($msgnum)
+               {
+                       $this->mail_body($msgnum);
+               }
+
+               function getMimeType($file)
+               {
+                       $file=basename($file);
+                       $mimefile=PHPGW_API_INC.'/phpgw_mime.types';
+                       $fp=fopen($mimefile,'r');
+                       $contents = explode("\n",fread ($fp, 
filesize($mimefile)));
+                       fclose($fp);
+
+                       $parts=explode('.',$file);
+                       $ext=$parts[(sizeof($parts)-1)];
+
+                       for($i=0;$i<sizeof($contents);$i++)
+                       {
+                               if (! ereg("^#",$contents[$i]))
+                               {
+                                       $line=split("[[:space:]]+", 
$contents[$i]);
+                                       if (sizeof($line) >= 2)
+                                       {
+                                               for($j=1;$j<sizeof($line);$j++)
+                                               {
+                                                       if ($line[$j] == $ext)
+                                                       {
+                                                               
$mimetype=$line[0];
+                                                               return 
$mimetype;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       return 'text/plain';
+               }
+
+               function is_uu_encoded($body)
+               {
+                       $lines = explode("\n",$body);
+                       $found_begin = 0;
+                       $found_end = 0;
+                       for($i=0;$i<count($lines);$i++)
+                       {
+                               if (ereg("^begin",$lines[$i]))
+                               {
+                                       //      echo 'Found the 
begin!<br>'."\n";
+                                       $tempvar = explode(' ',$lines[$i]);
+                                       //      echo 'Begin Statement : 
'.$lines[$i].' (count)='.count($tempvar).'<br>'."\n";
+                                       //      if (count($tempvar) == 3 && 
strpos($tempvar[2],'.')) $found_begin = 1;
+                                       if (count($tempvar) > 2 && 
is_long((int)$tempvar[1]))
+                                       {
+                                               $found_begin = 1;
+                                       }
+                                       //      echo 'Found_Begin = 
'.$found_begin.'  is_long='.is_long((int)$tempvar[1]).'<br>'."\n";
+                               }
+                               elseif ($found_begin)
+                               {
+                                       if (ereg("^end",$lines[$i]))
+                                       {
+                                               $found_end = 1;
+                                       }
+                               }
+                       }
+                       //   echo 'is_uu_encoded = '.$found_end.'<br>'."\n";
+                       return $found_end;
+               }
+
+               function split_uuencoded_into_parts(&$body,$boundary)
+               {
+                       $binary = Array();
+                       $body = ereg_replace('<br>',"\n",$body);
+                       $lines = explode("\n",$body);
+                       $parts=0;
+                       $tempbody='';
+                       if(!$boundary) $boundary = uniqid('');
+                       $mime_text_header = '--'.$boundary."\n".'Content-Type: 
text/plain; charset=us-ascii'."\n".'Content-Transfer-Encoding: 7bit'."\n\n";
+                       $newpart = 1;
+                       $found_begin = 0;
+                       $j=0;
+                       $binary = '';
+                       for($i=0;$i<count($lines);$i++)
+                       {
+                               if($newpart && 
!ereg("^begin",strtolower($lines[$i])))
+                               {
+                                       $tempbody .= 
$mime_text_header."\n".$lines[$i]."\n";
+                                       $newpart = 0;
+                                       $parts++;
+                               }
+                               elseif ($found_begin)
+                               {
+                                       if (!ereg("^end",$lines[$i]))
+                                       {
+                                               if($lines[$i]<>'' || 
$lines[$i]<>"\n")
+                                               {
+                                                       $binary[$j] = 
$lines[$i];
+                                                       $j++;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $attach = 
base64_encode($this->decode->uudecode($binary));
+                                               
$content_type=$this->getMimeType(strtolower($filename));
+                                               $tempbody .= 
"\n".'--'.$boundary."\r\n".'Content-Type: '.$content_type.'; 
name="'.$filename.'"'."\n"
+                                                       . 
'Content-Transfer-Encoding: base64'."\n".'Content-Disposition: inline; '
+                                                       . 
'filename="'.$filename.'"'."\n".$attach."\n".'--'.$boundary."\n";
+                                               $binary = Array();
+                                               $filename = '';
+                                               $found_begin = 0;
+                                               if (chop($lines[$i + 1]) <> '' 
&& chop($lines[$i + 1]) <> '.')
+                                               {
+                                                       $newpart = 1;
+                                                       $i += 2;
+                                               }
+                                       }
+                               }
+                               elseif (ereg("^begin",$lines[$i]))
+                               {
+                                       $lines[$i] = 
ereg_replace("\n",'',$lines[$i]);
+                                       $temparray = explode(' ',$lines[$i]);
+                                       if (is_int((int)$temparray[1]))
+                                       {
+                                               $newpart = 0;
+                                               
for($k=2,$filename='';$k<count($temparray);$k++)
+                                               {
+                                                       $filename .= 
$temparray[$k];
+                                               }
+                                               $filename = 
substr($filename,0,strlen($filename)-1);
+                                               $found_begin = 1;
+                                               $j=0;
+                                               $parts++;
+                                       }
+                               }
+                               else
+                               {
+                                       $tempbody .= $lines[$i];
+                               }
+                       }
+                       //    return $parts;
+                       //    echo 'Created '.$parts.' MIME parts!<br>'."\n";
+                       //    echo str_replace("\n",'<br>',$tempbody);
+                       $body = $tempbody;
+               }
+
+               function parse_boundary($header)
+               {
+                       //    echo $header.'<br>'."\n";
+                       $temp = explode(';',$header);
+
+                       $tboundary = explode('boundary="',$temp[1]);
+                       //    return 
quoted_printable_decode(substr($tboundary[1],0,strlen($tboundary[1])-1));
+                       if(count($tboundary) > 1)
+                       {
+                               return 
quoted_printable_decode(substr($tboundary[1],0,strpos($tboundary[1],'"')));
+                       }
+                       else
+                       {
+                               return '';
+                       }
+               }
+
+               function how_many_mime_attchs($body)
+               {
+                       $boundary_found = 0;
+                       if (!$this->header['Content-Type'])
+                       {
+                               return 0;
+                       }
+                       $this->boundary = 
$this->parse_boundary($this->header['Content-Type']);
+                       if($this->boundary <> '')
+                       {
+                               $boundary_found = 
count(explode($this->boundary,$body));
+                       }
+                       //    echo $this->boundary."<br>".'Boundary Found = 
'.$boundary_found.'<br>'."\n";
+                       if(!$boundary_found)
+                       {
+                               $end = strpos($body,'----=_NextPart');
+                               if($end)
+                               {
+                                       $start = $end;
+                                       while(substr($body,$end,1) <> ' ')
+                                       {
+                                               $end++;
+                                               $boundary = 
substr($body,$start+7,$end - $start);
+                                               $this->boundary = 
$this->create_header('Content-Type: multipart/mixed;',$this->header,' 
boundary="'.$boundary.'"');
+                                       }
+                                       $boundary_found = 
count(explode($boundary,$body));
+                               }
+                               else
+                               {
+                                       $boundary=uniqid('----=_NextPart');
+                                       $mime_text_header = 
'--'.$boundary."\n".'Content-Type: text/plain; 
charset=us-ascii'."\n".'Content-Transfer-Encoding: 7bit'."\n\n";
+                                       $body = 
$mime_text_header."\n".$body."\n".'--'.$boundary;
+                                       $this->create_header('Content-Type: 
multipart/mixed;',$this->header,' boundary="'.$boundary.'"');
+                                       $this->create_header('Mime-Version: 
1.0',$this->header);
+                                       $this->boundary = $boundary;
+                                       $boundary_found = 4;
+                               }
+                       }
+                       //    echo $this->boundary.'<br>'."\n";
+                       //    echo $this->header['Content-Type'].'<br>'."\n";
+                       return $boundary_found - 2;
+               }
+
+               function is_mime_encoded()
+               {
+                       $is = ($this->header['Content-Type'] && 
$this->header['Content-Type'] <> '' ? 1 : 0);
+                       return $is;
+               }
+
+               function get_content_type($header,$struct)
+               {
+                       if(strpos($header,';') > 0)
+                       {
+                               $tarray = explode(';',$header);
+                       }
+                       else
+                       {
+                               $tarray = array();
+                               $tarray[0] = $header;
+                       }
+                       $content_type = explode('/',$tarray[0]);
+                       switch (strtolower($content_type[0]))
+                       {
+                               case 'text':
+                                       $struct->type = 0;              // 
TYPETEXT;
+                                       break;
+                               case 'multipart':
+                                       $struct->type = 1;              // 
TYPEMULTIPART;
+                                       break;
+                               case 'message':
+                                       $struct->type = 2;              // 
TYPEMESSAGE;
+                                       break;
+                               case 'application':
+                                       $struct->type = 3;              // 
TYPEAPPLICATION;
+                                       break;
+                               case 'audio':
+                                       $struct->type = 4;              // 
TYPEAUDIO;
+                                       break;
+                               case 'image':
+                                       $struct->type = 5;              // 
TYPEIMAGE;
+                                       break;
+                               case 'video':
+                                       $struct->type = 6;              // 
TYPEVIDEO;
+                                       break;
+                               default:
+                                       $struct->type = 7;              // 
TYPEOTHER;
+                                       break;
+                       }
+                       if (count($content_type) >= 1)
+                       {
+                               $struct->subtype = strtolower($content_type[1]);
+                               $struct->ifsubtype = true;
+                       }
+                       $tttarray = new parameter;
+                       for ($i=1;$i<count($tarray);$i++)
+                       {
+                               $params = explode('=',$tarray[$i]);
+                               if (strtolower(trim($params[0])) == 'name')
+                               {
+                                       $ttarray = explode('"',$params[1]);
+                                       $params[1] = trim($ttarray[1]);
+                                       
while(substr($params[1],strlen($params[1]),1) == '"')
+                                       {
+                                               $params[1] = 
trim(substr($params[1],0,strlen($params[1])-1));
+                                       }
+                               }
+                               $tttarray->attribute = trim($params[0]);
+                               $tttarray->value = $params[1];
+                               $struct->parameters[] = $tttarray;
+                       }
+                       unset($tttarray);
+               }
+
+               function get_encoding_type($header,&$struct)
+               {
+                       switch (strtolower($header))
+                       {
+                               case '7bit':
+                                       $struct->encoding = 0;          // 
ENC7BIT;
+                                       break;
+                               case '8bit':
+                                       $struct->encoding = 1;          // 
ENC8BIT;
+                                       break;
+                               case 'binary':
+                                       $struct->encoding = 2;          // 
ENCBINARY;
+                                       break;
+                               case 'base64':
+                                       $struct->encoding = 3;          // 
ENCBASE64;
+                                       break;
+                               case 'quoted-printable':
+                                       $struct->encoding = 4;          // 
ENCQUOTEDPRINTABLE;
+                                       break;
+                               default:
+                                       $struct->encoding = 5;          // 
ENCOTHER;
+                                       break;
+                       }
+               }
+
+               function build_mime_structure($header)
+               {
+                       $struct = new struct;
+                       $tempvar = True;
+                       if (isset($header['Content-Type']) && 
$header['Content-Type'])
+                       {
+                               
$this->get_content_type($header['Content-Type'],$struct);
+                       }
+                       if (isset($header['Content-Transfer-Encoding']) && 
$header['Content-Transfer-Encoding'])
+                       {
+                               
$this->get_encoding_type($header['Content-Transfer-Encoding'],$struct);
+                       }
+                       else
+                       {
+                               $tempvar1 = 0;
+                               $struct->encoding = $tempvar1;
+                       }
+                       if (isset($header['Content-Description']) && 
$header['Content-Description'])
+                       {
+                               $struct->description = 
$header['Content-Description'];
+                               $struct->ifdescription = $tempvar;
+                       }
+                       if (isset($header['Content-Identifier']) && 
$header['Content-Identifier'])
+                       {
+                               $struct->id = $header['Content-Identifier'];
+                               $struct->ifid = $tempvar;
+                       }
+                       if (isset($header['Lines']) && $header['Lines'])
+                       {
+                               (int)$struct->lines = (int)$header['Lines'];
+                       }
+                       if (isset($header['Content-Length']) && 
$header['Content-Length'])
+                       {
+                               (int)$struct->bytes = 
(int)$header['Content-Length'];
+                       }
+                       if (isset($header['Content-Disposition']) && 
$header['Content-Disposition'])
+                       {
+                               $temparray = 
explode(';',$header['Content-Disposition']);
+                               $struct->disposition = $temparray[0];
+                               $struct->ifdisposition = $tempvar;
+                       }
+                       $ttarray = new parameter;
+                       if (isset($header['Mime-Version']) && 
$header['Mime-Version'])
+                       {
+                               $tempvar2 = 'Mime-Version';
+                               $ttarray->attribute = $tempvar2;
+                               $ttarray->value = $header['Mime-Version'];
+                               $struct->parameters[] = $ttarray;
+                               $struct->ifparameters = $tempvar;
+                       }
+                       unset($ttarray);
+                       return $struct;
+               }
+
+               function 
split_mime_msg_parts($body,$boundary,$part,&$sub_header,&$sub_body)
+               {
+                       $parts = explode('--'.$boundary,$body);
+                       $lines = explode("\n",$parts[$part]);
+                       $sub_body = '';
+                       for ($i=0,$j=0;$i<count($lines);$i++)
+                       {
+                               //      echo $lines[$i].'<br>'."\n";
+                               $lines[$i] = ereg_replace("\r",'',$lines[$i]);
+                               //    $lines[$i] = 
ereg_replace("\n",'',$lines[$i]);
+                               //      echo 'Line: '.$i.' : 
'.$lines[$i].'<br>'."\n";
+                               if (ereg("^Content-",$lines[$i]) || 
+                                       ereg("^x-no-archive:",$lines[$i]))
+                               {
+                                       
while(substr($lines[$i],strlen(chop($lines[$i]))-1) == ';')
+                                       {
+                                               $lines[$i] = 
strip_tags($lines[$i]);
+                                               $tline = $lines[$i];
+                                               $i++;
+                                               while($lines[$i] == '' || 
$lines[$i] == "\n")
+                                               {
+                                                       $i++;
+                                               }
+                                               $lines[$i] = 
strip_tags($lines[$i]);
+                                               $lines[$i] = $tline . 
chop($lines[$i]);
+                                               //  echo 'Lines = 
'.$lines[$i].'<br>'."\n";
+                                       }
+                                       //      
if(ereg("[[:space:]]x-mac-type=",ltrim($lines[$i + 1]))) {
+                                               //        $i++;
+                                               //        $lines[$i] = 
$lines[$i - 1] . ';' . $lines[$i];
+                                               //      }
+                                               //        
$this->create_header($lines[$i],$sub_header,$lines[$i+1]);
+                                               
$this->create_header($lines[$i],$sub_header);
+                               }
+                               else
+                               {
+                                       if($lines[$i]<>'')
+                                       {
+                                               $sub_body .= $lines[$i] . "\n";
+                                               $j++;
+                                       }
+                               }
+                       }
+                       if($this->is_uu_encoded($sub_body))
+                       {
+                               
$this->split_uuencoded_into_parts($sub_body,$boundary);
+                       }
+                       $this->create_header('Lines: '.$j,$sub_header);
+               }
+
+               function mail_fetchstructure($msgnum)
+               {
+                       $this->mail_body($msgnum);
+                       $this->struct = new struct;
+                       $this->sparts = array(new struct);
+                       $this->struct->parameters = array(new parameter);
+                       if ($this->is_uu_encoded($this->body))
+                       {
+                               //  echo 'This is a UUEncoded 
message!<br>'."\n";
+                               
$this->split_uuencoded_into_parts($this->body,$boundary);
+                               $this->create_header('Content-Type: 
multipart/mixed;',$this->header,' boundary="'.$boundary.'"');
+                               $this->create_header('Mime-Version: 
1.0',$this->header);
+                       }
+                       if (!$this->is_mime_encoded())
+                       {
+                               $boundary=uniqid('----=_NextPart');
+                               $mime_text_header = 
'--'.$boundary."\n".'Content-Type: text/plain; 
charset=us-ascii'."\n".'Content-Transfer-Encoding: 7bit'."\n\n";
+                               $this->body = 
$mime_text_header."\n".$this->body."\n".'--'.$boundary;
+                               $this->create_header('Content-Type: 
multipart/mixed;',$this->header,' boundary="'.$boundary.'"');
+                               $this->create_header('Mime-Version: 
1.0',$this->header);
+                       }
+                       if ($this->is_mime_encoded())
+                       {
+                               $this->numparts = 
$this->how_many_mime_attchs($this->body);
+                               $this->struct = 
$this->build_mime_structure($this->header);
+                               for($i=0;$i<=$this->numparts;$i++)
+                               {
+                                       
$this->split_mime_msg_parts($this->body,$this->parse_boundary(
+                                               $this->header['Content-Type']
+                                       ),
+                                       $i,$this->hsub[$i],
+                                       $this->bsub[$i]);
+                                       $this->sparts[$i] = 
$this->build_mime_structure($this->hsub[$i]);
+                               }
+                       }
+               }
+
+               function build_body_to_print()
+               {
+                       $str = '';
+                       for ($i=0;$i<=$this->numparts;$i++)
+                       {
+                               $part = (!$this->sparts[$i] ? $this->struct : 
$this->sparts[$i]);
+
+                               $str .= 
$this->decode->inline_display($part,$this->bsub[$i],'Section',$this->folder);
+                               $str .= "\n".'<p>';
+                       }
+                       return $str;
+               }
+       }
+?>
Index: nntp/inc/class.nntp.inc.php
diff -u /dev/null nntp/inc/class.nntp.inc.php:1.7.2.2.2.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/inc/class.nntp.inc.php Thu Dec 15 14:06:42 2005
@@ -0,0 +1,344 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare app (NNTP)                                               *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+       /* $Id: class.nntp.inc.php,v 1.7.2.2.2.1 2005/12/15 14:06:42 skwashd 
Exp $ */
+
+       include(PHPGW_APP_INC.'/message.inc.php');
+       include(PHPGW_APP_INC.'/class.mail.inc.php');
+
+       class nntp extends mail
+       {
+               var $db;
+               var $con;
+               var $folder;
+               var $groupname;
+               var $messagecount;
+               var $lowmsg;
+               var $highmsg;
+               var $active;
+               var $lastread;
+               var $msgnum;
+               var $display;
+
+               function nntp( $params = array() )
+               {
+                       $folder = '';
+                       $msgnum = '';
+                       if( is_array($params) && count($params) )
+                       {
+                               foreach ( $params as $key => $value )
+                               {
+                                       $$key = $value;
+                               }
+                       }
+                       
+                       if ( !$this->mail('nntp') )
+                       {
+                               return 0;
+                       }
+                       $this->db =& $GLOBALS['phpgw']->db;
+
+                       
if(!isset($GLOBALS['phpgw_info']['server']['nntp_server']) || 
$GLOBALS['phpgw_info']['server']['nntp_server']=='')
+                       {
+                               return $this->set_error('ERROR','Configuration 
Error','The administrator has not configured the NNTP Server.');
+                       }
+
+                       
if(!isset($GLOBALS['phpgw_info']['server']['nntp_port']) || 
intval($GLOBALS['phpgw_info']['server']['nntp_port'])==0)
+                       {
+                               $GLOBALS['phpgw_info']['server']['nntp_port'] = 
119;
+                       }
+                       if ( 
!$this->mail_open($GLOBALS['phpgw_info']['server']['nntp_server'], 
+                                               
$GLOBALS['phpgw_info']['server']['nntp_port'], 
+                                               
$GLOBALS['phpgw_info']['server']['nntp_login_username'], 
+                                               
$GLOBALS['phpgw_info']['server']['nntp_login_password']) )
+                       {
+                               if($GLOBALS['phpgw_info']['flags']['noheader'] 
== True)
+                               {
+                                       
$GLOBALS['phpgw']->common->phpgw_header();
+                                       echo parse_navbar();
+                               }
+
+                               echo '<p><center><b>' . lang('There was an 
error trying to connect to your news server.<br>Please contact your admin to 
check the news servername, username or password.').'</b></center>';
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
+
+                       if ($folder != '' && $msgnum != '')
+                       {
+                               if ( !$this->read_table($folder, $msgnum) )
+                               {
+                                       return 0;
+                               }
+                               $this->mail_header($this->msgnum);
+                               $this->mail_fetchstructure($this->msgnum);
+                               return 1;
+                       }
+               }
+
+               function update_lastread_info()
+               {
+                       $this->db->query('UPDATE newsgroups SET lastread = 
'.time().' WHERE con='.$this->con);
+               }
+
+               function save_to_db($groupdb)
+               {
+                       $this->db->query("SELECT con FROM newsgroups WHERE 
name='".$this->db->db_addslashes($groupdb['name'])."'");
+                       if ($this->db->num_rows() > 0)
+                       {
+                               $this->db->next_record();
+                               $con = $this->db->f('con');
+                               $this->db->query('UPDATE newsgroups SET 
messagecount='.$groupdb['count'].',lastmessage='.(int)$groupdb['last'][$i].',lastread='.time().'
 where con='.$con);
+                       }
+                       else
+                       {
+                               $this->db->query("insert into newsgroups 
(name,messagecount,lastmessage,lastread) 
values('".$this->db->db_addslashes($groupdb['name'])."',".(int)$groupdb["count"].','.(int)$groupdb['last'].','.time().')');
+                       }
+               }
+
+               function load_table()
+               {
+                       $retval = Array();
+                       $ret = Array();
+                       $retval['name'] = Array();
+                       $retval['count'] = Array();
+                       $retval['last'] = Array();
+
+                       if (!$this->msg2socket('LIST','^215',$response))
+                       {
+                               return 0;
+                       }
+
+                       /* Default is: GROUP HIGH LOW FLAGS */
+                       while ($line = $this->read_port())
+                       {
+                               $line = chop($line);
+                               if ($line == '.')
+                               {
+                                       break;
+                               }
+                               if (!ereg('^control',$line) && 
!ereg('^junk',$line) && !ereg('^to ',$line))
+                               {
+                                       if (!$template || ereg($template, 
$line))
+                                       {
+                                               $fields = explode(' ', $line);
+                                               $count = ($fields[1] >= 
$fields[2] ? (int)$fields[1] - (int)$fields[2] + 1 : 0);
+                                               $ret['name'] = $fields[0];
+                                               $ret['count'] = $count;
+                                               $ret['last'] = $fields[1];
+                                               //$retval[] = $ret;
+                                               if (strlen($ret['name']) <= 255)
+                                               {
+                                                       $this->save_to_db($ret);
+                                               }
+                                       }
+                               }
+                       }
+                       //      return $retval;
+               }
+
+               function noexist()
+               {
+                       $this->con          = 0;
+                       $this->groupname    = '';
+                       $this->mailbox      = '';
+                       $this->messagecount = 0;
+                       $this->lowmsg       = 0;
+                       $this->highmsg      = 0;
+                       $this->active       = 'N';
+                       $this->lastread     = 0;
+                       $this->msgnum       = 0;
+               }
+
+               function read_table($newsgroup,$msgnum=0)
+               {
+                       $this->db->query('SELECT 
name,messagecount,active,lastread FROM newsgroups WHERE con='.$newsgroup);
+                       if ($this->db->num_rows() > 0)
+                       {
+                               $this->db->next_record();
+                               $this->con          = $newsgroup;
+                               $this->folder       = 
stripslashes($this->db->f('name'));
+                               $this->mailbox      = $this->db->f('name');
+                               $this->messagecount = 
$this->db->f('messagecount');
+                               $this->lowmsg       = $this->mail_first_msg();
+                               $this->highmsg      = $this->mail_last_msg();
+                               $this->active       = $this->db->f('active');
+                               $this->lastread     = $this->db->f('lastread');
+                               $this->msgnum       = $msgnum;
+                               if ($this->active == 'N')
+                               {
+                                       
$GLOBALS['phpgw']->preferences->delete('nntp',$newsgroup);
+                                       
$GLOBALS['phpgw']->preferences->save_repository();
+                                       return 
$this->set_error('ERROR','Automatic Disabling','The newsgroup 
'.$this->groupname.' is not activated by the Administrator.');
+                               }
+                               elseif ($this->msgnum <> 0)
+                               {
+                                       if (($this->msgnum < $this->lowmsg) || 
($this->msgnum > $this->highmsg))
+                                       {
+                                               return 
$this->set_error('ERROR','Message does not 
exist',$this->mailbox.':'.$this->msgnum.' does not exist.');
+                                       }
+                                       else
+                                       {
+                                               return 1;
+                                       }
+                               }
+                               else
+                               {
+                                       return 1;
+                               }
+                       }
+                       else
+                       {
+                               $this->noexist();
+                               $this->set_error('ERROR','Not valid','The news 
folder '.$newsgroup.' is not available.');
+                               return 0;
+                       }
+               }
+
+               function xhdr($field,$first,$last)
+               {
+                       if (!$this->msg2socket('XHDR '.$field.' 
'.$first.'-'.$last,'^221',$response))
+                       {
+                               return 0;
+                       }
+
+                       $retval = Array();
+                       while ($line = $this->read_port())
+                       {
+                               $line = chop($line);
+                               if ($line == '.')
+                               {
+                                       break;
+                               }
+                               $breakpos = strpos($line,' ');
+                               $retval[substr($line,0,$breakpos)] = 
substr($line,$breakpos+1,strlen($line)-$breakpos);
+                       }
+                       return $retval;
+               }
+
+               function get_objects($field,$length)
+               {
+                       $newarray = Array();
+                       $start = $this->highmsg - $this->display;
+                       $stop = $this->highmsg;
+                       if($start < 0)
+                       {
+                               $start = $this->lowmsg;
+                       }
+                       $retval = $this->xhdr($field,$start,$this->highmsg);
+                       if (!$retval)
+                       {
+                               return 0;
+                       }
+                       while (list($nr,$fieldval) = each($retval))
+                       {
+                               $fieldval = 
$this->decode->phpGW_quoted_printable_decode($fieldval);
+                               if ($length && (strlen($fieldval) > $length))
+                               {
+                                       $fieldval = substr($fieldval, 0, 
$length).'...';
+                               }
+                               $newarray[$nr] = $fieldval;
+                       }
+                       return $newarray;
+               }
+
+               function get_subjects()
+               {
+                       $this->update_lastread_info();
+                       return $this->get_objects('Subject',35);
+               }
+
+               function get_list($field, $msgnum, $totaltodisplay)
+               {
+                       $newarray = Array();
+                       $fields = Array(
+                               0 => 'From',
+                               1 => 'Subject',
+                               2 => 'Date'
+                       );
+                       $i = 0;
+                       while($i < $totaltodisplay)
+                       {
+                               if ($this->mail_fetch_overview($msgnum))
+                               {
+                                       $newarray[$i]['Msgnum'] = $msgnum;
+                                       for ( $j = 0; $j < 2; ++$j)
+                                       {
+                                               $newarray[$i][$fields[$j]] = 
$this->decode->phpGW_quoted_printable_decode($this->header[$fields[$j]]);
+                                       }
+                                       $newarray[$i]['Date'] = 
$this->convert_date($this->header['Date']);
+                               }
+                               ++$i;
+                               $msgnum++;
+                       }
+                       return $newarray;
+               }
+
+               function get_next_article_number($msgnum)
+               {
+                       $retval = array();
+                       if (!$this->msg2socket('STAT 
'.$msgnum,'^223',$response))
+                       {
+                               return 0;
+                       }
+                       if (!$this->msg2socket('NEXT','^223',$response))
+                       {
+                               return 0;
+                       }
+                       //              echo 'Next_Msg = 
'.$response.'<br>'."\n";
+                       $retval = explode(' ',$response);
+                       return $retval[1];    
+               }
+
+               function get_prev_article_number($msgnum)
+               {
+                       $retval = array();
+                       if (!$this->msg2socket('STAT '.$msgnum, '^223', 
$response))
+                       {
+                               return 0;
+                       }
+                       if (!$this->msg2socket('LAST', '^223', $response))
+                       {
+                               return 0;
+                       }
+                       //echo "Prev_Msg = $response<br/>\n";
+                       $retval = explode(' ',$response);
+                       return $retval[1];    
+               }
+
+               function get_to()
+               {
+                       for($i=0;$i<count($this->msg->to);$i++)
+                       {
+                               $to = (!$this->msg->to[$i] ? $this->msg->to : 
$this->msg->to[$i]);
+                               $this->db->query("SELECT con FROM newsgroups 
WHERE name='".$to->personal."' and active='Y'");
+                               if ($this->db->num_rows() > 0)
+                               {
+                                       $this->db->next_record();
+                                       $con = $this->db->f('con');
+                                       $str[$i] = send_to($to,$con);
+                                       if 
($GLOBALS['phpgw_info']['user']['preferences']['nntp'][$con])
+                                       {
+                                               $str[$i] .= monitor(1,$con);
+                                       }
+                                       else
+                                       {
+                                               $str[$i] .= monitor(0,0);
+                                       }
+                               }
+                               else
+                               {
+                                       $str[$i] = '<tr><td 
align="left">'.$to->adl.monitor(0,0);
+                               }
+                       }
+                       return implode('',$str);
+               }
+       }
+?>
Index: nntp/inc/functions.inc.php
diff -u /dev/null nntp/inc/functions.inc.php:1.27.4.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/inc/functions.inc.php  Thu Dec 15 14:06:42 2005
@@ -0,0 +1,28 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare app (NNTP)                                                  *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+  /* $Id: functions.inc.php,v 1.27.4.1 2005/12/15 14:06:42 skwashd Exp $ */
+
+       if(isset($GLOBALS['folder']) && isset($GLOBALS['msgnum']))
+       {
+               $param = array
+                       (
+                               'folder' => $folder,
+                               'msgnum' => $msgnum
+                       );
+               $GLOBALS['nntp'] = CreateObject('nntp.nntp', $param);
+       }
+       else
+       {
+               $GLOBALS['nntp'] = CreateObject('nntp.nntp');
+       }
+?>
Index: nntp/index.php
diff -u /dev/null nntp/index.php:1.38.2.1.2.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/index.php      Thu Dec 15 14:06:41 2005
@@ -0,0 +1,148 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare application (NNTP)                                          *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+       /* $Id: index.php,v 1.38.2.1.2.1 2005/12/15 14:06:41 skwashd Exp $ */
+
+       @set_time_limit(0);     
+
+       $GLOBALS['phpgw_info']['flags'] = array
+                                       (
+                                               'currentapp' => 'nntp',
+                                               'noheader'   => True,
+                                               'nonavbar'   => True
+                                       );
+       include('../header.inc.php');
+
+       /**
+       * Shutdown function to close the connection to the NNTP server
+       */
+       function close_routine()
+       {
+               $GLOBALS['nntp']->close_port();
+       }
+
+       $news = array();
+
+       if ( is_array($GLOBALS['phpgw_info']['user']['preferences']['nntp']) )
+       {
+               foreach ( $GLOBALS['phpgw_info']['user']['preferences']['nntp'] 
as $db_id => $ignored)
+               {
+                       $news[] = $db_id;
+               }
+       }
+
+       if ( count($news) == 0 )
+       {
+               header('Location: 
'.$GLOBALS['phpgw']->link('/nntp/preferences.php'));
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       $GLOBALS['nntp']->display = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+       if ( $GLOBALS['nntp']->errorset )
+       {
+               echo "{$GLOBALS['nntp']->error['msg']} : 
{$GLOBALS['nntp']->error['desc']}<br>\n";
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+       else
+       {
+               $GLOBALS['phpgw']->common->phpgw_header();
+               echo parse_navbar();
+       }
+
+       register_shutdown_function('close_routine');
+
+       $p =& $GLOBALS['phpgw']->template;
+       $p->set_root( $GLOBALS['phpgw']->common->get_tpl_dir('nntp') );
+
+       $p->set_file('index_form', 'index.tpl');
+       $p->set_block('index_form','index','index');
+       $p->set_block('index_form','layout_table','layout_table');
+       $p->set_block('index_form','basic_row','basic_row');
+
+       $j = 0;
+       $i = count($news);
+
+       foreach ( $news as $group )
+       {
+               $j++;
+               $s = '';
+               if ( $GLOBALS['nntp']->read_table($group) )
+               {
+                       $channel_url = '<a 
href="'.$GLOBALS['phpgw']->link('/nntp/viewgroup.php', array('folder' => 
$group) ).'" target="new" style="text-decoration: none; color: #000000; 
text-align: center">';
+                       $channel_title = $GLOBALS['nntp']->mailbox.'</a>';
+               }
+               else
+               {
+                       $channel_url = '';
+                       $channel_title = 
$GLOBALS['nntp']->error['msg'].':'.$GLOBALS['nntp']->error['desc'];
+               }
+               
+               $var = Array(
+                       'channel_url'   => $channel_url,
+                       'channel_title' => $channel_title
+               );
+
+               $p->set_var($var);
+
+               if ($nntp->errorset)
+               {
+//                     echo 'Found an error reading group: 
'.$group[1]."<br>\n";
+                       $p->set_var('item_link','');
+                       
$p->set_var('item_label',$GLOBALS['nntp']->error['msg'].':'.$GLOBALS['nntp']->error['desc']);
+                       $s .= $p->fp('o_','basic_row');
+               }
+               elseif ($GLOBALS['nntp']->active == 'N')
+               {
+                       $p->set_var('item_link','');
+                       $p->set_var('item_label',lang('%1 not 
active',$GLOBALS['nntp']->mailbox));
+                       $s .= $p->fp('o_','basic_row');
+               }
+               else
+               {
+                       $links = $GLOBALS['nntp']->get_subjects();
+                       if (count($links)==0 || $links == 0)
+                       {
+                               $p->set_var('channel_url','');
+                               
$p->set_var('channel_title',$GLOBALS['nntp']->mailbox);
+                               $p->set_var('item_link','');
+                               $p->set_var('item_label','No articles found!');
+                               $s .= $p->fp('o_','basic_row');
+                       }
+                       else
+                       {
+                               krsort($links);
+                               $clinks = count($links);
+                               for ($k=0,reset($links); $k<$clinks; 
$k++,next($links))
+                               {
+                                       $key = key($links);
+                                       $link_url = 
+                                       $p->set_var('item_link', '<a href="' . 
$GLOBALS['phpgw']->link('/nntp/read_article.php', array('folder' => $group, 
'msgnum' => $key) ) . "\">\n");
+                                       $p->set_var('item_label', $links[$key] 
. '</a>');
+                                       $s .= $p->fp('o_','basic_row');
+                               }
+                       }
+               }
+               $p->set_var('rows',$s);
+               $p->set_var('section_' . $j,$p->fp('o','layout_table'));
+
+               if ($j == 3 || $i == 1)
+               {
+                       $p->pfp('out','index');
+                       $p->set_var('section_1', '');
+                       $p->set_var('section_2', '');
+                       $p->set_var('section_3', '');
+                       $j = 0;
+               }
+               $i--;
+       }
+       $GLOBALS['phpgw']->common->phpgw_footer();
+?>
Index: nntp/preferences.php
diff -u /dev/null nntp/preferences.php:1.36.4.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/preferences.php        Thu Dec 15 14:06:41 2005
@@ -0,0 +1,268 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare - NNTP preferences                                          *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+       /* $Id: preferences.php,v 1.36.4.1 2005/12/15 14:06:41 skwashd Exp $ */
+
+       $GLOBALS['phpgw_info']['flags'] = array
+                       (
+                               'currentapp'    => 'nntp',
+                               'enable_nextmatchs_class' => True,
+                               'noheader'      => True,
+                               'nonavbar'      => True
+                       );
+
+       include('../header.inc.php');
+
+       function get_tg()
+       {
+               $db = $GLOBALS['phpgw']->db;
+               $db->query("SELECT count(con) FROM newsgroups WHERE 
active='Y'");
+               $db->next_record();
+               $con = $db->f(0);
+               unset($db);
+               return $con;
+       }
+       
+       if( isset($_REQUEST['submit']) && $_REQUEST['submit'] )
+       {
+               $GLOBALS['phpgw']->preferences->read_repository();
+
+               $minarray = @unserialize(urldecode($_REQUEST['nntparray']) );
+
+               if ( $minarray !== false && is_array($minarray) )
+               {
+                       foreach ( $minarray as $value )
+                       {
+                               //echo "Deleting Preference $value<br />\n";
+                               if( 
isset($GLOBALS['phpgw_info']['user']['preferences']['nntp'][$value]) )
+                               {
+                                       
$GLOBALS['phpgw']->preferences->delete('nntp', $value);
+                               }
+                       }
+               }
+
+               for ( $i = 0 ; $i < count($_REQUEST['nntplist']); ++$i)
+               {
+                       //echo "Setting Preference 
{$_REQUEST['nntplist'][$i]}<br />\n";
+                       $GLOBALS['phpgw']->preferences->add('nntp', 
$_REQUEST['nntplist'][$i], 1);
+               }
+               $GLOBALS['phpgw']->preferences->save_repository(True);
+
+               $GLOBALS['phpgw']->redirect_link('/nntp/preferences.php', 
array('start' => $_REQUEST['start'], 'tg' => $_REQUEST['tg']) );
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       if ( !isset($_REQUEST['start']) || !$_REQUEST['start'] )
+       {
+               $start = 0;
+       }
+       else
+       {
+               $start = (int) $_REQUEST['start'];
+       }
+
+       if (!isset($_REQUEST['query_result']) || !$_REQUEST['query_result'] )
+       {
+               $query_result = 0;
+       }
+       else
+       {
+               $query_result = (int) $_REQUEST['query_result'];
+       }
+
+       if ( !isset($_REQUEST['order']) || !$_REQUEST['order'] )
+       {
+               $order = 1;
+       }
+       else
+       {
+               $order = (int) $_REQUEST['order'];
+       }
+
+       $sort = 'ASC';
+
+       $orderby = '';
+       if ( $order > 0 && $order < 4 ) //see below
+       {
+               $sort = isset($_REQUEST['sort']) && $_REQUEST['sort'] == 'DESC' 
? 'DESC' : 'ASC';
+
+               switch ($order)
+               {
+                       case 1:
+                               $orderby = ' ORDER BY con '.$sort;
+                               break;
+                       case 2:
+                               $orderby = ' ORDER BY name '.$sort;
+                               break;
+                       case 3:
+                               $orderby = ' ORDER BY active '.$sort;
+                               break;
+               }
+       }
+
+       $db2 = $GLOBALS['phpgw']->db;
+       
+       //FIXME this is ugly shit!
+       $query_result = get_var('query_result', array('POST'), 0);
+       if ( (isset($_REQUEST['search']) && $_REQUEST['search']) || 
(isset($_REQUEST['next']) && $_REQUEST['next']) )
+       {
+               if (isset($_REQUEST['next']) && $_REQUEST['next'])
+               {
+                       $query_result++;
+               }
+               $db2->query("SELECT name FROM newsgroups WHERE 
active='Y'$orderby");
+               $j = 0;
+               $i = 0;
+               while($db2->next_record())
+               {
+                       if (stristr($db2->f('name'),$query))
+                       {
+                               if($i==$query_result)
+                               {
+                                       $start = $j;
+                                       break;
+                               }
+                               else
+                               {
+                                       $i++;
+                               }
+                       }
+                       $j++;
+               }
+       }
+
+       $querystr = "SELECT con, name FROM newsgroups WHERE active='Y'$orderby";
+       $db2->limit_query($querystr,$start,__LINE__,__FILE__);
+
+       if(!$db2->num_rows())
+       {
+               header('Location: '.$GLOBALS['phpgw']->link('/nntp/admin.php'));
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+       else
+       {
+               $GLOBALS['phpgw']->common->phpgw_header();
+               echo parse_navbar();
+               $minarray = Array();
+               $nntpavail = Array();
+               while($db2->next_record())
+               {
+                       $nntpavail[] = array
+                                       (
+                                               'con'  => $db2->f('con'),
+                                               'name' => $db2->f('name')
+                                       );
+                       $minarray[] = $db2->f('con');
+               }
+               unset($db2);
+       }
+
+       $p = 
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('nntp'));
+       $templates = Array(
+               'nntp_form' => 'nntp.tpl'
+       );
+
+       $p->set_file($templates);
+
+       $p->set_block('nntp_form','nntp','nntp');
+       $p->set_block('nntp_form','nntp_list','nntp_list');
+
+       if (!isset($tg) || !$tg)
+       {
+               $tg = get_tg();
+       }
+       $first = count($minarray) ? min($minarray) : 0;
+
+       @reset($minarray);
+
+       $common_hidden_vars = '<input type="hidden" name="start" 
value="'.$start.'">'."\n"
+               . '<input type="hidden" name="first" value="'.$first.'">'."\n"
+               . '<input type="hidden" name="nntparray" 
value="'.urlencode(serialize($minarray)).'">'."\n"
+               . '<input type="hidden" name="tg" value="'.$tg.'">'."\n";
+       if(isset($order) && $order)
+       {
+               $common_hidden_vars .= '<input type="hidden" name="order" 
value="'.$order.'">'."\n";
+       }
+       if(isset($sort) && $sort)
+       {
+               $common_hidden_vars .= '<input type="hidden" name="sort" 
value="'.$sort.'">'."\n";
+       }
+       if(isset($query_result) && $query_result)
+       {
+               $common_hidden_vars .= '<input type="hidden" 
name="query_result" value="'.$query_result.'">'."\n";
+       }
+
+       $extra_parms = '&tg='.$tg;
+       if(isset($sort) && $sort)
+       {
+               $extra_parms .= '&sort='.$sort;
+       }
+       if(isset($order) && $order)
+       {
+               $extra_parms .= '&order='.$order;
+       }
+
+       $urlname = '/nntp/preferences.php';
+
+       $p->set_var(array
+               (
+                       'search_value'          => (isset($query) && 
$query?$query:''),
+                       'search'                => lang('search'),
+                       'next'                  => lang('next'),
+                       'nml'                   => 
$GLOBALS['phpgw']->nextmatchs->left($urlname,$start,$tg,$extra_parms),
+                       'nmr'                   => 
$GLOBALS['phpgw']->nextmatchs->right($urlname,$start,$tg,$extra_parms),
+                       'title'                 => lang('Newsgroups'),
+                       'action_url'            => 
$GLOBALS['phpgw']->link('/nntp/preferences.php'),
+                       'common_hidden_vars'    => $common_hidden_vars,
+                       'th_bg'                 => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
+                       'th_font'               => 
$GLOBALS['phpgw_info']['theme']['font'],
+                       'sort_con'              => 
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'1',$order,$urlname,' # 
','&tg='.$tg),
+                       'sort_group'            => 
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'2',$order,$urlname,lang('Name'),'&tg='.$tg),
+                       'sort_active'           => 
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'3',$order,$urlname,' 
'.lang('Active').' ','&tg='.$tg)
+               ));
+
+       if(count($GLOBALS['phpgw_info']['user']['preferences']['nntp']))
+       {
+               foreach($GLOBALS['phpgw_info']['user']['preferences']['nntp'] 
as $group => $ignored)
+               {
+                       $found[$group] = ' checked="checked"';
+               }
+       }
+
+       foreach ( $nntpavail as $key => $value )
+       {
+               $tr_color = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+
+               if (!$value['name'])
+               {
+                       $value['name']  = '&nbsp;';
+               }
+               $p->set_var(array
+                       (
+                               'tr_color' => $tr_color,
+                               'con'      => $value['con'],
+                               'group'    => $value['name'],
+                               'active'   => '<input type="checkbox" 
name="nntplist[]" value="'.$value['con'].'"'.$found[$value['con']].'>'
+                       ));
+
+               $p->parse('rows','nntp_list',True);
+       }
+
+       $p->set_var(array
+               (       
+                       'lang_update'   => lang('update'),
+                       'checkmark'     => 
$GLOBALS['phpgw']->common->get_image_path('email').'/check.gif'
+               ));
+
+       $p->pparse('out','nntp');
+       $GLOBALS['phpgw']->common->phpgw_footer();
+?>
Index: nntp/read_article.php
diff -u /dev/null nntp/read_article.php:1.26.4.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/read_article.php       Thu Dec 15 14:06:41 2005
@@ -0,0 +1,234 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare application (NNTP)                                          *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+  /* $Id: read_article.php,v 1.26.4.1 2005/12/15 14:06:41 skwashd Exp $ */
+
+       $folder = isset($_GET['folder']) ? $_GET['folder'] : 0; 
+       $msgnum = isset($_GET['msgnum']) ? $_GET['msgnum'] : 0;
+       
+       $GLOBALS['phpgw_info']['flags'] = array
+                               (
+                                       'currentapp'       => 'nntp',
+                                       'enable_vfs_class' => True
+                               );
+       include('../header.inc.php');
+
+       function close_routine()
+       {
+               $GLOBALS['nntp']->close_port();
+       }
+
+       @set_time_limit(0);
+
+       $GLOBALS['phpgw']->translation->add_app('email');
+
+       function compose($action,$icon)
+       {
+               $str = '';
+/*             $str = '<a 
href="'.$GLOBALS['phpgw']->link('/nntp/compose.php','action='.$action.'&folder='.$GLOBALS['nntp']->con.'&msgnum='.$GLOBALS['nntp']->msgnum).'">';
    */
+               $str .= '<img src="'.$GLOBALS['phpgw']->common->image('email', 
$icon).'" alt="'.lang($action).'">';
+/*             $str .= '</a>'; */
+               return $str;
+       }
+
+       if ( 
!isset($GLOBALS['phpgw_info']['user']['preferences']['nntp'][$folder]) )
+       {
+               echo 'You do not have access to this newsgroup!<br>'."\n";
+               $GLOBALS['phpgw']->common->phpgw_footer();
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       if( !$folder || !$msgnum )
+       {
+               echo lang('Cannot display the requested article from this 
newsgroup').'<br>'."\n";
+               $GLOBALS['phpgw']->common->phpgw_footer();
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       if ($GLOBALS['nntp']->errorset)
+       {
+               echo "{$GLOBALS['nntp']->error['msg']} : 
{$GLOBALS['nntp']->error['desc']}<br />\n";
+               $GLOBALS['phpgw']->common->phpgw_footer();
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       register_shutdown_function('close_routine');
+
+       $p =& $GLOBALS['phpgw']->template;
+       $p->set_root( $GLOBALS['phpgw']->common->get_tpl_dir('nntp') );
+
+       $p->set_file('message', 'msg.tpl');
+       $p->set_block('message','msg','msg');
+       $p->set_block('message','action','action');
+       $p->set_block('message','next_prev','next_prev');
+       $p->set_block('message','header','header');
+       $p->set_block('message','header_data','header_data');
+
+       $p->set_var(array
+                       (
+                               'th_em_folder' => 
$GLOBALS['phpgw_info']['theme']['em_folder'],
+                               'th_font'      => 
$GLOBALS['phpgw_info']['theme']['font'],
+                               'th_em_text'   => 
$GLOBALS['phpgw_info']['theme']['em_folder_text'],
+                               'th_bg'        => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
+                               'th_row_on'    => 
$GLOBALS['phpgw_info']['theme']['row_on'],
+                               'folder_url'   => 
$GLOBALS['phpgw']->link('/nntp/viewgroup.php', array('folder' => 
$GLOBALS['nntp']->con) ),
+                               'folder'       => $GLOBALS['nntp']->folder
+                       ));
+
+       $p->set_var($var);
+
+       $p->parse('out','header');
+
+       $p->set_var('url', compose('reply','sm_reply.png'));
+       $p->parse('rows','action',True);
+
+       $p->set_var('url', compose('reply all','sm_reply_all.png'));
+       $p->parse('rows','action',True);
+
+       $p->set_var('url', compose('forward','sm_forward.png'));
+       $p->parse('rows','action',True);
+
+       $p->set_var('url','<img 
src="'.$GLOBALS['phpgw']->common->image('email', 'sm_delete.png').'" 
alt="'.lang('delete').'">');
+       $p->parse('rows','action',True);
+
+       $np_msg = '<a 
href="'.$GLOBALS['phpgw']->link('/nntp/read_article.php','folder='.$GLOBALS['nntp']->con);
+
+       $pm = 
$GLOBALS['nntp']->get_prev_article_number($GLOBALS['nntp']->msgnum);
+       if ((int)$pm != 0)
+       {
+               $prev_msg = $np_msg.'&msgnum='.(int)$pm.'"><img border="0" 
src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left.gif').'" 
alt="'.lang('Previous').'"></a>';
+       }
+       else
+       {
+               $prev_msg = '<img border="0" 
src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left-grey.gif').'" 
alt="'.lang('Previous').'">';
+       }
+
+       $nm = 
$GLOBALS['nntp']->get_next_article_number($GLOBALS['nntp']->msgnum);
+       if ((int)$nm != 0)
+       {
+               $next_msg = $np_msg.'&msgnum='.(int)$nm.'"><img border="0" 
src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right.gif').'" 
alt="'.lang('Next').'"></a>';
+       }
+       else
+       {
+               $next_msg = '<img border="0" 
src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right-grey.gif').'" 
alt="'.lang('Next').'">';
+       }
+
+       $var = Array(
+               'pm' => $prev_msg,
+               'nm' => $next_msg
+       );
+       $p->set_var($var);
+
+       $p->parse('rows','next_prev',True);
+
+       $from = $GLOBALS['nntp']->msg->from[0];
+       $var = Array(
+               'label'        => lang('from'),
+               'header_title' => send_to($from,$GLOBALS['nntp']->con),
+               'header_icon'  => add_to_addressbook($from)
+       );
+       $p->set_var($var);
+       $p->parse('data','header_data');
+       $p->parse('rows','header',True);
+
+       $var = Array(
+               'data'  => '',
+               'label' => lang('to')
+       );
+       $p->set_var($var);
+       $to = new address;
+       for($i=0;$i<count($GLOBALS['nntp']->msg->to);$i++)
+       {
+               if (!$GLOBALS['nntp']->msg->to[$i]) { break; }
+               $to = $GLOBALS['nntp']->msg->to[$i];
+               $topersonal = $to->personal;
+               $GLOBALS['nntp']->db->query("SELECT con FROM newsgroups WHERE 
name='".$topersonal."' and active='Y'");
+
+               if ($GLOBALS['nntp']->db->num_rows() > 0)
+               {
+                       $GLOBALS['nntp']->db->next_record();
+                       $con = $GLOBALS['nntp']->db->f('con');
+                       $header_title = send_to($to,$GLOBALS['nntp']->con);
+                       if 
(!$GLOBALS['phpgw_info']['user']['preferences']['nntp'][$con])
+                       {
+                               $monitor = monitor(1,$con);
+                       }
+                       else
+                       {
+                               $monitor = monitor(0,0);
+                       }
+               }
+               else
+               {
+                       $toadl = $to->adl;
+                       $header_title = $toadl;
+                       $monitor = monitor(0,0);
+               }
+               if($i<count($GLOBALS['nntp']->msg->to)) { $monitor .= '<br>'; }
+               $var = Array(
+                       'header_title' => $header_title,
+                       'header_icon'  => $monitor
+               );
+               $p->set_var($var);
+               $p->parse('data','header_data',True);
+       }
+       $p->parse('rows','header',True);
+
+       if (isset($GLOBALS['nntp']->header['Cc']) && 
$GLOBALS['nntp']->header['Cc'])
+       {
+               $var = Array(
+                       'data'  => '',
+                       'label' => lang('cc')
+               );
+               $p->set_var($var);
+               for($I=0;$i<count($GLOBALS['nntp']->msg->cc);$i++)
+               {
+                       $var = Array(
+                               'header_title' => 
send_to($GLOBALS['nntp']->msg->cc[$i],$GLOBALS['nntp']->con),
+                               'header_icon'  => 
add_to_addressbook($GLOBALS['nntp']->msg->cc[$i])
+                       );
+                       
+                       $p->set_var($var);
+                       $p->parse('data','header_data',True);
+               }
+               $p->parse('rows','header',True);
+       }
+
+       $var = Array(
+               'label'        => lang('date'),
+               'header_title' => 
$GLOBALS['phpgw']->common->show_date($GLOBALS['nntp']->msg->udate),
+               'header_icon'  => '',
+               'data'         => ''
+       );
+       $p->set_var($var);
+
+       $p->parse('data','header_data',True);
+       $p->parse('rows','header',True);
+
+// Still doing nothing with attachments
+
+       $var = Array(
+               'label'        => lang('subject'),
+               'header_title' => $GLOBALS['nntp']->msg->subject,
+               'header_icon'  => '',
+               'data'         => ''
+       );
+       $p->set_var($var);
+       
+       $p->parse('data','header_data',True);
+       $p->parse('rows','header',True);
+
+       $p->set_var('textbody',$GLOBALS['nntp']->build_body_to_print());
+       $p->pparse('out','msg');
+
+       $GLOBALS['phpgw']->common->phpgw_footer();
+?>
Index: nntp/viewgroup.php
diff -u /dev/null nntp/viewgroup.php:1.23.4.1
--- /dev/null   Thu Dec 15 14:06:42 2005
+++ nntp/viewgroup.php  Thu Dec 15 14:06:41 2005
@@ -0,0 +1,139 @@
+<?php
+  /**************************************************************************\
+  * phpGroupWare application (NNTP)                                          *
+  * http://www.phpgroupware.org                                              *
+  * Written by Mark Peters <address@hidden>                             *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+  /* $Id: viewgroup.php,v 1.23.4.1 2005/12/15 14:06:41 skwashd Exp $ */
+
+       $GLOBALS['phpgw_info']['flags'] = array
+                               (
+                                       'currentapp'       => 'nntp',
+                                       'enable_nextmatchs_class' => True,
+                                       'enable_vfs_class' => True
+                               );
+       include('../header.inc.php');
+
+       function close_routine()
+       {
+               $GLOBALS['nntp']->close_port();
+       }
+
+       $folder = (int) isset($_GET['folder']) ? $_GET['folder'] : 0;
+       $msgnum = (int) isset($_GET['msgnum']) ? $_GET['msgnum'] : 0;
+       
+       @set_time_limit(0);
+
+       $GLOBALS['phpgw']->translation->add_app('email');
+
+       $GLOBALS['phpgw']->db->query("SELECT active FROM newsgroups WHERE con = 
{$folder} AND active = 'Y'", __LINE__, __FILE__);
+       if (($GLOBALS['phpgw']->db->num_rows() == 0) || 
!isset($GLOBALS['phpgw_info']['user']['preferences']['nntp'][$folder]) )
+       {
+               echo 'You do not have access to this newsgroup!'."<br>\n";
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       if(!$GLOBALS['folder'])
+       {
+               echo lang('Cannot display the requested newsgroup')."<br>\n";
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+
+       $GLOBALS['nntp']->display = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+       if ($GLOBALS['nntp']->errorset)
+       {
+               echo 
$GLOBALS['nntp']->error['msg'].':'.$GLOBALS['nntp']->error['desc']."<br>\n";
+               $GLOBALS['phpgw']->common->phpgw_exit();
+       }
+ 
+       register_shutdown_function("close_routine");
+
+       $p =& $GLOBALS['phpgw']->template;
+       $p->set_root( $GLOBALS['phpgw']->common->get_tpl_dir('nntp') );
+       
+       $p->set_file('view_group', 'view_group.tpl');
+       $p->set_block('view_group','vg','vg');
+       $p->set_block('view_group','vg_row','vg_row');
+
+       $nntp->read_table($folder);
+
+       $start = intval($_REQUEST['start']); 
+
+       if( !isset($_REQUEST['tm']) )
+       {
+               $tm = ($GLOBALS['nntp']->highmsg - $GLOBALS['nntp']->lowmsg);
+       }
+       else
+       {
+               $tm = $_REQUEST['tm'];
+       }
+       
+       if( !isset($_REQUEST['fm']) )
+       {
+               $fm = $GLOBALS['nntp']->lowmsg;
+       }
+       else
+       {
+               $fm = $_REQUEST['fm'];
+       }
+
+       $p->set_var(array
+               (
+                       'th_bg'         => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
+                       'th_font'       => 
$GLOBALS['phpgw_info']['theme']['font'],
+                       'th_text'       => 
$GLOBALS['phpgw_info']['theme']['th_text'],
+                       'th_em_folder'  => 
$GLOBALS['phpgw_info']['theme']['em_folder'],
+                       'th_em_text'    => 
$GLOBALS['phpgw_info']['theme']['em_folder_text'],
+                       'folder'        => $GLOBALS['nntp']->folder,
+                       'nml'           => 
$GLOBALS['phpgw']->nextmatchs->left('/nntp/viewgroup.php',$start,$tm,'&folder='.$GLOBALS['folder'].'&tm='.$tm.'&fm='.$fm),
+                       'nmr'           => 
$GLOBALS['phpgw']->nextmatchs->right('/nntp/viewgroup.php',$start,$tm,'&folder='.$GLOBALS['folder'].'&tm='.$tm.'&fm='.$fm),
+                       'row_color'     => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
+                       'from'          => '<font 
size="2"><b>'.lang('from').'</b></font>',
+                       'subject'       => '<font 
size="2"><b>'.lang('subject').'</b></font>',
+                       'date'          => '<font 
size="2"><b>'.lang('date').'</b></font>'
+                       //'size'        => '<font 
size="2"><b>'.lang('size').'</b></font>'
+               ));
+
+       $p->set_var($var);
+       $p->parse('rows','vg_row',True);
+
+       if ( 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] <= ($tm - 
$start) )
+       {
+               $totaltodisplay = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+       }
+       else
+       {
+               $totaltodisplay = ($tm - $start) - 1;
+       }
+
+       $firstmessage = ($fm + $start);
+       $list = $GLOBALS['nntp']->get_list('from', $firstmessage, 
$totaltodisplay);
+//     $subject = 
$GLOBALS['nntp']->get_list('subject',$firstmessage,$firstmessage+$totaltodisplay);
+//     $date = 
$GLOBALS['nntp']->get_list('date',$firstmessage,$firstmessage+$totaltodisplay);
+
+       for ( $i = 0; $i < $totaltodisplay; ++$i)
+       {
+               $tr_color = 
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+
+               $subject_url = 
$GLOBALS['phpgw']->link('/nntp/read_article.php', array('folder' => 
$GLOBALS['nntp']->con, 'msgnum' => $list[$i]['Msgnum']) );
+
+               $p->set_var(array
+                               (
+                                       'row_color' => $tr_color,
+                                       'from'      => '<font 
size="-1">'.$list[$i]['From'].'</font>',
+                                       'subject'   => '<font size="-1"><a 
href="'.$subject_url.'">'.$list[$i]['Subject'].'</a></font>',
+                                       'date'      => '<font 
size="-2">'.$GLOBALS['phpgw']->common->show_date($list[$i]['Date']).'</font>'
+                                       //'size'      => ''
+                               ));
+               $p->parse('rows','vg_row',True);
+       }        
+
+       $p->pparse('out','vg');
+       $GLOBALS['phpgw']->common->phpgw_footer();
+?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]