[LON-CAPA-cvs] cvs: loncom / lonsql

www lon-capa-cvs@mail.lon-capa.org
Mon, 24 Jun 2002 14:22:05 -0000


www		Mon Jun 24 10:22:05 2002 EDT

  Modified files:              
    /loncom	lonsql 
  Log:
  Handle doubly-used delimiter "&" in activity.log, install more filters for
  userlog.
  
  
Index: loncom/lonsql
diff -u loncom/lonsql:1.48 loncom/lonsql:1.49
--- loncom/lonsql:1.48	Tue Jun 18 17:14:23 2002
+++ loncom/lonsql	Mon Jun 24 10:22:05 2002
@@ -3,7 +3,7 @@
 # The LearningOnline Network
 # lonsql - LON TCP-MySQL-Server Daemon for handling database requests.
 #
-# $Id: lonsql,v 1.48 2002/06/18 21:14:23 www Exp $
+# $Id: lonsql,v 1.49 2002/06/24 14:22:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -204,10 +204,22 @@
     while ($line=<IN>) {
         chomp($line);
         my ($timestamp,$host,$log)=split(/\:/,$line);
-        foreach (split(/\&/,&unescape($log))) {
-	    my ($time,$res,$uname,$udom,$action,$values)=split(/\:/,$_);
+#
+# $log has the actual log entries; currently still escaped, and
+# %26(timestamp)%3a(url)%3a(user)%3a(domain)
+# then additionally
+# %3aPOST%3a(name)%3d(value)%3a(name)%3d(value)
+# or
+# %3aCSTORE%3a(name)%3d(value)%26(name)%3d(value)
+#
+# get delimiter between timestamped entries to be &&&
+        $log=~s/\%26(\d+)\%3a/\&\&\&$1\%3a/g;
+# now go over all log entries 
+        foreach (split(/\&\&\&/,&unescape($log))) {
+	    my ($time,$res,$uname,$udom,$action,@values)=split(/\:/,$_);
+            my $values=&unescape(join(':',@values));
+            $values=~s/\&/\:/g;
             $res=&unescape($res);
-            $values=&unescape($values);
             my $include=1;
             if (($filters{'username'}) && ($uname ne $filters{'username'})) 
                                                                { $include=0; }
@@ -226,7 +238,8 @@
             if (($filters{'action'} eq 'grade') && ($action ne 'CSTORE')) 
                                                                { $include=0; }
             if ($include) {
-	       push(@results,$time.':'.$res.':'.$uname.':'.$udom.':'.
+	       push(@results,($time<1000000000?'0':'').$time.':'.$res.':'.
+                                            $uname.':'.$udom.':'.
                                             $action.':'.$values);
             }
        }
@@ -251,7 +264,13 @@
         my ($timestamp,$host,$log)=split(/\:/,$line);
         $log=&unescape($log);
         my $include=1;
+        if (($filters{'start'}) && ($timestamp<$filters{'start'})) 
+                                                             { $include=0; }
+        if (($filters{'end'}) && ($timestamp>$filters{'end'})) 
+                                                             { $include=0; }
         if (($filters{'action'} eq 'log') && ($log!~/^Log/)) { $include=0; }
+        if (($filters{'action'} eq 'check') && ($log!~/^Check/)) 
+                                                             { $include=0; }
         if ($include) {
 	   push(@results,$timestamp.':'.$log);
         }