#!/usr/bin/perl
################################################################################
# #
# fsweblog 0.9.7.3 http://seth.positivism.org/blog.cgi?get=src #
# #
# Copyright (c) 2003/4/5 Seth Alan Woolley, released under the GNU GPL >= v.2 #
# See http://www.fsf.org/licenses/gpl.txt for a copy of the license. #
# #
################################################################################
# configuration variables
$hometitle = "ashanks' blog"; # required per RSS spec.
$homedescr = "This is fsweblog."; # required per RSS spec.
$homeTZ = "-08:00"; # for RSS timezone spec. (-08:00 is PST)
$homelang = "en-US"; # for RSS language spec.
$homecss = "$ENV{SCRIPT_NAME}?get=css"; # change to use non-builtin CSS
$homecss = "http://swoolley.org/man.cgi/c=1"; # non-builtin CSS
$turing = "fsweblog"; # turing test for commenters
# or edit the CSS below.
$relpath = "fsweblog/"; # relative path to paths below (from here)
$datadir = $relpath . "blogs"; # relative to the script for blogs.
$commentdir = $relpath . "comments"; # relative to the script for comments.
$noquery = 1; # 1 if PATH_INFO, undef for QUERY_STRING
$blogstart = 1; # start number of blogs to display
$rdfstart = 1; # start number of blogs to display w/RDF
$blogmax = 10; # maximum number of blogs to display
$rdfmax = 10; # maximum number of blogs to display w/RDF
# latest blog image: ?get=jpeg or ?get=png
@bg = (000,000,000); # background color of image, RGB, 0-255
@fg = (255,255,255); # foreground color of image, RGB, 0-255
$tp = undef; # transparent bg of image? make 1 or undef
# installation instructions
#
# Copy this file into a directory on your server with all execute permissions.
# Make sure to rename it "index.cgi" without ?get=src at the end (no quotes).
# Execute permissions are a+x, 755, or all with execute, and can be setup in
# your ftp program or by using the chmod unix utility: chmod 755 index.cgi
#
# Make a directory in the same directory as this file called $datadir
# ("blogs", by default). Set its permissions to 755 as well (the same as
# the script). This is where you upload or write your blogs directly to.
# The blogs are simply text files with the name set to the subject you want.
# Use the unix commands: mkdir blogs; chmod 755 blogs
#
# Make another directory in the same directory as this file called $commentdir
# ("comments", by default). Set its permissions to 775, a+xg+w, or all
# with execute and group with write in addition to its normal permissions.
# Change its group to the webserver group, typically apache, nogroup, or httpd.
# Use the commands: mkdir comments; chmod 775 comments; chgrp nogroup comments
#
# If you want to not enable comments, set the comments permissions to 755
# instead of 775. Then to enable comments on a blog-by-blog basis, create
# a directory the same name as the blog you created with 775 permissions,
# with a group of nogroup (or whatever your web server group is).
# Commands: mkdir comments; chmod 755 comments; chgrp nogroup comments;
# mkdir comments/blogtitle; chmod 775 comments/*; chgrp nogroup comments/*
# Repeat the second line of commands above when you create a new
# commentable blog.
#
# Security note: Anybody with permissions to the webserver group can then
# edit the comments on your site. To avoid this problem, have your
# administrator setup setgid permissions on the webserver to have your
# htdocs directory set to your group and then use your group instead of
# nogroup, or run in a virtual private server. To be safest, don't enable
# comments.
#
# If you are unable to find out your webserver group and/or change your
# directories' group to nogroup, then you can do what the GreyMatter
# install says, and do: chmod 777 comments
#
# That of course means you don't have to do any of the chgrp commands
# either, but you will have to have made the appropriate directories.
#
# Then, change the first line that says #!/bin/perl to #!/usr/bin/perl
# or #!/usr/local/bin/perl depending on your perl installation location.
#
# Lastly, edit the templates in the source code as you please, but remember
# that $ and @ are variable interpolating characters, so, so put \$ or \@
# if you want to use the characters literally. The unescaped $ and @
# references are subroutines and variables that can be used at any point
# within the template. Remember that the backquote character ` should be
# escaped if you want to use it literally as well because it's the template
# quoting character. It's used inside templates for example to do the dirty
# trick of repeating "for" loops. In the Content-type area at the top of each
# template, you can send your own headers, but be sure that carriage returns
# in the header and in the separating newline are "\r\n" instead of just the
# standard newline "\n", or the webserver will not know what you're doing.
#
# Optional latest blog image support simply requires GD installed on the
# server. For a phpBB latest blog image in your signature:
# [url=http://example.com/][img]http://example.com/index.cgi?get=png[/img][/url]
#
# To check for if GD is installed: perl -e 'use GD'
# To install GD if you don't have it: perl -MCPAN -e 'install GD'
#
################################################################################
#print "Content-type: text/plain\r\n\r\n$ENV{SCRIPT_NAME} $ENV{HTTP_HOST} $0 $ENV{PATH_INFO}";
($basename, $filename) = ($ENV{SCRIPT_NAME} =~ /^(.*\/)(.*)$/);
$homeurl = "http://$ENV{HTTP_HOST}$basename";
if ($filename eq "") { $filename = $0 }
my $PI = $ENV{PATH_INFO};
$PI =~ s!^/!!;
if ($PI ne '') {
if ($PI !~ m!/!) {
$ENV{QUERY_STRING} .= ';get=post;post=' . $PI;
} else {
# prevent response-splitting by filtering out newline stuff
my ($entry, $cmd5) = ($PI =~ m!([^/\r\n\l\f]*)/?([^\r\n\l\f]*)!);
if ($cmd5 ne '') {
print "Location: $homeurl$filename/$entry#id$cmd5\r\n\r\n";
} else {
print "Location: $homeurl$filename/$entry\r\n\r\n";
}
exit 1;
}
}
my ($QS, %args, $argsarray, %filetype, %filedata);
&parsequerystring();
my (%entry, %entries, %comments, $commentglobal, %commentsenable);
&grabdata();
#use Data::Dumper
#print STDERR Data::Dumper->Dump(
# [\%entries ],
# [ 'entries']
#);
my $get = $args{"get"};
if($get eq "") {
my ($lbb, $lbe) = &bound(scalar keys %entries, 'blog', $blogstart, $blogmax);
################################################## FRONT TEMPLATE BEGIN
print qq`Content-type: text/html\r\n\r
`;
################################################## FRONT TEMPLATE END
} elsif($get eq "post") {
&commentpost();
local $entry = $entry{$args{"post"}};
################################################## POST TEMPLATE BEGIN
print qq`Content-type: text/html\r\n\r
@{[&plaintext($hometitle)]} - @{[&plaintext($homedescr)]}