VincentLog
Home
About

FAQs

General
Admin
Assist
Student

Docs

Admin
Assistant

CGI

Admin
Assistant
Download
Form
Student

Packages

AdminInterface
Assignments
AssistantInterface
Form
Interface
Record
Roster
StudentInterface
SystemVariables
Teams
VincentFile
VincentLog


  0 #Vincent's Logging Package
  1 #Copyright 2000 Matt Jadud
  2 #This program is free software; you can redistribute it and/or
  3 #modify it under the terms of the GNU General Public License
  4 #as published by the Free Software Foundation; either version 2
  5 #of the License, or (at your option) any later version.
  6 #
  7 #This program is distributed in the hope that it will be useful,
  8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
  9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 10 #GNU General Public License for more details.
 11 #
 12 #You should have received a copy of the GNU General Public License
 13 #along with this program; if not, write to the Free Software
 14 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 15 
 16 use SystemVariables;
 17 
 18 package VincentLog; 
 19 use Fcntl qw(:flock);  # imports LOCK_EX, LOCK_SH, LOCK_NB
 20 
 21 my ($delim);
 22 $del = "|";
 23 
 24 return 1;
 25 
 26 sub clickLog  {
 27 
 28     my($username,
 29        $function,
 30        $message,
 31        $div,
 32        $path,
 33        $date,
 34        $year,
 35        $month,
 36        $day,
 37        $log);
 38 
 39     $username = $ENV{REMOTE_USER};
 40     $function = $_[0];
 41     $message  = $_[1];
 42     $div      = "|";
 43 
 44     $path = SystemVariables::getLogPath();
 45     $date = SystemVariables::getCurrentTime();
 46     ($year,$month,$day) = (split(/,/, $date))[0,1,2];
 47     $log  = $year . $month . $day;
 48     
 49     #The DEBUG script calls clickLog... which, would call DEBUG,
 50     # which would call clickLog.... this is not a good idea here...
 51     #SystemVariables::DEBUG("VLog:", $path . $log);
 52     #SystemVariables::DEBUG("VLog:", "Logging $function$div$message for $username.");
 53 
 54     open(LOG, ">>" . $path . $log) || die("Can't open logfile $path $log.");
 55     
 56     flock(LOG, LOCK_EX);
 57     
 58     print LOG $username, $div, $0, $div, $date, $div, $function, $div, $message, "n";
 59     
 60     close(LOG);
 61 }
 62 
 63 
 64 ##CONTRACT
 65 # fileLog : array[username, assignmentID, filename, username] -> void
 66 ##PURPOSE
 67 # fileLog generates a log entry for every file passing into the 
 68 # system. Logs are placed in the user's individual recordspace.
 69 ##DEPENDANCIES
 70 # VincentLog::filenameCleaner()
 71 # SystemVariables::currentTime()
 72 # SystemVariables::getStudentRecordPath()
 73 
 74 sub fileLog  {
 75 
 76     my ($username,
 77 	$file,
 78 	$path,
 79 	$theirname,
 80 	$assignment,
 81 	@input
 82 	);
 83 
 84     @input = @_;
 85     chomp @input;
 86 
 87     $username    = $input[0];
 88     $assignment  = $input[1];
 89     $file        = $input[2];
 90     $theirname   = $input[3];
 91     $ontimebit   = $input[4];
 92     $slipused    = $input[5];
 93     $currenttime = SystemVariables::currentTime();
 94     
 95     $theirname = filenameCleaner($theirname);
 96 
 97     $path     = SystemVariables::getStudentRecordPath($username);
 98     open(FILELOG, ">>$path" . "filelog") 
 99 	|| die ("Can't open filelog for $username !!");
 100     
 101     flock(FILELOG, LOCK_EX);
 102     
 103     print FILELOG $username, $del, $assignment, $del, 
 104     $file, $del, $theirname, $del, $currenttime, $del,
 105     $ontimebit, $del, $slipused, "n";
 106 
 107     close(FILELOG);
 108 }
 109 
 110 ##CONTRACT
 111 # filenameCleaner : string -> string
 112 ##PURPOSE
 113 # Takes a string representing a filename, and removes
 114 # all characters that might be potentially offensive
 115 # to the base filesystem and/or scripting language
 116 # responsible for handling the files.
 117 ##DEPENDANCIES
 118 # None.
 119 sub filenameCleaner  {
 120 
 121     $_ = $_[0];
 122     
 123     #Path separators
 124     s////g;
 125     s/\//g;
 126     s/://g;
 127 
 128     #Above the keyboard
 129     s/~//g;
 130     s/!//g;
 131     s/@//g;
 132     s/#//g;
 133     s/$//g;
 134     s/%//g;
 135     s/^//g;
 136     s/&//g;
 137     s/*//g;
 138     s/(//g;
 139     s/)//g;
 140     
 141     #Brackets
 142     s/\{//g;
 143     s/\}//g;
 144     s/[//g;
 145     s/]//g;
 146     
 147     #Punctuation
 148     s/,//g;
 149     s/;//g;
 150     s/'//g;
 151     s/"//g;
 152     s/`//g;
 153     s/|//g;
 154     s/?//g;
 155     s/<//g;
 156     s/>//g;
 157     
 158     #Spaces to Nothing..
 159     s/ //g;
 160     s/s+//g;
 161 
 162     #Carriage returns and LFs?
 163     s/n//g;
 164     s/r//g;
 165     
 166     #Just in case?
 167     chomp;
 168 
 169     return $_;
 170 }
 171 
 172 sub textCleaner  {
 173 
 174 
 175     $_ = $_[0];
 176     
 177     #Path separators
 178     s////g;
 179     s/\//g;
 180     #s/://g;
 181 
 182     #Above the keyboard
 183     s/~//g;
 184     #s/!//g;
 185     s/@//g;
 186     s/#//g;
 187     s/$//g;
 188     s/%//g;
 189     s/^//g;
 190     s/&//g;
 191     s/*//g;
 192     #s/(//g;
 193     #s/)//g;
 194     
 195     #Brackets
 196     s/\{//g;
 197     s/\}//g;
 198     s/[//g;
 199     s/]//g;
 200     
 201     #Punctuation
 202     s/,//g;
 203     s/;//g;
 204     s/'//g;
 205     #s/"//g;
 206     s/`//g;
 207     s/|//g;
 208     #s/?//g;
 209     s/<//g;
 210     s/>//g;
 211    
 212  
 213     #Carriage returns and LFs?
 214     s/n/ /g;
 215     s/r/ /g;
 216 
 217     #Extra spaces to one space
 218     s/s+/ /g;
 219     
 220     #Just in case?
 221     chomp;
 222 
 223     return $_;
 224 
 225 }
 226 
 227 ##CONTRACT
 228 # DEBUG : array -> void
 229 ##PURPOSE
 230 # Writes the contents of the passed array to STDOUT.
 231 # This is a non-explicit print to STDOUT, and
 232 # Perl CGIs seem to occasionally treat this 
 233 # differently than explicitly declaring STDOUT... 
 234 # This is not understood.
 235 ##DEPENDANCIES
 236 # None.
 237 sub useDebugging())'>DEBUG { if(SystemVariables::useDebugging())  { print "VinLog: ", @_, "n<P>"; } }

Last update: 1/6/01; 9:32:40 AM