#!/usr/bin/perl
############################################################################################
# Change the first line of this file if the path to your perl is not /usr/bin/perl
# Example: #!/usr/local/bin/perl
############################################################################################
# FastCGI script wrapper for this web application. Require FastCGI enabled web server.
# Author: Daniel Dinev; All rights reserved (c) 2001; http://www.chatologica.com/
############################################################################################
use strict; # make Perl more strict to code
$^W = 1 if ($^O !~ /win(16|32|dows)/i); # enable warnings
$| = 1; # do not buffer the script output
BEGIN {
# Now making the current working directory to be the directory where this script resides.
# This is needed usually if the web server is IIS on Windows platform!
my $path = $0; # $0 is the full path to this script
if($path =~ m{^(.*)[/\\][^/\\]+$}) { # remove script filename from the path
$path = $1;
chdir($path) || # move to the directory of this file
print "Content-type: text/html\n\nCan't navigate to '$path' directory: $!";
};
};
use lib qw(.);
use MTS4::STD::MyCarp; # make error messages appear on browser window
use MTS4::STD::CGI_Request;
use FCGI; # load Fast CGI perl module
${${$UNIVERSAL::MTS4}{'ENV'}}{'ORG_DIE'} = $SIG{__DIE__};
my $request = FCGI::Request();
while ($request->Accept >= 0){ # wait for an incoming request
eval { # run within eval to catch CORE::die
$SIG{__WARN__} = sub {&MTS4::STD::MyCarp::CgiDie(shift @_,'WARNING')};
$SIG{__DIE__} = sub {&MTS4::STD::MyCarp::CgiDie(shift @_,'ERROR')};
my $r = new MTS4::STD::CGI_Request;
$r->process; # process this cgi request
};
$request->Flush;
$request->Finish;
};