#!/usr/bin/perl
# viewnews.cgi
# NewsPro User CGI
# Version: 3.8 build 33
# See newspro.cgi for license information.
# SCRIPT SETTINGS
# If you are using Microsoft IIS, set the following to 1. If you are
# using Unix/Apache, set it to 2. Setting it 0 tries to determine
# automatically, and usually works just fine. If you use IIS yet have
# 500 error problems, try setting the variable to 2, then try 3.
$IIS = 0;
# ** FILE LOCKING **
# File locking is a feature, provided by the operating system, which
# prevents possible serious problems when NewsPro is being used by
# multiple users. Almost every operating system supports this, except
# for Windows 9x. Possible settings:
# 2 Enable file locking. If you know your server supports it, set
# UseFlock to this.
# 1 Auto-detect file locking support (default).
# 0 Disable file locking. This may result in file corruption.
$UseFlock = 0;
# If you want to use a subroutine other than DoNewsHTML for viewnews.cgi functions,
# other than search, enter the name here. e.g. 'DoHeadlineHTML'
$VNSub = 'DoNewsHTML';
# If you want to a template other than viewnews.tmpl for viewnews.cgi functions,
# enter the name here. The template file must be in your NewsPro directory
# (the same directory that viewnews.cgi is in).
$VNTmpl = 'viewnews.tmpl';
# Set this to 1 to automatically look for and load ViewNews addons.
# Generally, enable this only if you have addons installed.
# This does slow down viewnews.cgi, as it has to scan for addons
# whenever it is run.
$EnableAddons = 0;
# If you will be including viewnews.cgi into an HTML page via SSI,
# set the following to 1. Don't do this if you can use news.txt
# instead.
$VNSSI = 0;
# END OF SETTINGS (unless you encounter problems - then fill out the next section)
# SERVER PROBLEMS WORKAROUNDS
# If the script either gets its URL wrong or produces a fatal error
# about not being able to include npconfig.pl, set the following variables.
# While it won't hurt, most users don't have to.
$abspath = '';
# Set the above to the absolute path to NewsPro's directory, without
# a trailing slash. Example:
# $abspath = '/absolute/path/to/newspro';
$scripturl = '';
# Set the above to the URL to vienews.cgi. Example:
# $scripturl = 'http://www.myserver.com/newspro/viewnews.cgi';
# Once again, you only need to set the above two variables if you're
# having server problems.
# END SERVER PROBLEMS WORKAROUNDS
# The script begins...
eval { &main; };
if ($@) {
&NPdie("Untrapped Error: $@");
}
exit;
sub main {
# Microsoft servers. Try and be compatible...
if ($IIS != 2) {
if ($IIS == 0) {
if ($ENV{'SERVER_SOFTWARE'} =~ m!IIS!) {
$IIS = 1
}
}
if (($IIS) && ($0 =~ m!(.*)(\\|\/)!)) {
chdir($1);
}
if ($IIS == 1) {
print "HTTP/1.0 200 OK\n";
}
}
# That's over!
if ($UseFlock == 1) {
if ($^O ne 'MSWin32') {
$UseFlock = 1;
}
else {
if ($ENV{'PATH'} =~ /WINNT/i) { # Yes, this won't work if you didn't use the default name
# for your Windows directory. But the alternative is loading
# the Win32 module, which is time-consuming.
$UseFlock = 1;
}
else {
# We appear to be on Windows 9x.
$UseFlock = 0;
}
}
}
elsif ($UseFlock == 2) {
$UseFlock = 1;
}
# Server problem workaround #1
if ($abspath) {
push(@INC, $abspath);
}
require "npconfig.pl";
require "ndisplay.pl";
require "nplib.pl";
ReadForm();
SubmitFormFields();
push(@formfields, 'newstext');
# Put the script's URL into $scripturl.
# Don't if it was already set as a server problem workaround.
unless ($scripturl) {
$scripturl = &GetScriptURL;
}
ReadConfigInfo();
if ($EnableAddons) {&LoadAddons;}
if (@Addons_ViewNews_Handler) {
&RunAddons(@Addons_ViewNews_Handler);
}
if (query_string() eq "dispsearchform") {
print header();
print qq~
News Search