#!/bin/perl ########################################################################### #Net Paper #Version 3.20 #By Tony Hawk of Planet K #http://planetk.net #THIS SCRIPT IS NOT FREEWARE! Please DON'T redistribute this script. #Feel free to modify it as you see fit, but PLEASE leave some if not ALL the credits alone. ########################################################################### require "config.pl"; #*************************************************************************** #Be careful when modifying below this point! #*************************************************************************** $slash = ($nt eq 'no') ? '/' : '\\'; if ($ENV{'QUERY_STRING'} ne "") { # Parse the query string &defy1; $Q = 1; } else { &defy; $Q = 0; } @numdays = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); ($sec, $min, $hr, $day, $mon) = localtime; $min = "0$min" if $min < 10; $hr += $timefix; if($hr >= 24) { $hr -= 24; $day++; if($day > $numdays[$mon]) { $mon++; $day = 1; } } if ($hr < 0) { $hr += 24; $day--; if(!$day) { $mon--; $day = $numdays[$mon]; } } $mon++; $xm = ($hr > 11) ? 'pm' : 'am'; $hr = 12 if ($hr == 0); $hr -= 12 if ($hr > 12); $when = "$mon/$day at $hr:$min$xm $zone"; ################################################################## #Print the add news form########################################## ################################################################## if ($in{'action'} eq "addnews") { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print " \n"; print " Add News\n"; print "\n"; print "\n"; print "\n"; print "$Header\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "

Headline:
\n"; print "\n"; print "\n"; print "

Lead Paragraph:
\n"; print "\n"; print "\n"; print "

Body of Story:
\n"; print "\n"; print "\n"; print "

Font color (default is displayed, don't change):
\n"; print "\n"; print "\n"; print "

Background Color (default is displayed, don't change):
\n"; print "\n"; print "\n"; print "

FULL Location to your background image (this has been set, don't change ):
\n"; print "\n"; print "\n"; print "

FULL Location to your sound file (if desired):
\n"; print "\n"; print "

\n"; print "\n"; print "

Image Filename For Story (sorry only one image allowed, suggested image width is 450 pixels, don't make it too big:\n"; print "\n"; print " \n"; print "\n"; print "\n"; print "

\n"; print "\n"; print "


\n"; print "

Copyright ©1999 by Planet K\n"; print "All Rights Reserved.

\n"; print "\n"; print "\n"; } if ($in{'action'} eq "add3") { # Check to see that all information was filled in if (($in{'Headline'} eq "") || ($in{'Lead'} eq "") || ($in{'Body'} eq "") || ($in{'Password'} eq "")) { # Not all information was filled in &Error (Information_Incomplete); } unless ($in{'Password'} eq $Password) { # Password is incorrect &Error ("Password_Incorrect"); } # Expand the comments for html $in{'Body'} =~ s/\n/\n/go; $in{'Body'} =~ s/\cM//g; $in{'Body'} =~ s/\n\n/

/g; $in{'Body'} =~ s/\n/
/g; $in{'Body'} =~ s/\|//g; &get_file_name; open (NEWSFILE,">$htdir$slash$filename5.html"); $shortfile=$in{'file_name'}; $shortfile =~ s!^.*(\\|\/)!!; print NEWSFILE "\n"; print NEWSFILE "$Header\n"; print NEWSFILE "\n"; print NEWSFILE "\n"; print NEWSFILE "

\n"; print NEWSFILE "
$in{'Headline'}
\n"; if ($shortfile){ print NEWSFILE "

\n"; } print NEWSFILE "
Posted on: $when

\n"; print NEWSFILE "$in{'Lead'}

\n"; print NEWSFILE "$in{'Body'}


\n"; print NEWSFILE "

\n"; print NEWSFILE "$Footer\n"; close NEWSFILE; # Now update the nooz.dta file. open(GW,">>$htdir$slash$DataFile"); print GW "$in{'Headline'}||$filename5\.html||$in{'Lead'}||$shortfile||$when\n"; close GW; print "Content-type: text/html\n\n"; print "\n"; print " \n"; print " \n"; print " News Posted\n"; print " \n"; print "\n"; print "$Header\n"; print "

Your Story Was Posted!

\n"; print "The story $in{'Filename'} has been posted to directory $htdir$slash$filename5\.html


\n"; if ($shortfile){ print "

\n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print "

Please find the file

$in{'file_name'}

one last time so I may upload it for you.

\n"; print "

\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; if ($in{'file_name'}){ } print "
\n"; print "
\n"; print "
\n"; } print "\n \n"; print "

[View Story Just Added] [Add Another Story] [Delete Stories] [View All Stories]

\n"; } if ($in{'action'} eq "add2") { # Check to see that all information was filled in if (($in{'Headline'} eq "") || ($in{'Lead'} eq "") || ($in{'Body'} eq "")) { # Not all information was filled in &Error (Information_Incomplete); } if ($in{'file_name'}){ if($in{'file_name'} !~ /(\.jpg)|(\.jpeg)|(\.gif)$/i) { &nofile; } } $in{'Body'} =~ s/\cM//g; $in{'Body'} =~ s/\n\n/

/g; $in{'Body'} =~ s/\n/
/g; $in{'Body'} =~ s/\|//g; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print " \n"; print "\n"; print "\n"; print "$Header\n"; print "
\n"; print "\n"; print "\n"; print "
$in{'Headline'}
\n"; print "Posted on: $when

\n"; if ($in{'file_name'}){ print "

\n"; } print "$in{'Lead'}

\n"; print "$in{'Body'}


\n"; print "


\n"; print "

\n"; print "
\n"; print "\n"; print "

Password:
\n"; print "\n"; print "\n"; print "

Headline:
\n"; print "\n"; print "\n"; print "

Lead Paragraph:
\n"; print "\n"; print "\n"; print "

Body of Story:
\n"; print "\n"; print "\n"; print "

Font color:
\n"; print "\n"; print "\n"; print "

Background Color:
\n"; print "\n"; print "\n"; print "

FULL Location to your background image (if desired):
\n"; print "\n"; print "\n"; print "

FULL Location to your sound file (if desired):
\n"; print "\n"; print "

\n"; if ($in{'file_name'}){ print "\n"; print "

Filename and location of file to be uploaded:
$in{'file_name'}
If this is not correct, use your browsers BACK button and choose the correct file.
\n"; } print "\n"; print "

\n"; print "\n"; print "\n"; } ########################################################################## #####Delete News Area##################################################### ########################################################################## if ($in{'action'} eq "remove") { # Read in the datafile open (DATA, "$htdir$slash$DataFile"); @Data = ; close DATA; $Count = 0; foreach $Line (@Data) { @Temp = split (/\|\|/, $Line); $StoryLine[$Count] = "$Temp[0]    $Temp[3]
\n"; $Count++; } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print " Delete News\n"; print " \n"; print "\n"; print "\n"; print "$Header\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

To delete a news story from the system, select the story's\n"; print "headline and graphic below and press delete. NOTE: if you don't delete the graphic related to the\n"; print " story now, you will have to delete it by FTP unless the graphic is in use by another story and can be deleted at a later time.

\n"; print "
Password:
\n"; print "
\n"; print "\n"; print "
\n"; print "\n"; print "
Choose the story to delete:Delete Related Graphic:\n"; foreach $Story (@StoryLine) { print "$Story"; } print "
\n"; print "

\n"; print "\n"; print "

\n"; print "\n"; print "


Copyright ©1999 by Planet K\n"; print " All Rights Reserved.

\n"; print "\n"; print "\n"; } if ($in{'action'} eq "delete2") { if (($in{'Password'} eq "") || ($in{'Filename'} eq "")) { &Error ("Information_Incomplete"); } unless ($in{'Password'} eq $Password) { # The password doesn't match &Error ("Password_Incorrect"); } unlink ("$htdir$slash$in{'Filename'}"); unlink ("$htdir$slash$in{'Picname'}"); # Now update the index file for that directory. open(GW,"$htdir$slash$DataFile"); @lines = ; close GW; open (GB,">$htdir$slash$DataFile"); foreach $line (@lines) { chop $line; @TempData = split (/\|\|/, $line); if ($TempData[1] ne "$in{'Filename'}") { print GB "$line\n"; } } close GB; print "Content-type: text/html\n\n"; print "\n"; print " \n"; print " \n"; print " News Story Deleted\n"; print " \n"; print "\n"; print "$Header\n"; print "

News Story Deleted!

\n"; print "The news $in{'Filename'} has been deleted.

\n"; print "

[Delete Another Story] [Add A Story][View All Stories]

\n"; print "$Footer\n"; } ######################################################################################################################## ##### Area to display all stories ###################################################################################### ######################################################################################################################## if ($in{'action'} eq "") { # Display all stories # Open the datafile open (DATA, "$htdir$slash$DataFile"); @Data = reverse; close DATA; print "Content-type: text/html\n\n"; print "\n"; print " \n"; print " Available Stories\n"; print " \n"; print "

\n"; print "\n"; print "$Header\n"; foreach $Story (@Data) { @Temp = split (/\|\|/, $Story); print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; if (-M "$htdir$slash$Temp[1]" <= 1) { print "\n"; } elsif (-M "$htdir$slash$Temp[1]" <= 3) { print "\n"; } elsif (-M "$htdir$slash$Temp[1]" <= 5) { print "\n"; } print "$Temp[0]
Posted on $Temp[4]

$Temp[2]
\n"; print "
\n"; print "
\n"; } print "$Footer\n"; } if ($in{'action'} eq "view") { print "Location: $BaseURL/$in{'item'}\n\n"; } sub Error { local($UserError) = @_; if ($UserError eq "Information_Incomplete") { print "Content-type: text/html\n\n"; print "\n"; print " \n"; print " Information Incomplete\n"; print " \n"; print "\n"; print "$Header\n"; print "

Information Incomplete!

\n"; print "You did not fill out all required information. Please go back and make sure every field is filled in before submitting.

\n"; print "$Footer\n"; print "\n"; print "\n"; exit; } if ($UserError eq "Password_Incorrect") { print "Content-type: text/html\n\n"; print "\n"; print " \n"; print " Incorrect Password\n"; print " \n"; print "\n"; print "$Header\n"; print "

Incorrect Password!

\n"; print "The password you entered was incorrect. Please go back and re-enter your password.

\n"; print "$Footer\n"; print "\n"; print "\n"; exit; } } sub nofile { print "Content-type: text/html\n\n"; print "Illegal FIle Type\n"; print "\n"; print "

Illegal FIle Type

\n"; print "You may only upload gif and jpg files\n"; print "\n"; exit; } sub defy1 { # Get the input read(STDIN, $buffer, $ENV{'QUERY_STRING'}); @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; if ($htmliscool) { $value =~ s///g; } else { unless ($name eq 'body') { $value =~ s/<([^>]|\n)*>//g; } } $in{$name} = $value; } } sub get_file_name { $newnum=time; $newnum=substr($newnum,4,5); $date5=localtime(time); ($day, $month, $num, $time, $year) = split(/\s+/,$date5); $month=~tr/A-Z/a-z/; $PREF = "$month$num-"; $filename5="$PREF$newnum"; } sub defy { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; if ($htmliscool) { $value =~ s///g; } else { unless ($name eq 'body') { $value =~ s/<([^>]|\n)*>//g; } } $in{$name} = $value; } }