switch to json instead serialize + base64

This commit is contained in:
Sebijk 2023-10-14 14:19:41 +02:00
parent 8e3509d8b8
commit 8808752b30
8 changed files with 7684 additions and 13 deletions

View file

@ -58,7 +58,7 @@ if($_REQUEST['action'] == 'db')
{
// read default structure
include('../serverlib/database.struct.php');
$databaseStructure = unserialize(base64_decode($databaseStructure));
$databaseStructure = json_decode($databaseStructure, JSON_OBJECT_AS_ARRAY);
// get tables
$defaultTables = array();
@ -184,7 +184,7 @@ if($_REQUEST['action'] == 'db')
{
// read default structure
include('../serverlib/database.struct.php');
$databaseStructure = unserialize(base64_decode($databaseStructure));
$databaseStructure = json_decode($databaseStructure, JSON_OBJECT_AS_ARRAY);
$executedQueries = SyncDBStruct($databaseStructure);
// assign

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -457,7 +457,7 @@ elseif ($step == STEP_INSTALL) {
include './data/rootcerts.data.php';
// prepare structure
$databaseStructure = unserialize(base64_decode($databaseStructure));
$databaseStructure = json_decode($databaseStructure, JSON_OBJECT_AS_ARRAY);
// sanitize input
if (substr($_REQUEST['url'], -1) != '/') {
@ -552,7 +552,7 @@ elseif ($step == STEP_INSTALL) {
SQLEscape('postmaster@'.EncodeDomain($firstDomain), $connection),
'BMPlugin_Widget_Welcome,BMPlugin_Widget_EMail,BMPlugin_Widget_Websearch;BMPlugin_Widget_Mailspace,,BMPlugin_Widget_Quicklinks;BMPlugin_Widget_Webdiskspace,,',
'BMPlugin_Widget_Websearch,BMPlugin_Widget_Calendar,BMPlugin_Widget_Notes;,BMPlugin_Widget_Tasks,',
!ini_get('safe_mode') ? 'yes' : 'no',
'yes',
SQLEscape('a:8:{s:5:"mails";s:2:"on";s:11:"attachments";s:2:"on";s:3:"sms";s:2:"on";s:8:"calendar";s:2:"on";s:5:"tasks";s:2:"on";s:11:"addressbook";s:2:"on";s:5:"notes";s:2:"on";s:7:"webdisk";s:2:"on";}', $connection),
$utf8Mode ? 1 : 0,
$defaultInvoice,

View file

@ -24,6 +24,10 @@ require './common.inc.php';
require '../serverlib/config.inc.php';
require '../serverlib/version.inc.php';
if(file_exists(__DIR__."/lock_update")) {
die("Lockfile detected. Please remove the file lock_update if you want rerun.");
}
// target version
$target_version = '7.4.1-Beta4';
@ -299,7 +303,7 @@ elseif ($step == STEP_UPDATE_STEP) {
elseif ($do == 'struct2') {
include '../serverlib/database.struct.php';
$databaseStructure = unserialize(base64_decode($databaseStructure));
$databaseStructure = json_decode($databaseStructure);
$queries = SyncDBStruct($connection, $databaseStructure, true, isset($bm_prefs['db_is_utf8']) && $bm_prefs['db_is_utf8'] == 1);
if (count($queries) == 0) {
@ -823,6 +827,13 @@ elseif ($step == STEP_UPDATE_STEP) {
fwrite($fp, sprintf('<?php define(\'B1GMAIL_VERSION\', $b1gmail_version = \'%s\'); ?>', $target_version));
fclose($fp);
if(is_writable('./'))
{
$lock = @fopen('./lock_update', 'w');
$written = @fwrite($lock, '1');
@fclose($lock);
}
echo 'OK:DONE';
}

View file

@ -70,11 +70,10 @@ foreach($tables as $table)
}
// output
$structure = serialize($structure);
$structure = base64_encode($structure);
$structure = wordwrap($structure, 75, "'\n\t. '", true);
$structure = json_encode($structure, JSON_PRETTY_PRINT);
echo '<div style="float:right;"><h3>Export-Daten</h3>';
echo '<textarea cols=90 rows=40 readonly=readonly>$databaseStructure = ' . sprintf('% 66s', "// checksum: " . md5($structure)) . "\n\t" . ' \'' . $structure . '\';</textarea>';
echo '<br>checksum (SHA256):'.hash('sha256', $structure).'<br>';
echo '<textarea cols=90 rows=40 readonly=readonly>'. $structure . '</textarea>';
echo '</div>';
// clean up

View file

@ -3,6 +3,6 @@ error_reporting(E_ALL);
require '../src/serverlib/init.inc.php';
require '../src/serverlib/database.struct.php';
echo 'Syncing DB...';
$databaseStructure = unserialize(base64_decode($databaseStructure));
$databaseStructure = json_decode($databaseStructure, JSON_OBJECT_AS_ARRAY);
SyncDBStruct($databaseStructure);
echo 'DB synced...';
echo 'DB synced...';

View file

@ -1,4 +1,4 @@
<?php
error_reporting(E_ALL);
require '../src/serverlib/database.struct.php';
echo json_encode(unserialize(base64_decode($databaseStructure)), JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
echo $databaseStructure;