]> git.llucax.com Git - z.facultad/75.08/llamadas.git/blobdiff - inst/antifraude.pl
Agrego material pulenta para el final.
[z.facultad/75.08/llamadas.git] / inst / antifraude.pl
index 3e9a9f0faa0b13fb5ba8453fe58ed7eea9d69fde..6583252cba8982872bf5d5d9448203dbdfc05516 100644 (file)
@@ -76,18 +76,22 @@ sub logEntry {
        my $log = "$CONFDATA{logdir}/$CONFDATA{logfile}";
        # Fetch date and Format it
        ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-       $year += 1900; $year = sprintf("%02d", $year % 100); ++$mon;
-       $user = getlogin || "Unidentified";
-       $commonstring = "[$mday/$mon/$year $hour:$min:$sec|$user|antifraude]";
+       $mon =~ s/^(\d)$/0$1/;
+       $mday =~ s/^(\d)$/0$1/;
+       $hour =~ s/^(\d)$/0$1/;
+       $min =~ s/^(\d)$/0$1/;
+       $year += 1900; ++$mon;
+       $user = "$ENV{USER}";
+       $commonstring = "$mday/$mon/$year-$hour:$min $user antifraude:";
        # Append to log
        open(LOGFILE,">>$log") or die "No se pudo abrir el archivo de log";
        seek(LOGFILE,0,2);
-       print LOGFILE "$commonstring - $logentry\n";
+       print LOGFILE "$commonstring \"$logentry\"\n";
        $filesize = tell(LOGFILE);
        close(LOGFILE);
 
        # Chequeo el logsize y su lo supero me quedo con 100 lineas
-       if ($filesize > ($CONFDATA{logsize} * 1024 * 1024))
+       if ($filesize > $CONFDATA{logsize})
        {
                open(LOGFILE,"+<$log");
                do ($line = <LOGFILE>) until $. == 100;
@@ -133,13 +137,19 @@ sub checkUmbrales {
        if ($matchedUmbral > 0) {
                # Obtengo algunos datos
                ($central = $callsfile) =~ s/^.*\.//;
-               $user = getlogin || 'Unidentified';
+               $user = "$ENV{USER}";
 
                # Fetch date and Format it
                ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
                $year += 1900; ++$mon;
-               $date = "$year$mon$mday";
-               $time = "$hour$min$sec";
+               $mon =~ s/^(\d)$/0$1/;
+               $mday =~ s/^(\d)$/0$1/;
+               $hour =~ s/^(\d)$/0$1/;
+               $min =~ s/^(\d)$/0$1/;
+               $sec =~ s/^(\d)$/0$1/;
+               $user = "$ENV{USER}";
+               $date = "${year}${mon}${mday}";
+               $time = "${hour}${min}${sec}";
 
                # Preparo el registro de alarma
                $alarmEntry = "$callfields[7];$central;$callfields[0];$callfields[1];$regid;$callfields[2];$callfields[3];$user;$date;$time";
@@ -173,12 +183,6 @@ open(PARAMFILE,"$CONFDIR/umbrales.param") or die "No se pudo abrir el archivo de
 @UMBRALES = <PARAMFILE>;
 close(PARAMFILE);
 
-# For Debug Only
-print("\nLogdir: $CONFDATA{logdir}\n");
-print("Logfile: $CONFDATA{logfile}\n");
-print("Logsize: $CONFDATA{logsize}\n");
-print("Datadir: $CONFDATA{datadir}\n\n");
-
 # Proceso los archivos de llamadas
 @archivos = getCallFiles();
 FILE: foreach $filename (@archivos) {