#!/usr/bin/perl #--------------------------------------------------------- # - # Author: Mark Needham, Varcarme Ltd - # Date: January 2007 - # - #--------------------------------------------------------- #--------------------------------------------------------- # Startup - #--------------------------------------------------------- #print "Content-type: text/plain\n\n"; #print "Hello World\n\n"; #foreach $key (sort keys(%ENV)) { # print "$key = $ENV{$key}

\n"; # } #exit 0; $|=1; $sv_script = "index.pl"; #chdir '/var/www/vhosts/johncrawshaws.co.uk/httpdocs/vcsite'; require "protected/setup.pl"; require "library/subroutines.pl"; require "library/control.pl"; require "library/bespokefuncs.pl"; require "library/secimage.pl"; use CGI; use CGI::Carp qw( fatalsToBrowser ); use DBI; use MIME::Lite; #$sv_htmldebug = 1; #--------------------------------------------------------- # Main - #--------------------------------------------------------- $cgi = new CGI; $db = DBI->connect($dbiconnectstring,$dbiusername,$dbipassword); if(!$db) {errormsg("Could not connect to database.\n\nPlease contact your system administrator")} &main_init; &main_control; &main_bespokefuncs; &main_html; &main_debug; $db->disconnect; exit 0; #--------------------------------------------------------- sub main_init { #--------------------------------------------------------- $sv_debug .= ">>main_init\n"; &retrieve_parms; if ($sv_section eq 'login') {&action_logon;} &validate_cookie; if ($sv_section eq 'logout') {&action_logoff;$sv_section="index";} if ($sv_section eq "") {$sv_section="index";} $sv_debug .= ">>/main_init\n"; } #--------------------------------------------------------# sub retrieve_parms { #--------------------------------------------------------# $sv_debug .= ">>retrieve_parms\n"; $sv_session = $cgi->param('sid'); $sv_emailaddress = $cgi->param('ema'); $sv_section = $cgi->param('s'); $sv_section =~ s/_\d$//; # if _1,_2 etc on the end, ignore it. $sv_subsection = $cgi->param('ss'); $template = 'site_index'; $sv_debug .= "$sv_section\n"; $sv_debug .= ">>/retrieve_parms\n"; } #--------------------------------------------------------- sub main_html { #--------------------------------------------------------- $sv_debug .= ">>main_html\n"; &main_headers; &build_menus; # print "hello"; $template_html = template($template); $html = parse_html($template_html); $html =~ s/\&(?![\w\#]{2,6}?\;)/\&\;/ig; $html =~ s/\&\;\&\;/\&\&/ig; $html =~ s/\£/\£\;/ig; $html =~ s/\
/\/ig; $html =~ s/(\/\1 \/>/ig; $html =~ s/(\/\1 summary\="">/ig; unless ($sv_htmldebug) { $html =~ s/^\s+//mg; $html =~ s/\s+$//mg; $html =~ s/\s\s+/ /g; # $html =~ s/\<\!\-\-.*?\-\-\>//sg; $html =~ s/\n(\<\/(table|td|tr|html|head|form|a|p|div|span)>)/$1/isg; $html =~ s/\n(\<(td|tr|br|html|head|form|a |p|div|span))/$1/isg; $html =~ s/\n\s*\n/\n/sg; } print $html; $sv_debug .= ">>/main_html\n"; } #--------------------------------------------------------# sub build_menus { #--------------------------------------------------------# $tmp_main = $sv_section; } #--------------------------------------------------------- sub main_debug { #--------------------------------------------------------- $dbg_ip = $ipaddr; $dbg_cookie = $cgi->cookie('session'); foreach $key ($cgi->param()) {$dbg_parms .= "$key\=" . $cgi->param($key) . ","} $dbg_env = $ENV{'SERVER_PORT'} . "," . $ENV{'REQUEST_METHOD'}; $html = ""; print "\n"; }