Menu

#6 QSS 3 Alpha cannot read qmail-scanner 1.2 logs

open
nobody
None
5
2003-12-04
2003-12-04
Pantelis
No

I gave a try to the alpha release of QSS3, and i realized
that it couldn't parse the qmail-scanner 1.2 logs.

After some tweaking in the plainTextInput.class.php file,
i came up with the following:

In line 125, i changed the preg_match regexpr with this:

preg_match("/(\d+).(\S+).(\d+) (\d+):(\d+):(\d+).*\t
(\S*)\t(\S*)\t[^\t]*\t([^\t]*)\t([^\t]*)/i", $buffer,
$line);

This way i could read both log formats, but i still had a
problem as months were read as a string (i.e.: Jan, Feb,
etc.)

So, in line 142, i modified the date convertion code into
that:

# Convert date, dropping minutes and seconds to
enable caching
$dateconvert = array
('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', '
Oct', 'Nov', 'Dec');
$convert_result = array_search($line[2], $dateconvert);
if ($convert_result) {
$line[2] = $convert_result;
};
$date = mktime($line[4], 0, 0, $line[2], $line[1], $line
[3], -1);

--------------------

This seems to work ok with both log formats.
Any better suggestions would be welcome :)

Discussion

  • Alexandre Georges

    Logged In: YES
    user_id=343203

    Will be corrected in next release.

    Thanks !

    (I'm working with an old version of qmail-scanner ... please
    don't hit me ;)

     
  • Darren Coleman

    Darren Coleman - 2004-03-17

    Logged In: YES
    user_id=28008

    I also patched the old version (2.0.2):

    $date = explode(" ",$val[0]);
    if (count($date) > 2) {
    $date = strtotime($date[1]." ".$date[2]." ".$date
    [3]." ".$date[4]);
    } else {
    $date = explode("/",$val[0]);
    $dateT = $date[0];
    $date[0] = $date[1];
    $date[1] = $dateT;
    $date = strtotime(implode("/",$date));
    }

     

Log in to post a comment.

MongoDB Logo MongoDB