#!/usr/bin/perl
# log_parser.pl
# Functions for parsing this module's logs
# STTA Rev. 1.2 Copyright (c) Jess Prez Lorenzo  --- license GNU GPL 

 require './tarantella-lib.pl';
 
# parse_webmin_log(user, script, action, type, object, &params)
# Converts logged information from this module into human-readable form
sub parse_webmin_log
{
local ($user, $script, $action, $type, $object, $p) = @_;
	return ("HOLA COLEGA");
#&text("log_stta", "<tt>$object ---</tt>",
#	return &text("log_stta", "<tt>$object ---</tt>",
#		     "<tt>$p->{'name='}</tt>", "<tt>$p->{'dns_peer='}</tt>",
#		     "<tt>$p->{'ttaarray_status='}</tt>");
}

# parse_webmin_log(user, script, action, type, object, &params)
# Converts logged information from this module into human-readable form
sub parses_webmin_log
{
local ($user, $script, $action, $type, $object, $p, $long) = @_;
if ($action eq 'stop') {
	return $text{'log_stop'};
	}
elsif ($action eq 'start') {
	return $text{'log_start'};
	}
elsif ($type eq 'db') {
	return &text("log_${type}_${action}", "<tt>$object</tt>");
	}
elsif ($type eq 'table') {
	return &text("log_${type}_${action}", "<tt>$object</tt>",
		     "<tt>$p->{'db'}</tt>");
	}
elsif ($type eq 'field') {
	$p->{'size'} =~ s/\s+$//;
	return &text("log_${type}_${action}", "<tt>$object</tt>",
		     "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>",
		     "<tt>$p->{'type'}$p->{'size'}</tt>");
	}
elsif ($type eq 'data') {
	return &text("log_${type}_${action}", "<tt>$object</tt>",
		     "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>");
	}
elsif ($action eq 'exec') {
	return &text($long ? 'log_exec_l' : 'log_exec', "<tt>$object</tt>",
		     "<tt>$p->{'cmd'}</tt>");
	}
elsif ($type eq 'user' || $type eq 'perm' || $type eq 'host' ||
       $type eq 'tpriv' || $type eq 'cpriv') {
	$p->{'user'} = $text{'log_anon'}
		if ($p->{'user'} eq '-' || $p->{'user'} eq '%');
	$p->{'db'} = $text{'log_any'}
		if ($p->{'db'} eq '-' || $p->{'db'} eq '%');
	$p->{'host'} = $text{'log_any'}
		if ($p->{'host'} eq '-' || $p->{'host'} eq '%');
	local $t = "log_${type}_${action}";
	if ($long && $text{$t.'_l'}) { $t .= '_l'; }
	return &text($t, "<tt>$p->{'user'}</tt>",
		     "<tt>$p->{'host'}</tt>", "<tt>$p->{'db'}</tt>",
		     "<tt>$p->{'table'}</tt>", "<tt>$p->{'field'}</tt>");
	}
elsif ($action eq 'backup') {
	return &text($long ? 'log_backup_l' : 'log_backup', "<tt>$object</tt>",
		     "<tt>$p->{'file'}</tt>");
	}
elsif ($action eq 'execfile') {
	return &text($p->{'mode'} ? 'log_execupload' : 'log_execfile',
		     "<tt>$p->{'file'}</tt>");
	}
elsif ($action eq 'import') {
	return &text($p->{'mode'} ? 'log_importupload' : 'log_importfile',
		     "<tt>$p->{'file'}</tt>");
	}
else {
	return undef;
	}
}

