Hi friends,
i have a problem with the following script. Could you please correct this. It is indeed very urgent please look in to this.
I am calling this script on server X and this would inturn call server Y. this script should get the script from the server Y and display to the users of server Y. But, I am finding lot many errors in the script. I donno any thing about the CGI Scripting. Could you please fix this.
Thanks
#!"C:\Server\xampp\perl\bin\perl.exe"
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use CWT::MySQL;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
my $cwt = new CWT::MySQL();
my $url = $cwt->url;
my $cgi = new CGI;
$cwt->set( page_title => "CAVE Software");
my $action = $cwt->param('action');
# Function map for setting permissions and for specifying the action buttons
my %FunctionMap = (
SHOW_INDEX => { ROLES => [] },
SHOW_LOAD => { ROLES => [] },
SHOW_ML => { ROLES => [] },
SUBMIT_FORM => { ROLES => [] },
AUTO => { ROLES => [] },
SHOW_ETOOLS => { ROLES => [] },
);
#
# Map verbose parameter names into short versions and set the command
# to 'AUTO' if it isn't defined in the FunctionMap.
#
my $cmd = $cwt->param('CMD') || 'AUTO';
foreach (keys %FunctionMap) {
$cmd = $_ if ($cmd eq $FunctionMap{$_}{BUTTON});
}
$cmd = 'AUTO' unless defined $FunctionMap{$cmd};
$cwt->set( MAN_SECTION => $cmd );
#
# Send'em packin' if they don't have permission to see this function.
#
$cwt->require_role($FunctionMap{$cmd}{ROLES});
print $cwt->header();
print $cwt->start_html();
print $cgi->header();
print $cgi->start_html(-title=>"CAVE Software");
#
# SHOW_INDEX -- to see index.php
#
if ($cmd eq 'SHOW_INDEX') {
show_index();
#
#SHOW_ML
#
} elsif ($cmd eq 'SHOW_ML'){
show_ml();
#
#SHOW_LOAD
#
} elsif ($cmd eq 'SHOW_LOAD'){
show_load();
#
# SUBMIT_FORM
#
} elsif ($action) {
submit_form();
#
# AUTO -- Automatic function (if no CMD is given)
#
} elsif ($cmd eq 'AUTO') {
main_links();
#
# DEFAULT - Should never get here (AUTO should be the default if the entered
# parameter is not recognized).
#
} elsif ($cmd eq 'SHOW_ETOOLS') {
show_etools();
}
else {
print qq{<P>Invalid command ($cmd)};
}
#print $cwt->end_html();
print $cgi->end_html();
exit 0;
sub show_etools
{
print qq{<h1> I AM HERE </h1>};
$q = new CGI;
print $q->redirect("http://aristotle.eng.auburn.edu/version9/index.php");
}
####################################
# show_index
####################################
sub show_index
{
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get('http://aristotle.eng.auburn.edu/Version2/statistical/index.php');
if ($response->is_success) {
print $response->content;
}else{
die $response->status_line;
}
}
####################################
# show_ml
####################################
sub show_ml
{
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get('http://aristotle.eng.auburn.edu/Version3/MatDB/fload.php');
if ($response->is_success) {
print $response->content;
}else{
die $response->status_line;
}
}
####################################
# show_load
####################################
sub show_load
{
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get('http://aristotle.eng.auburn.edu/Version3/EnvDB/load.php');
if ($response->is_success) {
print $response->content;
}else{
die $response->status_line;
}
}
####################################
# submit_form
####################################
sub submit_form
{
my %form;
my $pars;
my $temp;
foreach my $p (param()) {
$form{$p} = param($p);
$temp = $form{$p};
$pars .= qq{$p=>"$temp",};
}
my $faction = qq{http://aristotle.eng.auburn.edu};
$faction .= $action;
my $ua=LWP::UserAgent->new();
my $req= POST "$faction",Content=>\%form;
my $content=$ua->request($req);
if ($content->is_success){
print $content->content;
}else{
print $content->status_line . "\n";
}
}
####################################
# main_links
####################################
sub main_links
{
print qq{<p><table align="center" width="100%"><tr><td>\n};
print qq{<table border="0" cellpadding="4" cellspacing="4" width="90%">\n};
print qq{<center><font size=+3>CAVE Software</font></center>};
print qq{<tr><td><br><ul>\n};
print qq{<li>\n};
print qq{<a href="http://aristotle2.eng.auburn.edu/version10/index.php">Click to use eTools</a></li>\n};
print qq{</li></ul></td></tr></table>\n};
print qq{</td></tr></table>\n};
}
------WebKitFormBoundary1cYMdngFzste8gxM
Content-Disposition: form-data; name="Item.Attachment.unused"
0