[LON-CAPA-cvs] cvs: loncom / lond lonsql /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 18 Jun 2002 19:39:13 -0000


www		Tue Jun 18 15:39:13 2002 EDT

  Modified files:              
    /loncom	lond lonsql 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Toward bug 121 - filters start to work now.
  
  lonsearchcat display definitely broken due to "escape" bugfix in lonsql.
  
  
Index: loncom/lond
diff -u loncom/lond:1.81 loncom/lond:1.82
--- loncom/lond:1.81	Fri May 17 10:03:04 2002
+++ loncom/lond	Tue Jun 18 15:39:13 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.81 2002/05/17 14:03:04 matthew Exp $
+# $Id: lond,v 1.82 2002/06/18 19:39:13 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1292,17 +1292,11 @@
 # ------------------------------------------------------------------- querysend
                    } elsif ($userinput =~ /^querysend/) {
                        my ($cmd,$query,
-			   $custom,$customshow)=split(/:/,$userinput);
+			   $arg1,$arg2,$arg3)=split(/\:/,$userinput);
 		       $query=~s/\n*$//g;
-		       unless ($custom or $customshow) {
-			   print $client "".
-			       sqlreply("$hostid{$clientip}\&$query")."\n";
-		       }
-		       else {
-			   print $client "".
+		       print $client "".
 			       sqlreply("$hostid{$clientip}\&$query".
-					"\&$custom"."\&$customshow")."\n";
-		       }
+					"\&$arg1"."\&$arg2"."\&$arg3")."\n";
 # ------------------------------------------------------------------ queryreply
                    } elsif ($userinput =~ /^queryreply/) {
                        my ($cmd,$id,$reply)=split(/:/,$userinput); 
Index: loncom/lonsql
diff -u loncom/lonsql:1.46 loncom/lonsql:1.47
--- loncom/lonsql:1.46	Tue Jun 18 11:04:05 2002
+++ loncom/lonsql	Tue Jun 18 15:39:13 2002
@@ -3,7 +3,7 @@
 # The LearningOnline Network
 # lonsql - LON TCP-MySQL-Server Daemon for handling database requests.
 #
-# $Id: lonsql,v 1.46 2002/06/18 15:04:05 www Exp $
+# $Id: lonsql,v 1.47 2002/06/18 19:39:13 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -195,7 +195,7 @@
 sub courselog {
     my ($path,$command)=@_;
     my %filters=();
-    foreach (split(/\=/,&unescape($command))) {
+    foreach (split(/\:/,&unescape($command))) {
 	my ($name,$value)=split(/\=/,$_);
         $filters{$name}=$value;
     }
@@ -205,9 +205,29 @@
         chomp($line);
         my ($timestamp,$host,$log)=split(/\:/,$line);
         foreach (split(/\&/,&unescape($log))) {
-	    my ($res,$uname,$udom,$action,$values)=split(/\:/,$_);
+	    my ($time,$res,$uname,$udom,$action,$values)=split(/\:/,$_);
             my $include=1;
-        }
+            if (($filters{'username'}) && ($uname ne $filters{'username'})) 
+                                                               { $include=0; }
+            if (($filters{'domain'}) && ($udom ne $filters{'domain'})) 
+                                                               { $include=0; }
+            if (($filters{'url'}) && ($res!~/$filters{'url'}/)) 
+                                                               { $include=0; }
+            if (($filters{'start'}) && ($time<$filters{'start'})) 
+                                                               { $include=0; }
+            if (($filters{'end'}) && ($time>$filters{'end'})) 
+                                                               { $include=0; }
+            if (($filters{'action'} eq 'view') && ($action)) 
+                                                               { $include=0; }
+            if (($filters{'action'} eq 'submit') && ($action ne 'POST')) 
+                                                               { $include=0; }
+            if (($filters{'action'} eq 'grade') && ($action ne 'CSTORE')) 
+                                                               { $include=0; }
+            if ($include) {
+	       push(@results,$time.':'.$res.':'.$uname.':'.$udom.':'.
+                                            $action.':'.$values);
+            }
+       }
     }
     close IN;
     return join('&',sort(@results));
@@ -218,7 +238,7 @@
 sub userlog {
     my ($path,$command)=@_;
     my %filters=();
-    foreach (split(/\=/,&unescape($command))) {
+    foreach (split(/\:/,&unescape($command))) {
 	my ($name,$value)=split(/\=/,$_);
         $filters{$name}=$value;
     }
@@ -337,7 +357,7 @@
 	    $queryid .= $run;
 	    print $client "$queryid\n";
 	    
-	    &logthis("QUERY: $query");
+	    &logthis("QUERY: $query - $arg1 - $arg2 - $arg3");
 	    sleep 1;
 
             my $result='';
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.240 loncom/lonnet/perl/lonnet.pm:1.241
--- loncom/lonnet/perl/lonnet.pm:1.240	Tue Jun 18 11:04:05 2002
+++ loncom/lonnet/perl/lonnet.pm	Tue Jun 18 15:39:13 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.240 2002/06/18 15:04:05 www Exp $
+# $Id: lonnet.pm,v 1.241 2002/06/18 19:39:13 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1836,7 +1836,7 @@
     my $uhome=&homeserver($uname,$udom);
     if ($uhome eq 'no_host') { return 'error: no_host'; }
     my $uhost=$hostname{$uhome};
-    my $command=&escape(join('&',map{$_.'='.$filters{$_}} keys %filters));
+    my $command=&escape(join(':',map{$_.'='.$filters{$_}} keys %filters));
     my $queryid=&reply("querysend:".$query.':'.$udom.':'.$uname.':'.$command,
                        $uhome);
     unless ($queryid=~/^$uhost\_/) { return 'error: '.$queryid; }
@@ -1844,7 +1844,6 @@
     my $reply='';
     for (1..100) {
 	sleep 2;
-        &logthis('wait');
         if (-e $replyfile.'.end') {
 	    if (my $fh=Apache::File->new($replyfile)) {
                $reply.=<$fh>;
@@ -1857,12 +1856,25 @@
 }
 
 sub courselog_query {
+#
+# possible filters:
+# url: url or symb
+# username
+# domain
+# action: view, submit, grade
+# start: timestamp
+# end: timestamp
+#
     my (%filters)=@_;
     unless ($ENV{'request.course.id'}) { return 'no_course'; }
+    if ($filters{'url'}) {
+	$filters{'url'}=&symbclean(&declutter($filters{'url'}));
+        $filters{'url'}=~s/\.(\w+)$/(\\.\\d+)*\\.$1/;
+        $filters{'url'}=~s/\.(\w+)\_\_\_/(\\.\\d+)*\\.$1/;
+    }
     my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
     return &log_query($cname,$cdom,'courselog',%filters);
-
 }
 
 sub userlog_query {