Skip to content

Commit 28bfeb9

Browse files
author
Marius Burkard
committed
- datalog history view and restore added missing files
1 parent b25bf4f commit 28bfeb9

14 files changed

+1372
-0
lines changed

interface/lib/classes/finediff.inc.php

Lines changed: 752 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
require_once '../../lib/config.inc.php';
32+
require_once '../../lib/app.inc.php';
33+
34+
/******************************************
35+
* Begin Form configuration
36+
******************************************/
37+
38+
$list_def_file = "list/dataloghistory.list.php";
39+
40+
/******************************************
41+
* End Form configuration
42+
******************************************/
43+
44+
//* Check permissions for module
45+
$app->auth->check_module_permissions('monitor');
46+
47+
$app->uses('listform_actions');
48+
49+
$app->listform_actions->SQLOrderBy = "ORDER BY sys_datalog.tstamp DESC, sys_datalog.datalog_id DESC";
50+
51+
$app->listform_actions->onLoad();
52+
53+
54+
?>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
require_once '../../lib/config.inc.php';
32+
require_once '../../lib/app.inc.php';
33+
34+
//* Check permissions for module
35+
$app->auth->check_module_permissions('monitor');
36+
37+
// Loading the template
38+
$app->uses('tpl');
39+
$app->tpl->newTemplate("form.tpl.htm");
40+
$app->tpl->setInclude('content_tpl', 'templates/dataloghistory_undo.htm');
41+
42+
require('lib/lang/'.$_SESSION['s']['language'].'_dataloghistory_undo.lng');
43+
$app->tpl->setvar($wb);
44+
45+
$id = intval($_GET['id']);
46+
47+
$record = $app->db->queryOneRecord('SELECT * FROM sys_datalog WHERE datalog_id = ?', $id);
48+
49+
$dbidx = explode(':', $record['dbidx']);
50+
51+
$old_record = $app->db->queryOneRecord('SELECT * FROM ?? WHERE ??=?', $record['dbtable'], $dbidx[0], $dbidx[1]);
52+
53+
if (is_array($old_record)) {
54+
if(!$data = unserialize(stripslashes($record['data']))) {
55+
$data = unserialize($record['data']);
56+
}
57+
58+
$new_record = $data['old'];
59+
60+
$app->db->datalogUpdate($record['dbtable'], $new_record, $dbidx[0], $dbidx[1]);
61+
62+
$app->tpl->setVar('success', true);
63+
} else {
64+
$app->tpl->setVar('success', false);
65+
}
66+
67+
$app->tpl_defaults();
68+
$app->tpl->pparse();
69+
70+
?>
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
require_once '../../lib/config.inc.php';
32+
require_once '../../lib/app.inc.php';
33+
34+
//* Check permissions for module
35+
$app->auth->check_module_permissions('monitor');
36+
37+
$app->load('finediff');
38+
39+
// Loading the template
40+
$app->uses('tpl');
41+
$app->tpl->newTemplate("form.tpl.htm");
42+
$app->tpl->setInclude('content_tpl', 'templates/dataloghistory_view.htm');
43+
44+
$app->load_language_file('web/monitor/lib/lang/'.$_SESSION['s']['language'].'_dataloghistory_view.lng');
45+
require('lib/lang/'.$_SESSION['s']['language'].'_dataloghistory_view.lng');
46+
$app->tpl->setvar($wb);
47+
48+
$id = intval($_GET['id']);
49+
50+
$record = $app->db->queryOneRecord('SELECT * FROM sys_datalog WHERE datalog_id = ?', $id);
51+
52+
$out['id'] = $id;
53+
54+
$out['timestamp'] = date($app->lng('conf_format_datetime'), $record['tstamp']);
55+
$out['table'] = $record['dbtable'];
56+
57+
$out['action_char'] = $record['action'];
58+
$out['action_name'] = $app->lng($record['action']);
59+
60+
$out['session_id'] = $record['session_id'];
61+
62+
if(!$data = unserialize(stripslashes($record['data']))) {
63+
$data = unserialize($record['data']);
64+
}
65+
66+
switch ($record['action']) {
67+
case 'i':
68+
$inserts = array();
69+
foreach ($data['new'] as $key=>$value) {
70+
$inserts[] = array(
71+
'key' => $key,
72+
'value' => nl2br($value),
73+
);
74+
}
75+
$app->tpl->setLoop('inserts', $inserts);
76+
break;
77+
case 'u':
78+
$updates = array();
79+
foreach ($data['new'] as $key=>$value) {
80+
if ($value != $data['old'][$key]) {
81+
$old = $data['old'][$key];
82+
$new = $value;
83+
$changes = show_diff_if_needed($old, $new);
84+
$updates[] = array(
85+
'key' => $key,
86+
'is_diff' => $changes['is_diff'],
87+
'old' => nl2br($changes['old']),
88+
'new' => nl2br($changes['new']),
89+
'diff' => nl2br($changes['diff']),
90+
);
91+
}
92+
}
93+
if (count($updates) > 0) {
94+
$app->tpl->setLoop('updates', $updates);
95+
} else {
96+
$out['no_changes'] = true;
97+
}
98+
break;
99+
case 'd':
100+
$deletes = array();
101+
foreach ($data['old'] as $key=>$value) {
102+
$deletes[] = array(
103+
'key' => $key,
104+
'value' => nl2br($value),
105+
);
106+
}
107+
$app->tpl->setLoop('deletes', $deletes);
108+
break;
109+
}
110+
111+
$app->tpl->setVar($out);
112+
113+
$app->tpl_defaults();
114+
$app->tpl->pparse();
115+
116+
function show_diff_if_needed($old, $new) {
117+
global $app;
118+
119+
$diff_min_lines = 6;
120+
121+
if (substr_count($old, "\n") >= $diff_min_lines || substr_count($new, "\n") >= $diff_min_lines) {
122+
$opcodes = FineDiff::getDiffOpcodes($old, $new);
123+
$html = FineDiff::renderUTF8DiffToHTMLFromOpcodes($old, $opcodes);
124+
return array('is_diff'=>true, 'old'=>'', 'new'=>'', 'diff'=>$html);
125+
} else {
126+
return array('is_diff'=>false, 'old'=>$old, 'new'=>$new, 'diff'=>'');
127+
}
128+
}
129+
130+
?>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
$wb['list_head_txt'] = 'Datalog-History';
3+
$wb['tstamp_txt'] = 'Datum';
4+
$wb['server_id_txt'] = 'Server';
5+
$wb['dbtable_txt'] = 'Datenbanktabelle';
6+
$wb['action_txt'] = 'Aktion';
7+
$wb['status_txt'] = 'Status';
8+
?>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$wb['list_head_txt'] = 'Datalog-History-Eintrag';
3+
$wb['success_txt'] = 'Erfolgreich zurückgesetzt';
4+
$wb['error_txt'] = 'Fehler beim Zurücksetzen: Eintrag existiert nicht mehr';
5+
$wb['btn_cancel_txt'] = 'Zurück';
6+
?>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
$wb['i'] = 'Insert';
3+
$wb['u'] = 'Update';
4+
$wb['d'] = 'Delete';
5+
$wb['list_head_txt'] = 'Datalog-History-Eintrag';
6+
$wb['id_txt'] = 'ID';
7+
$wb['timestamp_txt'] = 'Zeitpunkt';
8+
$wb['table_txt'] = 'Tabelle';
9+
$wb['action_txt'] = 'Aktion';
10+
$wb['session_id_txt'] = 'Session-ID';
11+
$wb['fields_txt'] = 'Felder';
12+
$wb['fields_inserted_txt'] = 'Eingefügte Felder';
13+
$wb['fields_updated_txt'] = 'Geänderte Felder';
14+
$wb['fields_deleted_txt'] = 'Gelöschte Felder';
15+
$wb['no_changes_txt'] = 'Keine Änderungen (Resync)';
16+
$wb['is_diff_txt'] = 'Die Änderungen werden hervorgehoben angezeigt';
17+
$wb['is_diff_inserts_txt'] = 'Einfügungen';
18+
$wb['is_diff_deletes_txt'] = 'Löschungen';
19+
$wb['field_txt'] = 'Feld';
20+
$wb['value_txt'] = 'Wert';
21+
$wb['old_txt'] = 'Alt';
22+
$wb['new_txt'] = 'Neu';
23+
$wb['btn_cancel_txt'] = 'Zurück';
24+
$wb['undo_txt'] = 'Rückgängig machen';
25+
$wb['undo_confirmation_txt'] = 'Soll diese Änderung wirklich rückgängig gemacht werden?';
26+
?>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
$wb["list_head_txt"] = 'Datalog History';
3+
$wb["tstamp_txt"] = 'Date';
4+
$wb["server_id_txt"] = 'Server';
5+
$wb["dbtable_txt"] = 'DB Table';
6+
$wb["action_txt"] = 'Action';
7+
$wb["status_txt"] = 'Status';
8+
?>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$wb['list_head_txt'] = 'Data Log History Entry';
3+
$wb['success_txt'] = 'Undo successful';
4+
$wb['error_txt'] = 'Error during undo: Record does not exist anymore';
5+
$wb['btn_cancel_txt'] = 'Back';
6+
?>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
$wb['i'] = 'Insert';
3+
$wb['u'] = 'Update';
4+
$wb['d'] = 'Delete';
5+
$wb['list_head_txt'] = 'Data Log History Entry';
6+
$wb['id_txt'] = 'ID';
7+
$wb['timestamp_txt'] = 'Timestamp';
8+
$wb['table_txt'] = 'Table';
9+
$wb['action_txt'] = 'Action';
10+
$wb['session_id_txt'] = 'Session ID';
11+
$wb['fields_txt'] = 'Fields';
12+
$wb['fields_inserted_txt'] = 'Inserted Fields';
13+
$wb['fields_updated_txt'] = 'Updated Fields';
14+
$wb['fields_deleted_txt'] = 'Deleted Fields';
15+
$wb['no_changes_txt'] = 'No changes (re-sync)';
16+
$wb['is_diff_txt'] = 'The differences are highlighted';
17+
$wb['is_diff_inserts_txt'] = 'Insertions';
18+
$wb['is_diff_deletes_txt'] = 'Deletions';
19+
$wb['field_txt'] = 'Field';
20+
$wb['value_txt'] = 'Value';
21+
$wb['old_txt'] = 'Old';
22+
$wb['new_txt'] = 'New';
23+
$wb['btn_cancel_txt'] = 'Back';
24+
$wb['undo_txt'] = 'Undo action';
25+
$wb['undo_confirmation_txt'] = 'Do you really want to undo this action?';
26+
?>

0 commit comments

Comments
 (0)