2017-06-13 07:09:36 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2020-02-26 01:58:11 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2016 - 2020
|
2017-06-13 07:09:36 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2022-10-11 00:35:14 +02:00
|
|
|
//includes files
|
2023-06-15 19:28:23 +02:00
|
|
|
require_once dirname(__DIR__, 2) . "/resources/require.php";
|
2020-01-06 20:34:30 +01:00
|
|
|
require_once "resources/check_auth.php";
|
2017-06-13 07:09:36 +02:00
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
|
if (permission_exists('database_transaction_add') || permission_exists('database_transaction_edit')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add multi-lingual support
|
|
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
|
|
|
|
|
2023-05-26 21:48:39 +02:00
|
|
|
//set default values
|
|
|
|
|
$search = '';
|
|
|
|
|
$action = '';
|
|
|
|
|
$page = 0;
|
2023-06-02 00:39:05 +02:00
|
|
|
$user_uuid = '';
|
|
|
|
|
$app_name = '';
|
|
|
|
|
$app_uuid = '';
|
|
|
|
|
$domain_name = '';
|
|
|
|
|
$username = '';
|
|
|
|
|
$transaction_code = '';
|
|
|
|
|
$transaction_address = '';
|
2023-05-26 21:48:39 +02:00
|
|
|
|
2019-11-21 05:06:47 +01:00
|
|
|
//set the variables
|
2023-05-26 21:48:39 +02:00
|
|
|
if (!empty($_GET["id"]) && is_uuid($_GET["id"])) {
|
2019-11-23 18:00:18 +01:00
|
|
|
$database_transaction_uuid = $_GET["id"];
|
2023-05-26 21:48:39 +02:00
|
|
|
$search = $_GET['search'] ?? '';
|
|
|
|
|
$page = $_GET['page'] ?? 0;
|
|
|
|
|
$action = $_GET['action'] ?? '';
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//pre-populate the form
|
2023-05-26 21:48:39 +02:00
|
|
|
if (!empty($_GET["id"]) && empty($_POST["persistformvar"])) {
|
2017-06-13 07:09:36 +02:00
|
|
|
|
|
|
|
|
$sql = "select ";
|
|
|
|
|
$sql .= "t.database_transaction_uuid, d.domain_name, u.username, t.user_uuid, t.app_name, t.app_uuid, ";
|
|
|
|
|
$sql .= "t.transaction_code, t.transaction_address, t.transaction_type, t.transaction_date, ";
|
|
|
|
|
$sql .= "t.transaction_old, t.transaction_new, t.transaction_result ";
|
2024-08-02 19:54:14 +02:00
|
|
|
$sql .= "from v_database_transactions as t ";
|
|
|
|
|
$sql .= "left outer join v_domains as d using (domain_uuid) ";
|
|
|
|
|
$sql .= "left outer join v_users as u using (user_uuid) ";
|
|
|
|
|
$sql .= "where (t.domain_uuid = :domain_uuid or t.domain_uuid is null) ";
|
2019-07-29 17:39:16 +02:00
|
|
|
$sql .= "and t.database_transaction_uuid = :database_transaction_uuid ";
|
|
|
|
|
$parameters['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$parameters['database_transaction_uuid'] = $database_transaction_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$row = $database->select($sql, $parameters, 'row');
|
2024-08-02 19:54:14 +02:00
|
|
|
|
2023-06-02 00:39:05 +02:00
|
|
|
if (!empty($row)) {
|
2017-06-13 07:09:36 +02:00
|
|
|
$user_uuid = $row["user_uuid"];
|
|
|
|
|
$app_name = $row["app_name"];
|
|
|
|
|
$app_uuid = $row["app_uuid"];
|
2024-08-02 19:54:14 +02:00
|
|
|
$domain_name = $row["domain_name"] ?? $text['label-global'];
|
2017-06-13 07:09:36 +02:00
|
|
|
$username = $row["username"];
|
|
|
|
|
$transaction_code = $row["transaction_code"];
|
|
|
|
|
$transaction_address = $row["transaction_address"];
|
2018-02-12 19:16:49 +01:00
|
|
|
$transaction_type = $row["transaction_type"];
|
2017-06-13 07:09:36 +02:00
|
|
|
$transaction_date = $row["transaction_date"];
|
|
|
|
|
$transaction_old = $row["transaction_old"];
|
|
|
|
|
$transaction_new = $row["transaction_new"];
|
|
|
|
|
$transaction_result = $row["transaction_result"];
|
|
|
|
|
}
|
2019-07-29 17:39:16 +02:00
|
|
|
unset($sql, $parameters, $row);
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-21 05:06:47 +01:00
|
|
|
//undo the transaction
|
2023-05-26 21:48:39 +02:00
|
|
|
if ($action == 'undo' && ($transaction_type == 'delete' || $transaction_type == 'update')) {
|
2019-11-21 05:06:47 +01:00
|
|
|
//get the array
|
|
|
|
|
$array = json_decode($transaction_old, true);
|
|
|
|
|
|
|
|
|
|
//save to the data
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = $app_name;
|
|
|
|
|
$database->app_uuid = $app_uuid;
|
|
|
|
|
$database->save($array);
|
|
|
|
|
$message = $database->message;
|
|
|
|
|
|
|
|
|
|
//redirect the user
|
|
|
|
|
$_SESSION["message"] = $text['message-update'];
|
2023-05-26 21:48:39 +02:00
|
|
|
header("Location: database_transactions.php?".(!empty($search) ? "&search=".urlencode($search) : null).(!empty($page) ? "&page=".urlencode($page) : null));
|
2024-08-02 19:54:14 +02:00
|
|
|
}
|
2019-11-21 05:06:47 +01:00
|
|
|
|
2018-02-12 19:16:49 +01:00
|
|
|
//get the type if not provided
|
2023-05-05 18:46:37 +02:00
|
|
|
if (empty($transaction_type)) {
|
2023-06-02 00:39:05 +02:00
|
|
|
if (empty($transaction_old) || $transaction_old == null || $transaction_old == "null") {
|
2018-02-13 17:33:51 +01:00
|
|
|
$transaction_type = 'add';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$transaction_type = 'update';
|
|
|
|
|
}
|
2018-02-13 17:24:59 +01:00
|
|
|
}
|
2018-02-12 19:16:49 +01:00
|
|
|
|
2020-02-11 05:48:33 +01:00
|
|
|
//include the header
|
2020-01-06 20:34:30 +01:00
|
|
|
$document['title'] = $text['title-database_transaction'];
|
2017-06-13 07:09:36 +02:00
|
|
|
require_once "resources/header.php";
|
|
|
|
|
|
|
|
|
|
//show the content
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "<div class='action_bar' id='action_bar'>\n";
|
|
|
|
|
echo " <div class='heading'><b>".$text['title-database_transaction']."</b></div>\n";
|
|
|
|
|
echo " <div class='actions'>\n";
|
2023-05-26 21:48:39 +02:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'database_transactions.php?'.(!empty($search) ? "&search=".urlencode($search) : null).(is_numeric($page) ? "&page=".urlencode($page) : null)]);
|
2019-11-23 18:00:18 +01:00
|
|
|
if ($transaction_type == 'delete' || $transaction_type == 'update') {
|
2023-05-26 21:48:39 +02:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-undo'],'icon'=>'undo-alt','id'=>'btn_save','style'=>'margin-left: 15px;','link'=>'database_transaction_edit.php?id='.urlencode($database_transaction_uuid).'&action=undo'.(!empty($search) ? "&search=".urlencode($search) : null).(is_numeric($page) ? "&page=".urlencode($page) : null)]);
|
2019-11-21 05:06:47 +01:00
|
|
|
}
|
2020-02-11 05:48:33 +01:00
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div style='clear: both;'></div>\n";
|
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
2018-02-12 19:16:49 +01:00
|
|
|
echo "<table width='400' border='0' cellpadding='0' cellspacing='0'>\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "<td valign='top'>\n";
|
|
|
|
|
echo " <table>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-app_name']."\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
echo " <td class='vtable' align='left'>\n";
|
2019-11-23 18:00:18 +01:00
|
|
|
echo " ".escape($app_name)."\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-user_uuid']."\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
echo " <td class='vtable' align='left'>\n";
|
2018-08-27 23:13:04 +02:00
|
|
|
echo " ".escape($username)."\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
|
|
|
|
|
echo "<td valign='top'>\n";
|
2018-02-12 19:16:49 +01:00
|
|
|
echo " <table border='0'>\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-transaction_code']."\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
echo " <td class='vtable' align='left'>\n";
|
2018-08-27 23:13:04 +02:00
|
|
|
echo " ".escape($transaction_code)."\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-transaction_address']."\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
echo " <td class='vtable' align='left'>\n";
|
2018-08-27 23:13:04 +02:00
|
|
|
echo " ".escape($transaction_address)."\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
echo "</td>\n";
|
2018-02-12 19:16:49 +01:00
|
|
|
|
|
|
|
|
echo "<td valign='top'>\n";
|
|
|
|
|
echo " <table border='0'>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-transaction_type']."\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
echo " <td class='vtable' align='left'>\n";
|
2018-08-27 23:13:04 +02:00
|
|
|
echo " ".escape($transaction_type)."\n";
|
2018-02-12 19:16:49 +01:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <th width='10%' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-domain']."\n";
|
|
|
|
|
echo " </th>\n";
|
|
|
|
|
echo " <td width='90%' aclass='vtable' align='left'>\n";
|
2018-08-27 23:13:04 +02:00
|
|
|
echo " ".escape($domain_name);
|
2018-02-12 19:16:49 +01:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo "</table>\n";
|
|
|
|
|
|
2023-05-26 21:48:39 +02:00
|
|
|
if (!empty($_REQUEST["debug"]) && $_REQUEST["debug"] == "true") {
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "<table width='50%' border='0' cellpadding='0' cellspacing='0'>\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-transaction_old']."\n";
|
|
|
|
|
echo "</th>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
echo " <textarea name='transaction_old' style='width: 100%; height: 80px;'>".escape($transaction_old)."</textarea>\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2024-08-02 19:54:14 +02:00
|
|
|
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-transaction_new']."\n";
|
|
|
|
|
echo "</th>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
echo " <textarea name='transaction_new' style='width: 100%; height: 80px;'>".escape($transaction_new)."</textarea>\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2024-08-02 19:54:14 +02:00
|
|
|
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<th valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-transaction_result']."\n";
|
|
|
|
|
echo "</th>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
echo " <textarea name='transaction_result' style='width: 100%; height: 80px;'>".escape($transaction_result)."</textarea>\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo "</table>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//define the array _difference function
|
|
|
|
|
//this adds old and new values to the array
|
|
|
|
|
function array_difference($array1, $array2) {
|
2018-02-13 17:21:42 +01:00
|
|
|
$array = array();
|
2023-06-03 01:52:38 +02:00
|
|
|
if (is_array($array1)) {
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($array1 as $key => $value) {
|
2023-06-03 01:52:38 +02:00
|
|
|
if (is_array($array2[$key])) {
|
|
|
|
|
if (isset($array1[$key]) && isset($array2[$key])) {
|
|
|
|
|
$array[$key] = array_difference($array1[$key], $array2[$key]);
|
|
|
|
|
}
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2018-02-13 17:21:42 +01:00
|
|
|
$array[$key]['old'] = $value;
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-03 01:52:38 +02:00
|
|
|
if (is_array($array2)) {
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($array2 as $key => $value) {
|
2023-06-03 01:52:38 +02:00
|
|
|
if (is_array($value)) {
|
|
|
|
|
if (isset($array1[$key]) && isset($array2[$key])) {
|
|
|
|
|
$array[$key] = array_difference($array1[$key], $array2[$key]);
|
|
|
|
|
}
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2018-02-13 17:21:42 +01:00
|
|
|
$array[$key]['new'] = $value;
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-13 17:21:42 +01:00
|
|
|
return $array;
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//show the content from the difference array as a list
|
|
|
|
|
function show_difference($array) {
|
2018-02-13 17:21:42 +01:00
|
|
|
|
2017-06-13 07:09:36 +02:00
|
|
|
//loop through the array
|
2018-02-13 17:21:42 +01:00
|
|
|
foreach ($array as $key => $value) {
|
2023-06-02 00:39:05 +02:00
|
|
|
if (!empty($value) && !isset($value['old']) && !isset($value['new'])) {
|
2017-06-13 07:09:36 +02:00
|
|
|
if (!is_numeric($key)) {
|
|
|
|
|
//get the table name
|
|
|
|
|
$_SESSION['name'] = $key;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//get the row id
|
|
|
|
|
$_SESSION['row'] = $key;
|
|
|
|
|
}
|
|
|
|
|
$array = show_difference($value);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//set the variables
|
2023-06-03 01:52:38 +02:00
|
|
|
$old = $value['old'] ?? '';
|
|
|
|
|
$new = $value['new'] ?? '';
|
2017-06-13 07:09:36 +02:00
|
|
|
//determine if the value has changed
|
|
|
|
|
if (strval($old) == strval($new) && isset($old)) {
|
|
|
|
|
$color = "#000000";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$color = "#ff0000";
|
|
|
|
|
}
|
|
|
|
|
//set the table header
|
2023-05-26 21:48:39 +02:00
|
|
|
if (!empty($_SESSION['previous_name']) && $_SESSION['previous_name'] !== $_SESSION['name'] || !empty($_SESSION['previous_row']) && $_SESSION['previous_row'] !== $_SESSION['row']) {
|
2017-06-13 07:09:36 +02:00
|
|
|
echo str_replace("<th>name</th>","<th>".$_SESSION['name']."</th>",$_SESSION['table_header']);
|
|
|
|
|
//echo $_SESSION['table_header'];
|
|
|
|
|
}
|
|
|
|
|
$_SESSION['previous_name'] = $_SESSION['name'];
|
|
|
|
|
$_SESSION['previous_row'] = $_SESSION['row'];
|
|
|
|
|
//show the results
|
2019-11-23 18:00:18 +01:00
|
|
|
echo "<tr class='list-row' style='color: $color;'>\n";
|
|
|
|
|
echo " <td class=\"vtable\" style='color: $color;'>".escape($key)."</td>\n";
|
|
|
|
|
echo " <td class=\"vtable\" style='color: $color;'>".escape($old)."</td>\n";
|
|
|
|
|
echo " <td class=\"vtable\" style='color: $color;'>".escape($new)."</td>";
|
2017-06-13 07:09:36 +02:00
|
|
|
echo "</tr>\n";
|
|
|
|
|
//echo "</table>\n";
|
|
|
|
|
}
|
2018-02-13 17:21:42 +01:00
|
|
|
unset($key,$old,$new,$value);
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//decode the json to arrays
|
2023-06-03 01:52:38 +02:00
|
|
|
$before = json_decode($transaction_old ?? '', true);
|
|
|
|
|
$after = json_decode($transaction_new ?? '', true);
|
2017-06-13 07:09:36 +02:00
|
|
|
|
|
|
|
|
//unset the sessions
|
|
|
|
|
unset($_SESSION['previous_name']);
|
|
|
|
|
unset($_SESSION['previous_row']);
|
|
|
|
|
|
2018-02-13 17:21:42 +01:00
|
|
|
//show the add
|
2018-02-12 19:16:49 +01:00
|
|
|
if ($transaction_type == "add") {
|
2018-02-13 17:21:42 +01:00
|
|
|
|
|
|
|
|
//multiple dimensional array into a 2 dimensional array
|
2023-06-02 00:39:05 +02:00
|
|
|
if (!empty($after)) {
|
2018-02-13 17:21:42 +01:00
|
|
|
$x = 0;
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($after as $key => $value) {
|
2018-02-13 17:21:42 +01:00
|
|
|
$id = 0;
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($value as $row) {
|
2018-02-13 17:21:42 +01:00
|
|
|
$sub_id = 0;
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($row as $sub_key => $val) {
|
2023-06-03 01:52:38 +02:00
|
|
|
if (!empty($val) && is_array($val)) {
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($val as $sub_row) {
|
2023-06-03 01:52:38 +02:00
|
|
|
if (!empty($sub_row) && is_array($sub_row)) {
|
|
|
|
|
foreach ($sub_row as $k => $v) {
|
|
|
|
|
$array[$x]['schema'] = $sub_key;
|
|
|
|
|
$array[$x]['row'] = $sub_id;
|
|
|
|
|
$array[$x]['name'] = $k;
|
|
|
|
|
$array[$x]['value'] = htmlentities($v ?? '');
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
$sub_id++;
|
2018-02-13 17:21:42 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$array[$x]['schema'] = $key;
|
|
|
|
|
$array[$x]['row'] = $id;
|
|
|
|
|
$array[$x]['name'] = $sub_key;
|
|
|
|
|
$array[$x]['value'] = htmlentities($val);
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$id++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-23 18:00:18 +01:00
|
|
|
echo "<br />\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "<table width='100%'>\n";
|
2023-06-02 00:39:05 +02:00
|
|
|
if (!empty($array)) {
|
2023-06-03 01:52:38 +02:00
|
|
|
$previous_schema = null;
|
2020-02-11 05:48:33 +01:00
|
|
|
foreach ($array as $row) {
|
2020-01-08 21:25:59 +01:00
|
|
|
if ($row['schema'] !== $previous_schema || $row['row'] !== $previous_row) {
|
|
|
|
|
echo "<tr><td colspan='4'> </td></tr>\n";
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo " <th>".escape($row['schema'])."</th>\n";
|
|
|
|
|
echo " <th>value</th>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
echo "<tr class='list-row'>\n";
|
|
|
|
|
echo " <td class=\"vtable\" style='color: #000000;'>".escape($row['name'])."</td>\n";
|
|
|
|
|
echo " <td class=\"vtable\" style='color: #ff0000;'>".escape($row['value'])."</td>\n";
|
2018-02-13 17:21:42 +01:00
|
|
|
echo "</tr>\n";
|
2024-08-02 19:54:14 +02:00
|
|
|
|
2020-01-08 21:25:59 +01:00
|
|
|
$previous_schema = $row['schema'];
|
|
|
|
|
$previous_row = $row['row'];
|
2018-02-13 17:21:42 +01:00
|
|
|
}
|
2020-01-08 21:25:59 +01:00
|
|
|
echo "</table>\n";
|
2018-02-13 17:21:42 +01:00
|
|
|
}
|
|
|
|
|
/*
|
2023-06-02 00:39:05 +02:00
|
|
|
if (!empty($after)) {
|
2018-02-13 17:21:42 +01:00
|
|
|
//create the table header
|
|
|
|
|
$array = array_difference(null, $after, 1);
|
|
|
|
|
$table_header = "<tr><td colspan='5'> </td></tr>\n";
|
|
|
|
|
$table_header .= "<tr>\n";
|
|
|
|
|
$table_header .= " <th>name</th>\n";
|
|
|
|
|
$table_header .= " <th> </th>\n";
|
|
|
|
|
$table_header .= " <th>new</th>\n";
|
|
|
|
|
$table_header .= "</tr>\n";
|
|
|
|
|
$_SESSION['table_header'] = $table_header;
|
|
|
|
|
|
|
|
|
|
//show the difference
|
|
|
|
|
echo "<table border='0' cellpadding='3'>\n";
|
|
|
|
|
show_difference($array);
|
|
|
|
|
echo "</table>\n";
|
|
|
|
|
}
|
|
|
|
|
*/
|
2018-02-12 19:16:49 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-13 17:21:42 +01:00
|
|
|
//show the update
|
2018-02-12 19:16:49 +01:00
|
|
|
if ($transaction_type == "update") {
|
|
|
|
|
if (count($before) > 0 && count($after) > 0) {
|
2018-02-13 17:21:42 +01:00
|
|
|
|
2018-02-12 19:16:49 +01:00
|
|
|
//create the table header
|
|
|
|
|
$array = array_difference($before, $after, 1);
|
|
|
|
|
$table_header = "<tr><td colspan='5'> </td></tr>\n";
|
|
|
|
|
$table_header .= "<tr>\n";
|
|
|
|
|
$table_header .= " <th>name</th>\n";
|
|
|
|
|
$table_header .= " <th>old</th>\n";
|
|
|
|
|
$table_header .= " <th>new</th>\n";
|
|
|
|
|
$table_header .= "</tr>\n";
|
|
|
|
|
$_SESSION['table_header'] = $table_header;
|
2024-08-02 19:54:14 +02:00
|
|
|
|
2018-02-12 19:16:49 +01:00
|
|
|
//show the difference
|
2019-11-23 18:00:18 +01:00
|
|
|
echo "<br />\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "<table width='100%'>\n";
|
2018-02-12 19:16:49 +01:00
|
|
|
show_difference($array);
|
|
|
|
|
echo "</table>\n";
|
|
|
|
|
}
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//show the delete
|
2018-02-12 19:16:49 +01:00
|
|
|
if ($transaction_type == "delete") {
|
2019-11-23 18:00:18 +01:00
|
|
|
echo "<br /><br />\n";
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "<table width='100%'>\n";
|
2023-06-02 00:39:05 +02:00
|
|
|
if (!empty($before)) {
|
2020-02-26 01:58:11 +01:00
|
|
|
foreach ($before as $table_name => $rows) {
|
2019-11-23 18:00:18 +01:00
|
|
|
echo " <tr>\n";
|
2020-02-26 01:58:11 +01:00
|
|
|
echo " <th>".escape($table_name)."</th><th> </th>\n";
|
2019-11-23 18:00:18 +01:00
|
|
|
echo " </tr>\n";
|
2020-02-26 01:58:11 +01:00
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
foreach ($row as $key => $value) {
|
|
|
|
|
echo " <tr class='list-row'>\n";
|
|
|
|
|
echo " <td>".escape($key)."</td><td>".escape($value)."</td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td colspan='3'><br /><br /></td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
}
|
2019-11-23 18:00:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-06-13 07:09:36 +02:00
|
|
|
}
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "</table>\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
|
|
|
|
|
//add a few lines at the end
|
2020-02-11 05:48:33 +01:00
|
|
|
echo "<br /><br />\n";
|
2017-06-13 07:09:36 +02:00
|
|
|
|
|
|
|
|
//include the footer
|
|
|
|
|
require_once "resources/footer.php";
|
|
|
|
|
|
2020-02-26 01:58:11 +01:00
|
|
|
?>
|