--- rat/lonpageflip.pm 2000/10/03 20:33:06 1.1 +++ rat/lonpageflip.pm 2000/10/05 22:14:11 1.2 @@ -10,7 +10,7 @@ # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, # 10/02 Gerd Kortemeyer) # -# 10/03 Gerd Kortemeyer +# 10/03,10/05 Gerd Kortemeyer package Apache::lonpageflip; @@ -91,24 +91,79 @@ sub tracetable { # ================================================================ Main Handler sub handler { - my $r=shift; + my $r=shift; # ------------------------------------------- Set document type for header only -# if ($r->headers_only) { + if ($r->header_only) { $r->content_type('text/html'); $r->send_http_header; -# return OK; -# } + return OK; + } + + +# --------BEGIN DEBUG ONLY TRASH + $r->content_type('text/html'); + $r->send_http_header; + + $r->print(''); +# --------END DEBUG ONLY TRASH + + + if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) { + $ENV{'form.postdata'}=~/(\w+)\:(.*)/; + my $direction=$1; + my $currenturl=$2; + my $redirecturl=$currenturl; + $currenturl=~s/^http\:\/\///; + $currenturl=~s/^[^\/]+//; + $currenturl=Apache::lonnet::declutter($currenturl); +# ---------------------------------------------------------------- Tie database + if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', + &GDBM_READER,0640)) { +# ---------------------------------------------- Get ID(s) for current resource + my $syval=$hash{'ids_/res/'.$currenturl}; + if ($syval) { +# ------------------------------------------------------------------- Has ID(s) + my @possiblities=split(/\,/,$syval); + $r->print($direction.' '.$currenturl.' '.$syval); + + } else { +# --------------------------------------------------------- Does not have ID(s) + $r->print('Weird'); + } +# ------------------------------------- Program needs to get here to untie hash + unless(untie(%hash)) { + $r->log_reason('Could not untie database hash '. + $ENV{'request.course.fn'}.' for '.$ENV{'user.name'}. + ' at '.$ENV{'user.domain'}); + return HTTP_SERVICE_UNAVAILABLE; + } +# ------------------------------------------------------------ Now do something + } else { +# ----------------------------------------- Serious problem, could not tie hash + $r->log_reason('Could not tie database hash '. + $ENV{'request.course.fn'}.' for '.$ENV{'user.name'}. + ' at '.$ENV{'user.domain'}); + return HTTP_SERVICE_UNAVAILABLE; + } +# -------------------------- Class was not initialized or page fliped strangely + } else { + $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course"; + return HTTP_NOT_ACCEPTABLE; + } +# ------TRASH BELOW +# --------------------------- TRASH - $r->print(''.$ENV{'form.postdata'}.''); + $r->print(''); return OK; +# ========================================================= TOTAL TRASH my $requrl=$r->uri; # ----------------------------------------------------------------- Tie db file