in reply to Re: Perl in ISAPI
in thread Perl in ISAPI

Windows 2000, IIS 5.0. There are no event log messages or perl log messages. We put a trace statement in to dump out the html page to the event log just before the print stmt and it is the correct html and gif. It just never makes it to the browser. Code follows:
use lib "D:/WebContent/Archive/modules"; # use strict; use warnings; # use win32::EventLog; use ArchiveInput; use ArchiveOutput; use ArchiveRender; use Win32::ODBC; ###################################################################### +################################# my %in = (); my $deny = '[^a-zA-Z0-9 \-\_\/\(\)\,\.\:]'; my %clean = ( 'K', '^(-?\d{1,2})$' , # key (index) to searc +h 'Q', '^([^&=|`\x5C]{1,25})$', # query (value) to sea +rch for in key 'R', '^([^&=|`\x5C]{1,200})$', # query match to star +t list from (for scrolling through list) 'A', '^(.{1,50})$', # account number 'OA', '^(.{1,50})$', # old account number 'P', '^(\d{1,6})$', # page number 'S', '^([012345]{1})$', # size for GIF display 'D', '^(.{1,50})$', # document for account ( +typically just a date) 'DT', '^(.{1,16})$', 'DF', '^(.{1,256})$', 'DO', '^([0-9A-Z]{1,16})$', 'O', '^([0-3])$', 'F', '^([124])$', 'DB', '^([a-zA-Z0-9]{1,99})$', # CHANGE 10-20-2005 s +et DB length to 99 'I', '^([0-2])$', 'Z', '^([0-1])$', 'ARCGUID','^(.{1,100})$', #dmw - added key 'IACGUID','^(.{1,100})$', #dmw - added key 'VTGGUID','^(.{1,100})$', #dmw - added key 'SSN', '^(.{1,100})$' , 'UserID','^(.{1,100})$' , 'CaseNo','^(.{1,100})$' , ); my %default = ( 'K', '', 'Q', '', 'R', '', 'A', '', 'OA', '', 'P', 1, 'S', 1, 'D', '', 'DT', '', 'DF', '', 'DO', '', 'O', 0, 'F', 1, 'DB', '', 'I', 0, 'Z', 0, 'ARCGUID', '', #dmw - added key 'IACGUID', '', #dmw - added key 'VTGGUID', '', #dmw - added key 'SSN', 'x' , 'UserID','x' , 'CaseNo','x' , ); my $forcepdf=0; # force the documents to be shown as PDFs in an + IFRAME my $framegifs=0; # force GIFs to be displayed in IFRAMES, disables +side-by-side viewing (0=off, 1=just gif, 2=gif in relay page) my $batchselect=0; # show selection checkboxes in search results li +sting documents my %substitute = (); my $interface="agent-access.plx"; my $image="imagea.plx"; my $relay="relay.plx"; my $imgdirectory='../images'; my $advanceby=5; my $includepath = 'D:/WebContent/Archive/templates/'; my $page; my @rx=(512,640,800,1024,1280,1600); my @ry=(662,828,1035,1325,1656,2070); my @accounts; my @search; my @documents; my @reports; my $found; my $temp; my $lastpage; my $lastset; my $i; my $larger; my $smaller; my $next; my $previous; my $forward; my $backward; my $rotleft; my $rotright; my $facing; my $reportname; my $reportpage; my $reportpagecount; my $recaccount; my $recname; my $recaddress; my $reckey; my $html; my $selected; my $checkaccount; my @indexlist; my $index; my $indexfound; my $indexnumber; my $indexflags; my $indexdescription; my @databaselist; my $dbshort; my $dbdescription; my $matchvalue; my $matchaccount; my $matchdocument; my $matchtype; my $matchfile; my $matchoffset; my $matchpages; my $column; my $row; my @rowcolumns; my $searchtable = "cellpadding=\"3\" class=\"outline\""; my $searchtitle = "class=\"headers\""; my $searchrow = "bgcolor=\"#BBBBFF\""; my $linkset; my $imageurl; my $baseurl; my $input = new ArchiveInput(\%in,\%clean,\%default,$deny); my $output = new ArchiveOutput(); my $archive = new ArchiveRender("ip,7003",300); # CHANGE 10-20-2005 + Changed timeout from default 120 to 300 #added DMW ****************************************** # Init Vars my %info; my $GUID = ''; my $UserID = $ENV{HTTP_SYMUSER}; my $CaseNo = "x"; my $SSN = "x"; my $ReturnCode= 9; my $sqldatabase; my $whichguid; # my @aawevent; # Retrieve GUID from URL and set Variables; fail if no GUID if ($in{ARCGUID} ne '') { $in{DB} = "RetirementServicesStatements"; # CHANGE 10-2 +0-2005 removed access to RetAll database $GUID = $in{ARCGUID}; $whichguid = 'ARCGUID'; } elsif ($in{IACGUID} ne '') { $in{DB} = "IndividualStatements"; $GUID = $in{IACGUID}; $whichguid = 'IACGUID'; } elsif ($in{VTGGUID} ne '') { $in{DB} = "RetirementServicesStatements"; # CHANGE 10-2 +0-2005 removed access to RetAll database $GUID = $in{VTGGUID}; $whichguid = 'VTGGUID'; } else { print "Content-type: text/html\n\n"; print "Invalid Access - No GUID Supplied"; die; #where's my guid!!! } # Call SQL $sqldatabase = new Win32::ODBC("DSN=;uid=;pwd="); # Init Connecti +on if( ! $sqldatabase->Sql( "exec spf_SessionData_s02 '$GUID','$UserID',$ +CaseNo,$SSN,$ReturnCode" ) ) # Only proceed if ReturnCode is 0 { while( $sqldatabase->FetchRow() ) { $in{SSN} = $sqldatabase->Data ('SSN'); # Get SSN $in{CaseNo} = $sqldatabase->Data ('CaseNo'); #Get CaseNo ( +Account Number) $in{ReturnCode} = $sqldatabase->Data ('ReturnCode'); #Get +CaseNo (Account Number) } }else{ print "Content-type: text/html\n\n"; print "Invalid Access - Credentials cannot be verified"; $sqldatabase->Close(); # Close Database Connection # CHANGE 10 +-26-2005 die; #Bad user! No Document for you! } $sqldatabase->Close(); # Close Database Connection if ( $in{ReturnCode} == 0){ # do nothing } else { print "Content-type: text/html\n\n"; if ( $in{ReturnCode} == 1){ print "The requested customer statement is not available."; } elsif ( $in{ReturnCode} == 2){ print "The requested customer statement is not available."; } elsif ( $in{ReturnCode} == 3){ print "Session timed out. To view statements for this account p +lease start a new session by closing this window, clicking on the ‘An +other Account’ tab, and re-entering the account number."; } die; } if ($in{ARCGUID} ne '') { # If ARC, Filter results based on SSN $in{Q} = $in{SSN}; $in{K} = 5; # MDW clumsy - should just use the replace operator... replace - w +ith nothing... # my @SSNparts = (' ',' ',' '); # @SSNparts = split (/-/, $in{SSN}); # $in{SSN} = $SSNparts[0] . $SSNparts[1] . $SSNparts[2]; $in{SSN} =~ s/-//g; } elsif ($in{IACGUID} ne '') { # If IRC, Show results based on Date $in{K} = 2; } elsif ($in{VTGGUID} ne '') { # If VTG, Show results based on Date $in{K} = 2; } $in{A} = $in{CaseNo}; # Set the Account numb +er to the encoded account number # $in{OA} = $in{A}; # " $in{SSN} = ''; $in{UserID} = ''; $in{CaseNo} = ''; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # validate database parameter # @databaselist=$archive->queryExtendedDatabaseList(); # @databaselist=('mtc1;Metacode Data','afp1;AFP Data'); # @databaselist=('Contracts;Contracts','RetirementServicesStatements;S +tatements','RetirementServicesBillingStatements;Billing Statements',' +RetirementServicesCorrespondence;Correspondence','Archie;Archie','Ret +All;All'); $found='NO'; foreach $temp (@databaselist) { ($dbshort,$dbdescription)=split(/;/,$temp); if($in{DB} eq $dbshort) { $found='YES' } } if ($found ne 'YES') { ($in{DB})=split(/;/,$databaselist[0]); } $archive->setdatabase($in{DB}); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # ###################################################################### +################################# # # determine operating mode # $page='default'; $page='search'; # multiple matches if ($in{OA} ne '') { $page='view'; # we are viewing an account } else { @indexlist=$archive->queryExtendedQueryList(); if ($in{K} ne '') { $indexfound=0; foreach $index (@indexlist) { ($indexnumber,$indexflags,$indexdescription)=split(/;/,$in +dex); if($in{K}<1) { if ($indexflags=~m/w/) { $in{K}=$indexnumber; $indexfound=1; $batchselect=0; last; } } elsif($in{K} eq $indexnumber) { $indexfound=1; last; } } if($indexfound==1) { # a query was just submitted if ($indexflags=~m/h/) { # OK, can use batch selection } else { $batchselect=0; } $input->reset('OA','D','DT','DF','DO','P','B','N'); # c +lean up page display variables just in case there are any hanging aro +und if($in{R} eq "") { $in{R}=$in{Q}; } @search=$archive->queryExtendedIndexQueryWithPageCount($in +{K},$in{Q},$in{R},$in{A},""); $in{R} = ""; if ($indexflags=~m/j/ && $#search==1) { $page='view'; # single match ($matchvalue,$matchaccount,$matchdocument,$matchtype,$ +matchfile,$matchoffset)=split(/;/,$search[1]); $in{A}=$matchaccount; $in{OA}=$matchaccount; $in{D}=$matchdocument; $in{DT}=$matchtype; $in{DF}=$matchfile; $in{DO}=$matchoffset; $input->reset('K','Q','R'); } elsif ($#search<1){ $page='nomatch'; # no match } else { $page='search'; # multiple matches } } else { $batchselect=0; $indexdescription=""; } } } #print "Content-type: text/html\n\n"; #$input->dump(); #die; ###################################################################### +################################# # # get date and report list # if ($page eq 'view') { @documents=$archive->queryExtendedDocuments($in{A}); # get +list of available documents # check for valid date $found='NO'; if($in{D} ne "" && $in{DF} ne "" && $in{DO} ne "") { foreach $temp (@documents) { ($matchdocument,$matchtype,$matchfile,$matchoffset)=split( +/;/,$temp); if($in{D} eq $matchdocument && $in{DT} eq $matchtype && $i +n{DF} eq $matchfile && $in{DO} eq $matchoffset) { $found='YES'; last; } } } if($found ne 'YES') { if($in{D} ne "" && $in{DF} ne "" && $in{DO} ne "") { # a document is specified but our list may be too short to + include it # (it could also be invalid, but we have no way to detect +the difference between the two states right now) push @documents,"$in{D};$in{DT};$in{DF};$in{DO}"; } elsif ($#documents>=0) { # no document specified, choose the more recent #print "Content-type: text/html\n\n"; #print "The requested customer statement is not available."; #die; ($matchdocument,$matchtype,$matchfile,$matchoffset)=split( +/;/,$documents[0]); $in{D}=$matchdocument; $in{DT}=$matchtype; $in{DF}=$matchfile; $in{DO}=$matchoffset; } else { # no document specified, empty list of documents $input->reset('D','DF','DT','DO'); $page='nodocuments'; # dump user to no docu +ments screen } } } $lastpage=$default{'P'}; if ($page eq 'view') { @reports=$archive->queryExtendedReports($in{A},$in{D},$in{DT},$in{ +DF},$in{DO}); # get report list if ($#reports>=0) { $lastpage=shift @reports; # BSG specific, translate french characters for($i=0;$i<=$#reports;$i++) { $reports[$i]=~tr/\x82\x87\x96/\xE9\xE7\xFB/; } } else { # no report list for some reason $page='nodocuments'; # dump user to no document +s screen } } ###################################################################### +################################# # # check page related parameters # if ($in{F}<1) {$in{F}=1;} if ($in{F}>4) {$in{F}=4;} if ($in{P}<1) {$in{P}=1;} if ($in{P}>$lastpage) {$in{P}=$lastpage;} ###################################################################### +################################# # # generate new settings for buttons # $larger =$in{S}+1; if ($larger>5) {$l +arger=5;} $smaller =$in{S}-1; if ($smaller<0) {$s +maller=0;} $next =$in{P}+$in{F}; if ($next>$lastpage) {$ +next=$lastpage;} $previous =$in{P}-$in{F}; if ($previous<1) {$prev +ious=1;} $forward =$in{P}+$advanceby*$in{F}; if ($forward>$lastpage) {$ +forward=$lastpage;} $backward =$in{P}-$advanceby*$in{F}; if ($backward<1) {$ba +ckward=1;} $rotleft =$in{O}+1; if ($rotleft>3) {$rotleft=0;} $rotright =$in{O}-1; if ($rotright<0) {$rotright=3; +} $lastset =$lastpage+1-$in{F}; if ($lastset<1) +{$lastset=1;} if($in{F}==1) { $facing=2; } elsif ($in{F}==2) { $facing=4; } else { $facing=1; } ###################################################################### +################################# # # build substitution table # $input->copyto(\%substitute); $substitute{INDEXDESC} = $indexdescription; $substitute{INTERFACE} = $interface; $substitute{IMGDIR} = $imgdirectory; $substitute{PAGES} = $lastpage; $substitute{RESULTS} = $#search; $substitute{PIXELSX} = $rx[$in{S}]; $substitute{PIXELSY} = $ry[$in{S}]; $substitute{NEWSEARCH} = $interface . '?' . $input->url($whichguid +,$GUID,'S','A','DB','F'); $substitute{PDF} = $image . '?' . $input->urlwith('P',1,'N',$lastp +age,'I',0); $substitute{PDFNOBG} = $image . '?' . $input->urlwith('P',1,'N',$l +astpage,'B',0,'I',0); $substitute{TEXT} = $image . '?' . $input->urlwith('P',1,'N',$last +page,'CPIX',20,'CPIY',10,'I',0); $substitute{TARGET} = 'target="_blank"'; $substitute{ZOOMIN} = $interface . '?' . $input->urlwith('S',$larg +er); $substitute{ZOOMOUT} = $interface . '?' . $input->urlwith('S',$sma +ller); $substitute{ZOOMNORM} = $interface . '?' . $input->urlwith('S',$de +fault{S}); $substitute{FIRST} = $interface . '?' . $input->urlwith('P',1); + $substitute{LAST} = $interface . '?' . $input->urlwith('P',$lastse +t); $substitute{NEXT} = $interface . '?' . $input->urlwith('P',$next); + $substitute{PREVIOUS} = $interface . '?' . $input->urlwith('P',$pr +evious); $substitute{FASTFORWARD} = $interface . '?' . $input->urlwith('P',$for +ward); $substitute{REWIND} = $interface . '?' . $input->urlwith('P',$back +ward); $substitute{MORE} = ""; $substitute{ROTLEFT} = $interface . '?' . $input->urlwith('O',$rot +left); $substitute{ROTRIGHT} = $interface . '?' . $input->urlwith('O',$ro +tright); $substitute{ROTNORM} = $interface . '?' . $input->urlwith('O',$def +ault{O}); $substitute{FACING} = $interface . '?' . $input->urlwith('F',$faci +ng); $substitute{FLIPSIDE} = $interface . '?' . $input->urlwith('Z',1-$ +in{Z}); $substitute{ADVANCEBY} = $advanceby; $substitute{USERNAME} = $ENV{REMOTE_USER}; ###################################################################### +################################# # # generate document and report lists and image url # if($page eq 'view') { $selected=0; $substitute{DOCUMENTS}=''; foreach $temp (@documents) { ($matchdocument,$matchtype,$matchfile,$matchoffset)=split(/;/, +$temp); $substitute{DOCUMENTS}.="<option value=\"" . $interface . '?' +. $input->urlwith($whichguid,$GUID,'K','','Q','','D',$matchdocument,' +DT',$matchtype,'DF',$matchfile,'DO',$matchoffset,'P',$default{P},'N', +1) . "\""; if($in{D} eq $matchdocument && $in{DT} eq $matchtype && $in{DF +} eq $matchfile && $in{DO} eq $matchoffset) { $substitute{DOCUMENTS}.=" selected"; } if($matchtype ne "") { $substitute{DOCUMENTS}.=">" . $matchdocument . " (" . $ma +tchtype .")</option>\n"; } else { $substitute{DOCUMENTS}.=">" . $matchdocument . "</option>\ +n"; } } $reportpage=1; $substitute{REPORTS}.="<option selected></option>\n"; $substitute{PDFREPORTS}.="<option selected></option>\n"; foreach $temp (@reports) { ($reportname,$reportpagecount)=split(/;/,$temp); $substitute{REPORTS}.="<option value=\"" . $interface . '?' . +$input->urlwith($whichguid,$GUID,'P',$reportpage,'N',1) . "\">" . $re +portname . "</option>\n"; $substitute{PDFREPORTS}.="<option value=\"" . $image . '?' . $ +input->urlwith('P',$reportpage,'N',$reportpagecount) . "\">" . $repor +tname . "</option>\n"; $reportpage+=$reportpagecount; } if($#reports<0) { $page='view-noreport'; } elsif($#reports==0 && $reports[0] =~ "^Start of Document;") { $page='view-noreport'; } if($forcepdf==1) { $imageurl=$substitute{PDF}; } elsif($framegifs==2) { $imageurl=$relay . '?' . $input->urlwith('P',$in{P}+0); } else { $imageurl=$image . '?' . $input->urlwith('P',$in{P}+0); } if ($in{I}>0 || $framegifs>0 || $forcepdf==1 || $in{DT} =~ m/HTML/ +i || $in{DT} =~ m/XML/i || substr($in{DT},0,1) eq ".") { $substitute{IMAGE}="<IFRAME id=\"frameimage\" src=\"$imageurl\ +" scrolling=\"auto\" frameborder=\"1\">ERROR: your browser does not s +upport the iframe tag</IFRAME>"; } else { $substitute{IMAGE} ="<table><tr><td>"; $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$imageur +l\" border=1></a>"; if($in{F}==4 && $in{P}+3<=$lastpage) { $substitute{IMAGE}.="</td><td>"; $imageurl=$image . '?' . $input->urlwith('P',$in{P}+1); $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$ima +geurl\" border=1></a>"; $substitute{IMAGE}.="</td></tr><tr><td>"; $imageurl=$image . '?' . $input->urlwith('P',$in{P}+2); $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$ima +geurl\" border=1></a>"; $substitute{IMAGE}.="</td><td>"; $imageurl=$image . '?' . $input->urlwith('P',$in{P}+3); $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$ima +geurl\" border=1></a>"; } elsif($in{F}==4 && $in{P}+2<=$lastpage) { $substitute{IMAGE}.="</td><td>"; $imageurl=$image . '?' . $input->urlwith('P',$in{P}+1); $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$ima +geurl\" border=1></a>"; $substitute{IMAGE}.="</td></tr><tr><td>"; $imageurl=$image . '?' . $input->urlwith('P',$in{P}+2); $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$ima +geurl\" border=1></a>"; $substitute{IMAGE}.="</td><td>"; } elsif($in{F}>=2 && $in{P}+1<=$lastpage) { $substitute{IMAGE}.="</td><td>"; $imageurl=$image . '?' . $input->urlwith('P',$in{P}+1); $substitute{IMAGE}.="<a href=\"$imageurl\"><img src=\"$ima +geurl\" border=1></a>"; } $substitute{IMAGE}.="</td></tr></table>"; # $substitute{IMAGE}="<IFRAME id=\"frameimage\" src=\"$imageur +l\" scrolling=\"auto\" frameborder=\"1\">ERROR: your browser does not + support the iframe tag</IFRAME>"; } } if($page eq 'nodocuments') { @indexlist=$archive->queryExtendedQueryList(); } ###################################################################### +################################# # # built database and index drop down lists # if($page ne 'view') { $substitute{DBLIST}=''; foreach $temp (@databaselist) { ($dbshort,$dbdescription)=split(/;/,$temp); $substitute{DBLIST}.="<option value=\"" . $interface . '?' . $ +input->urlwith($whichguid,$GUID,'DB',$dbshort,'K','','Q','','R','','A +','') . "\""; if($in{DB} eq $dbshort) { $substitute{DBLIST}.=" selected"; } $substitute{DBLIST}.=">" . $dbdescription . "</option>\n"; } $substitute{SELECT}=""; foreach $index (@indexlist) { ($indexnumber,$indexflags,$indexdescription)=split(/;/,$index) +; if($indexflags=~m/i/) { # index is invisible to user, do not display } elsif($indexflags=~m/s/ && $in{A} eq '') { # account must be selected and isn't } elsif($in{K} ne '' && $indexnumber==$in{K}) { $substitute{SELECT}.="<option value=\"$indexnumber\" selec +ted>$indexdescription</option>\n"; } else { $substitute{SELECT}.="<option value=\"$indexnumber\">$inde +xdescription</option>\n"; } } } ###################################################################### +################################# # # generate search results table # if($page eq 'search') { # # build search results # $substitute{SEARCH}="<table $searchtable>\n"; $substitute{SEARCH}.="<tr>\n"; if ($batchselect==1) { $page='searchbatch'; $substitute{SEARCH}.="<td $searchtitle>Select</td>\n"; } foreach $column (split(/;/,$search[0])) { $substitute{SEARCH}.="<td $searchtitle><b>$column</b></td>\n"; } $substitute{SEARCH}.="</tr>\n"; shift @search; $baseurl=$input->myfullurl(); $baseurl=~s/interface.*$//; foreach $row (@search) { $substitute{SEARCH}.="<tr>\n"; @rowcolumns=split(/;/,$row . "_____"); # need to fo +rce split to show empty last columns $matchvalue=shift @rowcolumns; $matchaccount=shift @rowcolumns; $matchdocument=shift @rowcolumns; $matchtype=shift @rowcolumns; $matchfile=shift @rowcolumns; $matchoffset=shift @rowcolumns; $matchpages=shift @rowcolumns; $linkset=0; # batch print: if ($batchselect==1) { $substitute{SEARCH}.="<td $searchrow align=\"center\"><inp +ut type=\"checkbox\" name=\"PDF\" value=\""; $substitute{SEARCH}.=$baseurl . $image . '?' . $input->url +with($whichguid,$GUID,'K','','Q','','A',$matchaccount,'OA',$matchacco +unt,'D',$matchdocument,'DT',$matchtype,'DF',$matchfile,'DO',$matchoff +set,'N','100') . "\""; if($matchtype eq "HTML" || $matchtype eq "XML") { $substitute{SEARCH}.=" output=\"HTML\""; } else { $substitute{SEARCH}.=" output=\"PDF\""; } $substitute{SEARCH}.=" account=\"" . $matchaccount . "\" d +ocument=\"" . $matchdocument . "\" pages=\"" . $matchpages . "\">"; } foreach $column (@rowcolumns) { if($column eq "_____") { last; } if($linkset==1) { $substitute{SEARCH}.="<td $searchrow>$column</td>\n"; } else { $substitute{SEARCH}.="<td $searchrow><a href=\"" . $in +terface . '?' . $input->urlwith($whichguid,$GUID,'K','','Q','','A',$m +atchaccount,'OA',$matchaccount,'D',$matchdocument,'DT',$matchtype,'DF +',$matchfile,'DO',$matchoffset) . "\">$column</a></td>\n"; $linkset=1; } } $substitute{SEARCH}.="</tr>\n"; } $substitute{SEARCH}.="</table>\n"; if($matchvalue ne '' && $#search>=29) { $temp=$interface . '?' . $input->urlwith($whichguid,$GUID,'R', +$matchvalue); $substitute{MORE}="<a href=\"$temp\">More</a>"; } } ###################################################################### +################################# # # generate the html using the html templates and substitution table # $html=$output->page($page,$includepath,\%substitute); print $html; #print "Content-type: text/html\n\n"; #$input->dump();