2014-07-14 08:18:11 +02:00
|
|
|
<?php
|
|
|
|
// ______ __ _______ _______ _______
|
2019-01-30 16:18:44 +01:00
|
|
|
// | __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __|
|
|
|
|
// | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
|
|
// |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
2014-07-14 08:18:11 +02:00
|
|
|
//
|
|
|
|
// ============================================================================
|
2020-11-27 13:52:35 +01:00
|
|
|
// Copyright (c) 2007-2021 Artica Soluciones Tecnologicas, http://www.artica.es
|
2014-07-14 08:18:11 +02:00
|
|
|
// This code is NOT free software. This code is NOT licenced under GPL2 licence
|
|
|
|
// You cannnot redistribute it without written permission of copyright holder.
|
|
|
|
// ============================================================================
|
2019-01-30 16:18:44 +01:00
|
|
|
$ownDir = dirname(__FILE__).'/';
|
|
|
|
$ownDir = str_replace('\\', '/', $ownDir);
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-11-21 13:08:58 +01:00
|
|
|
// Don't start a session before this import.
|
|
|
|
// The session is configured and started inside the config process.
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once $ownDir.'../include/config.php';
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once $config['homedir'].'/include/functions.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_db.php';
|
|
|
|
require_once $config['homedir'].'/include/auth/mysql.php';
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-11-21 13:08:58 +01:00
|
|
|
global $config;
|
2014-07-14 08:18:11 +02:00
|
|
|
|
|
|
|
// Login check
|
2019-01-30 16:18:44 +01:00
|
|
|
if (!isset($_SESSION['id_usuario'])) {
|
|
|
|
$config['id_user'] = null;
|
|
|
|
} else {
|
|
|
|
$config['id_user'] = $_SESSION['id_usuario'];
|
2014-07-14 08:18:11 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
check_login();
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (! check_acl($config['id_user'], 0, 'PM')) {
|
|
|
|
db_pandora_audit('ACL Violation', 'Trying to access audit CSV export');
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
2014-07-14 08:18:11 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter_type = (string) get_parameter('filter_type');
|
|
|
|
$filter_user = (string) get_parameter('filter_user');
|
|
|
|
$filter_text = (string) get_parameter('filter_text');
|
|
|
|
$filter_period = get_parameter('filter_period', null);
|
2018-05-04 13:38:04 +02:00
|
|
|
$filter_period = ($filter_period !== null) ? (int) $filter_period : 24;
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter_ip = (string) get_parameter('filter_ip');
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter = '1=1';
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
if (!empty($filter_type)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter .= sprintf(" AND accion = '%s'", $filter_type);
|
2014-07-14 08:18:11 +02:00
|
|
|
}
|
2018-05-04 13:38:04 +02:00
|
|
|
|
|
|
|
if (!empty($filter_user)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter .= sprintf(" AND id_usuario = '%s'", $filter_user);
|
2014-07-14 08:18:11 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
if (!empty($filter_text)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter .= sprintf(" AND (accion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $filter_text, $filter_text);
|
2018-05-04 13:38:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($filter_ip)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $filter_ip);
|
2018-05-04 13:38:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($filter_period)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
switch ($config['dbtype']) {
|
|
|
|
case 'mysql':
|
|
|
|
$filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -'.$filter_period.' HOUR)';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'postgresql':
|
|
|
|
$filter .= ' AND fecha >= NOW() - INTERVAL \''.$filter_period.' HOUR \'';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'oracle':
|
|
|
|
$filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \''.$filter_period.'\' HOUR)';
|
|
|
|
break;
|
|
|
|
}
|
2014-07-14 08:18:11 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$sql = sprintf('SELECT * FROM tsesion WHERE %s ORDER BY fecha DESC', $filter);
|
2018-05-04 13:38:04 +02:00
|
|
|
$result = db_get_all_rows_sql($sql);
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
print_audit_csv($result);
|