www.newman.ac.uk/cgi/ #!/usr/local/bin/perl -Tw # parser.pl v 1.5.12 # by Wayne Myers (et al) # Enormous thanks to: # Chay Palton, Damion Yates, George Auckland, # Dan Tagg, T.V. Raman, Mark Foster, Peter Burden, # Jack Evans, Steve at wels.net, Gene D., Maurice Walshe # Mark A. Rowe and many others. # parser.pl aka BETSIE is Copyright 1998 - 2001 BBC Digital Media # See LICENCE for full licence details # See README for more information # See ChangeLog for version changes # modules use Socket; use strict; # variables my $version = "1.5.12"; # version number my @x = (); # all the lines of the html page we're parsing my $contents = ""; # @x concatenated my $inpath = ""; # path_info string from which we get the rest my $qs; # query string, used for authorisation process my $root = ""; # domain of the page we are looking at my $path = ""; # path of the page we are looking at my $file = ""; # name of the file we are looking at my $postdata = ""; # POST method data my $method = "GET"; # $method remains this way unless we get POST data my $length = -1; # but is the length of content if any greater in a POST my $count; # counter for main request loop my $httptype; # http type of request my $code; # http return code my $msg; # http message my $newurl; # used to store redirect target my $tag; # used to store meta redirect tags my $loop_flag; # flag used to make sure we get the right page my $script_flag; # flag used to see if we are in script tags or not my $ws_flag; # flag used to minimise unnecessary white space my $set = 0; # is 1 if we want the settings page my $body; # the body tag my $cookies; # cookies we want to pass on to other server my @setcookies; # cookies server wants us to pass onto user my $header; # the http header we want to send the browser my $extraheaders; # extra headers to send the server on requests my $nocontenttype = 1; # flag unset when content type is printed my $basic_realm; # contains strin my $set_auth = 0; # flag set when required authorisation is provided # VARIABLES YOU MIGHT WANT TO CHANGE: my $pathtoparser = "http://$ENV{'www.newman.ac.uk/cgi/'}$ENV{'parser.pl'}"; my $selfnuke = "(?:$pathtoparser|$ENV{'parser.pl'})"; # used to eliminate textonly links to self my $maxpost = 65536; # is maximum number of bytes in a POST my $parsehome = "http://www.bbc.co.uk/education/betsie/"; my $name = $ENV{'parser.pl'}; # name of this file $name =~ s/^.*\/(\w\.+)$/$1/; my $agent = $ENV{'HTTP_USER_AGENT'}; # pretend to be the calling browser my $allowchars = '[a-zA-Z0-9_.\-\/\#\?\&\=\%\~\+\:]'; # allowed characters my $alarm = 20; # number of seconds before we time out # variables for colour/font settings etc # be sure to amend make_body() if you amend them my $setstr = "/0005"; # is default string for settings. my $chsetstr = "/1005"; # string used for default change settings page # next five arrays are for each set of colour options. feel free to add to or amend these. my @bg = ('#000000', '#FFFFFF', '#0000FF', '#FFFFCC'); my @text = ('#FFFF00', '#000000', '#FFFFFF', '#000000'); my @link = ('#00FFFF', '#0000FF', '#FFFFCC', '#0000FF'); my @vlink = ('#00CCFF', '#0000CC', '#FFFF99', '#0000CC'); my @alink = ('#FFFF00', '#000000', '#FFFFFF', '#000000'); # ten fonts. again, you can change these if you like my @font_face = ("Verdana, Arial", "Times", "Courier", "Helvetica", "Arial", "Bookman Old Style", "Geneva", "Chicago", "Courier New", "System"); # VARIABLES YOU MUST SUPPLY: my $localhost = "www.newman.ac.uk"; # name of the actual machine which is localhost # (not necessarily same as server name if its virtual) my $parsecontact = "wayne.myers\@bbc.co.uk"; my @safe = qw (www.newman.ac.uk);