Diff for /nsdl/lonsql between versions 1.4 and 1.7

version 1.4, 2005/11/17 22:51:59 version 1.7, 2005/11/24 21:34:31
Line 404  sub make_new_child { Line 404  sub make_new_child {
                 }                  }
             } else {              } else {
                 # Do an sql query                  # Do an sql query
                 $result = &do_sql_query($query,$arg1,$arg2);                  $result = &nsdl_query($query,$arg1,$arg2);
             }              }
             # result does not need to be escaped because it has already been              # result does not need to be escaped because it has already been
             # escaped.              # escaped.
Line 420  sub make_new_child { Line 420  sub make_new_child {
         exit;          exit;
     }      }
 }  }
   
 ########################################################  
 ########################################################  
   
 =pod  
   
 =item &do_sql_query  
   
 Runs an sql metadata table query.  
   
 Inputs: $query, $custom, $customshow  
   
 Returns: A string containing escaped results.  
   
 =cut  
   
 ########################################################  
 ########################################################  
 {  
     my @metalist;  
   
 sub process_file {  
     if ( -e $_ &&  # file exists  
          -f $_ &&  # and is a normal file  
          /\.meta$/ &&  # ends in meta  
          ! /^.+\.\d+\.[^\.]+\.meta$/  # is not a previous version  
          ) {  
         push(@metalist,$File::Find::name);  
     }  
 }  
   
 sub do_sql_query {  
     my ($query) = @_;  
     &logthis('doing query '.$query);  
    
     my @results = ();  
    
     #  
     if ($query) {  
         #prepare and execute the query  
  my $aref=&nsdl_query($query);  
  foreach my $row (@$aref) {  
     my @b=map { &escape($_); } @$row;  
     push @results,join(",", @b);  
  }  
           
     }  
     return join("&",@results);  
 } # End of &do_sql_query  
   
 } # End of scoping curly braces for &process_file and &do_sql_query  
 ########################################################  
 ########################################################  ########################################################
   
 =pod  =pod
Line 845  sub HUPSMAN {                      # sig Line 793  sub HUPSMAN {                      # sig
 #  #
 # Takes SQL query  # Takes SQL query
 # sends it to NSDL  # sends it to NSDL
 # has to return array reference  
 #  #
   
 sub nsdl_query {  sub nsdl_query {
     my $query=shift;      my $query=shift;
     my ($keyword)=($query=~/\"\%([^\%]+)\%\"/);      my ($keyword)=($query=~/\"\%([^\%]+)\%\"/);
     $keyword=&escape($keyword);      $keyword=&escape($keyword);
     &logthis('Doing '.$keyword);      my $url='http://search.nsdl.org?verb=Search&s=0&n=500&q=-link.primaryCollection:oai\:nsdl.org\:nsdl.nsdl\:00254%20'.$keyword;
     my $url='http://search.nsdl.org?verb=Search&s=0&n=500&q='.$keyword;  
     my $ua=new LWP::UserAgent;      my $ua=new LWP::UserAgent;
     my $response=$ua->get($url);      my $response=$ua->get($url);
     my $parser=HTML::LCParser->new(\$response->content);      my $parser=HTML::LCParser->new(\$response->content);
     my %result=();      my $is='';
     my $is=();  
     my $cont='';      my $cont='';
     my $array=[];  
     my $token;      my $token;
       my %result=();
       my $allresults='';
     while ($token=$parser->get_token) {      while ($token=$parser->get_token) {
  if ($token->[0] eq 'T') {   if ($token->[0] eq 'T') {
     $cont.=$token->[1];      $cont.=$token->[1];
  } elsif ($token->[0] eq 'S') {   } elsif ($token->[0] eq 'S') {
     if ($token->[1] eq 'record') {      if ($token->[1] eq 'record') {
  %result=();   %result=();
     } elsif ($token->[1]=/^dc\:/) {      } elsif ($token->[1]=~/^dc\:/) {
  $is=$token->[1];   $is=$token->[1];
  $cont='';   $cont='';
     }      }
Line 877  sub nsdl_query { Line 823  sub nsdl_query {
 #  #
 # Now store it away  # Now store it away
 #  #
     } elsif ($token->[1]=/^dc\:/) {                  my $url=$result{'dc:identifier'};
                   if ($url=~/^http\:/) {
                      $url=~s/^http:\//\/ext/;
                   } else {
                      $url='';
                   }
                   $allresults.='&'.
                       &escape($result{'dc:title'}).','.
                       &escape($result{'dc:creator'}).','.
                       &escape($url).','.
                       &escape($result{'dc:subject'}).',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,';
       } elsif ($token->[1]=~/^dc\:/) {
  $result{$is}=$cont;   $result{$is}=$cont;
     }      }
  }   }
     }      }
     return $array;      $allresults=~s/^\&//;
   &logthis($allresults);
       return $allresults;
 }  }
   
 =pod  =pod

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


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.