#!/usr/bin/perl
#####################
##About This Script##########################################################
#####################
### Pete's GoScript v2.0 - by Pete Stein (pete@slack.net) - 6-1-00
### http://www.slack.net/~pete/perl
###
### This script copyright Pete Stein, pete@slack.net from Pete's Perl Scripts
### at http://www.slack.net. Users of this script acknowledge the following
### terms and conditions. This script is provided free of charge and as a
### result is Freeware, but still owned and copyright Pete Stein. Users may
### modify the script but may not in any circumstance redistribute or sell
### this script in any form or fashion without express consent of Pete Stein.
### Users are not obligated to provide any acknowledgement of the origin of
### this script if used on their site, but they certainly may if they so
### desire. Users furthermore acknowledge that the aforementioned parties
### in relation to Pete's Perl Scripts are in no way responsible in any
### circumstance for any damages or undesirable effects cause by use or
### misuse of any Pete's Perl Scripts script.
####################
##Things to modify###########################################################
####################
### I know there are a lot of things, but you'll probably appreciate all
### the features in the end if you really need something(s).
### Is where go.cgi will look for pages. Include the trailing slash.
### Mine is /home/pete/public_html/
$path = "/home/cisweb/public_html/";
### Full url to go.cgi
### Mine is http://www.slack.net/~pete/cgi-bin/go.cgi
$urltogo = "http://canadianchristianity.com/cgi-bin/na.cgi";
### The sublayout variable is used to search subdirectories for header and
### footer files. This way if your site has a lot of big sections and you
### want them each to use a different layout, you don't have to run 10 Go-
### Scripts. Setting to 0 will not search subdirectories, and will only
### look for header/footer files in the directory where go.cgi is installed.
### Setting to 1 will search subdirectories.
$sublayout = 1;
### This variable stores the location of a 404 error message page you can make.
### This is cool because you can make your own custom message instead of your
### server's default. Impress your friends! If GoScript can't find the filename
### specified in go=, it will print this file instead. This file will be read
### from the directory specified in $path
$fof = "404.php";
### $filend is a suffix added to path/file. So if you set it
### to .html, you can use go.cgi?page=index
$filend = ".html";
### $layoutwitherror is a variable used to indicate whether or not you want 404
### messages to be displayed by themselves or inside the layout you normally use
### with GoScript. Setting to 0 will make it display the 404 message on it's own.
### Setting to 1 will put it inside the header and footer.
$layoutwitherror = 1;
### By default, documents are called by go.cgi?(anything)=document.html or
### whatever. If "short" is enabled, documents can be called simply by
### go.cgi?document.html
$short = 1;
### Do you want GoScript to log hits to a file? Setting to 1 will enable logging,
### setting to 0 will disable.
$golog = 0;
### If logging is enabled, what is the name of the logfile?
### ![You must create this file and set it's permission to 777]!
$logfile = "golog";
### Some people might want to log all documents automatically. If this is you,
### set this variable to 0. Some people might want it so that they can chose
### which documents to log. If you have 5000 pages and only want to log 5, set
### this to 1. You can then fill in a list of files you want to log.
$logall = 1;
### If you have $logall set to 1, fill in this array with all of the documents
### you want to log. If you are using auto-extensions, just fill in the name
### without the extension. If you aren't, include it.
@logpages = ("example.html","etc.html");
### !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ###
### SECURITY LIST ### IMPORTANT ### MAKE SURE TO READ THIS ###
### !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ###
### If you have a cgi-bin or any sort of other directory in which you do not want
### anyone accessing documents, be sure to fill out this array. Entries in this
### array, when found in a url, will automatically produce a 404 message to
### prevent users from accessing sensitive documents or program scripts. These
### are case insensitive so if you have cgi-bin and someone tries Cgi-bin then
### you're still ok. This is in case somebody's server is case insensitive or
### something. I don't know:)
@dontshow = ("cgi-bin","logs","private","secret","admin", "restricted");
###############################
##Web Administration settings##############################################
###############################
### First off, do you even want Web Administration enabled? If set to 0, this
### feature will be totally disabled. If you're concerned about security
### and don't want this anyway then setting this to 0 will totally lock out
### this feature.
$webadmin = 0;
### Login information for the administration console
$webuser = "clementsm";
$webpass = "@WebMaster2011";
### If you want to use your existing layout for the layout of the console
### then set this to 1. If you want plain white background and black text,
### set to 0.
$usegeneric = 0;
###################################
##End of Settings - Don't Touch:)##########################################
###################################
$request_method = $ENV{ 'REQUEST_METHOD' };
$isssi = 0;
if ($request_method eq "GET" || $request_method eq "get") {
$query_string = $ENV{ 'QUERY_STRING' };
@key_value_pairs = split( /&/, $query_string );
$fe = 0;
foreach $key_value (@key_value_pairs)
{
$fe = $fe + 1;
if ($short == 0) {
($key, $value) = split( /=/, $key_value );
}
if ($short == 1) {
$value = $key_value;
}
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
if ($fe == 1) { $go=$value; }
else {
if ($key eq "theme") { $theme = $value; }
if ($key eq "ssi.head" || $key eq "ssi.foot") { $isssi = 1; }
if ($key eq "ssi.head") { $thessi = "head"; }
if ($key eq "ssi.foot") { $thessi = "foot"; }
}
# this next line replaces all occurences of : with /, which, by the way,
# will allow you to access subdirectories. If you don't want : to be
# replaced, just remove the next line.
$go =~ s/\:/\//g;
}
}
if ($request_method eq "POST" || $request_method eq "post") {
###
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
if ($ENV{'QUERY_STRING'})
{
$buffer = "$buffer\&$ENV{'QUERY_STRING'}";
}
@pairs = split(/&/,$buffer);
foreach $pair (@pairs)
{
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$FORM{$name} = $value;
}
###
}
print "Content-type: text/html\n\n";
if ($request_method ne "POST" && $request_method ne "post") {
### prevent users from snatching your password file:)
if ($layoutwitherror == 0) {
foreach $bads (@dontshow) {
if ($go =~ /$bads\//i) {
print $go;
$go = "";
&badurl;
}
}
}
if ($layoutwitherror == 1) {
foreach $bads (@dontshow) {
if ($go =~ /$bads\//i) {
print $go;
$go = "-1";
}
}
}
}
if ($webadmin == 1) {
if ($go eq "$webuser") {
if ($usegeneric == 1) {
open(DAHEADHEAD,"nahead.go");
while ($line = ) {
print $line;
}
close(DAHEADHEAD);
}
else {
print "GoScript Web Administration\n";
print "";
}
print "
login namepassword
";
if ($usegeneric == 1) {
open(DAFOOTFOOT,"nafoot.go");
while ($line = ) {
print $line;
}
close(DAFOOTFOOT);
}
else {
print "