#!/usr/bin/perl
sub
SetCookie
{
my
$r
=
shift
;
if
(
$r
) {
print
$r
->SetCookie (
$r
->{sysOut}->{sysName},
$r
->{frames},
$r
->{sysOut}->{
'7-bit'
} );
}
elsif
( $0 =~
"NoFrames"
) {
print
$r
->SetCookie (
$defaultSysOut
,
"no"
,
"false"
);
}
else
{
print
$r
->SetCookie (
$defaultSysOut
,
"yes"
,
"false"
);
}
}
sub
CheckBrowser
{
my
@browser
=
split
( / /,
$ENV
{HTTP_USER_AGENT} );
if
(
$browser
[0]=~/Mozilla/) {
my
@model
=
split
(/\//,
$browser
[0]);
local
$brand
=
$model
[0];
local
$version
=
$model
[1];
}
$wantFrames
= ( ((
$version
>= 2) && (
$brand
eq
"Mozilla"
))
|| ((
$version
>= 3) && (
$browser
[0] =~ /MSIE/)) )
?
$wantFrames
=
"yes"
:
$wantFrames
=
"no"
;
}
main:
{
my
%input
= ();
my
$r
= LiveGeez::Request->new ( 0 );
if
( (
$pathInfo
=
$ENV
{PATH_INFO}) ) {
if
(
$pathInfo
=~
"/Selamta/"
) {
$r
->ParseCookie;
$input
{file} =
"/index.sera.html"
;
$input
{sysOut} = (
$r
->{
'cookie-geezsys'
} )
? (
$r
->{
'cookie-geezsys'
} )
:
"FirstTime"
;
$input
{
'7-bit'
} = (
$r
->{
'cookie-7-bit'
} )
? (
$r
->{
'cookie-7-bit'
} )
: (
$ENV
{HTTP_USER_AGENT} =~ /Mac/i )
?
"true"
:
"false"
;
$input
{frames} = (
$r
->{
'cookie-frames'
} )
? (
$r
->{
'cookie-frames'
} )
: CheckBrowser
;
}
else
{
my
@fileString
=
split
(
'/'
,
$pathInfo
);
my
$sys
=
$fileString
[1];
if
(
$#fileString
== 1 ||
$fileString
[2] eq
"index.html"
) {
$input
{file} =
"/index.sera.html"
;
}
else
{
$input
{file} =
$pathInfo
;
$input
{file} =~ s/\/
$sys
//;
$input
{file} .=
"/index.sera.html"
if
(
$input
{file} !~ /htm(l)?$/ );
}
$sys
=
"FirstTime"
if
( (
$sys
=~ /image/i) || (
$sys
eq
"ENHPFR"
) );
$input
{sysOut} =
$sys
;
}
}
else
{
$r
->ParseCgi ( \
%input
);
}
if
(
$input
{sysOut} =~ /image/i ||
$input
{sys} =~ /image/i
||
$input
{sysOut} eq
"FirstTime"
||
$input
{sys} eq
"FirstTime"
||
$input
{sysOut} eq
"ENHPFR"
||
$input
{sys} eq
"ENHPFR"
)
{
$input
{sysOut} =
$defaultSysOut
;
delete
(
$input
{sys} );
$r
->{FirstTime} =
"true"
;
$r
->{setCookie} =
"true"
;
}
$r
->ParseQuery ( \
%input
);
undef
(
%input
);
SetCookie (
$r
)
if
(
$r
->{setCookie} );
if
(
$r
->{type} eq
"file"
) {
$r
->HeaderPrint;
$r
->{isArticle} =
"true"
if
(
$r
->{file} =~ /[0-9]\.sera/ );
if
( $0 =~
"NoFrames"
) {
$r
->{frames} =
"no"
;
$r
->{scriptURL} =~ s/G.pl/NoFrames.pl/;
$r
->{scriptBase} =~ s/G.pl/NoFrames.pl/;
}
if
(
$r
->{isArticle} ) {
if
(
$r
->{frames} eq
"skip"
) {
ProcessFramesFile (
$r
);
}
elsif
(
$r
->{frames} eq
"no"
) {
ProcessNoFramesFile (
$r
);
}
else
{
OpenFrameSet (
$r
,
"/misc/Frames/frame.html"
);
}
}
else
{
$r
->{mainPage} =
"true"
if
(
$r
->{file} =~ m
ProcessFramesFile (
$r
);
}
}
else
{
ProcessRequest (
$r
) ||
$r
->DieCgi (
"Unrecognized Request."
);
}
exit
(0);
}