#!/usr/bin/perl -w # Blosxom # Author: Rael Dornfest # Modified by: Zack Weinberg # Further modified by: REparsed # Version: 3+5i (05.04.2007) my $url = "http://reparsed.net"; my $datadir = "/home/reparsed/blog"; my $num_entries = 20; use strict; use CGI; undef $/; my (undef, $pi_yr, $pi_mo, $pi_da) = split(/\//, CGI::path_info()); $pi_mo = ucfirst(lc($pi_mo)) if defined($pi_mo); chdir($datadir) or die "entering $datadir: $!\n"; open(F, "< .head") or die "opening $datadir/.head: $!\n"; my $head = ; close F; $head =~ s/(\$\w+)/$1/gee; open(F, "< .foot") or die "opening $datadir/.foot: $!\n"; my $foot = ; close F; $foot =~ s/(\$\w+)/$1/gee; open(F, "< .story") or die "opening $datadir/.story: $!\n"; my $story = ; close F; my %mtimes = (); opendir(D, ".") or die "opendir($datadir): $!\n"; while (defined($_ = readdir(D))) { /\.txt$/ or next; $mtimes{$_} = (stat($_))[9]; } closedir(D); print "Content-Type: text/html; charset=utf-8\n\n"; print $head; my $curdate = ''; my $fn; foreach $fn (sort { $mtimes{$b} <=> $mtimes{$a} } keys %mtimes) { last if $num_entries-- <= 0 && !$pi_yr; my @mtime = localtime($mtimes{$fn}); my($yr,$mo,$da,$hr,$mn) = ( $mtime[5] + 1900, $mtime[4] + 1, $mtime[3], $mtime[2], $mtime[1] ); next if $pi_yr && $yr != $pi_yr; last if $pi_yr && $yr < $pi_yr; next if $pi_mo && $mo ne $pi_mo; next if $pi_da && $da != $pi_da; last if $pi_da && $da < $pi_da; $mn = sprintf("%.2d", $mn); $hr = sprintf("%.2d", $hr); if (open(F, $fn)) { my $body = ; close F; my $thisstory = $story; $thisstory =~ s/(\$\w+)/$1/gee; print $thisstory; } else { print "

cannot open $fn: $!\n"; } } print $foot;