Diff for /loncom/interface/lonindexer.pm between versions 1.63 and 1.69

version 1.63, 2003/03/19 14:50:32 version 1.69, 2003/07/17 21:11:09
Line 84  my @Omit = (); Line 84  my @Omit = ();
 # ----------------------------- Handling routine called via Apache and mod_perl  # ----------------------------- Handling routine called via Apache and mod_perl
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
       my $c = $r->connection();
     $r->content_type('text/html');      $r->content_type('text/html');
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
     $fnum=0;      $fnum=0;
     $dnum=0;      $dnum=0;
     untie %hash;  
   
     # Deal with stupid global variables (is there a way around making      # Deal with stupid global variables (is there a way around making
     # these global to this package?  It is just so wrong....)      # these global to this package?  It is just so wrong....)
Line 124  sub handler { Line 124  sub handler {
   
     $extrafield='';      $extrafield='';
     my $diropendb =       my $diropendb = 
  "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db";   "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
       %hash = ();
     if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {      {
    my %dbfile;
    if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
       while(my($key,$value)=each(%dbfile)) {
    $hash{$key}=$value;
       }
       untie(%dbfile);
    }
       }
       {
  if ($ENV{'form.launch'} eq '1') {   if ($ENV{'form.launch'} eq '1') {
     &start_fresh_session();      &start_fresh_session();
         }          }
Line 309  END Line 318  END
   
 <script type="text/javascript">  <script type="text/javascript">
 $catalogmodefunctions  $catalogmodefunctions
 function openWindow(url, wdwName, w, h, toolbar,scrollbar) {  function openWindow(url, wdwName, w, h, toolbar,scrollbar,locationbar) {
     var options = "width=" + w + ",height=" + h + ",";      var options = "width=" + w + ",height=" + h + ",";
     options += "resizable=yes,scrollbars="+scrollbar+",status=no,";      options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
     options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";      options += "menubar=no,toolbar="+toolbar+",location="+locationbar+",directories=no";
     var newWin = window.open(url, wdwName, options);      var newWin = window.open(url, wdwName, options);
     newWin.focus();      newWin.focus();
 }  }
Line 493  END Line 502  END
   
 # --------------------------------------------------- end the output and return  # --------------------------------------------------- end the output and return
  $r->print('</body></html>'."\n");   $r->print('</body></html>'."\n");
  untie(%hash);  #    } else {
     } else {  # $r->print('<html><head></head><body>Unable to tie hash to db '.
  $r->print('<html><head></head><body>Unable to tie hash to db '.  #  'file</body></html>');
   'file</body></html>');  # return OK;
  return OK;      }
       if(! $c->aborted()) {
    my %dbfile;
           if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {
               while (my($key,$value) = each(%hash)) {
                   $dbfile{$key}=$value;
               }
               untie(%dbfile);
           }
     }      }
   
     return OK;      return OK;
 }  }
   
 # ----------------------------------------------- recursive scan of a directory  # ----------------------------------------------- recursive scan of a directory
 sub scanDir {  sub scanDir {
     my ($r,$startdir,$indent,$hashref)=@_;      my ($r,$startdir,$indent,$hashref)=@_;
       my $c = $r->connection();
     my ($compuri,$curdir);      my ($compuri,$curdir);
     my $dirptr=16384;      my $dirptr=16384;
     $indent++;      $indent++;
Line 512  sub scanDir { Line 531  sub scanDir {
     my %dupdirs = %dirs;      my %dupdirs = %dirs;
     my @list=&get_list($r,$startdir);      my @list=&get_list($r,$startdir);
     foreach my $line (@list) {      foreach my $line (@list) {
           return if ($c->aborted());
  my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5);    my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5); 
  next if $strip =~ /.*\.meta$/;   next if $strip =~ /.*\.meta$/;
  my (@fileparts) = split(/\./,$strip);   my (@fileparts) = split(/\./,$strip);
Line 666  sub display_line { Line 686  sub display_line {
  $r->print("Up $tabtag</tr></form>\n");   $r->print("Up $tabtag</tr></form>\n");
  return OK;   return OK;
     }      }
   # Do we have permission to look at this?
   
       return OK if (!&Apache::lonnet::allowed('bre',$startdir.$filecom[0]));
   
 # display domain  # display domain
     if ($filecom[1] eq 'domain') {      if ($filecom[1] eq 'domain') {
Line 723  sub display_line { Line 746  sub display_line {
 # display file  # display file
     if ($fnptr == 0 and $filecom[3] ne '') {      if ($fnptr == 0 and $filecom[3] ne '') {
  my $filelink = $startdir.$filecom[0];   my $filelink = $startdir.$filecom[0];
  return OK if (!&Apache::lonnet::allowed('bre',$filelink));  
  my @file_ext = split (/\./,$listname);   my @file_ext = split (/\./,$listname);
  my $curfext = $file_ext[-1];   my $curfext = $file_ext[-1];
         if (@Omit) {          if (@Omit) {
Line 798  sub display_line { Line 820  sub display_line {
   
  $r->print("<img src=$iconpath$iconname border='0' />\n");   $r->print("<img src=$iconpath$iconname border='0' />\n");
  $r->print (" <a href=\"javascript:openWindow('".$filelink.   $r->print (" <a href=\"javascript:openWindow('".$filelink.
    "', 'metadatafile', '450', '500', 'no', 'yes')\";".     "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".
    " TARGET=_self>$listname</a> ");     " TARGET=_self>$listname</a> ");
   
  $r->print (" (<a href=\"javascript:openWindow('".$filelink.   $r->print (" (<a href=\"javascript:openWindow('".$filelink.
    ".meta', 'metadatafile', '400', '450', 'no', 'yes')\"; ".     ".meta', 'metadatafile', '400', '450', 'no', 'yes','no')\"; ".
    "TARGET=_self>metadata</a>) ") if ($metafile == 1);     "TARGET=_self>metadata</a>) ") if ($metafile == 1);
   
  $r->print("</td>\n");   $r->print("</td>\n");
Line 946  sub setvalues { Line 968  sub setvalues {
 sub cleanup {  sub cleanup {
     if (tied(%hash)){      if (tied(%hash)){
  &Apache::lonnet::logthis('Cleanup indexer: hash');   &Apache::lonnet::logthis('Cleanup indexer: hash');
         unless (untie(%hash)) {  
     &Apache::lonnet::logthis('Failed cleanup indexer: hash');  
         }  
     }      }
 }  }
   

Removed from v.1.63  
changed lines
  Added in v.1.69


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