#!/usr/bin/perl # # Publish Jr. # dan@cederholm.tv # December 2001 version .04 # # Simple script for keeping a weblog journal updated, with photo and # entry archives # # Usage: Build form with action set to this file, as well as four fields: # "date_month" - A drop down list of the 12 months (optional) # "img_src" - Large image name # "img_thumb - Thumbnail image name # "entry" - Textarea for content # Should auto-create an archive file with YYYYMM format as name and add any # photos to the photo file # use strict; use CGI; # Set variables my $q = new CGI(); my $filename = "/path/to/homepage/file"; my $archive = "/path/to/archive/directory"; my $photos = "/path/to/photos/archive/file"; my $entry = $q->param("entry"); my $imgSrc = $q->param("img_src"); my $imgThumb = $q->param("img_thumb"); my ($d, $m, $y) = (localtime)[3,4,5]; my @months = ("01","02","03","04","05","06","07","08","09","10","11","12"); my $year = $y+1900; my $month = $months[$m]; my $day = $d; my $date = $year . $month . $day; my $monthReadable = $q->param("date_month"); # Turn double line breaks to HTML
tags on new entries $entry =~ s/\r\r+|\n\n+\r\n+|\n\r+/\
/s;
# Open the homepage and archive files, capturing existing content in an array
open FILE,"+<$filename";
open ARCHIVE,"+<$archive/$year$month";
open PHOTOS,"+<$photos";
my @content = ";
print ARCHIVE "$entry ";
# Now print the old stuff
print FILE @content;
print ARCHIVE @archive;
print PHOTOS @photos;
close FILE;
close ARCHIVE;
close PHOTOS;
# Print a confirmation to the screen
print "Content-type: text/html\n\n";
print "
";
print ARCHIVE "
$monthReadable $day, $year link
";
# If there's an image specified, print it to both as well as the photo archive page
if ($imgSrc ne "") {
print FILE "
";
print ARCHIVE "
";
print PHOTOS "
";
}
print FILE "$entry
$monthReadable $day, $year