#!/usr/bin/perl # 6.11.2008, Sampo Kellomaki (sampo@iki.fi) # # PlainDoc blog helper (used for zxblog) # # 1 2 3 4 5 6 7 # <> body... <> # 1 2 3 # <> # # mini_httpd -p 8443 -c '*.pl' -S -E zxid.pem # https://sp1.zxid.org:8334/blogpage.html $cvsid = '$Id: pdblog.pl,v 1.6 2009-02-18 14:01:42 sampo Exp $'; ### Choose your cvs client. For special needs, create shell script and point to that. #$cvswrapper = 'cvs'; #$cvswrapper = 'svn'; $cvswrapper = '/sampo/cvs3001'; # Custom script use Data::Dumper; use File::Copy; use filex; open STDERR, ">>/tmp/pdblog.err"; #$root = './'; $root = ''; @wday = qw(Sun Mon Tue Wed Thu Fri Sat); @mon = qw(Jan Feb Mar May Jun Jul Aug Sep Oct Nov Dec); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time); $ts = sprintf("%s, %d-%s-%04d, %02d:%02d", $wday[$wday], $mday, $mon[$mon], $year+1900, $hh,$mm); undef $/; $cgi = if $ENV{REQUEST_METHOD} eq 'POST'; $cgi .= '&' . $ENV{QUERY_STRING}; warn "cgi($cgi)"; $cgi = filex::cgi_split($cgi); warn "START: " . Dumper($cgi) . "\nENV: " . Dumper(\%ENV); if ($$cgi{'edit'}) { } elsif ($$cgi{'confirmfb'}) { $a = $$cgi{'a'}; die "Evil article id a($a) dotdot" if $a =~ /\.\./; $t = $$cgi{'t'}; $t =~ s/\"/''/gs; $c = $$cgi{'c'}; die "Evil Content($c) textarea" if $c =~ /textarea/; $c =~ s/\r//gs; $rows = tr/\n/\n/; # Count newlines and make textarea 3 lines larger $rows += 3; warn "a($a) t($t) c($c)"; print <pdblog confirm $t

Confirmation of Submission "$t" to article "$a"

Your Submission

Anonymous (giving admin email may avoid censure or speed approval)
Federated Single Sign-On (SSO)
    If you choose federated SSO based identity, please choose your IdP (Identity Provider) and login You are already logged in using federated SSO.

Your email for admin: (not displayed)
From: (your name and/or email for public display)
Subject:

Privacy, censorship, and copyright policies
You are submitting from $ENV{REMOTE_ADDR} using $ENV{HTTP_USER_AGENT}.


pdblog.pl version: $cvsid HTML ; } elsif ($$cgi{'addfb'}) { $a = $$cgi{'a'}; die "Evil article id a($a)" if $a =~ /\.\./; $t = $$cgi{'t'}; $t =~ s/\"/''/gs; $t =~ s/\r//gs; # Avoid CRLF $c = $$cgi{'c'}; die "Evil Content($c) textarea" if $c =~ /textarea/; $c =~ s/\r//gs; # Avoid CRLF $path = "$root$a.pd"; warn "a($a) t($t) c($c) path($path)"; if (open(F, "+<$path")) { # Update in place with file lock held! flock F, 2; # Exclusive seek(F, 0, 0); $x = ; warn "got from($path) data($x)"; $x =~ s/<>/<>\n\n<>\n\n$c\n\n<>/gs; $x =~ s/<>/<>\n\n$c\n\n<>\n\n<>/gs; warn "writing to($path) data($x)"; seek(F, 0, 0); print F $x; truncate F, tell F; flock F, 8; close F; } else { die "$$: Cant update($path): $!"; } warn "GEN1"; system './pd2tex', '-notex', '-nodbx', '-nortf', '-nohtml2', '-htmldir', '', $path; # *** Check that generation was successful warn "CVS $cvswrapper ci path($path)"; system $cvswrapper, 'ci', '-m', 'pdblog-addfb', $path; warn "GEN2"; system './pd2tex', '-notex', '-nodbx', '-nortf', '-nohtml2', '-htmldir', '', $path; # For cvsid #copy("${root}html/$a.html", "$root$a.html") or die "Cant copy from ${root}html/$a.html to $root$a.html: $!"; warn "REDIR"; print "Location: $a.html\n\n"; exit; } else { die "no op specified: " . Dumper($cgi) . "\nENV: " . Dumper(\%ENV); } __END__