From 163665e4b535c0dc6aef28edf031dae18757308c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Apr 2019 11:34:06 +0200 Subject: [PATCH 1/2] FIX A page of a site replaced with another when switching in edit mode Conflicts: htdocs/website/index.php --- htdocs/website/index.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 60b4e4e20cb..1ec9c2c65c4 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -213,7 +213,21 @@ $htmlheadercontentdefault.='-->'."\n"; * Actions */ -$backtopage=$_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir','alpha')?'§ion_dir='.urlencode(GETPOST('section_dir','alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php +// Protections +if ($action == 'updatesource' && (GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x'))) +{ + $action = 'preview'; // To avoid to update another page or another site when we click on button to select another site or page. +} +if (GETPOST('refreshsite', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action. +{ + $pageid=0; + if ($action == 'addsite') $action = 'preview'; + if ($action == 'updatesource') $action = 'preview'; +} +if (GETPOST('refreshpage', 'alpha') && ! in_array($action, array('updatecss'))) $action='preview'; + + +$backtopage=$_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' @@ -270,15 +284,6 @@ if ($action == 'adddir' && $permtouploadfile) } */ - -if (GETPOST('refreshsite','alpha')) // If we change the site, we reset the pageid and cancel addsite action. -{ - $pageid=0; - if ($action == 'addsite') $action = 'preview'; -} -if (GETPOST('refreshpage','alpha') && ! in_array($action, array('updatecss'))) $action='preview'; - - // Add site if ($action == 'addsite') { @@ -1755,7 +1760,7 @@ if (! GETPOST('hide_websitemenu')) $out.=ajax_combobox('website'); print $out; //print ''; - print ''; + print ''; if ($websitekey) From becefeebff7fae7bf81fd1f2a709e1b6b9833664 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Apr 2019 19:39:04 +0200 Subject: [PATCH 2/2] Fix upload of files without extension --- htdocs/core/lib/files.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 964e368c4e3..5a3a3a9307c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1552,10 +1552,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio // dol_sanitizeFileName the file name and lowercase extension $info = pathinfo($destfull); - $destfull = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension'])); + $destfull = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].($info['extension']!='' ? ('.'.strtolower($info['extension'])) : '')); $info = pathinfo($destfile); - $destfile = dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension'])); - + $destfile = dol_sanitizeFileName($info['filename'].($info['extension']!='' ? ('.'.strtolower($info['extension'])) : '')); $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'