Commit 28bfeb97 authored by Marius Burkard's avatar Marius Burkard

- datalog history view and restore added missing files

parent b25bf4f5
This diff is collapsed.
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/dataloghistory.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('monitor');
$app->uses('listform_actions');
$app->listform_actions->SQLOrderBy = "ORDER BY sys_datalog.tstamp DESC, sys_datalog.datalog_id DESC";
$app->listform_actions->onLoad();
?>
<?php
/*
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
//* Check permissions for module
$app->auth->check_module_permissions('monitor');
// Loading the template
$app->uses('tpl');
$app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl', 'templates/dataloghistory_undo.htm');
require('lib/lang/'.$_SESSION['s']['language'].'_dataloghistory_undo.lng');
$app->tpl->setvar($wb);
$id = intval($_GET['id']);
$record = $app->db->queryOneRecord('SELECT * FROM sys_datalog WHERE datalog_id = ?', $id);
$dbidx = explode(':', $record['dbidx']);
$old_record = $app->db->queryOneRecord('SELECT * FROM ?? WHERE ??=?', $record['dbtable'], $dbidx[0], $dbidx[1]);
if (is_array($old_record)) {
if(!$data = unserialize(stripslashes($record['data']))) {
$data = unserialize($record['data']);
}
$new_record = $data['old'];
$app->db->datalogUpdate($record['dbtable'], $new_record, $dbidx[0], $dbidx[1]);
$app->tpl->setVar('success', true);
} else {
$app->tpl->setVar('success', false);
}
$app->tpl_defaults();
$app->tpl->pparse();
?>
<?php
/*
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
//* Check permissions for module
$app->auth->check_module_permissions('monitor');
$app->load('finediff');
// Loading the template
$app->uses('tpl');
$app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl', 'templates/dataloghistory_view.htm');
$app->load_language_file('web/monitor/lib/lang/'.$_SESSION['s']['language'].'_dataloghistory_view.lng');
require('lib/lang/'.$_SESSION['s']['language'].'_dataloghistory_view.lng');
$app->tpl->setvar($wb);
$id = intval($_GET['id']);
$record = $app->db->queryOneRecord('SELECT * FROM sys_datalog WHERE datalog_id = ?', $id);
$out['id'] = $id;
$out['timestamp'] = date($app->lng('conf_format_datetime'), $record['tstamp']);
$out['table'] = $record['dbtable'];
$out['action_char'] = $record['action'];
$out['action_name'] = $app->lng($record['action']);
$out['session_id'] = $record['session_id'];
if(!$data = unserialize(stripslashes($record['data']))) {
$data = unserialize($record['data']);
}
switch ($record['action']) {
case 'i':
$inserts = array();
foreach ($data['new'] as $key=>$value) {
$inserts[] = array(
'key' => $key,
'value' => nl2br($value),
);
}
$app->tpl->setLoop('inserts', $inserts);
break;
case 'u':
$updates = array();
foreach ($data['new'] as $key=>$value) {
if ($value != $data['old'][$key]) {
$old = $data['old'][$key];
$new = $value;
$changes = show_diff_if_needed($old, $new);
$updates[] = array(
'key' => $key,
'is_diff' => $changes['is_diff'],
'old' => nl2br($changes['old']),
'new' => nl2br($changes['new']),
'diff' => nl2br($changes['diff']),
);
}
}
if (count($updates) > 0) {
$app->tpl->setLoop('updates', $updates);
} else {
$out['no_changes'] = true;
}
break;
case 'd':
$deletes = array();
foreach ($data['old'] as $key=>$value) {
$deletes[] = array(
'key' => $key,
'value' => nl2br($value),
);
}
$app->tpl->setLoop('deletes', $deletes);
break;
}
$app->tpl->setVar($out);
$app->tpl_defaults();
$app->tpl->pparse();
function show_diff_if_needed($old, $new) {
global $app;
$diff_min_lines = 6;
if (substr_count($old, "\n") >= $diff_min_lines || substr_count($new, "\n") >= $diff_min_lines) {
$opcodes = FineDiff::getDiffOpcodes($old, $new);
$html = FineDiff::renderUTF8DiffToHTMLFromOpcodes($old, $opcodes);
return array('is_diff'=>true, 'old'=>'', 'new'=>'', 'diff'=>$html);
} else {
return array('is_diff'=>false, 'old'=>$old, 'new'=>$new, 'diff'=>'');
}
}
?>
<?php
$wb['list_head_txt'] = 'Datalog-History';
$wb['tstamp_txt'] = 'Datum';
$wb['server_id_txt'] = 'Server';
$wb['dbtable_txt'] = 'Datenbanktabelle';
$wb['action_txt'] = 'Aktion';
$wb['status_txt'] = 'Status';
?>
<?php
$wb['list_head_txt'] = 'Datalog-History-Eintrag';
$wb['success_txt'] = 'Erfolgreich zurückgesetzt';
$wb['error_txt'] = 'Fehler beim Zurücksetzen: Eintrag existiert nicht mehr';
$wb['btn_cancel_txt'] = 'Zurück';
?>
<?php
$wb['i'] = 'Insert';
$wb['u'] = 'Update';
$wb['d'] = 'Delete';
$wb['list_head_txt'] = 'Datalog-History-Eintrag';
$wb['id_txt'] = 'ID';
$wb['timestamp_txt'] = 'Zeitpunkt';
$wb['table_txt'] = 'Tabelle';
$wb['action_txt'] = 'Aktion';
$wb['session_id_txt'] = 'Session-ID';
$wb['fields_txt'] = 'Felder';
$wb['fields_inserted_txt'] = 'Eingefügte Felder';
$wb['fields_updated_txt'] = 'Geänderte Felder';
$wb['fields_deleted_txt'] = 'Gelöschte Felder';
$wb['no_changes_txt'] = 'Keine Änderungen (Resync)';
$wb['is_diff_txt'] = 'Die Änderungen werden hervorgehoben angezeigt';
$wb['is_diff_inserts_txt'] = 'Einfügungen';
$wb['is_diff_deletes_txt'] = 'Löschungen';
$wb['field_txt'] = 'Feld';
$wb['value_txt'] = 'Wert';
$wb['old_txt'] = 'Alt';
$wb['new_txt'] = 'Neu';
$wb['btn_cancel_txt'] = 'Zurück';
$wb['undo_txt'] = 'Rückgängig machen';
$wb['undo_confirmation_txt'] = 'Soll diese Änderung wirklich rückgängig gemacht werden?';
?>
<?php
$wb["list_head_txt"] = 'Datalog History';
$wb["tstamp_txt"] = 'Date';
$wb["server_id_txt"] = 'Server';
$wb["dbtable_txt"] = 'DB Table';
$wb["action_txt"] = 'Action';
$wb["status_txt"] = 'Status';
?>
<?php
$wb['list_head_txt'] = 'Data Log History Entry';
$wb['success_txt'] = 'Undo successful';
$wb['error_txt'] = 'Error during undo: Record does not exist anymore';
$wb['btn_cancel_txt'] = 'Back';
?>
<?php
$wb['i'] = 'Insert';
$wb['u'] = 'Update';
$wb['d'] = 'Delete';
$wb['list_head_txt'] = 'Data Log History Entry';
$wb['id_txt'] = 'ID';
$wb['timestamp_txt'] = 'Timestamp';
$wb['table_txt'] = 'Table';
$wb['action_txt'] = 'Action';
$wb['session_id_txt'] = 'Session ID';
$wb['fields_txt'] = 'Fields';
$wb['fields_inserted_txt'] = 'Inserted Fields';
$wb['fields_updated_txt'] = 'Updated Fields';
$wb['fields_deleted_txt'] = 'Deleted Fields';
$wb['no_changes_txt'] = 'No changes (re-sync)';
$wb['is_diff_txt'] = 'The differences are highlighted';
$wb['is_diff_inserts_txt'] = 'Insertions';
$wb['is_diff_deletes_txt'] = 'Deletions';
$wb['field_txt'] = 'Field';
$wb['value_txt'] = 'Value';
$wb['old_txt'] = 'Old';
$wb['new_txt'] = 'New';
$wb['btn_cancel_txt'] = 'Back';
$wb['undo_txt'] = 'Undo action';
$wb['undo_confirmation_txt'] = 'Do you really want to undo this action?';
?>
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
//* Name of list
$liste['name'] = 'dataloghistory';
//* Database table
$liste['table'] = 'sys_datalog';
//* Primary index column
$liste['table_idx'] = 'datalog_id';
//* Search Field Prefix
$liste['search_prefix'] = 'search_';
//* Records per page
$liste['records_per_page'] = "15";
//* Script file for listing
$liste['file'] = 'dataloghistory_list.php';
//* Script file to edit
$liste['edit_file'] = 'dataloghistory_list.php';
//* Script file to delete
$liste['delete_file'] = 'dataloghistory_list.php';
//* Paging template
$liste['paging_tpl'] = 'templates/paging.tpl.htm';
//* Enable auth
$liste['auth'] = 'no';
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field' => "tstamp",
'datatype' => "DATETIME",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => "");
$liste['item'][] = array( 'field' => 'server_id',
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'op' => '=',
'prefix' => '',
'suffix' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'width' => '',
'value' => '');
$liste["item"][] = array( 'field' => "action",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('i' => "Insert", 'u' => "Update", 'd' => "Delete"));
$liste["item"][] = array( 'field' => "dbtable",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
?>
<tmpl_if name="list_head_txt">
<div class='page-header'>
<h1><tmpl_var name="list_head_txt"></h1>
</div>
</tmpl_if>
<tmpl_if name="list_desc_txt"><p><tmpl_var name="list_desc_txt"></p></tmpl_if>
<p class="fieldset-legend"><tmpl_var name="list_head_txt"></p>
<div class="table-wrapper marginTop15">
<table class="table">
<thead class="dark form-group-sm">
<tr>
<th data-column="tstamp"><tmpl_var name="tstamp_txt"></th>
<th data-column="server_id"><tmpl_var name="server_id_txt"></th>
<th data-column="action"><tmpl_var name="action_txt"></th>
<th data-column="dbtable"><tmpl_var name="dbtable_txt"></th>
<th class="small-col text-right">{tmpl_var name='search_limit'}</th>
</tr>
<tr>
<td>&nbsp;</td>
<td><select class="form-control" name="search_server_id">{tmpl_var name='search_server_id'}</select></td>
<td><select class="form-control" name="search_action">{tmpl_var name='search_action'}</select></td>
<td><input class="form-control" type="text" name="search_dbtable" value="{tmpl_var name='search_dbtable'}" /></td>
<td class="text-right">
<button type="button" class="btn btn-default formbutton-default formbutton-narrow" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" data-submit-form="pageForm" data-form-action="monitor/dataloghistory_list.php"><span class="icon icon-filter"></span></button>
</td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr>
<td><a href="#" data-load-content="monitor/dataloghistory_view.php?id={tmpl_var name='id'}">{tmpl_var name="tstamp"}</a></td>
<td><a href="#" data-load-content="monitor/dataloghistory_view.php?id={tmpl_var name='id'}">{tmpl_var name="server_id"}</a></td>
<td><a href="#" data-load-content="monitor/dataloghistory_view.php?id={tmpl_var name='id'}">{tmpl_var name="action"}</a></td>
<td><a href="#" data-load-content="monitor/dataloghistory_view.php?id={tmpl_var name='id'}">{tmpl_var name="dbtable"}</a></td>
<td class="text-right"></td>
</tr>
</tmpl_loop>
<tmpl_unless name="records">
<tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td colspan="5">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
</tr>
</tmpl_unless>
</tbody>
<tfoot>
<tr>
<td colspan="5"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</div>
</div>
<tmpl_if name="list_head_txt">
<div class='page-header'>
<h1><tmpl_var name="list_head_txt"></h1>
</div>
</tmpl_if>
<tmpl_if name='success'>
<tmpl_var name='success_txt'>
<tmpl_else>
<tmpl_var name='error_txt'>
</tmpl_if>
<div class="clear">
<div class="right">
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="monitor/dataloghistory_list.php">{tmpl_var name='btn_cancel_txt'}</button>
</div>
</div>
<tmpl_if name="list_head_txt">
<div class='page-header'>
<h1><tmpl_var name="list_head_txt"></h1>
</div>
</tmpl_if>
<div class="table-wrapper marginTop15">
<table class="table">
<thead class="dark form-group-sm">
<tr>
<th width="25%"><tmpl_var name="id_txt"></th>
<th><tmpl_var name="id"></th>
</tr>
</thead>
<tbody>
<tr>
<td><tmpl_var name="timestamp_txt"></td>
<td><tmpl_var name="timestamp"></td>
</tr>
<tr>
<td><tmpl_var name="table_txt"></td>
<td><tmpl_var name="table"></td>
</tr>
<tr>
<td><tmpl_var name="action_txt"></td>
<td><tmpl_var name="action_name"></td>
</tr>
<tr>
<td><tmpl_var name="session_id_txt"></td>
<td><tmpl_var name="session_id"></td>
</tr>
</tbody>
</table>
</div>
<tmpl_if name='action_char' value='i'>
<h2><tmpl_var name="fields_inserted_txt"></h2>
</tmpl_if>
<tmpl_if name='action_char' value='u'>
<h2><tmpl_var name="fields_updated_txt"></h2>
</tmpl_if>
<tmpl_if name='action_char' value='d'>
<h2><tmpl_var name="fields_deleted_txt"></h2>
</tmpl_if>
<div class="table-wrapper marginTop15">
<table class="table">
<tmpl_if name='action_char' value='i'>
<thead class="dark form-group-sm">
<tr>
<th width="25%"><tmpl_var name="field_txt"></th>
<th><tmpl_var name="value_txt"></th>
</tr>
</thead>
<tmpl_loop name='inserts'>
<tr>
<td><tmpl_var name="key"></td>
<td><tmpl_var name="value"></td>
</tr>
</tmpl_loop>
</tmpl_if>
<tmpl_if name='action_char' value='u'>
<tmpl_if name='no_changes'>
<tbody>
<tr>
<td class="text-center"><h3><tmpl_var name="no_changes_txt"></h3></td>
</tr>
</tbody>
<tmpl_else>
<thead class="dark form-group-sm">
<tr>
<th width="25%"><tmpl_var name="field_txt"></th>
<th><tmpl_var name="old_txt"></th>
<th><tmpl_var name="new_txt"></th>
</tr>
</thead>
<tbody>
<tmpl_loop name='updates'>
<tmpl_if name='is_diff'>
<tr>
<td><tmpl_var name="key"></td>
<td colspan="2">
<div class="alert alert-warning"><tmpl_var name="is_diff_txt"> (<span class="finediff"><ins><tmpl_var name="is_diff_inserts_txt"></ins></span> / <span class="finediff"><del><tmpl_var name="is_diff_deletes_txt"></del></span>)</div>
<div class="finediff"><tmpl_var name="diff"></div>
</td>
</tr>
<tmpl_else>
<tr>
<td><tmpl_var name="key"></td>
<td><tmpl_var name="old"></td>
<td><tmpl_var name="new"></td>
</tr>
</tmpl_if>
</tmpl_loop>
</tbody>
</tmpl_if>
</tmpl_if>
<tmpl_if name='action_char' value='d'>
<thead class="dark form-group-sm">
<tr>
<th width="25%"><tmpl_var name="field_txt"></th>
<th><tmpl_var name="value_txt"></th>
</tr>
</thead>
<tbody>
<tmpl_loop name='deletes'>
<tr>
<td><tmpl_var name="key"></td>
<td><tmpl_var name="value"></td>
</tr>
</tmpl_loop>
</tbody>
</tmpl_if>
</table>
</div>
<div class="clear">
<div class="right">
<tmpl_if name='action_char' value='u'>
<a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('monitor/dataloghistory_undo.php?id={tmpl_var name='id'}','{tmpl_var name='undo_confirmation_txt'}');"> {tmpl_var name='undo_txt'}</a>
</tmpl_if>
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="monitor/dataloghistory_list.php">{tmpl_var name='btn_cancel_txt'}</button>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment