From 090b0e90d20aceed65805bd0950dd45703142f37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Feb 2020 23:52:48 +0100 Subject: [PATCH 01/13] FIX #13183 --- htdocs/install/upgrade2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index c5d1d7837e9a8..b5cf6e4c9ddc3 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -5024,7 +5024,7 @@ function migrate_users_socialnetworks() $obj->socialnetworks = '[]'; } $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); - $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX."user SET socialnetworks='".$db->escape(json_encode($socialnetworks, true))."'"; $sqlupd.= ', skype=null'; $sqlupd.= ', twitter=null'; $sqlupd.= ', facebook=null'; From 6366881f91e0a14cd3f9d02b5a8c3ad22448a95d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Feb 2020 00:41:25 +0100 Subject: [PATCH 02/13] FIX #13175 --- .../bank/account_statement_document.php | 6 +-- htdocs/compta/bank/releve.php | 2 +- htdocs/core/photos_resize.php | 49 ++++++++++++------- .../tpl/document_actions_post_headers.tpl.php | 3 +- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 08447216dda5d..bdb3ac4620ed3 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -137,9 +137,9 @@ $modulepart = 'bank'; $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; - $param = '&id='.$object->id.'&num='.$num; - $uri = '&num='.$num; - $relativepathwithnofile = $id."/statement/".$num."/"; + $param = '&id='.$object->id.'&num='.urlencode($num); + $moreparam = '&num='.urlencode($num);; + $relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($num)."/"; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 9ae1d5d7d83b9..a16927bda0b1d 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -49,7 +49,7 @@ $langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan")); $action = GETPOST('action', 'alpha'); -$id = GETPOST('account', 'int'); +$id = GETPOST('account', 'int') ? GETPOST('account', 'int') : GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $dvid = GETPOST('dvid', 'alpha'); $numref = GETPOST('num', 'alpha'); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 17c7cb9e974b2..dd59b20c964d9 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -38,6 +38,10 @@ $backtourl = GETPOST('backtourl'); $cancel = GETPOST('cancel', 'alpha'); +$file = GETPOST('file', 'alpha'); +$num = GETPOST('num', 'alpha'); // Used for document on bank statement + + // Security check if (empty($modulepart)) accessforbidden('Bad value for modulepart'); $accessallowed = 0; @@ -249,19 +253,25 @@ if (empty($backtourl)) { - if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('propal'))) $backtourl = DOL_URL_ROOT."/comm/propal/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]); + $regs = array(); + + if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('propal'))) $backtourl = DOL_URL_ROOT."/comm/propal/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('bank')) && preg_match('/\/statement\/([^\/]+)\//', $file, $regs)) { + $num = $regs[1]; + $backtourl = DOL_URL_ROOT."/compta/bank/account_statement_document.php?id=".$id.'&num='.urlencode($num).'&file='.urldecode($file); + } + elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($file); + elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?id=".$id.'&file='.urldecode($file); + else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($file); } @@ -283,11 +293,11 @@ } } -if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) +if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") && GETPOSTISSET("sizey")) { $fullpath = $dir."/".$original_file; - $result = dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']); + $result = dol_imageResizeOrCrop($fullpath, 0, GETPOST('sizex', 'int'), GETPOST('sizey', 'int')); if ($result == $fullpath) { @@ -357,7 +367,7 @@ $fullpath = $dir."/".$original_file; //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; - $result = dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']); + $result = dol_imageResizeOrCrop($fullpath, 1, GETPOST('w', 'int'), GETPOST('h', 'int'), GETPOST('x', 'int'), GETPOST('y', 'int')); if ($result == $fullpath) { @@ -445,7 +455,7 @@ */ print ''."\n"; -print '
'; +print ''; print ''; print '
'; @@ -454,7 +464,7 @@ print $langs->trans("NewLength").': px   '.$langs->trans("or").'   '; print $langs->trans("NewHeight").': px  
'; -print ''; +print ''; print ''; print ''; print ''; @@ -497,7 +507,8 @@ print ''; print ''; print '
'; - print ''; + + print ''; print ''; print '
diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index a3de72723a47b..2a3d703d16fd9 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -23,6 +23,7 @@ // $permissiontoadd = permission or not to add a file (can use also $permission) and permission or not to edit file name or crop file (can use also $permtoedit) // $modulepart = for download // $param = param to add to download links +// $moreparam = param to add to download link for the form_attach_new_file function // $upload_dir // $object // $filearray @@ -109,7 +110,7 @@ // Show upload form (document and links) $formfile->form_attach_new_file( - $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject)?'':'&withproject=1'), + $_SERVER["PHP_SELF"].'?id='.$object->id.(empty($withproject)?'':'&withproject=1').(empty($moreparam)?'':$moreparam), '', 0, 0, From 4b4d1bcce21fbfd959eaa1760ca4947e0c1e0eae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Feb 2020 03:05:58 +0100 Subject: [PATCH 03/13] Fix disable accountancy chart that is deprecated. --- htdocs/accountancy/admin/account.php | 3 +++ htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 3 +++ 2 files changed, 6 insertions(+) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 333efefbc9dfa..d75d61e347fb7 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -278,6 +278,8 @@