#!/usr/bin/perl # BY RUNNING THIS SCRIPT, YOU AGREE TO THE LICENSE # BELOW. # See readme.txt for setup instructions. # 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; don't change it unless # you have problems. If you use IIS yet have 500 error problems, # try setting the variable to 2, then try 3. $IIS = 0; # If you use a server that allows file locking (most UNIXes and Windows NT do, # Windows 9x does not), set this to 1 to prevent accidental file corruption if # two people use the script at the exact same time. $UseFlock = 1; # It is possible to view NewsPro's configuration without logging in - this is # a debugging and problem-solving feature. No usernames or passwords are revealed. # It is recommended that you leave this on, but it is possible to turn this off # by setting this to 0. $DebugFeatures = 1; # 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 newspro.cgi. Example: # $scripturl = 'http://www.myserver.com/newspro/newspro.cgi'; # Once again, you only need to set the above two variables if you're # having server problems. # END SERVER PROBLEMS WORKAROUNDS =pod ******NewsPro****** Version: 3.7.5 ######### LICENSE INFORMATION ########### Copyright Amphibian Internet. All Rights Reserved. This software is currently FREE (of charge). It cannot, however be used by sites with illegal or pornographic content. Pricing may change in the future. You are free to modify this script in any way you please. However, you MAY NOT REDISTRIBUTE NewsPro in any form. This includes modified and unmodified versions, and applies whether or not you would charge a fee. Commercial sites using NewsPro MUST place a link to the NewsPro site on their main news site. The DisplayLink setting (in Advanced Settings) will do this occasionally, but in some scenarios the link must be added manually. This software is provided without warranty. Or, in legal language: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Website: http://amphibian.gagames.com/newspro/ Email: newspro@amphibian.hypermart.net ######### END LICENSE INFORMATION ########### =cut ####### # START NEWSPRO ITSELF ####### ####### # ERROR HANDLING ####### unless ($JustLoadSubs) { # This should trap just about every error. eval { &main; }; if ($@) { &NPdie("Untrapped Error: $@"); } exit; } ####### # ADVANCED SETTINGS DEFINITION ####### sub AdvancedSettingsLoad { @advancedsettings = ('CommercialUser' , 'DisplayLink' , 'draw_line', 'TimeOffset', 'AutoBuild' , 'AutoLinkURL', 'ShowNewsControls', 'EnableGlossary' , 'draw_line', 'NumberLimit' , 'EnableHeadlines' , 'HeadlineNumber' , 'ArchiveNumber', 'ArcHtmlExt', 'EnableBROption', 'Modify_ItemsPerPage' , 'MaxSearchResults' , 'CheckFileTime' , 'CreateAnchors', 'draw_line', 'DisableHTML', 'BasicLayout'); $AdvDescr{'AutoBuild'} = "Automatically build news after submitting or modifying news?"; $AdvDescr{'DisplayLink'} = qq~ Display a link to the NewsPro home page after your news? Commercial users must leave this on, or add a link to their news page manually. It is completely optional for non-commercial sites (though it would be nice!). Finally, this link is only added automatically to your news.txt file. If you are a commercial user and do not use news.txt to display your news, you must manually add a link to your page.~; $AdvDescr{'CommercialUser'} = "Commercial sites must set this to Yes. Any site which sells a product, promotes a company, or is owned and operated by a for-profit corporation is considered commercial. Ad banners placed by a web host do not make a site commercial, however any paid ads placed by the site owner do make a site commercial."; $AdvDescr{'CheckFileTime'} = "Check if newsdat.txt has been modified between the two steps of Modify News? Set this to No if you receive "file has been modified" errors unnecessarily."; $AdvDescr{'ArcHtmlExt'} = "Extension of archive HTML files. (no period, just the extension)"; $AdvDescr{'ArchiveNumber'} = "Allows you to archive by number of news items instead of by time, i.e. have each archive page have 20 items. To do this, set this setting to the number of news items on each archive page, and make sure that you have archiving enabled and set to Monthly via Change Settings. To archive normally, set this to 0."; $AdvDescr{'EnableGlossary'} = "Enable the Glossary feature? This will result in a Edit Glossary option for Webmaster users and a Glossary On/Off button on the Submit page. The Glossary allows you to replace a certain piece of text with another automatically, i.e. the name of your site with a link to your site."; $AdvDescr{'TimeOffset'} = "Set this to the difference in hours between you (or the time you want displayed) and your server. For instance, if you live in Boston and your server is in London, set this to -5."; $AdvDescr{'NumberLimit'} = "If, instead of choosing which articles to display on your main news page by time, you'd like to display a certain fixed number and archive/delete the rest, set this to that number. If NumberLimit is set, it will override any NewsAge time you set on the main Change Settings page."; $AdvDescr{'EnableHeadlines'} = "Automatically write a list of your headlines to headlines.txt when you build news? You can change the format of the headlines by editing ndisplay.pl."; $AdvDescr{'HeadlineNumber'} = "The number of headlines to include in your headlines file. Set to 0 to include all the news on your main page."; $AdvDescr{'Modify_ItemsPerPage'} = "The number of news items that are displayed at once on a Modify News page"; $AdvDescr{'AutoLinkURL'} = "Automatically change a URL into a link?"; $AdvDescr{'ShowNewsControls'} = "Shows some news controls at the bottom of your main news page (news.txt): search news, view all news, and if e-mail notification is enabled allows users to subscribe/unsubscribe. This does not modify the output of viewnews.cgi. While the default controls cannot be edited, you can copy the HTML for the controls into your own page and edit them there."; $AdvDescr{'CreateAnchors'} = "Creates an <a name> tag with the news item's ID number along with each news item. Do not disable unless your news style somehow prevents you from using these."; $AdvDescr{'BasicLayout'} = "Uses a very simple, black-and-white layout for NewsPro script pages. Does not affect any generated news files, only the look and feel of newspro.cgi."; $AdvDescr{'DisableHTML'} = "Remove all HTML tags from submitted news items?"; $AdvDescr{'MaxSearchResults'} = "The maximum number of news items returned as results in a search (using viewnews.cgi)."; $AdvDescr{'EnableBROption'} = "Adds the option whether or not to convert line breaks to <br> upon submission to the Submit News page. If this option is off, no option will be given and line breaks will always be converted to <br>. (This will ONLY work on English copies of NewsPro) "; # The following controls which settings are yes/no (1/0) and which aren't. %AdvYesNo = ('AutoBuild' => '1', 'DisplayLink' => '1', 'CommercialUser' => '1', 'CheckFileTime' => '1', 'Display_Week_Day' => '1', 'Display_Month' => '1', 'Display_Month_Day' => '1', 'Display_Year' => '1', 'Display_Time' => '1', 'Display_Time_Zone' => '1', '12HourClock' => '1', 'EnableGlossary' => '1', 'EnableHeadlines' => '1', 'UseCookies' => '1', 'ShowNewsControls' => '1', 'WrapEmailText' => '1', 'CreateAnchors' => '1', 'DisableHTML' => '1', 'BasicLayout' => '1', 'EnableBROption' => '1', 'AutoLinkURL' => '1'); if (@Addons_AdvancedSettingsLoad) { &RunAddons(@Addons_AdvancedSettingsLoad); } } sub StartUp { # Version number. Do NOT change! Used internally! $npversion = '3.7.5'; # Build number. Also, do not change! $npBuild = 29; # Server problem workaround #1 if ($abspath) { push(@INC, $abspath); } # Require npconfig.pl require "npconfig.pl"; # Require nplib.pl require "nplib.pl"; # Location of ndisplay.pl (required in GenHTML) $ndisplaypl = "ndisplay.pl"; # Put the script's URL into $scripturl. # Don't if it was already set as a server problem workaround. unless ($scripturl) { $scripturl = &GetScriptURL; } # Get form input &ReadForm; unless ($npconfigversion == 3) { &NPdie('You are using an out-of-date version of npconfig.pl. Visit the NewsPro homepage and download a newer version.'); } unless ($nplibBuild == 7) { &NPdie('You are using an out-of-date version of nplib.pl. Visit the NewsPro homepage and download a newer version.'); } unless ($nplangversion == 3.7) { &NPdie('You are using an out-of-date version of nplang.pl. Visit the NewsPro homepage and download a newer version of NewsPro.'); } } 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! StartUp(); $qstring = query_string(); # Now, look at the query string and decide what to do. # Log the user out. if ($qstring eq "logout") { &ClearCookies; $HeaderPrinted = 1; &NPHTMLHead($Messages{'Section_LogOut'}); print $Messages{'LogOut_Message'}; &NPHTMLFoot; exit; } # Save initial setup. if ($qstring eq "firsttimesave") { &FirstTimeSave; } # Debugging feature: show configuration (no passwords are displayed). if ($qstring eq "showconfig") { print header(); if ($DebugFeatures) { &ReadConfigInfo; $thetime = time; print "
$Messages{'MainPage_Welcome'} $Cookies{'uname'}! $Messages{'MainPage_Choose'}
$Messages{'MainPage_LangWarning'}
$Messages{'Section_Submit'}: $Messages{'MainPage_Descriptions_Submit'}
$Messages{'Section_Build'}: $Messages{'MainPage_Descriptions_Build'}
~;
unless ($NPConfig{'AutoBuild'}) { print $Messages{'MainPage_Descriptions_Build_NoAuto'}; }
print qq~
$Messages{'Section_Modify'}: $Messages{'MainPage_Descriptions_Modify'}
~;
if ($up == 1) { print $Messages{'MainPage_Modify_1'}; }
else { print $Messages{'MainPage_Modify_2'}; }
print qq~
$Messages{'Section_UserInfo'}: $Messages{'MainPage_Descriptions_UserInfo'}
~;
if ($up == 3) {
print qq~
Change Settings/Advanced Settings: Webmaster users only. Change a wide variety of program settings.
Edit Users: Add or remove various NewsPro user accounts. You cannot remove other Webmaster users.
~;
}
if (@Addons_MainPage) {
&RunAddons(@Addons_MainPage);
}
if ($NPConfig{'EnableGlossary'} && $up == 3) {
print qq~
Edit Glossary: Edit the Glossary, which allows you to replace a certain piece of text with another while submitting.
~;
}
print qq~
$Messages{'Section_LogOut'}: $Messages{'MainPage_Descriptions_LogOut'}
$Messages{'MainPage_YourVersion'} $npversion (Build $npBuild) $Messages{'MainPage_CurrentVersion'}
~;
if ($up == 3) {
print qq~$Messages{'MainPage_Upgrade'}
$Messages{'MainPage_Addons'} ($Messages{'MainPage_Download'}): $addons
Visit the NewsPro Web page or read the FAQ.
~;
}
print qq~
~;
} else {
print q~~;
if (@Addons_NPHTMLHead) {
&RunAddons(@Addons_NPHTMLHead);
}
print qq~
~; unless ($NPConfig{'BasicLayout'}) { print qq~ $Messages{'NewsPro'} $npversion $Messages{'NewsPro'} $npversion "; } print ''; } sub PrintNewsControls { my ($newscontrols, $vnurl); $vnurl = $scripturl; $vnurl =~ s/newspro\.(cgi|pl)/viewnews\.$1/i; $newscontrols = qq~ $Messages{'Controls_View'}~; if ($NPConfig{'EnableEmail'}) { $newscontrols .= qq~ $Messages{'Controls_Email'} ~; } if (@Addons_NewsControls) { &RunAddons(@Addons_NewsControls); } return $newscontrols; } ####### # NEWS SUBMISSION SUBS ####### # DisplaySubForm: Displays the Submit News page sub DisplaySubForm { &GetTheDate(); # Load form fields data from npconfig.pl &SubmitFormFields; &NPHTMLHead($Messages{'Section_Submit'}); print qq~'; if (@Addons_DisplaySubForm_Post4) { &RunAddons(@Addons_DisplaySubForm_Post4); } &NPHTMLFoot; } # SaveNews: Saves a new news entry to newsdat.txt sub SaveNews { SubmitFormFields(); &loadND; # Strip newlines, HTML comments, and other bad things. foreach $key (keys %in) { if($NPConfig{'DisableHTML'}) { $in{$key} = HTMLescape($in{$key}); } if (($key eq 'newstext' || $FormFieldsNewlines{$key} == 1) && $in{'broption'} != 1) { $in{$key} =~ s/\n/ /g; } else { $in{$key} =~ s/\n//g; } $in{$key} =~ s/\r//g; $in{$key} =~ s/``x/` ` x/g; $in{$key} =~ s///g; ${$key} = $in{$key}; } # Begin glossary code if ($glossaryon == 1) { &LoadGlossary; foreach $i (@glossary) { $newstext =~ s/([^\w\d\<]|\A)\Q$i\E([^\w\d\>]|\Z)/$1$Glossary{$i}$2/g; } } if ($NPConfig{'AutoLinkURL'}) { $newstext =~ s/([\s\(]|\A| )(http:\/\/|ftp:\/\/|https:\/\/)([^\s\)"'<>]+)/$1$2$3<\/a>/gi; } # End glossary code $newsname = $Cookies{'uname'}; $newstime = time; # Generate news ID $rando = int(rand(99999)); $newsid = join(',', time, $rando, $newscat); $snid = join(',', time, $rando, ''); # Ensure news ID is not already being used. while ($NewsID{$snid} ne '') { $rando = int(rand(99999)); $newsid = join(',', time, $rando, $newscat); $snid = join(',', time, $rando, ''); } if (@Addons_SaveNews) { &RunAddons(@Addons_SaveNews); } $newsline = &JoinDataFile; # Open the news database for append. NPopen('NEWSDAT',">>$NPConfig{'admin_path'}/newsdat.txt"); print NEWSDAT "$newsline\n"; close(NEWSDAT); if (@Addons_SaveNews_3) { &RunAddons(@Addons_SaveNews_3); } if ($NPConfig{'AutoBuild'}) { &GenHTML; exit; } &NPHTMLHead($Messages{'Save_NewsSaved'}); print qq~ $Messages{'Save_Message'} ~; if (@Addons_SaveNews_2) { &RunAddons(@Addons_SaveNews_2); } &NPHTMLFoot; } ####### # NEWS BUILDING AND ARCHIVING ####### # GenHTML: This is the core of the Build News function. # It generates all the various news files. sub GenHTML { # This line exists for compatibility with ndisplay.pl $ArcHtmlExt = $NPConfig{'ArcHtmlExt'}; # Load ndisplay.pl require $ndisplaypl; # Check if we have a current version of ndisplay.pl unless ($ndisplayversion == 3) { if ($ndisplayversion == 2) { &UpgradeND3; } elsif (!$ndisplayversion) { NPdie("Your ndisplay.pl does not contain the required $ndisplayversion line. Restore the original ndisplay.pl"); } } # Set variables to the current time and the time before which news is "old" $currenttime = time; ($oldtime, $newtime) = PastDaysTime($NPConfig{'NewsAge'}); # Open the links text file if we're archiving monthly. if ($NPConfig{'NewsArcDel'} == 2 && $NPConfig{'ArcTime'} >= 2) { $linktxtpath = ">$NPConfig{'archive_path'}/arclinks.txt"; NPopen('LINKTXT', $linktxtpath); } # Open the main archive file if we're archiving into one file. if ($NPConfig{'NewsArcDel'} == 2 && $NPConfig{'ArcTime'} == 1) { $bigarcpath = ">$NPConfig{'archive_path'}/archive.txt"; NPopen('BIGARC', $bigarcpath); } # Read in newsdat.txt &loadND; $newsnum = @NewsData; # If NumberLimit is set, change the "archive time" to the number of seconds since the # nth most recent article was posted, where n = NumberLimit. # This is a bit of a workaround, as the script was designed to archive by time. if ($NPConfig{'NumberLimit'}) { $oldnum = $newsnum - $NPConfig{'NumberLimit'}; if ($oldnum > 0) { $oldtime = $NewsData[$oldnum]->{'newstime'}; } else { $oldtime = $NewsData[0]->{'newstime'}; } } $newsnum--; # Open the main output file, news.txt NPopen('NEWSHTML', ">$NPConfig{'htmlfile_path'}/news.txt"); # Print out identifier comment. print NEWSHTML qq~ ~; if (@Addons_BuildNews_PreLoop) { &RunAddons(@Addons_BuildNews_PreLoop); } # Start processing newsdat.txt line-by-line NDLOOP: while ($newsnum >= 0) { # Split the entry into its various components getNDvar($newsnum); if (@Addons_BuildNews_1) { &RunAddons(@Addons_BuildNews_1); } if ($NPConfig{'NewsArcDel'} eq "0" || $newstime >= $oldtime) { # News goes onto the main page. $BeingArchived = 0; $FileName = "$NPConfig{'htmlfile_path'}/news.txt"; &DoNewsHTML; if ($NPConfig{'CreateAnchors'}) {print NEWSHTML qq~~;} print NEWSHTML $newshtml; # Make a headline if headlines are enabled. if ($NPConfig{'EnableHeadlines'}) { &DoHeadline; } } elsif ($NPConfig{'NewsArcDel'} == 2 && $newstime < $oldtime) { # News too old to go on main page. $BeingArchived = 1; if (@Addons_BuildNews_2) { &RunAddons(@Addons_BuildNews_2); } if ($NPConfig{'ArcTime'} == 1) { # Print to the main archive file. $FileName = "$NPConfig{'archive_path'}/archive.txt"; &DoArchiveHTML; if ($NPConfig{'CreateAnchors'}) {print BIGARC qq~~;} print BIGARC $newshtml; } elsif ($NPConfig{'ArchiveNumber'}) { $FileName = "$NPConfig{'archive_path'}/arc$ArcCounter.txt"; &DoArchiveHTML; &ArcNumberHandler($newshtml); } elsif ($NPConfig{'ArcTime'} == 2) { # Print to the appropriate individual archive. $arcname = "arc$Month" . "-$Year"; unless ($OpenArchive{$arcname}) { &DoArcFile($arcname); } $FileName = "$NPConfig{'archive_path'}/$arcname.txt"; &DoArchiveHTML; if ($NPConfig{'CreateAnchors'}) {print $arcname qq~~;} print $arcname $newshtml; } elsif ($NPConfig{'ArcTime'} == 3) { # Print to the appropriate individual archive. my ($arcDay, $arcMonth); $arcDay = "0$Day" if $Day <10; $arcDay = $Day if $Day >=10; $arcMonth = "0$ActualMonth" if $ActualMonth <10; $arcMonth = $ActualMonth if $ActualMonth >=10; $arcname = "arc-$Year$arcMonth$arcDay"; unless ($OpenArchive{$arcname}) { &DoArcFile($arcname); } $FileName = "$NPConfig{'archive_path'}/$arcname.txt"; &DoArchiveHTML; if ($NPConfig{'CreateAnchors'}) {print $arcname qq~~;} print $arcname $newshtml; } else { last NDLOOP; } } # Entry processed, remove 1 from counter. $newsnum--; } # If ShowNewsControls is on, add them. if ($NPConfig{'ShowNewsControls'}) { print NEWSHTML &PrintNewsControls; } # If DisplayLink is on, add a link. if ($NPConfig{'DisplayLink'}) { # You can modify this link if you'd like. print NEWSHTML qq~ $Messages{'DisplayLink'} $Messages{'NewsPro'}. ~; } # Close news.txt close(NEWSHTML); # Close the main archive file if we archive to one big file. if ($NPConfig{'NewsArcDel'} == 2 && $NPConfig{'ArcTime'} == 1) { close(BIGARC); } # Close the individual monthly archives if we archive monthly. if ($NPConfig{'NewsArcDel'} == 2 && $NPConfig{'ArcTime'} >= 2) { # Format archive links &EndArcLinks; foreach $key (keys %OpenArchive) { &EndArcFile($key); } } # Close the headlines file if headlines are enabled. if ($HeadlineFileOpen) { close(HEADLINES); $HeadlineFileOpen = 0; } if (@Addons_BuildNews_Post) { &RunAddons(@Addons_BuildNews_Post); } # Done! Print confirmation page. unless ($SilentBuild) { &NPHTMLHead($Messages{'Build_Title'}); print $Messages{'Build_Message'}; &NPHTMLFoot; } } # DoArcFile: Opens and prepares a monthly archive file. sub DoArcFile { # Name of file is passed to it. local ($arcfile) = @_; # Get full path $arcfilepath = ">$NPConfig{'archive_path'}/$arcfile.txt"; # Open (create) the file. NPopen($arcfile, $arcfilepath); $OpenArchive{$arcfile} = 1; if ($NPConfig{'ArcTime'} == 2) { $ArcDate{$arcfile} = ucfirst("$Months[$Month] $Year"); } elsif ($NPConfig{'ArcTime'} == 3) { $ArcDate{$arcfile} = "$Day $Months[$Month] $Year"; } # Add a link to this file to the archive links file. if ($NPConfig{'NewsArcDel'} == 2 && $NPConfig{'ArcTime'} >= 2) { &DoLinkHTML; print LINKTXT $newshtml; } } # EndArcFile: Closes a monthly archive file, and prepares the HTML version of it. sub EndArcFile { # Name of archive file is passed to it. my $arcfile = shift; # Close that archive file. close($arcfile); # Get full paths $archtmlpath = ">$NPConfig{'archive_path'}/$arcfile.$NPConfig{'ArcHtmlExt'}"; $arcfilepath = "$NPConfig{'archive_path'}/$arcfile.txt"; # Open HTML archive file and HTML archive template my $arctxt = ''; NPopen('ARCTXT', $arcfilepath); while ( You do not have permission to modify any news items.~;
}
else {
print qq~ ~;
unless ($newsnum < 0) {
print qq~
$Messages{'Modify_Save'} $Messages{'And'} $Messages{'Modify_Or'}
.
~;
}
else {
print qq~
~;
}
}
print " ";
&NPHTMLFoot;
}
# RemoveNewsSave: Performs modifications
sub RemoveNewsSave {
SubmitFormFields();
my $fieldName;
foreach $key (keys %in) {
if($NPConfig{'DisableHTML'}) {
$in{$key} =~ s/>/>/g;
$in{$key} =~ s/<//g;
} else {
$in{$key} =~ s/\n//g;
}
$in{$key} =~ s/\r//g;
$in{$key} =~ s/``x/` ` x/g;
$in{$key} =~ s///g;
${$key} = $in{$key};
}
&loadND;
if ($nd_age != $in{'ndage'} && $NPConfig{'CheckFileTime'}) {
&NPdie("It appears that the news database (newsdat.txt) has been modified since you first accessed the Modify News page. Click your browser's back button and reload/refresh the Modify page to continue. If you receive this error when you're certain the file hasn't been modified, change CheckFileTime via Advanced Settings.");
}
$totnewsnum = @NewsData;
$newsnum = 0;
push(@formfields,'newstext');
if (@Addons_RemoveNewsSave) {
&RunAddons(@Addons_RemoveNewsSave);
}
while ($newsnum < $totnewsnum) {
$chknum = "chk--$newsnum";
if ($in{$chknum} eq "remove") {
$NewsData[$newsnum] = "del";
}
elsif ($in{$chknum} eq "keep") {
&getNDvar_nodate($newsnum);
foreach $i (@formfields) {
if ($DisableModify{$i} != 1 && ($DisableModify{$i} != 2 || $up > 1)) {
if ($in{"$i--$newsnum"} ne $NewsData[$newsnum]->{$i}) {
$NewsData[$newsnum]->{$i} = $in{"$i--$newsnum"};
$ChangedItems{$newsnum} = 1;
}
}
}
}
$newsnum++;
}
&saveND;
if (@Addons_RemoveNewsSave_2) {
&RunAddons(@Addons_RemoveNewsSave_2);
}
if ($in{'shownext'}) {
&RemoveNews($in{'shownextnum'});
} else {
if ($NPConfig{'AutoBuild'}) {
&GenHTML;
} else {
&NPHTMLHead($Messages{'ModifySave_Title'});
print $Messages{'ModifySave_Message'};
&NPHTMLFoot;
}
}
}
#######
# LOGIN AND USER MANAGEMENT
#######
# CheckLogin: Checks to see if the user is logged in; if not, allow the user to log in.
sub CheckLogin {
&ReadConfigInfo;
$npversionfull = $npversion . '_build' . $npBuild;
if($NPConfig{'CommercialUser'}) {
$npversionfull .= "_com";
}
&GetCookies;
my @users = split (/\|/, $NPConfig{'userdata'});
foreach $i (@users) {
my ($username, $password, $email, $permissions) = split (/~/, $i);
$password =~ s/\(tilde\)/~/g;
$password =~ s/\(pipe\)/\|/g;
$password =~ s/\(btick\)/\`/g;
$CPassword{$username} = $password;
$Email{$username} = $email;
$UserPermissions{$username} = $permissions;
push (@usernames, $username);
}
$up = $UserPermissions{$Cookies{'uname'}};
if ($qstring eq "login") {
if (crypt ($in{'pword'}, $CPassword{$in{'uname'}}) eq $CPassword{$in{'uname'}} && length($CPassword{$in{'uname'}}) > 2) {
SetCookies('uname',$in{'uname'},'pword',$in{'pword'});
&NPHTMLHead("$in{'uname'} $Messages{'Login_Is'}.");
print qq~
$Messages{'Login_OKMessage'}$Messages{'Login_OKClick'} ~; &NPHTMLFoot; exit; } elsif ($in{'uname'} eq "setup" && $NPConfig{'firsttime'} eq "yes") { FirstTimePage(); exit; } else { print header(); &NPHTMLHead($Messages{'Login_NoTitle'}); print qq~ $Messages{'Login_NoMessage'} |