Diff for /rat/lonuserstate.pm between versions 1.67 and 1.74

version 1.67, 2003/11/01 16:42:13 version 1.74, 2004/04/23 15:43:41
Line 41  use Apache::lonmsg; Line 41  use Apache::lonmsg;
 use Safe;  use Safe;
 use Safe::Hole;  use Safe::Hole;
 use Opcode;  use Opcode;
   use Apache::lonenc;
   
 # ---------------------------------------------------- Globals for this package  # ---------------------------------------------------- Globals for this package
   
Line 52  my $errtext; # variable with all errors Line 53  my $errtext; # variable with all errors
 my $retfurl; # variable with the very first URL in the course  my $retfurl; # variable with the very first URL in the course
 my %randompick; # randomly picked resources  my %randompick; # randomly picked resources
 my %randompickseed; # optional seed for randomly picking resources  my %randompickseed; # optional seed for randomly picking resources
   my %encurl; # URLs in this folder are supposed to be encrypted
   my %hiddenurl; # this URL (or complete folder) is supposed to be hidden
   
 # ----------------------------------- Remove version from URL and store in hash  # ----------------------------------- Remove version from URL and store in hash
   
Line 159  sub loadmap { Line 162  sub loadmap {
                         } elsif ($turi=~/^\/*uploaded\//) { # uploaded                          } elsif ($turi=~/^\/*uploaded\//) { # uploaded
     if (($embstyle eq 'img') || ($embstyle eq 'emb')      if (($embstyle eq 'img') || ($embstyle eq 'emb')
                              || ($embstyle eq 'ssi')) {                               || ($embstyle eq 'ssi')) {
                                 $turi='/adm/wrapper'.$turi;                                  unless ($turi =~/\.page$/) {
                                       $turi='/adm/wrapper'.$turi;
                                   }
                             } elsif ($turi!~/\.(sequence|page)$/) {                              } elsif ($turi!~/\.(sequence|page)$/) {
  $turi='/adm/coursedocs/showdoc'.$turi;   $turi='/adm/coursedocs/showdoc'.$turi;
                             }                              }
                         } else { # normal internal resource                          } elsif ($turi=~/\S/) { # normal non-empty internal resource
                            if (($embstyle eq 'img') || ($embstyle eq 'emb')) {      my $mapdir=$uri;
        $turi='/adm/wrapper'.$turi;      $mapdir=~s/[^\/]+$//;
                            }      $turi=&Apache::lonnet::hreflocation($mapdir,$turi);
       if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
    $turi='/adm/wrapper'.$turi;
       }
                         }                          }
     }      }
   # Store reverse lookup, remove query string
                     if (defined($hash{'ids_'.$turi})) {      my $idsuri=$turi;
                         $hash{'ids_'.$turi}.=','.$rid;      $idsuri=~s/\?.+$//;
                       if (defined($hash{'ids_'.$idsuri})) {
                           $hash{'ids_'.$idsuri}.=','.$rid;
                     } else {                      } else {
                         $hash{'ids_'.$turi}=''.$rid;                          $hash{'ids_'.$idsuri}=''.$rid;
                     }                      }
                                 
                     if                      if
Line 278  sub loadmap { Line 288  sub loadmap {
                     if ($token->[2]->{'name'} eq 'parameter_randompickseed') {                      if ($token->[2]->{'name'} eq 'parameter_randompickseed') {
  $randompick{$referid}=$token->[2]->{'value'};   $randompick{$referid}=$token->[2]->{'value'};
                     }                      }
                       if ($token->[2]->{'name'} eq 'parameter_encrypturl') {
    if ($token->[2]->{'value'}=~/^yes$/i) {
       $encurl{$referid}=1;
    }
                       }
                       if ($token->[2]->{'name'} eq 'parameter_hiddenresource') {
    if ($token->[2]->{'value'}=~/^yes$/i) {
       $hiddenurl{$referid}=1;
    }
                       }
                 }                   } 
   
             }              }
Line 447  sub accinit { Line 467  sub accinit {
                             "request.course.uri" => $courseuri);                               "request.course.uri" => $courseuri); 
 }  }
   
 # ------------------------------------- Selectively delete from randompick maps  # ---------------- Selectively delete from randompick maps and hidden url parms
   
 sub pickrandom {  sub hiddenurls {
     my $randomoutentry='';      my $randomoutentry='';
     foreach my $rid (keys %randompick) {      foreach my $rid (keys %randompick) {
         my $rndpick=$randompick{$rid};          my $rndpick=$randompick{$rid};
Line 491  sub pickrandom { Line 511  sub pickrandom {
             }              }
         }          }
     }      }
   # ------------------------------ take care of explicitly hidden urls or folders
       foreach my $rid (keys %hiddenurl) {
    $hash{'randomout_'.$rid}=1;
    my ($mapid,$resid)=split(/\./,$rid);
    $randomoutentry.='&'.
       &Apache::lonnet::symbclean(
            &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).
          '___'.$resid.'___'.
       &Apache::lonnet::declutter($hash{'src_'.$rid})
          ).'&';
       }
   # --------------------------------------- append randomout entry to environment
     if ($randomoutentry) {      if ($randomoutentry) {
  &Apache::lonnet::appenv('acc.randomout' => $randomoutentry);   &Apache::lonnet::appenv('acc.randomout' => $randomoutentry);
     }      }
Line 516  sub readmap { Line 548  sub readmap {
    unlink($fn.'.state');     unlink($fn.'.state');
    unlink($fn.'parms.db');     unlink($fn.'parms.db');
    undef %randompick;     undef %randompick;
      undef %hiddenurl;
      undef %encurl;
    $retfurl='';     $retfurl='';
    if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) &&     if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) &&
        (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640))) {         (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640))) {
Line 533  sub readmap { Line 567  sub readmap {
     if (defined($hash{'map_start_'.$uri})) {      if (defined($hash{'map_start_'.$uri})) {
         &traceroute('0',$hash{'map_start_'.$uri},'&');          &traceroute('0',$hash{'map_start_'.$uri},'&');
         &accinit($uri,$short,$fn);          &accinit($uri,$short,$fn);
         &pickrandom();          &hiddenurls();
     }      }
 # ------------------------------------------------------- Put versions into src  # ------------------------------------------------------- Put versions into src
     foreach (keys %hash) {      foreach (keys %hash) {
Line 541  sub readmap { Line 575  sub readmap {
     $hash{$_}=&putinversion($hash{$_});      $hash{$_}=&putinversion($hash{$_});
  }   }
     }      }
   # ---------------------------------------------------------------- Encrypt URLs
       foreach (keys %encurl) {
    $hash{'src_'.$_}=&Apache::lonenc::encrypted($hash{'src_'.$_});
       }
   # ----------------------------------------------- Close hashes to finally store
   # --------------------------------- Routine must pass this point, no early outs
     unless ((untie(%hash)) && (untie(%parmhash))) {      unless ((untie(%hash)) && (untie(%parmhash))) {
       &Apache::lonnet::logthis("<font color=blue>WARNING: ".        &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                        "Could not untie coursemap $fn for $uri.</font>");                          "Could not untie coursemap $fn for $uri.</font>"); 
     }      }
   # ---------------------------------------------------- Store away initial state
     {      {
      my $cfh;       my $cfh;
      if ($cfh=Apache::File->new(">$fn.state")) {       if ($cfh=Apache::File->new(">$fn.state")) {

Removed from v.1.67  
changed lines
  Added in v.1.74


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.