Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.401 and 1.409

version 1.401, 2003/08/14 22:23:53 version 1.409, 2003/09/09 18:46:28
Line 76  qw(%perlvar %hostname %homecache %badSer Line 76  qw(%perlvar %hostname %homecache %badSer
    %libserv %pr %prp %metacache %packagetab %titlecache      %libserv %pr %prp %metacache %packagetab %titlecache 
    %courselogs %accesshash %userrolehash $processmarker $dumpcount      %courselogs %accesshash %userrolehash $processmarker $dumpcount 
    %coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseresdatacache      %coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseresdatacache 
    %domaindescription %domain_auth_def %domain_auth_arg_def $tmpdir);     %domaindescription %domain_auth_def %domain_auth_arg_def 
      %domain_lang_def %domain_city %domain_longi %domain_lati $tmpdir);
   
 use IO::Socket;  use IO::Socket;
 use GDBM_File;  use GDBM_File;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
Line 243  sub critical { Line 245  sub critical {
     }      }
     return $answer;      return $answer;
 }  }
   
   # -------------- Remove all key from the env that start witha lowercase letter
   #                (Which is alweways a lon-capa value)
   sub cleanenv {
       foreach my $key (keys(%ENV)) {
    if ($key =~ /^[a-z]/) {
       delete($ENV{$key});
    }
       }
   }
     
 # ------------------------------------------- Transfer profile into environment  # ------------------------------------------- Transfer profile into environment
   
Line 377  sub userload { Line 389  sub userload {
  my $curtime=time;   my $curtime=time;
  while ($filename=readdir(LONIDS)) {   while ($filename=readdir(LONIDS)) {
     if ($filename eq '.' || $filename eq '..') {next;}      if ($filename eq '.' || $filename eq '..') {next;}
     my ($atime)=(stat($perlvar{'lonIDsDir'}.'/'.$filename))[8];      my ($mtime)=(stat($perlvar{'lonIDsDir'}.'/'.$filename))[9];
     if ($curtime-$atime < 3600) { $numusers++; }      if ($curtime-$mtime < 3600) { $numusers++; }
  }   }
  closedir(LONIDS);   closedir(LONIDS);
     }      }
Line 1216  sub courseacclog { Line 1228  sub courseacclog {
     my $fnsymb=shift;      my $fnsymb=shift;
     unless ($ENV{'request.course.id'}) { return ''; }      unless ($ENV{'request.course.id'}) { return ''; }
     my $what=$fnsymb.':'.$ENV{'user.name'}.':'.$ENV{'user.domain'};      my $what=$fnsymb.':'.$ENV{'user.name'}.':'.$ENV{'user.domain'};
     if ($fnsymb=~/(problem|exam|quiz|assess|survey|form)$/) {      if ($fnsymb=~/(problem|exam|quiz|assess|survey|form|page)$/) {
         $what.=':POST';          $what.=':POST';
  foreach (keys %ENV) {   foreach (keys %ENV) {
             if ($_=~/^form\.(.*)/) {              if ($_=~/^form\.(.*)/) {
Line 2124  sub dump { Line 2136  sub dump {
    return %returnhash;     return %returnhash;
 }  }
   
   # -------------------------------------------------------------- keys interface
   
   sub getkeys {
      my ($namespace,$udomain,$uname)=@_;
      if (!$udomain) { $udomain=$ENV{'user.domain'}; }
      if (!$uname) { $uname=$ENV{'user.name'}; }
      my $uhome=&homeserver($uname,$udomain);
      my $rep=reply("keys:$udomain:$uname:$namespace",$uhome);
      my @keyarray=();
      foreach (split(/\&/,$rep)) {
         push (@keyarray,&unescape($_));
      }
      return @keyarray;
   }
   
 # --------------------------------------------------------------- currentdump  # --------------------------------------------------------------- currentdump
 sub currentdump {  sub currentdump {
    my ($courseid,$sdom,$sname)=@_;     my ($courseid,$sdom,$sname)=@_;
Line 2256  sub customaccess { Line 2283  sub customaccess {
             $access=($effect eq 'allow');              $access=($effect eq 'allow');
             last;              last;
         }          }
    if ($realm eq '' && $role eq '') {
               $access=($effect eq 'allow');
    }
     }      }
     return $access;      return $access;
 }  }
Line 2794  sub modifyuser { Line 2824  sub modifyuser {
              ' in domain '.$ENV{'request.role.domain'});               ' in domain '.$ENV{'request.role.domain'});
     my $uhome=&homeserver($uname,$udom,'true');      my $uhome=&homeserver($uname,$udom,'true');
 # ----------------------------------------------------------------- Create User  # ----------------------------------------------------------------- Create User
     if (($uhome eq 'no_host') && ($umode) && ($upass)) {      if (($uhome eq 'no_host') && 
    (($umode && $upass) || ($umode eq 'localauth'))) {
         my $unhome='';          my $unhome='';
         if (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) {           if (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) { 
             $unhome = $desiredhome;              $unhome = $desiredhome;
Line 3379  sub EXT { Line 3410  sub EXT {
 # ----------------------------------------------------- Cascading lookup scheme  # ----------------------------------------------------- Cascading lookup scheme
     if (!$symbparm) { $symbparm=&symbread(); }      if (!$symbparm) { $symbparm=&symbread(); }
     my $symbp=$symbparm;      my $symbp=$symbparm;
     my $mapp=(split(/\_\_\_/,$symbp))[0];      my $mapp=(&decode_symb($symbp))[0];
   
     my $symbparm=$symbp.'.'.$spacequalifierrest;      my $symbparm=$symbp.'.'.$spacequalifierrest;
     my $mapparm=$mapp.'___(all).'.$spacequalifierrest;      my $mapparm=$mapp.'___(all).'.$spacequalifierrest;
Line 3458  sub EXT { Line 3489  sub EXT {
  my $filename;   my $filename;
  if (!$symbparm) { $symbparm=&symbread(); }   if (!$symbparm) { $symbparm=&symbread(); }
  if ($symbparm) {   if ($symbparm) {
     $filename=(split(/\_\_\_/,$symbparm))[2];      $filename=(&decode_symb($symbparm))[2];
  } else {   } else {
     $filename=$ENV{'request.filename'};      $filename=$ENV{'request.filename'};
  }   }
Line 3733  sub gettitle { Line 3764  sub gettitle {
     delete($titlecache{$symb});      delete($titlecache{$symb});
  }   }
     }      }
     my ($map,$resid,$url)=split(/\_\_\_/,$symb);      my ($map,$resid,$url)=&decode_symb($symb);
     my $title='';      my $title='';
     my %bighash;      my %bighash;
     if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',      if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
Line 3779  sub symbverify { Line 3810  sub symbverify {
 # direct jump to resource in page or to a sequence - will construct own symbs  # direct jump to resource in page or to a sequence - will construct own symbs
     if ($thisfn=~/\.(page|sequence)$/) { return 1; }      if ($thisfn=~/\.(page|sequence)$/) { return 1; }
 # check URL part  # check URL part
     my ($map,$resid,$url)=split(/\_\_\_/,$symb);      my ($map,$resid,$url)=&decode_symb($symb);
     unless (&symbclean($url) eq &symbclean($thisfn)) { return 0; }      unless (&symbclean($url) eq &symbclean($thisfn)) { return 0; }
   
     $symb=&symbclean($symb);      $symb=&symbclean($symb);
Line 3822  sub symbclean { Line 3853  sub symbclean {
     return $symb;      return $symb;
 }  }
   
   # ---------------------------------------------- Split symb to find map and url
   
   sub decode_symb {
       return split(/\_\_\_/,shift);
   }
   
 # ------------------------------------------------------ Return symb list entry  # ------------------------------------------------------ Return symb list entry
   
 sub symbread {  sub symbread {
Line 4168  BEGIN { Line 4205  BEGIN {
            next if (/^(\#|\s*$)/);             next if (/^(\#|\s*$)/);
 #           next if /^\#/;  #           next if /^\#/;
            chomp;             chomp;
            my ($domain, $domain_description, $def_auth, $def_auth_arg)             my ($domain, $domain_description, $def_auth, $def_auth_arg,
                = split(/:/,$_,4);         $def_lang, $city, $longi, $lati) = split(/:/,$_);
            $domain_auth_def{$domain}=$def_auth;     $domain_auth_def{$domain}=$def_auth;
            $domain_auth_arg_def{$domain}=$def_auth_arg;             $domain_auth_arg_def{$domain}=$def_auth_arg;
            $domaindescription{$domain}=$domain_description;     $domaindescription{$domain}=$domain_description;
      $domain_lang_def{$domain}=$def_lang;
      $domain_city{$domain}=$city;
      $domain_longi{$domain}=$longi;
      $domain_lati{$domain}=$lati;
   
 #          &logthis("Domain.tab: $domain, $domain_auth_def{$domain}, $domain_auth_arg_def{$domain},$domaindescription{$domain}");  #          &logthis("Domain.tab: $domain, $domain_auth_def{$domain}, $domain_auth_arg_def{$domain},$domaindescription{$domain}");
 #          &logthis("Domain.tab: $domain ".$domaindescription{$domain} );  #          &logthis("Domain.tab: $domain ".$domaindescription{$domain} );
        }         }

Removed from v.1.401  
changed lines
  Added in v.1.409


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>