Apache-NNTPGateway

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

WriteMakefile(
    'NAME'		=> 'Apache::NNTPGateway',
    'VERSION_FROM'	=> 'NNTPGateway.pm', # finds $VERSION
    'PREREQ_PM'		=> 
	{
	'Apache'            => 1.20, 
	'Apache::Constants' => 1.0, 
	'Apache::URI'       => 1.0, 
	'Apache::Request'   => 0.30, 
	'Apache::Log'       => 1.0, 
	'CGI::Cookie'       => 1.10, 
	'Net::NNTP'         => 2.0, 
	'Net::Config'       => 1.10, 
	'Net::Cmd'          => 2.0, 
	'Net::Domain'       => 2.0, 
	'Mail::Address'     => 1.10, 
	'File::Spec'        => 0.80, 
	}, # e.g., Module::Name => 1.1
);

NNTPGateway.html  view on Meta::CPAN

<PRE> Here is the list of all actions that can be performed on the current newsgroup.</PRE>
<DL><DT><A NAME="list">list</A></DT>
<DD>

<PRE>  List articles, all articles from the current newsgroup or only unread
  articles if the user/client allready did a B&lt;catchup&gt;.</PRE>
</DD>
<DT><A NAME="catchup">catchup</A></DT>
<DD>

<PRE>  Mark all current articles as read. This use a Cookie.</PRE>
</DD>
<DT><A NAME="last">last</A></DT>
<DD>

<PRE>  Read the last article available from the newsserver.</PRE>
</DD>
<DT><A NAME="read">read</A></DT>
<DD>

<PRE>  Read article by ID.</PRE>

NNTPGateway.html  view on Meta::CPAN

<H1><A NAME="Changes">Changes</A></H1>
<DT><A NAME="v0.9">v0.9</A></DT>
<DD>

<PRE> * Article id or subject added to title in read.
 * More CSS classes everywhere... read the sources.</PRE>
</DD>
<DT><A NAME="v0.8">v0.8</A></DT>
<DD>

<PRE> * Cookie domain better handled for catchup.
 * NNTPGatewayNewsGroupTest removed. Set up a new Location and set
   NNTPGatewayNewsGroup to the test group and NNTPGatewayDebug on to
   acheive the same fonctionnality.
 * Some more directives to control users checking
   (NNTPGatewayUsersNamesCaseInsensitive, NNTPGatewayNonLocalPostOk).
 * Some handling of Cache-Control.
 * Made this module ready for my first CPAN contribution ;-)
 ** Cleaning source code.
 ** Cleaning Documentation.
 ** CPAN Enabled distrib (Makefile.PL, .tar.gz dist, README file, CPAN
    ID ...).</PRE>
</DD>
<DT><A NAME="v0.7">v0.7</A></DT>
<DD>

<PRE> * The configuration directive B&lt;NNTPGatewayCatchupCookieName&gt; do not exists anymore.
 * Disconnections to news server start to be better handled.
 
=item v0.6</PRE>

<PRE> First public release</PRE>
<H1><A NAME="TODO">TODO</A></H1>
<DL><DT><A NAME="*%20%0a%20%0a%20Safe%20sharing%20of%20the%20NNTP%20global.">* 
 
 Safe sharing of the NNTP global.</A></DT>
<DD>

NNTPGateway.pm  view on Meta::CPAN

$VERSION = '0.9';

# Needed packages

use Apache::Constants qw(:common);
use Apache::URI qw();
use Apache::Request qw();
use Apache::Log qw();

#use CGI qw/:standard/;
use CGI::Cookie qw();

# Net::NNTP @ISA Net::Cmd, IO::Socket
use IO::Socket;
use Net::Cmd qw(CMD_REJECT CMD_ERROR);
use Net::NNTP qw();

use Net::Config qw();
use Net::Domain qw();

use Mail::Address qw();

NNTPGateway.pm  view on Meta::CPAN

my $Title                  = $PKG_NAME;
my $NNTP_Server            = $DEFAULT_NEWS_SERVER;
my $The_Newsgroup          = undef;
my $The_GroupDescription   = undef;
my $NewsUrl                = "news://$NNTP_Server/$The_Newsgroup";
my $Base                   = '/';
my $StyleSheet             = '';
my $Anonymous_Post_Allowed = 0;
my $Organization           = $DEFAULT_ORGANIZATION;
my $Templates_Dir          = $DEFAULT_TEMPLATES_DIR;
my $Catchup_Cookie_Name    = undef;
my $The_User               = '';



# Subs decl --------------------------------------------------------------

sub handler ( $ );

sub action_list ( $ );
sub action_catchup ( $ );

NNTPGateway.pm  view on Meta::CPAN

###
sub action_catchup ( $ ) {
  my ($r) = @_;
  
  # Prepare catchup...
  my $catchupid   = $Args->{last_art};
  my $catchupdate = $NNTP->date();
  my $newnewsok   = $NNTP->newnews( $catchupdate, $The_Newsgroup )?1:0;

  # Build the catchup cookie
  my $cookie      = new CGI::Cookie 
    ( 
     -name    => $Catchup_Cookie_Name, 
     -value   => "Id=${catchupid},Date=${catchupdate}", 
     # 10 years should be enough as expiration date.
     -expires => '+10y', 
     -domain  => $COOKIE_DOMAIN, 
     -path    => $Base
    );
  $r->header_out( 'Set-Cookie' => $cookie );

  # Print html header
  &print_html_head( $r, 1 );
  # Print menu
  &print_html_menu( $r );
  $r->print( "\n<hr noshade>\n" );

  # Just Inform user
  $r->print
    ( 

NNTPGateway.pm  view on Meta::CPAN





# Utilities ---------------------------------------------------------


### Sub get_args() ###
# status = &get_args( request ):
# - Description: Fill in the global hash Args. The args are processed
#   in this order: Cookies, path_info, environment variables, GET then
#   POST args, each arg overriding previous one if already defined.
# - Arguments  : the Apache request
# - Return     : 1=ok, 0=failure
###
sub get_args ( $ ) {
  my $r = shift;

  # Empty Args...
  $Args = {};

  # Get cookies vals
  my %cookies    = CGI::Cookie->parse( $r->header_in('Cookie'));
  my $catchupval = $cookies{$Catchup_Cookie_Name}->value() if $cookies{$Catchup_Cookie_Name};
  $r->log->notice( "Got cookie $Catchup_Cookie_Name: $catchupval" ) if $DEBUG;
  # See action_catchup for settings of cookies
  if ( $catchupval =~ /^(Id)=(\d+),\s*(Date)=(\d+)$/ ) {
    $Args->{catchup_id}   = $2;
    $Args->{catchup_date} = $4;
  }

  # Parse path_info to get the action and such ...
  my $pi = $r->path_info();
  $pi =~ s/^\/*//;
  $Args->{action}      = undef;

NNTPGateway.pm  view on Meta::CPAN

  $The_Newsgroup        = $r->dir_config( 'NNTPGatewayNewsGroup' );
  unless ( $The_Newsgroup ) {
    # NewsGroup is a required config parameter
    $r->log_error( "Configuration directive NNTPGatewayNewsGroup should be set in <Location $Base>!" );
    return 0;
  }
  $The_GroupDescription = $r->dir_config( 'NNTPGatewayGroupDescription' ) || '&nbsp;';
  $NNTP_Server          = $r->dir_config( 'NNTPGatewayNewsServer' ) || $DEFAULT_NEWS_SERVER;
  $NewsUrl              = "news://${NNTP_Server}/${The_Newsgroup}";
  $DEFAULT_ACTION_NAME  = $r->dir_config( 'NNTPGatewayDefaultAction' ) || $DEFAULT_ACTION_NAME;
  $Catchup_Cookie_Name  = 'NNTPGatewayCatchup.' . $The_Newsgroup;
  $Organization         = $r->dir_config( 'NNTPGatewayOrganization' ) || $Organization;
  $Title                = $r->dir_config( 'NNTPGatewayTitle' ) || "NNTPGateway: $NewsUrl";
  $StyleSheet           = $r->dir_config( 'NNTPGatewayStyleSheet' ) || undef;

  # Anonymous posts configuration
  $Anonymous_Post_Allowed = &is_true( $r->dir_config( 'NNTPGatewayAnonymousPostAllowed' )) || 0;
  if ( $Anonymous_Post_Allowed ) {
    # Get a list of anonymous posters names if any, 
    # AnonymousPosters mail1=Name 1, name2=Name 2,  ...
    my $anon_names = $r->dir_config( 'NNTPGatewayAnonymousPosters' );

NNTPGateway.pm  view on Meta::CPAN


=over 4

=item list

  List articles,   all  articles from   the current newsgroup  or  only unread
  articles if the user/client already did a B<catchup>.

=item catchup

  Mark all current articles as read. This use a Cookie.

=item last

  Read the last article available from the newsserver.

=item read

  Read article by ID.

=item followup

NNTPGateway.pm  view on Meta::CPAN


 * Article id or subject added to title in read.
 * More CSS classes everywhere... read the sources.
 * use Apache::Log qw(); to access to log functions.
 * Makefile.PL improved to really check used modules versions.
 * Call  Net::Cmd functions in a  clean manner to make perl  5.6 happy (end of
   that Bareword "CMD_ERROR" install bug).

=item v0.8

 * Cookie domain better handled for catchup.
 * NNTPGatewayNewsGroupTest   removed.  Set  up    a  new  Location  and   set
   NNTPGatewayNewsGroup to  the test group and  NNTPGatewayDebug on to achieve
   the same functionality.
 * Some       more       directives   to       control        users   checking
   (NNTPGatewayUsersNamesCaseInsensitive, NNTPGatewayNonLocalPostOk).
 * Some handling of Cache-Control.
 * Made this module ready for my first CPAN contribution ;-)
 ** Cleaning source code.
 ** Cleaning Documentation.
 ** CPAN  Enabled distrib (Makefile.PL,   .tar.gz dist,  README file, CPAN  ID
    ...).

=item v0.7

 * The configuration directive B<NNTPGatewayCatchupCookieName> do not exists anymore.
 * Disconnections to news server start to be better handled.

=item v0.6

 First public release

=back


=head1 TODO



( run in 0.277 second using v1.01-cache-2.11-cpan-4e96b696675 )