{ use lib "$ENV{PRODUCT_ROOT}/homepage/current/layout/show/lib"; use definitions qw( %MenuColor %BkgColor ); # for default and sareas definition (color, look-and-feel, etc...) $server_name = $ENV{'WWW_HOST'}; $title = $this->the('title') || 'Elsevier Science'; $main = $method = ''; $framed = $this->the('framed') || ''; $sarea = lc the('sarea') || ''; $mode = lc the('mode') || ''; #$jobref = the('ref') || ''; for frame only - not used yet.. $key = the('key') || ''; if (($sarea eq '') && ($key =~ m/^s(\w+)$/i)) { $sarea = lc $1; } # default to "sarea = saa" in the 'prgm' mode $sarea = 'saa' if (($mode eq 'prgm') && ($sarea eq '')); $new_arguments = arguments; unless ($main = the('main')) { # Do we want a form? my $form = the('form') || $this->the('form'); if ($form) { $main = '/cgi-bin/homepage/guestbook/formhandler.cgi'; my (%temp) = %{$new_arguments}; $temp{'action'} = 'index.htt'; $temp{'form'} = $form; $new_arguments = \%temp; $method = 'exec'; # Embed a simple file? } elsif ($main = the('file')) { $method = 'embed'; } else { my $modes = $this->the('modes'); if (ref $modes eq 'HASH') { #my $mode = the('mode'); unless ( $mode && $modes->{$mode}) { $mode = $this->the('mode'); } my $ref = $modes->{$mode}; ($main, $method, $framed) = @{$ref}; } } } unless (defined $main) { $main = $this->the('main'); $method = $this->the('method'); } # this is to use the default color scheme for the search - do not pass it in this case $sarea = '' if (($method eq 'exec') && ($main eq '/cgi-bin/inca/search/search.cgi')); ""; }>
| { embed (\'/homepage/layout/frames/topframe.htt', {'framed' => '0', 'sarea' => $sarea}) }> | |
| { embed_mold (\'show/menu.htt', {'sarea' => $sarea, 'mode' => $mode}, $this); }> |
{
use IPC::Open2;
use STEALTH::CGI;
use Cwd;
use File::Basename;
sub URL_Encode {
my ($argref) = @_ ;
my @encoded ;
my ($name, $value) ;
while (($name, $value) = each %$argref) {
$name =~ s/^@// ;
if (ref $value) {
if (ref($value) eq 'ARRAY') {
my $item ;
for $item (@$value) {
push @encoded,
$name . '=' . &STEALTH::CGI::cgi_encode($item) ;
}
}
} else {
push @encoded, $name . '=' . &STEALTH::CGI::cgi_encode ($value);
}
}
join('&', @encoded) ;
}
sub _cgi_post {
my ($cgi_cmd, $cgi_args) = @_;
my $post_string = URL_Encode($cgi_args);
my $dir = cwd();
# $ENV{'REQUEST_METHOD'} = 'POST';
# No need to post as the direct exec that we do of the CGI here does not have the
# usual GET limitations
$ENV{'REQUEST_METHOD'} = 'GET';
$ENV{'CONTENT_TYPE'} = 'application/x-www-form-urlencoded';
$ENV{'CONTENT_LENGTH'} = length $post_string;
$ENV{'QUERY_STRING'} = $post_string;
# $ENV{'QUERY_STRING'} = '';
$ENV{'SCRIPT_NAME'} = $cgi_cmd;
my $cgi_root = $ENV{'DOCUMENT_ROOT'};
# make this work for optional trailing slash
$cgi_root =~ s:/content/?$::;
$cgi_root = initial grep { -d $_ . '/cgi-bin' }
($cgi_root, '/server/www', '/server/accept');
$cgi_cmd = $cgi_root . $cgi_cmd;
chdir (dirname ($cgi_cmd));
local (*FH, *PFH);
unless (open2 \*FH, \*PFH, $cgi_cmd) {
::error "page.htt could not start $cgi_cmd: $!";
return;
}
# print PFH $post_string;
1 while (scalar " . "NOT DEFINED - ERROR" if (! $MainText); $MainText } elsif ($method eq 'POST') { # now post a request and display the content my $res = ''; eval { use HTTP::Request::Common qw(POST); use LWP::UserAgent; *IO::Select::DESTROY = sub {} unless defined &IO::Select::DESTROY; *HTTP::Headers::DESTROY = sub {} unless defined &HTTP::Headers::DESTROY; my $ua = new LWP::UserAgent; my $URL = "http://$server_name$main"; my $req = POST $URL, $new_arguments; my $response = $ua->request($req); if ($response->is_success) { $res = $response->content; } else { $res = $response->error_as_HTML; } undef $response; undef $req; }; $res; } elsif ($method eq 'exec') { join ('', _cgi_post ($main, $new_arguments)); } elsif ($method eq 'embed') { embed(\$main, $new_arguments); } }> |