[LON-CAPA-cvs] cvs: modules /gerd/irt encrypt_activity.pl

www www@source.lon-capa.org
Sat, 18 Dec 2010 21:09:42 -0000


www		Sat Dec 18 21:09:42 2010 EDT

  Added files:                 
    /modules/gerd/irt	encrypt_activity.pl 
  Log:
  Activity log encrypter
  
  

Index: modules/gerd/irt/encrypt_activity.pl
+++ modules/gerd/irt/encrypt_activity.pl
my $newfile=shift;
$newfile=~s/\W//gs;

unless ($newfile) { 
   print "Need file name\n";
   exit; 
}
print "Unzipping\n";
system("gunzip activity.log.xml.gz");
unless (open(IN,'activity.log.xml')) { 
   print "Could not open file.\n"; 
   exit; 
}
print "Opened file, converting.\n";
my $line;
open(OUT,">$newfile.log.xml");
while ($line=<IN>) {
   $line=~s/\<student\>([^\:]+)\:(\w+)\<\/student\>/&encrypt($1,$2)/gse;
   print OUT $line;
}
close(OUT);
close(IN);
print "Done converting, zipping.\n";
system("gzip $newfile.log.xml");
print "Removing original file.\n";
unlink('activity.log.xml');
print "Done.\n";
exit;

sub encrypt {
   my ($user,$domain)=@_;
   return '<student>'.crypt($user,42).':'.$domain.'</student>';
}