2014-07-14 08:18:11 +02:00
|
|
|
<?php
|
|
|
|
// ______ __ _______ _______ _______
|
|
|
|
//| __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __|
|
|
|
|
//| __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
|
|
//|___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
//
|
|
|
|
// ============================================================================
|
|
|
|
// Copyright (c) 2007-2010 Artica Soluciones Tecnologicas, http://www.artica.es
|
|
|
|
// This code is NOT free software. This code is NOT licenced under GPL2 licence
|
|
|
|
// You cannnot redistribute it without written permission of copyright holder.
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-01-30 11:48:20 +01:00
|
|
|
$ownDir = dirname(__FILE__) . '/';
|
|
|
|
$ownDir = str_replace("\\", "/", $ownDir);
|
2018-05-04 13:38:04 +02:00
|
|
|
require_once($ownDir . "../include/config.php");
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-05-04 13:38:04 +02: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-05-04 13:38:04 +02:00
|
|
|
global $config;
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
if (! isset($_SESSION["id_usuario"])) {
|
|
|
|
session_start();
|
|
|
|
session_write_close();
|
2014-07-14 08:18:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Login check
|
2016-11-18 13:01:13 +01:00
|
|
|
if (!isset($_SESSION["id_usuario"])) {
|
2014-07-14 08:18:11 +02:00
|
|
|
$config['id_user'] = null;
|
|
|
|
}
|
|
|
|
else {
|
2016-11-18 13:01:13 +01:00
|
|
|
$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
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
if (! check_acl($config['id_user'], 0, "PM")) {
|
|
|
|
db_pandora_audit("ACL Violation", "Trying to access audit CSV export");
|
|
|
|
require("general/noaccess.php");
|
2014-07-14 08:18:11 +02:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2018-05-04 13:38:04 +02: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);
|
|
|
|
$filter_period = ($filter_period !== null) ? (int) $filter_period : 24;
|
|
|
|
$filter_ip = (string) get_parameter("filter_ip");
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
$filter = "1=1";
|
2014-07-14 08:18:11 +02:00
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
if (!empty($filter_type)) {
|
|
|
|
$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)) {
|
|
|
|
$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)) {
|
2018-05-21 16:00:54 +02: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)) {
|
2018-05-21 16:00:54 +02:00
|
|
|
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $filter_ip);
|
2018-05-04 13:38:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($filter_period)) {
|
2014-07-14 08:18:11 +02:00
|
|
|
switch ($config["dbtype"]) {
|
|
|
|
case "mysql":
|
2018-05-04 13:38:04 +02:00
|
|
|
$filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -' . $filter_period . ' HOUR)';
|
2014-07-14 08:18:11 +02:00
|
|
|
break;
|
|
|
|
case "postgresql":
|
2018-05-04 13:38:04 +02:00
|
|
|
$filter .= ' AND fecha >= NOW() - INTERVAL \'' . $filter_period . ' HOUR \'';
|
2014-07-14 08:18:11 +02:00
|
|
|
break;
|
|
|
|
case "oracle":
|
2018-05-04 13:38:04 +02:00
|
|
|
$filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \'' . $filter_period . '\' HOUR)';
|
2014-07-14 08:18:11 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-04 13:38:04 +02:00
|
|
|
$sql = sprintf( "SELECT * FROM tsesion WHERE %s ORDER BY fecha DESC", $filter);
|
|
|
|
$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);
|
2014-07-14 08:18:11 +02:00
|
|
|
|
|
|
|
?>
|