#!/usr/bin/perl $Password = "woods"; $BaseDir = "/InetPub/wwwroot/LostAcresResort/resortnews/openings"; $BaseURL = "http://www.lostacresresort.com/resortnews/openings"; $CGI_URL = "http://www.lostacresresort.com/resortnews/openings/openings.cgi"; $DataFile = "openings.dta"; $allow_html = 1; # Set to 1 to allow html commands in the text require '/InetPub/wwwroot/ResortWebOnline/cgi-bin/subroutines/specials.lib'; if ($ENV{'QUERY_STRING'} ne "") { # Parse the query string &UnWeb1; $Q = 1; } else { &UnWeb; $Q = 0; } if ($in{'action'} eq "add") { # Add a story header('Add Stories'); body('#D2B48C'); print "\n"; print "
\n"; footer(); } if ($in{'action'} eq "add2") { # Check to see that all information was filled in if (($in{'Filename'} eq "") || ($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"); } # Write the information to the file # Write the Headline, Lead Paragraph, and Body for future editing open (NEWFILE,">$BaseDir/$in{'Filename'}.head"); print NEWFILE "$in{'Headline'}"; close NEWFILE; open (NEWFILE,">$BaseDir/$in{'Filename'}.lead"); print NEWFILE "$in{'Lead'}"; close NEWFILE; open (NEWFILE,">$BaseDir/$in{'Filename'}.body"); print NEWFILE "$in{'Body'}"; close NEWFILE; # Expand the comments for html $in{'Body'} =~ s/\n/\n"; print NEWFILE "
\n"; print NEWFILE "$in{'Body'}
\n"; $Footer = foot1(); print NEWFILE "$Footer"; close NEWFILE; # Now update the index file for that directory. open(GW,">>$BaseDir/$DataFile"); print GW "$in{'Headline'}\t$in{'Filename'}.html\t$in{'Lead'}\n"; close GW; header('Stories Posted'); body('#FFFFFF'); hr(); print "
\n"; footer(); } if ($in{'action'} eq "delete") { # Delete a story # Read in the datafile open (DATA, "$BaseDir/$DataFile"); @Data = ; close DATA; $Count = 0; foreach $Line (@Data) { @Temp = split (/\t/, $Line); $StoryLine[$Count] = "
\n"; print "\n"; print "Please Enter Your Password: | \n";
print "|
Choose the story to delete: | \n";
print "
\n"; print "
\n"; print "\n"; print "\n"; footer(); } 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 ("$BaseDir/$in{'Filename'}"); $fname = "$in{'Filename'}"; @fname = split (/.html/ , $fname); unlink ("$BaseDir/$fname[0].head"); unlink ("$BaseDir/$fname[0].lead"); unlink ("$BaseDir/$fname[0].body"); # Now update the index file for that directory. open(GW,"$BaseDir/$DataFile"); @lines =\n"; footer(); } if ($in{'action'} eq "change") { # Change a story # Read in the datafile open (DATA, "$BaseDir/$DataFile"); @Data = ; close DATA; $Count = 0; foreach $Line (@Data) { @Temp = split (/\t/, $Line); $StoryLine[$Count] = "
\n"; print "\n"; print "Please Enter Your Password: | \n";
print "|
Choose the story to change: | \n";
print "
\n"; print "
\n"; print "\n"; print "\n"; footer(); } if ($in{'action'} eq "change2") { # Change a story $fname = "$in{'Filename'}"; @fname = split (/.html/ , $fname); open (HEAD, "$BaseDir/$fname[0].head"); @Head = ; close HEAD; open (LEAD, "$BaseDir/$fname[0].lead"); @Lead =\n"; print NEWFILE "
\n"; print NEWFILE "$in{'Body'}
\n";
$Footer = foot1();
print NEWFILE "$Footer";
close NEWFILE;
# Now update the index file for that directory.
open(GW,"$BaseDir/$DataFile");
@lines = \n";
footer();
}
if ($in{'action'} eq "") { # Display all available stories
# Open the datafile
open (DATA, "$BaseDir/$DataFile");
@Data = ;
close DATA;
header('Available Stories');
body('#D2B48C');
print " \n";
foreach $Story (@Data) {
@Temp = split (/\t/, $Story);
print " \n";
}
footer();
}
if ($in{'action'} eq "view") {
print "Location: $BaseURL/$in{'item'}\n\n";
}
sub Error {
local($UserError) = @_;
if ($UserError eq "Information_Incomplete") {
header('Information Incomplete');
body('#FFFFFF');
hr();
print " \n";
footer();
exit;
}
if ($UserError eq "Password_Incorrect") {
header('Incorrect password');
body('#FFFFFF');
hr();
print " \n";
footer();
exit;
}
}
sub UnWeb1 {
# Get the input
# read(STDIN, $buffer, $ENV{'QUERY_STRING'});
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s///g;
if ($allow_html != 1) {
$value =~ s/<([^>]|\n)*>//g;
}
else {
unless ($name eq 'body') {
$value =~ s/<([^>]|\n)*>//g;
}
}
$in{$name} = $value;
}
}
sub UnWeb {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s///g;
if ($AllowHTML != 1) {
$value =~ s/<([^>]|\n)*>//g;
}
else {
unless ($name eq 'body') {
$value =~ s/<([^>]|\n)*>//g;
}
}
$in{$name} = $value;
}
}
Stories Changed!
Click on a headline to view the full article:$Temp[0]
\n";
print "$Temp[2]Information Incomplete!
Incorrect Password!