#!/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 = ; my @archive = ; my @photos = ; close FILE; close ARCHIVE; # Now open them again, so that the new entry can be added above the older ones open FILE,"+<$filename"; open ARCHIVE,"+<$archive/$year$month"; open PHOTOS,"+<$photos"; # Print a value for each form field print FILE " $monthReadable $day, $year link
"; 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 " \"Click "; print ARCHIVE " \"Click "; print PHOTOS "
\"Click $monthReadable $day, $year
"; } print FILE "$entry

"; 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 " Publish Jr.™

Publish Jr.

Congratulations!
You've just added an entry for $monthReadable $day, $year

Here is what your entry looks like:

$monthReadable $day, $year
"; # If there's an image, print it if ($imgSrc ne "") { print "\"Click "; } # Continue printing the rest of the page print " $entry

« Go to homepage

"; exit();