Diff for /loncom/cgi/metadata_keywords.pl between versions 1.6 and 1.7

version 1.6, 2003/09/01 03:37:27 version 1.7, 2008/11/28 20:50:25
Line 61 Line 61
   
 # ------------------------------------------------- Modules used by this script  # ------------------------------------------------- Modules used by this script
   
 use lib '/home/httpd/lib/perl/';  
 use LONCAPA::Configuration;  
   
   $|=1;
 use strict;  use strict;
 use DBI;  use DBI;
   use lib '/home/httpd/lib/perl/';
   use Apache::lonlocal;
   use LONCAPA::Configuration;
   use LONCAPA::loncgi;
   
 # ---------------------------- Print MIME Content-type and other initialization  # ---------------------------- Print MIME Content-type and other initialization
 $|=1;  
 print 'Content-type: text/plain'."\n\n";  print 'Content-type: text/plain'."\n\n";
   
   &main();
   
   sub main {
       if (!&LONCAPA::loncgi::check_ipbased_access('metadatakeywords')) {
           if (!&LONCAPA::loncgi::check_cookie_and_load_env()) {
               &Apache::lonlocal::get_language_handle();
               print(&LONCAPA::loncgi::missing_cookie_msg());
               return;
           }
   
           if (!&LONCAPA::loncgi::can_view('metadata_keywords')) {
               &Apache::lonlocal::get_language_handle();
               print(&LONCAPA::loncgi::unauthorized_msg('metadata_keywords'));
               return;
           }
       }
   
       &Apache::lonlocal::get_language_handle();
   
 # --- Make sure that database can be accessed and that this is a library server  # --- Make sure that database can be accessed and that this is a library server
 # library server test  # library server test
   
 # By default, loncapa_apache.conf is also read by the read_conf subroutine.  # By default, loncapa_apache.conf is also read by the read_conf subroutine.
 my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');      my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
 my %perlvar=%{$perlvarref};      my %perlvar=%{$perlvarref};
 undef($perlvarref);      undef($perlvarref);
   
 unless ($perlvar{'lonRole'} eq 'library') {      unless ($perlvar{'lonRole'} eq 'library') {
     print "This can only be run on a library server!\n";           print(&Apache::lonlocal::mt('This can only be run on a library server!)."\n");
     exit;           return;
 }      }
   
 # database test  # database test
 my $dbh;      my $dbh;
 {      {
     unless (          unless (
     $dbh = DBI->connect("DBI:mysql:loncapa","www",             $dbh = DBI->connect("DBI:mysql:loncapa","www",
  $perlvar{'lonSqlAccess'},      $perlvar{'lonSqlAccess'},
  { RaiseError =>0,PrintError=>0})      { RaiseError =>0,PrintError=>0})
     ) {          ) { 
  print "Cannot connect to database!\n";      print "Cannot connect to database!\n";
  exit;      return;
           }
     }      }
 }      %perlvar=(); # undefine it
 %perlvar=(); # undefine it  
   
 # ------------------------ Loop through database records and print out keywords  # ------------------------ Loop through database records and print out keywords
 my $sth=$dbh->prepare("select * from metadata");      my $sth=$dbh->prepare("select * from metadata");
 $sth->execute();      $sth->execute();
 my @row;      my @row;
 while (@row=$sth->fetchrow_array) {      while (@row=$sth->fetchrow_array) {
     print $row[4]."\n";          print $row[4]."\n";
 }      }
   
 # --------------------------------------------------- Close database connection  # --------------------------------------------------- Close database connection
 $dbh->disconnect();      $dbh->disconnect();
       return;
   }

Removed from v.1.6  
changed lines
  Added in v.1.7


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