package usabcgi; sub get_config_info { open FILEIN, ("gsdlsite.cfg") || die "ERROR: Could not open site configuration file\n"; my $configfile; while() { $configfile .= $_; } close(FILEIN); ($infotype) = @_; $configfile =~ /^$infotype\s+(\S+)\s*\n/m; $loc=$1; $loc =~ s/\"//g; return ($loc); } sub get_httpimg { my ($imageloc) = usabcgi::get_config_info("httpimg"); if(!($imageloc =~ "http")) {$imageloc="http://".$ENV{HTTP_HOST}.$imageloc;} return $imageloc; } sub get_httpusab { my ($htmlloc) = usabcgi::get_config_info("httpimg"); if(!($htmlloc =~ "http")) {$htmlloc="http://".$ENV{HTTP_HOST}.$htmlloc;} $htmlloc =~ s/images/usability/; return $htmlloc; } sub printscript { print "\n"; } sub printbanner { ($title)=@_; ($imageloc) = usabcgi::get_httpimg(); print "\n\n"; print "\n

Greenstone Usability - $title

"; if ($imageloc) { print "\"Greenstone"; } print "
"; } sub printaplinks { # this is a hack ($htmlloc) = usabcgi::get_httpusab(); print "

\n"; print "About\n • Privacy\n"; } sub printstyle { ($browser) = @_; $browser=~/([^\/]*)\/([0-9]+\.[0-9]+)/; if(($1 ne "Netscape")||($2 > 4.77)){ print "\n"; } } sub checkidno { if((!($ENV{QUERY_STRING}=~/\d/)) || ($ENV{QUERY_STRING}=~/\D/) ) { print "

Each report sent has an ID number. This page needs one of those numbers to work.

\n"; print "

Contact us with any queries about this.\n"; print "\n"; die; } } sub getusabreportdetails { ($etcfileloc) = usabcgi::get_config_info("gsdlhome"); if(!($etcfileloc =~/\/$/)) {$etcfileloc.="/";} $etcfileloc .= "etc/usability.txt"; open (FILEIN, $etcfileloc) or die "could not open usability.txt\n"; while(){ $etcfile.=$_; } close(FILEIN); if(!($etcfile=~ / $ENV{QUERY_STRING}\&usabend;/)) { print "

Each report has an ID number. This program needs one of those ID numbers to work, and the ID number provided wasn't found.

\n"; print "

Contact us with any queries about this.\n"; print ""; die; } #get the report for whjich details are to be viewed. $etcfile=~/report-id := $ENV{QUERY_STRING}\&usabend\;\n/; $report = $&; $tmp=$'; $tmp=~/----------------------?/; $report.=$`; @pairs=split(/\&usabend\;\n/,$report); foreach $pair (@pairs) { ($name, $value)= split(/ := /,$pair); #this splits long values up for display purposes @tmplist = split(/ /,$value); foreach $item (@tmplist){ if(length $item > 60){ $tmp=""; while(length $item > 60){ $tmp.= substr $item, 0, 60; $tmp.=" "; $item = substr $item, 60; } $tmp.=$item; $item=$tmp; } } $value = join(' ',@tmplist); #this adds html tags for breaks $value =~ s/\n/\\n/g; $reportvals{$name}=$value; } return %reportvals; } 1;