##################################################
## This module is not Object Oriented
## It merely contains general utility subroutines used
## in DLPS middleware
package DlpsUtils;
use Exporter ( );
@ISA = qw( Exporter );
@EXPORT = qw( SortUniquifyList
PrintStringToFile
TrimSpaces
errorBail
GetParallelHash
Min
Max
GetHtmlTemplateText
OutputHtmlPage
OutputMimeTypedPage
StartHtmlPage
FinishPage
SetupHtmlDebugging
CollectionResolution
Flatten8bitChars
SimpleHtmlFilter
CleanResidualTags
FilterCharEnts_All
GetIntersection
GetNWayIntersection
CleanCgiParameters
FindHostName
StartSession
BuildPullDown
BuildSelect
BuildTextInput
);
use CGI;
use DlpsSession;
# ----------------------------------------------------------------------
# NAME : Flatten8bitChars
# PURPOSE : obvious
# CALLED BY : ANY
# CALLS : NONE
# INPUT : scalar
# RETURNS : scalar flattened
# GLOBALS : NONE
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub Flatten8bitChars
{
my $w = shift;
$w =~ tr/ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåçèéêëìíîïñòóôõöøùúûüý>/aaaaaaceeeeiiiinoooooouuuuysaaaaaaceeeeiiiinoooooouuuuyy/;
return $w;
}
# ----------------------------------------------------------------------
# NAME : Max
# PURPOSE : obvious
# CALLED BY : ANY
# CALLS : NONE
# INPUT : 2 scalar values which can be compared numerically
# RETURNS : the Max of the two values
# GLOBALS : NONE
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub Max
{
my ( $a, $b ) = @_;
return $b if ( $b > $a );
return $a;
}
# ----------------------------------------------------------------------
# NAME : Min
# PURPOSE : obvious
# CALLED BY : ANY
# CALLS : NONE
# INPUT : 2 scalar values which can be compared numerically
# RETURNS : the Min of the two values
# GLOBALS : NONE
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub Min
{
my ( $a, $b ) = @_;
return $b if ( $b < $a );
return $a;
}
# ----------------------------------------------------------------------
# NAME : GetAuthListFromENV
# PURPOSE : concat the restricted and public envvars, strip '-dev'
# and split into a list
# CALLED BY : ANY
# CALLS : NONE
# INPUT : NONE
# RETURNS : list of authorized collections
# GLOBALS : $ENV
# SIDE-EFFECTS : NONE
# NOTES : -dev is for development
# ----------------------------------------------------------------------
sub GetAuthListFromENV
{
my $env = $ENV{'AUTHZD_COLL'} . $ENV{'PUBLIC_COLL'};
$env =~ s,-dev,,g;
$env =~ s,^[\s:],,;
$env =~ s,[\s:]$,,;
return split( /:/, $env );
}
# ----------------------------------------------------------------------
# NAME : SortUniquifyList
# PURPOSE : sort and uniq any list (alphabetically by default,
# numerically if any second param with any value at all is passed in)
# CALLED BY : ANY
# CALLS : NONE
# INPUT : reference to an array
# RETURNS : NONE
# GLOBALS :
# SIDE-EFFECTS : changes array via reference
# NOTES :
# ----------------------------------------------------------------------
sub SortUniquifyList
{
my ( $aRef, $numeric ) = @_;
my %hash;
foreach my $item ( @$aRef )
{ $hash{$item}++; }
if ( defined ( $numeric ) )
{
@$aRef = sort { $a <=> $b } ( keys %hash );
}
else
{
@$aRef = sort ( keys %hash );
}
}
# ----------------------------------------------------------------------
# NAME : OutputHtmlPage
# PURPOSE :
#
# CALLED BY :
# CALLS :
# INPUT : ref to string of entire html to print
# RETURNS : NONE
# GLOBALS :
# SIDE-EFFECTS : prints to STDOUT
# NOTES :
# ----------------------------------------------------------------------
sub OutputHtmlPage
{
my $sRef = shift ;
# print out html header
print &CGI::header(
-type => 'text/html'
);
# mod_perl version of same ( not sure this will be ever be needed )
# $gReq->content_type( 'text/html' );
# $gReq->send_http_header;
# return "OK" if $gReq->header_only;
print $$sRef;
}
# ----------------------------------------------------------------------
# NAME : OutputMimeTypedPage
# PURPOSE :
#
# CALLED BY :
# CALLS :
# INPUT : ref to string of entire content to print, mime type,
# and value for "expires" (usually 'now')
# RETURNS : NONE
# GLOBALS :
# SIDE-EFFECTS : prints to STDOUT
# NOTES :
# ----------------------------------------------------------------------
sub OutputMimeTypedPage
{
my ( $sRef, $mimeType ) = @_;
# print out header
print &CGI::header(
-type => $mimeType,
-expires => 'now'
);
# print page
print $$sRef;
}
# ----------------------------------------------------------------------
# NAME : DumpEnvVars
# PURPOSE : print HTML dump of all environment variables
# CALLED BY : debugging routines
# CALLS :
# INPUT :
# RETURNS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub DumpEnvVars
{
my $s = '';
$s .= q{} .
&CGI::h2(qq{ENVIRONMENT VARIABLES})
. q{};
foreach my $key (sort keys %ENV)
{
$s .= qq{$key } . qq{$ENV{$key}
\n};
}
return ( $s );
}
# ----------------------------------------------------------------------
# NAME : errorBail
# PURPOSE : an enhanced bail function
# CALLED BY : various
# CALLS :
# INPUT : zero or more strings to be printed as error messages to
# the web browser
# RETURNS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub errorBail
{
my( @errors ) = @_;
my $s = '';
$s .= &StartHtmlPage ( 'DLPS Error Page', '#FFFFFF' );
$s .= join( "\n", @errors );
$s .= &FinishPage;
&OutputHtmlPage ( \$s );
exit;
}
# ----------------------------------------------------------------------
# NAME : StartHtmlPage
# PURPOSE : print HTML title and header
# CALLED BY : main
# CALLS : Apache::Request->print
# INPUT : request object
# RETURNS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub StartHtmlPage
{
my ( $title, $color ) = @_;
my $s = '';
$s .= &CGI::start_html( -title => $title,
-bgcolor => $color
);
return $s;
}
# ----------------------------------------------------------------------
# NAME : FinishPage
# PURPOSE : print HTML to close body and html
# CALLED BY : main
# CALLS : CGI::end_html
# INPUT : NONE
# RETURNS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub FinishPage
{
return ( &CGI::end_html );
}
# ----------------------------------------------------------------------
# NAME :
# PURPOSE :
#
# CALLED BY :
# CALLS :
# INPUT :
# RETURNS :
# GLOBALS :
# SIDE-EFFECTS :
# NOTES :
# ----------------------------------------------------------------------
sub SetupHtmlDebugging
{
my $debugVal = shift;
$ENV{'DEBUG'} = $debugVal;
print &CGI::header(
-type => 'text/html'
);
print &DlpsUtils::StartHtmlPage ( 'DEBUG', '#FFFFFF' );
}
# ----------------------------------------------------------------------
# NAME : CollectionResolution
# PURPOSE : set up authorized and requested collection arrays
# CALLED BY : main
# CALLS : NONE
# INPUT : NONE
# RETURNS :
# GLOBALS : eventually uses Environment variable set by Auth System
# SIDE-EFFECTS : sets globals @gRequestedColls, @gAuthzdColls ( sorted and
# and uniq-ed from here on out
# NOTES : currently hard coded authzd collections
# ----------------------------------------------------------------------
sub CollectionResolution
{
my ( $cgi, $authzdCollsRef ) = @_;
my @RequestedColls = $cgi->param( 'c' );
if ( !defined( @RequestedColls ) ||
scalar ( @RequestedColls ) == 0 )
{ @RequestedColls = @$authzdCollsRef; }
# uniquify lists
&SortUniquifyList ( $authzdCollsRef );
&SortUniquifyList ( \@RequestedColls );
# set requested colls to only those they requested that are also authorized
@RequestedColls = &GetIntersection ( $authzdCollsRef, \@RequestedColls );
# overwrite the query string's collections with the updated list of requested ones
$cgi->param( 'c', @RequestedColls );
return ( @RequestedColls );
}
# ----------------------------------------------------------------------
# NAME : GetParallelHash
# PURPOSE : buils a hash from two parallel arrays using the first
# array to key the second array
# CALLED BY : clients
# CALLS : NONE
# INPUT : references to two lists
# RETURNS : hash
# GLOBALS : NONE
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub GetParallelHash
{
my ( $aRef1, $aRef2 ) = @_;
my ( %hash, $i );
foreach my $item ( @$aRef1 )
{
$hash{$item} = @$aRef2[$i++];
}
return %hash;
}
# ----------------------------------------------------------------------
# NAME : GetIntersection
# PURPOSE : get the intersection of two uniqued lists
# CALLED BY : CollectionResolution
# CALLS : NONE
# INPUT : references to two lists
# RETURNS : list of intersection of the two lists
# GLOBALS : NONE
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub GetIntersection
{
my ( $aRef1, $aRef2 ) = @_;
my @a = @$aRef1;
my @b = @$aRef2;
my @toReturn = ( );
foreach my $item ( @a )
{
push ( @toReturn, grep ( /^$item$/, @b ) );
}
return ( @toReturn );
}
# ----------------------------------------------------------------------
# NAME : GetNWayIntersection
# PURPOSE : get the intersection of N uniqued lists
# CALLED BY : clients
# CALLS : GetIntersection
# INPUT : reference to list of references to N lists
# RETURNS : list of common elements across N lists
# GLOBALS : NONE
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub GetNWayIntersection
{
my $setOfSetRefsRef = shift;
my @nWayIntersection = @{ pop( @$setOfSetRefsRef ) };
SETLOOP:
while ( @$setOfSetRefsRef )
{
@nWayIntersection =
&GetIntersection( pop( @$setOfSetRefsRef ), \@nWayIntersection );
if ( scalar( @nWayIntersection ) == 0 )
{
last SETLOOP;
}
}
# now uniquify list
&SortUniquifyList ( \@nWayIntersection );
return ( @nWayIntersection );
}
# ----------------------------------------------------------------------
# NAME : CleanCgiParameters
# PURPOSE : remove all empty URL parameters
# CALLED BY :
# CALLS : CGI->param, CGI->delete
# INPUT : CGI object
# RETURNS : NONE
# GLOBALS :
# SIDE-EFFECTS : changes CGI object
# NOTES :
# ----------------------------------------------------------------------
sub CleanCgiParameters
{
my $cgi = shift;
foreach my $p ( $cgi->param )
{
if ( !$cgi->param( $p ))
{ $cgi->delete( $p ); }
}
}
# ----------------------------------------------------------------------
# NAME : BuildText
# PURPOSE : use CGI to create a text input box
# CALLED BY :
# CALLS :
# INPUT :
# RETURNS :
# GLOBALS :
# SIDE-EFFECTS :
# NOTES :
# ----------------------------------------------------------------------
sub BuildTextInput
{
my ( $cgi, $name, $piParamsRef ) = @_;
my $s = '';
my ( $size, $class, $default, $override );
if ( exists ( $$piParamsRef{'size'} ) )
{ $size = $$piParamsRef{'size'} ; }
if ( exists ( $$piParamsRef{'class'} ) )
{ $class = $$piParamsRef{'class'} ; }
if ( exists ( $$piParamsRef{'default'} ) )
{
$default = $$piParamsRef{'default'} ;
$override = 1 ;
}
# $s .= qq{
\n} if ( $class );
$s .= $cgi->textfield (
-name => $name,
-size => $size,
-class => $class,
-default => $default,
-override => $override,
);
# $s .= qq{
\n} if ( $class );
return $s;
}
# ----------------------------------------------------------------------
# NAME : BuildSelect
# PURPOSE : use CGI to create a "popup menu"
# CALLED BY : FilterCollPickPage
# CALLS : CGI->popup_menu
# INPUT : CGI obj, select's name, ref to list of values, default value
# RETURNS : html text for select
# GLOBALS :
# SIDE-EFFECTS :
# NOTES :
# ----------------------------------------------------------------------
sub BuildSelect
{
my ( $cgi, $name, $listRef, $default, $size, $multiple ) = @_;
my $s;
if ( $size == 1 )
{
$s = $cgi->popup_menu(
-name => $name,
-values => $listRef,
-default => $default,
);
}
elsif ( ! defined ($multiple) )
{
$s = $cgi->scrolling_list(
-name => $name,
-values => $listRef,
-default => $default,
-size => $size,
);
}
else
{
$s = $cgi->scrolling_list(
-name => $name,
-values => $listRef,
-default => $default,
-size => $size,
-multiple => $multiple
);
}
return $s;
};
# ----------------------------------------------------------------------
# NAME : BuildPullDown
# PURPOSE : use CGI to create a "popup menu"
# CALLED BY : FilterCollPickPage
# CALLS : CGI->popup_menu
# INPUT : CGI obj, select's name, ref to list of values, default value
# RETURNS : html text for select
# GLOBALS :
# SIDE-EFFECTS :
# NOTES : This routine ALWAYS expects a labels hash
# ----------------------------------------------------------------------
sub BuildPullDown
{
my ( $cgi, $name, $listRef, $default, $labelsHashRef, $otherParamsHashRef ) = @_;
my $s = '';
if ( defined ( $otherParamsHashRef ) )
{
$s = $cgi->popup_menu(
-name => $name,
-values => $listRef,
-default => $default,
-labels => $labelsHashRef,
%$otherParamsHashRef,
);
}
else
{
$s = $cgi->popup_menu(
-name => $name,
-values => $listRef,
-default => $default,
-labels => $labelsHashRef,
);
}
return $s;
}
# **********************************************************************
# NAME : GetHtmlTemplateText
# PURPOSE : read into scalar full text of an html template page
# also fill in some values for some general variables
# CALLED BY : ServePage
# CALLS : NONE
# INPUT : filename of html template
# RETURNS : scalar of template's text
# NOTES :
# **********************************************************************
sub GetHtmlTemplateText
{
my $pageName = shift;
open( PAGE, "<$pageName" ) ||
&errorBail( $gERRORS{'PAGE_NOT_FOUND'}, $pageName );
my $text = join( '', );
close ( PAGE );
return $text;
}
# ----------------------------------------------------------------------
# NAME : FindHostName
# PURPOSE : find the name of the host that is running this program, or
# set it to something in case we are running on the command line
# CALLED BY : main
# CALLS : NONE
# INPUT : NONE
# RETURNS : string
# GLOBALS : $ENV vars
# SIDE-EFFECTS : NONE
# NOTES :
# ----------------------------------------------------------------------
sub FindHostName
{
my $host = '';
if ( $ENV{'HTTP_HOST'} )
{
$host = $ENV{'HTTP_HOST'};
}
## if run on the command line
else
{
$host = $ENV{'HOST'};
}
return $host;
}
# ----------------------------------------------------------------------
# NAME : SimpleHtmlFilter
# PURPOSE : replace <, >, and & with entity references; nothing more
#
# CALLED BY :
# CALLS :
# INPUT : ref to string
# RETURNS : NONE
# GLOBALS :
# SIDE-EFFECTS : changes string via reference
# NOTES :
# ----------------------------------------------------------------------
sub SimpleHtmlFilter
{
my $sRef = shift;
$$sRef =~ s,\&,\&\;,gs;
$$sRef =~ s,\<,\<\;,gs;
$$sRef =~ s,\>,\>\;,gs;
}
# ----------------------------------------------------------------------
# NAME : CleanResidualTags
# PURPOSE :
#
# CALLED BY :
# CALLS :
# INPUT :
# RETURNS :
# GLOBALS :
# SIDE-EFFECTS :
# NOTES :
# ----------------------------------------------------------------------
sub CleanResidualTags
{
my $sRef = shift;
$$sRef =~ s,?TITLE[^>]*>,
,g;
$$sRef =~ s,]*>,: ,g;
$$sRef =~ s,^[^<>]*>, ,;
$$sRef =~ s,<[^<>]*$, ,;
$$sRef =~ s,, / ,g;
$$sRef =~ s,, ,g;
$$sRef =~ s,
, / ,g;
$$sRef =~ s,?[A-Z0-9][^<>]+>, ,g;
}
# ----------------------------------------------------------------------
# NAME :
# PURPOSE :
#
# CALLED BY :
# CALLS :
# INPUT :
# RETURNS :
# GLOBALS :
# SIDE-EFFECTS :
# NOTES : This copied from gums-idx.dev
# -----------------------------------------------------------------------
my $icons = '/icons';
my $greek = $icons . '/greek'; # no trailing slash here
my $grol = $icons . '/grol'; # no trailing slash here
my $misc = $icons . '/misc'; # no trailing slash here
my %charEntHash_CH_Greek; # Chadwick-Healey
my %charEntHash_Misc;
my %charEntHash_ISO_Greek;
sub InitCharEntHash_CH_Greek
{
%charEntHash_CH_Greek =
('initzzz' => "1",
'grdot' => ".",
'GRAa' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAc' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAd' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAg' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAr' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAra' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRArg' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAs' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAsa' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAsc' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GRAsg' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'GREa' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GREd' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GREr' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GREra' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GREs' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GREsa' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GREsc' => "![\"[Egr]\"](../%5C%22$greek/Egr.gif%5C%22)
",
'GRHc' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHg' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHr' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHra' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHrc' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHrg' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHs' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHsa' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHsc' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRHsg' => "![\"[EEgr]\"](../%5C%22$greek/EEgr.gif%5C%22)
",
'GRIa' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIc' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIg' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIr' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIra' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIrg' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIs' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIsa' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GRIsc' => "![\"[Igr]\"](../%5C%22$greek/Igr.gif%5C%22)
",
'GROa' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROar' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROdc' => "![\"[Ocirgr]\"](../%5C%22$greek/Ocirgr.gif%5C%22)
",
'GROg' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROr' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROra' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROrg' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROs' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROsa' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GROsc' => "![\"[Ogr]\"](../%5C%22$greek/Ogr.gif%5C%22)
",
'GRRr' => "![\"[Rgr]\"](../%5C%22$greek/Rgr.gif%5C%22)
",
'GRRs' => "![\"[Rgr]\"](../%5C%22$greek/Rgr.gif%5C%22)
",
'GRST' => "
",
'GRUa' => "![\"[Ugr]\"](../%5C%22$greek/Ugr.gif%5C%22)
",
'GRUr' => "![\"[Ugr]\"](../%5C%22$greek/Ugr.gif%5C%22)
",
'GRUra' => "![\"[Ugr]\"](../%5C%22$greek/Ugr.gif%5C%22)
",
'GRUs' => "![\"[Ugr]\"](../%5C%22$greek/Ugr.gif%5C%22)
",
'GRWc' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWcs' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWd' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWia' => "![\"[OHacugr]\"](../%5C%22$greek/OHacugr.gif%5C%22)
",
'GRWr' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWra' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWrc' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWrg' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWs' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWsa' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'GRWsc' => "![\"[OHgr]\"](../%5C%22$greek/OHgr.gif%5C%22)
",
'grA' => "
",
'grAs' => "![\"[Agr]\"](../%5C%22$greek/Agr.gif%5C%22)
",
'grB' => "
",
'grC' => "
",
'grD' => "
",
'grE' => "
",
'grF' => "
",
'grG' => "
",
'grH' => "
",
'grI' => "
",
'grK' => "
",
'grL' => "
",
'grM' => "
",
'grN' => "
",
'grO' => "
",
'grP' => "
",
'grQ' => "
",
'grR' => "
",
'grS' => "
",
'grST' => "
",
'grT' => "
",
'grU' => "
",
'grV' => "
",
'grW' => "
",
'grX' => "
",
'grY' => "
",
'grZ' => "
",
'gra' => "
",
'graa' => "
",
'graad' => "![\"[aacugr]\"](../%5C%22$greek/aacugr.gif%5C%22)
",
'grac' => "
",
'gracd' => "![\"[acirgr]\"](../%5C%22$greek/acirgr.gif%5C%22)
",
'graci' => "
",
'gracs' => "
",
'grad' => "![\"[agr]\"](../%5C%22$greek/agr.gif%5C%22)
",
'gradc' => "![\"[acirgr]\"](../%5C%22$greek/acirgr.gif%5C%22)
",
'grag' => "
",
'grai' => "
",
'graia' => "
",
'graic' => "
",
'grais' => "
",
'graisa' => "
",
'grap' => "
",
'grar' => "
",
'grara' => "
",
'grarg' => "
",
'gras' => "
",
'grasa' => "
",
'grasad' => "![\"[asagr]\"](../%5C%22$greek/asagr.gif%5C%22)
",
'grasc' => "
",
'grasci' => "
",
'grasd' => "![\"[asmogr]\"](../%5C%22$greek/asmogr.gif%5C%22)
",
'grasg' => "
",
'grasi' => "
",
'grasia' => "
",
'grb' => "
",
'grc' => "
",
'grcolon' => "
",
'grd' => "
",
'gre' => "
",
'grea' => "
",
'gread' => "![\"[eacugr]\"](../%5C%22$greek/eacugr.gif%5C%22)
",
'grec' => "![\"[egr]\"](../%5C%22$greek/egr.gif%5C%22)
",
'grecs' => "![\"[esmogr]\"](../%5C%22$greek/esmogr.gif%5C%22)
",
'gred' => "![\"[egr]\"](../%5C%22$greek/egr.gif%5C%22)
",
'greda' => "![\"[eacugr]\"](../%5C%22$greek/eacugr.gif%5C%22)
",
'gredg' => "![\"[egragr]\"](../%5C%22$greek/egragr.gif%5C%22)
",
'greg' => "
",
'grei' => "![\"[egr]\"](../%5C%22$greek/egr.gif%5C%22)
",
'grer' => "
",
'grera' => "
",
'grerg' => "
",
'gres' => "
",
'gresa' => "
",
'gresad' => "![\"[esagr]\"](../%5C%22$greek/esagr.gif%5C%22)
",
'gresc' => "![\"[esmogr]\"](../%5C%22$greek/esmogr.gif%5C%22)
",
'gresg' => "
",
'grf' => "
",
'grg' => "
",
'grh' => "
",
'grha' => "
",
'grhai' => "
",
'grhc' => "
",
'grhcd' => "![\"[eecirgr]\"](../%5C%22$greek/eecirgr.gif%5C%22)
",
'grhci' => "
",
'grhcr' => "
",
'grhcri' => "
",
'grhcs' => "
",
'grhd' => "![\"[eegr]\"](../%5C%22$greek/eegr.gif%5C%22)
",
'grhg' => "
",
'grhgd' => "![\"[eegragr]\"](../%5C%22$greek/eegragr.gif%5C%22)
",
'grhi' => "
",
'grhia' => "
",
'grhic' => "
",
'grhicr' => "
",
'grhid' => "![\"[eeigr]\"](../%5C%22$greek/eeigr.gif%5C%22)
",
'grhig' => "
",
'grhisc' => "
",
'grhr' => "
",
'grhra' => "
",
'grhrc' => "
",
'grhrci' => "
",
'grhrd' => "![\"[eerougr]\"](../%5C%22$greek/eerougr.gif%5C%22)
",
'grhrg' => "
",
'grhric' => "
",
'grhs' => "
",
'grhsa' => "
",
'grhsai' => "
",
'grhsc' => "
",
'grhsci' => "
",
'grhsg' => "
",
'grhsi' => "
",
'gri' => "
",
'gria' => "
",
'griad' => "
",
'gric' => "
",
'gricr' => "
",
'grics' => "
",
'grid' => "
",
'grida' => "
",
'gridg' => "
",
'grig' => "
",
'grir' => "
",
'grira' => "
",
'grirc' => "
",
'grirg' => "
",
'gris' => "
",
'grisa' => "
",
'grisc' => "
",
'grisd' => "![\"[ismogr]\"](../%5C%22$greek/ismogr.gif%5C%22)
",
'grisg' => "
",
'grk' => "
",
'grl' => "
",
'grm' => "
",
'grn' => "
",
'gro' => "
",
'groa' => "
",
'groad' => "![\"[oacugr]\"](../%5C%22$greek/oacugr.gif%5C%22)
",
'groc' => "![\"[ogr]\"](../%5C%22$greek/ogr.gif%5C%22)
",
'grod' => "![\"[ogr]\"](../%5C%22$greek/ogr.gif%5C%22)
",
'grog' => "
",
'grogd' => "![\"[ogragr]\"](../%5C%22$greek/ogragr.gif%5C%22)
",
'groi' => "![\"[ogr]\"](../%5C%22$greek/ogr.gif%5C%22)
",
'gror' => "
",
'grora' => "
",
'grorc' => "![\"[orougr]\"](../%5C%22$greek/orougr.gif%5C%22)
",
'grorg' => "
",
'gros' => "
",
'grosa' => "
",
'grosc' => "![\"[osmogr]\"](../%5C%22$greek/osmogr.gif%5C%22)
",
'grosdc' => "![\"[osmogr]\"](../%5C%22$greek/osmogr.gif%5C%22)
![\"[cirgr]\"](../%5C%22$greek/cirgr.gif%5C%22)
",
'grosg' => "
",
'grp' => "
",
'grq' => "
",
'grr' => "
",
'grra' => "![\"[rgr]\"](../%5C%22$greek/rgr.gif%5C%22)
",
'grrg' => "![\"[rgr]\"](../%5C%22$greek/rgr.gif%5C%22)
",
'grrr' => "
",
'grrra' => "![\"[rrougr]\"](../%5C%22$greek/rrougr.gif%5C%22)
",
'grrrg' => "![\"[rrougr]\"](../%5C%22$greek/rrougr.gif%5C%22)
",
'grrs' => "
",
'grs' => "
",
'grst' => "
",
'grt' => "
",
'gru' => "
",
'grua' => "
",
'gruad' => "
",
'gruc' => "
",
'grucr' => "
",
'grucs' => "
",
'grud' => "
",
'gruda' => "
",
'grug' => "
",
'grui' => "![\"[ugr]\"](../%5C%22$greek/ugr.gif%5C%22)
",
'grur' => "
",
'grura' => "
",
'grurc' => "
",
'grurdc' => "![\"[urcgr]\"](../%5C%22$greek/urcgr.gif%5C%22)
",
'grurg' => "
",
'grus' => "
",
'grusa' => "
",
'grusc' => "
",
'grusg' => "
",
'grv' => "
",
'grw' => "
",
'grwa' => "
",
'grwac' => "![\"[ohacugr]\"](../%5C%22$greek/ohacugr.gif%5C%22)
",
'grwad' => "![\"[ohacugr]\"](../%5C%22$greek/ohacugr.gif%5C%22)
",
'grwai' => "
",
'grwc' => "
",
'grwcd' => "![\"[ohcirgr]\"](../%5C%22$greek/ohcirgr.gif%5C%22)
",
'grwci' => "
",
'grwcs' => "
",
'grwd' => "![\"[ohgr]\"](../%5C%22$greek/ohgr.gif%5C%22)
",
'grwdc' => "![\"[ohcirgr]\"](../%5C%22$greek/ohcirgr.gif%5C%22)
",
'grwdg' => "![\"[ohgragr]\"](../%5C%22$greek/ohgragr.gif%5C%22)
",
'grwg' => "
",
'grwgi' => "
",
'grwi' => "
",
'grwia' => "
",
'grwic' => "
",
'grwirc' => "
",
'grwis' => "
",
'grwr' => "
",
'grwra' => "
",
'grwrc' => "
",
'grwrd' => "![\"[ohrougr]\"](../%5C%22$greek/ohrougr.gif%5C%22)
",
'grwrg' => "
",
'grws' => "
",
'grwsa' => "
",
'grwsai' => "
",
'grwsc' => "
",
'grwsg' => "
",
'grx' => "
",
'gry' => "
",
'grz' => "
",
);
}
sub InitCharEntHash_Misc
{
%charEntHash_Misc =
('initzzz' => "1",
'#38' => "&",
'#60' => ">",
'#62' => "<",
'emsp' => " ",
'ensp' => " ",
'Prime' => "
",
'prime' => "
",
'plus' => "+",
'nldr' => "..",
'mldr' => "...",
'hellip' => "...",
'tilde' => "~",
'le' => "<=",
'ndash' => "-",
'hyphen' => "-",
'pound' => "#",
'mdash' => "--",
'yog' => "
",
'Yog' => "
",
'darr' => "
",
'uarr' => "
",
'larr' => "
",
'rarr' => "
",
'OEli' => "OE",
'oeli' => "
",
'esse' => "\ß",
'ldqu' => '"',
'rdqu' => '"',
'rdquo' => '"',
'grdquo' => '"',
'lsqu' => "`",
'lsquo' => "`",
'rsqu' => "'",
'rsquo' => "'",
'grsqu' => '"',
'lcub' => "{",
'lsquor' => "`",
'rcub' => "}",
'frac12' => "1/2",
'frac14' => "1/4",
'frac34' => "3/4",
'frac13' => "1/3",
'frac15' => "1/5",
'frac16' => "1/6",
'frac18' => "1/8",
'frac23' => "2/3",
'frac25' => "2/5",
'frac35' => "3/5",
'frac38' => "3/8",
'frac58' => "5/8",
'Acaron' => "[A]",
'Cacute' => "[C]",
'Ccaron' => "[C]",
'Dcaron' => "[D]",
'Ecaron' => "[E]",
'Icaron' => "[I]",
'Nacute' => "[N]",
'Ncaron' => "[N]",
'Ocaron' => "[O]",
'Rcaron' => "[R]",
'Ruml' => "[R]",
'Scaron' => "[S]",
'Ucaron' => "[U]",
'ucaron' => "[u]",
'Zcaron' => "[Z]",
'Zdot' => "[Z]",
'acedil' => "[a]",
'bacute' => "[b]",
'cacute' => "[c]",
'ccaron' => "[c]",
'cgrave' => "[c]",
'dcaron' => "[d]",
'gacute' => "[g]",
'hacute' => "[h]",
'iogon' => "[i]",
'ltilde' => "[l]",
'ncaron' => "[n]",
'ngrave' => "[n]",
'rcaron' => "[r]",
'rgrave' => "[r]",
'sacute' => "[s]",
'scaron' => "[s]",
'sgrave' => "[s]",
'stilde' => "[s]",
'uring' => "[u]",
'utilde' => "[u]",
'wacute' => "[w]",
'ycirc' => "[y]",
'zcaron' => "[z]",
'zdot' => "[z]",
'breve' => "
",
'caron' => "
",
'cir' => "
",
'Dagger' => "
",
'dagger' => "
",
'angst' => "
",
'dot' => "
",
'bull' => "
",
'grave' => "
",
'lacute' => "
",
'macute' => "
",
'nacute' => "
",
'racute' => "
",
'zacute' => "
",
'acaron' => "
",
'ecaron' => "
",
'icaron' => "
",
'ocaron' => "
",
'edot' => "
",
'imacr' => "
",
'etilde' => "
",
'itilde' => "
",
'check' => "
",
);
}
sub InitCharEntHash_ISO_Greek
{
%charEntHash_ISO_Greek=
('initzzz' => "1",
'Agr' => "
",
'agr' => "
",
'aacgr' => "
",
'aacugr' => "
",
'aaigr' => "
",
'acigr' => "
",
'acirgr' => "
",
'agigr' => "
",
'agragr' => "
",
'agvgr' => "
",
'aiotgr' => "
",
'aragr' => "
",
'araigr' => "
",
'arcgr' => "
",
'arcigr' => "
",
'arggr' => "
",
'argigr' => "
",
'arigr' => "
",
'arougr' => "
",
'asagr' => "
",
'asaigr' => "
",
'ascgr' => "
",
'ascigr' => "
",
'asggr' => "
",
'asgigr' => "
",
'asigr' => "
",
'asmogr' => "
",
'Bgr' => "
",
'bgr' => "
",
'Ggr' => "
",
'ggr' => "
",
'Dgr' => "
",
'dgr' => "
",
'Egr' => "
",
'egr' => "
",
'eacgr' => "
",
'eacugr' => "
",
'egvgr' => "
",
'egragr' => "
",
'eragr' => "
",
'erggr' => "
",
'erougr' => "
",
'esagr' => "
",
'esggr' => "
",
'esmogr' => "
",
'Zgr' => "
",
'zgr' => "
",
'EEgr' => "
",
'eegr' => "
",
'eeacgr' => "
",
'eeacugr' => "
",
'eeaigr' => "
",
'eecigr' => "
",
'eecirgr' => "
",
'eegigr' => "
",
'eegvgr' => "
",
'eegragr' => "
",
'eeigr' => "
",
'eeragr' => "
",
'eeraigr' => "
",
'eercgr' => "
",
'eercigr' => "
",
'eerggr' => "
",
'eergigr' => "
",
'eerigr' => "
",
'eerougr' => "
",
'eesagr' => "
",
'eesaigr' => "
",
'eescgr' => "
",
'eescigr' => "
",
'eesggr' => "
",
'eesgigr' => "
",
'eesigr' => "
",
'eesmogr' => "
",
'THgr' => "
",
'thgr' => "
",
'Igr' => "
",
'igr' => "
",
'iacgr' => "
",
'iacugr' => "
",
'iadgr' => "
",
'icirgr' => "
",
'idiagr' => "
",
'igdgr' => "
",
'igvgr' => "
",
'igragr' => "
",
'iragr' => "
",
'ircgr' => "
",
'irggr' => "
",
'irougr' => "
",
'isagr' => "
",
'iscgr' => "
",
'isggr' => "
",
'ismogr' => "
",
'Kgr' => "
",
'kgr' => "
",
'Lgr' => "
",
'lgr' => "
",
'Mgr' => "
",
'mgr' => "
",
'Ngr' => "
",
'ngr' => "
",
'Xgr' => "
",
'xgr' => "
",
'Ogr' => "
",
'ogr' => "
",
'oacgr' => "
",
'oacugr' => "
",
'ogvgr' => "
",
'ogragr' => "
",
'oragr' => "
",
'orggr' => "
",
'orougr' => "
",
'osagr' => "
",
'osggr' => "
",
'osmogr' => "
",
'Pgr' => "
",
'pgr' => "
",
'Rgr' => "
",
'rgr' => "
",
'rrougr' => "
",
'rsmogr' => "
",
'Sgr' => "
",
'sgr' => "
",
'sfgr' => "
",
'Tgr' => "
",
'tgr' => "
",
'Ugr' => "
",
'ugr' => "
",
'uacugr' => "
",
'uadgr' => "
",
'ucirgr' => "
",
'udiagr' => "
",
'ugdgr' => "
",
'ugvgr' => "
",
'ugragr' => "
",
'uragr' => "
",
'urcgr' => "
",
'urggr' => "
",
'urougr' => "
",
'usagr' => "
",
'uscgr' => "
",
'usggr' => "
",
'usmogr' => "
",
'PHgr' => "
",
'phgr' => "
",
'KHgr' => "
",
'khgr' => "
",
'PSgr' => "
",
'psgr' => "
",
'OHgr' => "
",
'ohgr' => "
",
'ohacgr' => "
",
'ohacugr' => "
",
'ohaigr' => "
",
'ohcigr' => "
",
'ohcirgr' => "
",
'ohgigr' => "
",
'ohgragr' => "
",
'ohiotgr' => "
",
'ohragr' => "
",
'ohraigr' => "
",
'ohrcgr' => "
",
'ohrcigr' => "
",
'ohrggr' => "
",
'ohrgigr' => "
",
'ohrigr' => "
",
'ohrougr' => "
",
'ohsagr' => "
",
'ohsaigr' => "
",
'ohscgr' => "
",
'ohscigr' => "
",
'ohsggr' => "
",
'ohsgigr' => "
",
'ohsigr' => "
",
'ohsmogr' => "
",
'DIGgr' => "
",
'diggr' => "
",
'KOgr' => "
",
'kogr' => "
",
'samgr' => "
",
'SLgr' => "
",
'slgr' => "
",
'acugr' => "
",
'apos' => "
",
'cirgr' => "
",
'cogr' => "
",
'colon' => "
",
'comma' => "
",
'diagr' => "
",
'gdgr' => "
",
'gragr' => "
",
'hyphen' => "
",
'iotgr' => "
",
'laquo' => "
",
'lpar' => "
",
'lsqb' => "
",
'period' => "
",
'qmgr' => "
",
'ragr' => "
",
'raquo' => "
",
'rcgr' => "
",
'rggr' => "
",
'rougr' => "
",
'rpar' => "
",
'rsqb' => "
",
'sagr' => "
",
'scgr' => "
",
'sdgr' => "
",
'sggr' => "
",
'smogr' => "
",
);
}
sub FilterCharEnts_CH_Greek
{
my $sRef = shift;
if (! $charEntHash_CH_Greek{'initzzz'})
{
&InitCharEntHash_CH_Greek;
};
$$sRef =~ s,(\&([^ \;]+?)\;),$charEntHash_CH_Greek{$2} ? $charEntHash_CH_Greek{$2} : $1,eg;
if ( $ENV{'DEBUG'} && $ENV{'charents'} )
{
if ( $1 )
{
print "[|$1| -> |$2| -> |$charEntHash_CH_Greek{$2}|]"
}
}
}
sub FilterCharEnts_ISO_Greek
{
my $sRef = shift;
if (! $charEntHash_ISO_Greek{'initzzz'})
{
&InitCharEntHash_ISO_Greek;
};
$$sRef =~ s,(\&([^ \;]+?)\;),$charEntHash_ISO_Greek{$2} ? $charEntHash_ISO_Greek{$2} : $1,eg;
if ( $ENV{'DEBUG'} && $ENV{'charents'} )
{
if ( $1 )
{
print "[|$1| -> |$2| -> |$charEntHash_ISO_Greek{$2}|]"
}
}
}
sub FilterCharEnts_Misc
{
my $sRef = shift;
if (! $charEntHash_Misc{'initzzz'})
{
&InitCharEntHash_Misc;
};
# A few complex regexps
$$sRef =~ s|\&super([^\;]+)\;|$1|g;
# All the rest
$$sRef =~ s,(\&([^ \;]+?)\;),$charEntHash_Misc{$2} ? $charEntHash_Misc{$2} : $1,eg;
if ( $ENV{'DEBUG'} && $ENV{'charents'} )
{
if ( $1 )
{
print "[|$1| -> |$2| -> |$charEntHash_Misc{$2}|]"
}
}
}
sub FilterCharEnts_All
{
my $sRef = shift;
FilterCharEnts_Misc( $sRef );
FilterCharEnts_ISO_Greek( $sRef );
FilterCharEnts_CH_Greek( $sRef );
}
# ----------------------------------------------------------------------
# NAME : StartSession
# PURPOSE : set the global $gSessionId and creates a DlpsSession object
# (which wraps an Apache::Session::DBI object)
# CALLED BY : main
# CALLS : DlpsSession->new
# INPUT :
# RETURNS :
# GLOBALS :
# NOTES :
# ----------------------------------------------------------------------
sub StartSession
{
my $cgi = shift;
# get session id if there is one passed in
my $sid = $cgi->param('sid');
my $dso;
eval
{
$dso = new DlpsSession( $sid );
};
if ( $@ )
{
&errorBail( $@ );
}
$sid = $dso->GetSessionId( ); # update global session id variable
$cgi->param( 'sid', $sid ); # update cgi obj with session id param
if ( ( $ENV{'DEBUG'} eq 'session' ) ||
( $ENV{'DEBUG'} eq 'all' ) )
{
print( &CGI::p("Debugging $0"), &CGI::br(), &CGI::hr() );
print( &CGI::p(qq{Session ID is: }, $sid), &CGI::br(), &CGI::hr() );
}
return $dso;
}
# ----------------------------------------------------------------------
# NAME : PrintStringToFile
# PURPOSE :
# CALLED BY :
# CALLS :
# INPUT : string, filename of file to print it to
# RETURNS : NONE
# GLOBALS :
# SIDE-EFFECTS :
# NOTES :
# ----------------------------------------------------------------------
sub PrintStringToFile
{
my ( $s, $file ) = @_;
open ( TEMPFILE, ">$file" ) || die;
print TEMPFILE $s;
close ( TEMPFILE );
}
# ----------------------------------------------------------------------
# NAME : TrimSpaces
# PURPOSE : remove leading and trailing white space from a string
# CALLED BY :
# CALLS :
# INPUT : reference a string
# RETURNS :
# GLOBALS :
# SIDE-EFFECTS : changes string by reference
# NOTES :
# ----------------------------------------------------------------------
sub TrimSpaces
{
my $sRef = shift;
$$sRef =~ s,^\s*,,;
$$sRef =~ s,\s*$,,;
}
# **********************************************************************
# **********************************************************************
1;