From 00e0649cde9a010aca9bd5f47c4142790ec4a617 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Aug 2012 07:38:06 +0200 Subject: [PATCH 01/12] Fix: strict mode plaza --- htdocs/ecm/class/ecmdirectory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index e0519073386..a684be57701 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -567,9 +567,9 @@ class EcmDirectory // extends CommonObject $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c; $this->cats[$obj->rowid]['login_c'] = $obj->login_c; - if ($obj->rowid_fille) + if (! empty($obj->rowid_fille)) { - if (is_array($this->cats[$obj->rowid]['id_children'])) + if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) { $newelempos=count($this->cats[$obj->rowid]['id_children']); //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements
"; From 0ad137e73419bdb077c375dc75add335e4f5b5dd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Aug 2012 07:47:41 +0200 Subject: [PATCH 02/12] Fix: uniformize code --- htdocs/core/lib/files.lib.php | 4 ++-- htdocs/ecm/search.php | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 36851694460..4ac18c0985f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -139,12 +139,12 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil closedir($dir); // Obtain a list of columns - if ($sortcriteria) + if (! empty($sortcriteria)) { $myarray=array(); foreach ($file_list as $key => $row) { - $myarray[$key] = $row[$sortcriteria]; + $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:''); } // Sort the data if ($sortorder) array_multisort($myarray, $sortorder, $file_list); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 16ca5d56a36..8870d50c639 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -48,9 +48,9 @@ $result = restrictedArea($user, 'ecm',''); $user->getrights('ecm'); // Get parameters -$socid = isset($_GET["socid"])?$_GET["socid"]:''; -$action = isset($_GET["action"])?$_GET["action"]:$_POST['action']; -$section=isset($_GET["section"])?$_GET["section"]:$_POST['section']; +$socid = GETPOST('socid','int'); +$action = GETPOST('action','alpha'); +$section=GETPOST('section'); if (! $section) $section=0; $upload_dir = $conf->ecm->dir_output.'/'.$section; @@ -66,9 +66,9 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; $ecmdir = new EcmDirectory($db); -if (! empty($_REQUEST["section"])) +if (! empty($section)) { - $result=$ecmdir->fetch($_REQUEST["section"]); + $result=$ecmdir->fetch($section); if (! $result > 0) { dol_print_error($db,$ecmdir->error); @@ -123,10 +123,8 @@ print_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search")); //print "
\n"; print $langs->trans("FeatureNotYetAvailable").'.

'; -if ($mesg) { print $mesg."
"; } - // Tool bar -$head = ecm_prepare_head_fm($fac); +$head = ecm_prepare_head_fm($ecmdir); //dol_fiche_head($head, 'search_form', '', 1); @@ -210,7 +208,6 @@ print ''; print '
'; // End of page -$db->close(); - llxFooter(); +$db->close(); ?> From 026cf124afe72d417a9d8947df6f2a55d177e0ff Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Aug 2012 16:35:39 +0200 Subject: [PATCH 03/12] Fix: avoid php warning --- htdocs/admin/security_other.php | 48 ++++++++++++++------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 2ba43a0aedf..dab17330f27 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,10 @@ $langs->load("users"); $langs->load("admin"); $langs->load("other"); -if (!$user->admin) accessforbidden(); +if (! $user->admin) + accessforbidden(); + +$action=GETPOST('action','alpha'); $upload_dir=$conf->admin->dir_temp; @@ -46,57 +49,51 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) dol_add_file_process($upload_dir,0,0); } -if ($_GET["action"] == 'activate_captcha') +if ($action == 'activate_captcha') { dolibarr_set_const($db, "MAIN_SECURITY_ENABLECAPTCHA", '1','chaine',0,'',$conf->entity); header("Location: security_other.php"); exit; } -else if ($_GET["action"] == 'disable_captcha') +else if ($action == 'disable_captcha') { dolibarr_del_const($db, "MAIN_SECURITY_ENABLECAPTCHA",$conf->entity); header("Location: security_other.php"); exit; } - -if ($_GET["action"] == 'activate_advancedperms') +else if ($action == 'activate_advancedperms') { dolibarr_set_const($db, "MAIN_USE_ADVANCED_PERMS", '1','chaine',0,'',$conf->entity); header("Location: security_other.php"); exit; } -else if ($_GET["action"] == 'disable_advancedperms') +else if ($action == 'disable_advancedperms') { dolibarr_del_const($db, "MAIN_USE_ADVANCED_PERMS",$conf->entity); header("Location: security_other.php"); exit; } - -if ($_GET["action"] == 'MAIN_SESSION_TIMEOUT') +else if ($action == 'MAIN_SESSION_TIMEOUT') { if (! dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } - -if ($_GET["action"] == 'MAIN_UPLOAD_DOC') +else if ($action == 'MAIN_UPLOAD_DOC') { if (! dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',$_POST["MAIN_UPLOAD_DOC"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } - -if ($_GET["action"] == 'MAIN_UMASK') +else if ($action == 'MAIN_UMASK') { if (! dolibarr_set_const($db, "MAIN_UMASK", $_POST["MAIN_UMASK"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } - -if ($_GET["action"] == 'MAIN_ANTIVIRUS_COMMAND') +else if ($action == 'MAIN_ANTIVIRUS_COMMAND') { if (! dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", $_POST["MAIN_ANTIVIRUS_COMMAND"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } - -if ($_GET["action"] == 'MAIN_ANTIVIRUS_PARAM') +else if ($action == 'MAIN_ANTIVIRUS_PARAM') { if (! dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", $_POST["MAIN_ANTIVIRUS_PARAM"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); @@ -168,11 +165,11 @@ print ''.$langs->trans("UseCaptchaCode").''; print ''; if (function_exists("imagecreatefrompng")) { - if ($conf->global->MAIN_SECURITY_ENABLECAPTCHA == 0) + if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } - if($conf->global->MAIN_SECURITY_ENABLECAPTCHA == 1) + else { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } @@ -193,11 +190,11 @@ $var=!$var; print ""; print ''.$langs->trans("UseAdvancedPerms").''; print ''; -if ($conf->global->MAIN_USE_ADVANCED_PERMS == 0) +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } -if($conf->global->MAIN_USE_ADVANCED_PERMS == 1) +else { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } @@ -274,7 +271,7 @@ if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; print ""; print ''; print ''; @@ -291,7 +288,7 @@ print ''.$langs->trans("AntiVirusParam").'
'; print $langs->trans("AntiVirusParamExample"); print ''; print ''; -print ''; +print ''; print ""; print ''; print ''; @@ -303,17 +300,12 @@ print ''; print ''; - // Form to test upload -dol_htmloutput_mesg($mesg); - -// Affiche formulaire upload print '
'; $formfile=new FormFile($db); $formfile->form_attach_new_file(DOL_URL_ROOT.'/admin/security_other.php',$langs->trans("FormToTestFileUploadForm"),0,0,1); llxFooter(); - $db->close(); ?> From b9ac974013fbcdb18904160d10893aada6cd017d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 2 Sep 2012 22:04:30 +0200 Subject: [PATCH 04/12] Fix: use ajax button on/off --- htdocs/admin/security_other.php | 91 +++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index dab17330f27..a77e70deb45 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -49,30 +49,35 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) dol_add_file_process($upload_dir,0,0); } -if ($action == 'activate_captcha') +if (preg_match('/set_(.*)/',$action,$reg)) { - dolibarr_set_const($db, "MAIN_SECURITY_ENABLECAPTCHA", '1','chaine',0,'',$conf->entity); - header("Location: security_other.php"); - exit; + $code=$reg[1]; + $value=(GETPOST($code) ? GETPOST($code) : 1); + if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } } -else if ($action == 'disable_captcha') + +else if (preg_match('/del_(.*)/',$action,$reg)) { - dolibarr_del_const($db, "MAIN_SECURITY_ENABLECAPTCHA",$conf->entity); - header("Location: security_other.php"); - exit; -} -else if ($action == 'activate_advancedperms') -{ - dolibarr_set_const($db, "MAIN_USE_ADVANCED_PERMS", '1','chaine',0,'',$conf->entity); - header("Location: security_other.php"); - exit; -} -else if ($action == 'disable_advancedperms') -{ - dolibarr_del_const($db, "MAIN_USE_ADVANCED_PERMS",$conf->entity); - header("Location: security_other.php"); - exit; + $code=$reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } } + else if ($action == 'MAIN_SESSION_TIMEOUT') { if (! dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity)) dol_print_error($db); @@ -165,14 +170,21 @@ print ''.$langs->trans("UseCaptchaCode").''; print ''; if (function_exists("imagecreatefrompng")) { - if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - } + if (! empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA'); + } + else + { + if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } + } } else { @@ -180,28 +192,29 @@ else $desc = $form->textwithpicto('',$langs->transnoentities("EnableGDLibraryDesc"),1,'warning'); print $desc; } -print ""; - -print ""; -print ''; +print ''; // Enable advanced perms $var=!$var; print ""; print ''.$langs->trans("UseAdvancedPerms").''; print ''; -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +if (! empty($conf->use_javascript_ajax)) { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS'); } else { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } } -print ""; - -print ""; -print ''; +print ""; print ''; From a00205a17d4c7e83221b09ae1352a0b97394fe53 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 13 Aug 2012 11:42:50 +0200 Subject: [PATCH 05/12] New: add possibility to set and del anothers constants --- htdocs/core/ajax/constantonoff.php | 9 +-- htdocs/core/lib/ajax.lib.php | 94 +++++++++++++++++++----------- 2 files changed, 66 insertions(+), 37 deletions(-) diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index a79a9f5d0ff..d195df7631f 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -30,6 +30,8 @@ if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +$action=GETPOST('action','alpha'); +$name=GETPOST('name','alpha'); /* * View @@ -45,17 +47,16 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if ((isset($_GET['action']) && ! empty($_GET['action'])) && (isset($_GET['name']) && ! empty($_GET['name'])) ) +if (! empty($action) && ! empty($name)) { $entity = GETPOST('entity','int'); - $action = GETPOST('action', 'alpha'); - $name = GETPOST('name', 'alpha'); + $value = (GETPOST('value')?GETPOST('value'):1); if ($user->admin) { if ($action == 'set') { - dolibarr_set_const($db, $name, 1, 'chaine', 0, '', $entity); + dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); } else if ($action == 'del') { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 2993197b660..ebfb2cfdd8d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -346,7 +346,7 @@ function ajax_combobox($htmlname, $event=array()) * On/off button for constant * * @param string $code Name of constant - * @param array $input Input element + * @param array $input Input element (enable/disable or show/hide another element, set/del another constant) * @param int $entity Entity to set * @return void */ @@ -359,10 +359,11 @@ function ajax_constantonoff($code,$input=array(),$entity=false) $out= ''; + $out.= ''; $out.= ''.img_picto($langs->trans("Disabled"),'switch_off').''; $out.= ''.img_picto($langs->trans("Enabled"),'switch_on').''; From 8a5fe809f441c4a163c343c3e5df161518c0e4f3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 2 Sep 2012 22:31:25 +0200 Subject: [PATCH 11/12] Fix: remove deprecated function and avoid warnings --- htdocs/societe/canvas/actions_card_common.class.php | 4 ++-- htdocs/societe/soc.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 0e22c08b86d..3faba3cf2d8 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -436,7 +436,7 @@ abstract class ActionsCardCommon $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } - $modCodeClient = new $module; + $modCodeClient = new $module($db); $this->tpl['auto_customercode'] = $modCodeClient->code_auto; // We verified if the tag prefix is used if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); @@ -714,4 +714,4 @@ abstract class ActionsCardCommon } -?> \ No newline at end of file +?> diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b08667613af..156133c9252 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1013,7 +1013,7 @@ else $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } - $modCodeClient = new $module; + $modCodeClient = new $module($db); // We verified if the tag prefix is used if ($modCodeClient->code_auto) { @@ -1031,7 +1031,7 @@ else $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } - $modCodeFournisseur = new $module; + $modCodeFournisseur = new $module($db); // On verifie si la balise prefix est utilisee if ($modCodeFournisseur->code_auto) { From d2ae90f938c6c34022bfec61196431ee2c22b38f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 2 Sep 2012 22:48:52 +0200 Subject: [PATCH 12/12] Fix: strict mode everywhere --- htdocs/core/db/mysql.class.php | 14 +++++------ htdocs/core/db/mysqli.class.php | 14 +++++------ htdocs/core/lib/ajax.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 19 ++++++++++----- htdocs/core/modules/DolibarrModules.class.php | 16 ++++++------- .../modules/expedition/modules_expedition.php | 2 +- .../modules/livraison/modules_livraison.php | 2 +- htdocs/imports/import.php | 24 ++++++++++++------- htdocs/main.inc.php | 2 +- 9 files changed, 55 insertions(+), 40 deletions(-) diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 8d6b08d90de..7bb8b77f399 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2002-2007 Rodolphe Quiedeville - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2001 Fabien Seisen + * Copyright (C) 2002-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -714,10 +714,10 @@ class DoliDBMysql global $conf; // Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) - $cryptType = ($conf->db->dolibarr_main_db_encryption?$conf->db->dolibarr_main_db_encryption:0); + $cryptType = (isset($conf->db->dolibarr_main_db_encryption)?$conf->db->dolibarr_main_db_encryption:0); //Encryption key - $cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); + $cryptKey = (! empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); $return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":""); diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 3db424d4db2..4d4b9d9be1b 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2002-2005 Rodolphe Quiedeville - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2001 Fabien Seisen + * Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -709,10 +709,10 @@ class DoliDBMysqli global $conf; // Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) - $cryptType = ($conf->db->dolibarr_main_db_encryption?$conf->db->dolibarr_main_db_encryption:0); + $cryptType = (isset($conf->db->dolibarr_main_db_encryption)?$conf->db->dolibarr_main_db_encryption:0); //Encryption key - $cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); + $cryptKey = (! empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); $return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":""); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 70a88760adf..e5b8a1d5f12 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -350,7 +350,7 @@ function ajax_combobox($htmlname, $event=array()) * @param int $entity Entity to set * @return void */ -function ajax_constantonoff($code,$input=array(),$entity=false) +function ajax_constantonoff($code, $input=array(), $entity=false) { global $conf, $langs; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cccc2429817..86ad6f2a2fb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3033,12 +3033,13 @@ function get_exdir($num,$level=3,$alpha=0,$withoutslash=0) /** * Creation of a directory (this can create recursive subdir) * - * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') - * @return int < 0 if KO, 0 = already exists, > 0 if OK + * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') + * @param string $dataroot Data root directory (to avoid having the data root in the loop) + * @return int < 0 if KO, 0 = already exists, > 0 if OK */ -function dol_mkdir($dir) +function dol_mkdir($dir, $dataroot='') { - global $conf; + global $db, $conf; dol_syslog("functions.lib::dol_mkdir: dir=".$dir,LOG_INFO); @@ -3048,8 +3049,14 @@ function dol_mkdir($dir) $nberr=0; $nbcreated=0; - $ccdir = ''; - $cdir = explode("/",$dir); + $ccdir=''; + if (! empty($dataroot)) { + // Remove data root from loop + $dir = str_replace($dataroot.'/', '', $dir); + $ccdir = $dataroot.'/'; + } + + $cdir = explode("/", $dir); $num=count($cdir); for ($i = 0; $i < $num; $i++) { diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index ab33d464c8d..0e676200fcb 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1170,7 +1170,7 @@ abstract class DolibarrModules $err=0; - if (is_array($this->dirs)) + if (isset($this->dirs) && is_array($this->dirs) && ! empty($this->dirs)) { foreach ($this->dirs as $key => $value) { @@ -1184,19 +1184,19 @@ abstract class DolibarrModules $subname = empty($this->dirs[$key][3])?'':strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output) $forcename = empty($this->dirs[$key][4])?'':strtoupper($this->dirs[$key][4]); // Change the module name if different - if ($forcename) $constname = 'MAIN_MODULE_'.$forcename."_DIR_"; - if ($subname) $constname = $constname.$subname."_"; + if (! empty($forcename)) $constname = 'MAIN_MODULE_'.$forcename."_DIR_"; + if (! empty($subname)) $constname = $constname.$subname."_"; - $name = $constname.strtoupper($this->dirs[$key][0]); + $name = $constname.strtoupper($this->dirs[$key][0]); } // Define directory full path ($dir must start with "/") if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) $fulldir = DOL_DATA_ROOT.$dir; else $fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir; // Create dir if it does not exists - if ($fulldir && ! file_exists($fulldir)) + if (! empty($fulldir) && ! file_exists($fulldir)) { - if (dol_mkdir($fulldir) < 0) + if (dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) { $this->error = $langs->trans("ErrorCanNotCreateDir",$fulldir); dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR); @@ -1205,9 +1205,9 @@ abstract class DolibarrModules } // Define the constant in database if requested (not the default mode) - if ($addtodatabase) + if (! empty($addtodatabase)) { - $result = $this->insert_dirs($name,$dir); + $result = $this->insert_dirs($name, $dir); if ($result) $err++; } } diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index f650e4bd84f..a40fddc9ef6 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -246,4 +246,4 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs) return -1; } } -?> +?> \ No newline at end of file diff --git a/htdocs/core/modules/livraison/modules_livraison.php b/htdocs/core/modules/livraison/modules_livraison.php index de778563c46..663c7198755 100644 --- a/htdocs/core/modules/livraison/modules_livraison.php +++ b/htdocs/core/modules/livraison/modules_livraison.php @@ -251,4 +251,4 @@ function delivery_order_pdf_create($db, $object, $modele, $outputlangs='') } } -?> +?> \ No newline at end of file diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index c9bd77bacb6..5b28b54af5a 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -35,8 +35,8 @@ $langs->load("exports"); $langs->load("errors"); // Security check -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'import',$origin_id,''); +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result=restrictedArea($user, 'import'); $entitytoicon=array( 'invoice'=>'bill','invoice_line'=>'bill', @@ -68,7 +68,8 @@ $entitytolang=array( // Translation code $datatoimport = GETPOST('datatoimport'); $format = GETPOST('format'); $filetoimport = GETPOST('filetoimport'); -$action = GETPOST('action'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); $step = (GETPOST('step') ? GETPOST('step') : 1); $import_name = GETPOST('import_name'); $hexa = GETPOST('hexa'); @@ -92,7 +93,7 @@ foreach($fieldsarray as $elem) { $tabelem=explode('=',$elem,2); $key=$tabelem[0]; - $val=$tabelem[1]; + $val=(isset($tabelem[1])?$tabelem[1]:''); if ($key && $val) { $array_match_file_to_database[$key]=$val; @@ -192,7 +193,7 @@ if ($action == 'add_import_model') if ($step == 3 && $datatoimport) { - if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) + if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { dol_mkdir($conf->import->dir_temp); $nowyearmonth=dol_print_date(dol_now(),'%Y%m%d%H%M%S'); @@ -451,6 +452,14 @@ if ($step == 3 && $datatoimport) dol_fiche_head($head, 'step3', $langs->trans("NewImport")); + /* + * Confirm delete file + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '
'; + } print ''; @@ -511,7 +520,7 @@ if ($step == 3 && $datatoimport) print "\n"; // Search available imports - $filearray=dol_dir_list($conf->import->dir_temp,'files',0,'','','name',SORT_DESC); + $filearray=dol_dir_list($conf->import->dir_temp, 'files', 0, '', '', 'name', SORT_DESC); if (count($filearray) > 0) { $dir=$conf->import->dir_temp; @@ -545,8 +554,7 @@ if ($step == 3 && $datatoimport) // Affiche date fichier print ''; // Del button - print ''; // Action button print '
'.dol_print_date(dol_filemtime($dir.'/'.$file),'dayhour').''.img_delete().''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 06e0d7df71f..3c1b9e99493 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1000,7 +1000,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; } // jQuery File Upload - if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)) + if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || defined('REQUIRE_JQUERY_FILEUPLOAD')) { print ''."\n"; print ''."\n";