mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:51:59 +01:00
download audit log in csv
This commit is contained in:
parent
a35ef4be57
commit
46a6110d50
@ -205,6 +205,8 @@ $memcached_servers = array(
|
||||
$partitions_to_monitor = array('/', '/home', '/var', '/tmp');
|
||||
$config['DATA_PARTITION'] = '/var';
|
||||
|
||||
$config['DELIMITER'] = "\t";
|
||||
|
||||
$langs = array(
|
||||
'hu',
|
||||
'en',
|
||||
|
35
webui/controller/audit/download.php
Normal file
35
webui/controller/audit/download.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerAuditDownload extends Controller {
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "message/headers.tpl";
|
||||
$this->layout = "common/layout-empty";
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
|
||||
$this->load->model('audit/audit');
|
||||
|
||||
if(Registry::get('admin_user') == 0 && Registry::get('auditor_user') == 0) {
|
||||
die("go away");
|
||||
}
|
||||
|
||||
$this->document->title = $this->data['text_message'];
|
||||
|
||||
header("Cache-Control: public, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Disposition: attachment; filename=audit-" . time() . ".csv");
|
||||
header("Content-Transfer-Encoding: binary\n");
|
||||
|
||||
$this->model_audit_audit->print_audit_to_csv();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -7,6 +7,9 @@ require_once("config.php");
|
||||
|
||||
require(DIR_SYSTEM . "/startup.php");
|
||||
|
||||
$session = new Session();
|
||||
Registry::set("session", $session);
|
||||
|
||||
$request = new Request();
|
||||
Registry::set("request", $request);
|
||||
|
||||
@ -63,6 +66,7 @@ Registry::set('letters', $letters);
|
||||
Registry::set('ldap_types', array("AD", "iredmail", "lotus", "zimbra"));
|
||||
Registry::set('health_smtp_servers', $health_smtp_servers);
|
||||
Registry::set('partitions_to_monitor', $partitions_to_monitor);
|
||||
Registry::set('actions', $actions);
|
||||
|
||||
|
||||
if(Registry::get('username')) {
|
||||
|
@ -79,8 +79,11 @@ class ModelAuditAudit extends Model {
|
||||
if($n > 0) {
|
||||
if($n > MAX_AUDIT_HITS) { $n = MAX_AUDIT_HITS; }
|
||||
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . TABLE_AUDIT . " $where $sortorder LIMIT $from," . $data['page_len'], $arr);
|
||||
|
||||
$this->session->set("audit_query", array('where' => $where, 'sortorder' => $sortorder, 'arr' => $arr));
|
||||
|
||||
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("audit query: '%s', param: '%s' in %.2f s, %d hits", $query->query, implode(' ', $arr), $query->exec_time, $query->num_rows)); }
|
||||
|
||||
if(isset($query->rows)) {
|
||||
@ -105,6 +108,24 @@ class ModelAuditAudit extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function print_audit_to_csv() {
|
||||
$actions = array_flip(Registry::get('actions'));
|
||||
|
||||
$a = $this->session->get("audit_query");
|
||||
|
||||
if(isset($a['where']) && isset($a['sortorder']) && isset($a['arr'])) {
|
||||
print "Date" . DELIMITER . "ID" . DELIMITER . "User" . DELIMITER . "IP-address" . DELIMITER . "Action" . DELIMITER . "Piler ID" . DELIMITER . "Description\n";
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . TABLE_AUDIT . " " . $a['where'] . " " . $a['sortorder'], $a['arr']);
|
||||
foreach($query->rows as $q) {
|
||||
if(DEMO_MODE == 1) { $q['ipaddr'] = anonimize_ip_addr($q['ipaddr']); }
|
||||
|
||||
print date(DATE_TEMPLATE . " H:i:s", $q['ts']) . DELIMITER . $q['id'] . DELIMITER . $q['email'] . DELIMITER . $q['ipaddr'] . DELIMITER . $actions[$q['action']] . DELIMITER . $q['piler_id'] . DELIMITER . $q['description'] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function append_search_criteria($s = '', &$arr = array()) {
|
||||
$q = "";
|
||||
|
||||
|
@ -23,4 +23,28 @@ class Request {
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Session {
|
||||
|
||||
public function __construct() {
|
||||
//session_start();
|
||||
}
|
||||
|
||||
|
||||
public function get($s = '') {
|
||||
if($s && isset($_SESSION[$s])) { return $_SESSION[$s]; }
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public function set($k = '', $v = '') {
|
||||
|
||||
if($k) { $_SESSION[$k] = $v; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@ -101,6 +101,11 @@
|
||||
<?php if($page < $total_pages) { ?> <a href="#" class="navlink" onclick="Piler.navigation(<?php print $total_pages; ?>);"><i class="icon-double-angle-right icon-large"></i></a><?php } else { ?> <span class="navlink"><i class="icon-double-angle-right icon-large"></i></span><?php } ?>
|
||||
|
||||
<?php } else { print $text_none_found; } ?>
|
||||
|
||||
<?php if($n > 0) { ?>
|
||||
<a href="index.php?route=audit/download"><button class="btn btn-small btn-inverse">Export CSV</button></a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -23,30 +23,28 @@
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="boxfooter">
|
||||
|
||||
<div id="pagenav">
|
||||
<div class="navrow">
|
||||
<?php if($n >= $page_len){ ?>
|
||||
<div id="pagingleft">
|
||||
<?php if($page > 0) { ?><a href="#" class="navlink" onclick="Piler.navigation(0);"><<</a> <?php } else { ?><span class="navlink"><< </span><?php } ?>
|
||||
<?php if($page > 0) { ?><a href="#" class="navlink" onclick="Piler.navigation(<?php print $prev_page; ?>);"> < </a> <?php } else { ?><span class="navlink"> < </span><?php } ?>
|
||||
</div>
|
||||
<span class="piler-right-margin">
|
||||
<?php if($page > 0) { ?><a href="#" onclick="Piler.navigation(0);"><<</a> <?php } else { ?><span class="navlink"><< </span><?php } ?>
|
||||
<?php if($page > 0) { ?><a href="#" onclick="Piler.navigation(<?php print $prev_page; ?>);"> < </a> <?php } else { ?><span class="navlink"> < </span><?php } ?>
|
||||
|
||||
<div id="pagingcenter">
|
||||
<?php print $hits_from; ?>-<?php print $hits_to; ?>, <?php print $text_total; ?>: <?php print $n; ?>
|
||||
</div>
|
||||
|
||||
<div id="pagingright">
|
||||
<?php if($next_page <= $total_pages){ ?><a href="#" class="navlink" onclick="Piler.navigation(<?php print $next_page; ?>);">> </a> <?php } else { ?><span class="navlink">> </span><?php } ?>
|
||||
<?php if($page < $total_pages) { ?> <a href="#" class="navlink" onclick="Piler.navigation(<?php print $total_pages; ?>);"> >> </a><?php } else { ?> <span class="navlink"> >></span><?php } ?>
|
||||
</div>
|
||||
<?php if($next_page <= $total_pages){ ?><a href="#" onclick="Piler.navigation(<?php print $next_page; ?>);">> </a> <?php } else { ?><span class="navlink">> </span><?php } ?>
|
||||
<?php if($page < $total_pages) { ?> <a href="#" onclick="Piler.navigation(<?php print $total_pages; ?>);"> >> </a><?php } else { ?> <span class="navlink"> >></span><?php } ?>
|
||||
</span>
|
||||
|
||||
<?php } else { ?> <?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($n > 0) { ?>
|
||||
<a href="index.php?route=audit/download"><button class="btn btn-medium btn-inverse">Export CSV</button>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user