From 398e820a3145614e3628bc4de70e572b0e6d7193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Feb 2021 20:26:22 +0100 Subject: [PATCH] code syntax comm directory --- htdocs/master.inc.php | 85 ++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 9efff08306f..c63ace353b3 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -45,18 +45,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php'; $conf = new Conf(); // Set properties specific to database -$conf->db->host = $dolibarr_main_db_host; -$conf->db->port = $dolibarr_main_db_port; -$conf->db->name = $dolibarr_main_db_name; -$conf->db->user = $dolibarr_main_db_user; -$conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass; -$conf->db->type = $dolibarr_main_db_type; +$conf->db->host = $dolibarr_main_db_host; +$conf->db->port = $dolibarr_main_db_port; +$conf->db->name = $dolibarr_main_db_name; +$conf->db->user = $dolibarr_main_db_user; +$conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass; +$conf->db->type = $dolibarr_main_db_type; $conf->db->prefix = $dolibarr_main_db_prefix; $conf->db->character_set = $dolibarr_main_db_character_set; $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; -if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type = constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example) +if (defined('TEST_DB_FORCE_TYPE')) { + $conf->db->type = constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example) +} // Set properties specific to conf file $conf->file->main_limit_users = $dolibarr_main_limit_users; @@ -68,18 +70,17 @@ $conf->file->strict_mode = empty($dolibarr_strict_mode) ? '' : $dolibarr_strict_ $conf->file->instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id; // Unique id of instance $conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT); // Define array of document root directories ('/home/htdocs') $conf->file->dol_url_root = array('main' => (string) DOL_URL_ROOT); // Define array of url root path ('' or '/dolibarr') -if (!empty($dolibarr_main_document_root_alt)) -{ +if (!empty($dolibarr_main_document_root_alt)) { // dolibarr_main_document_root_alt can contains several directories $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt); $i = 0; - foreach ($values as $value) $conf->file->dol_document_root['alt'.($i++)] = (string) $value; + foreach ($values as $value) { + $conf->file->dol_document_root['alt'.($i++)] = (string) $value; + } $values = preg_split('/[;,]/', $dolibarr_main_url_root_alt); $i = 0; - foreach ($values as $value) - { - if (preg_match('/^http(s)?:/', $value)) - { + foreach ($values as $value) { + if (preg_match('/^http(s)?:/', $value)) { // Show error message $correct_value = str_replace($dolibarr_main_url_root, '', $value); print 'Error:
'."\n"; @@ -99,36 +100,39 @@ if (!empty($dolibarr_main_document_root_alt)) } // Chargement des includes principaux de librairies communes -if (!defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory -if (!defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; -if (!defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +if (!defined('NOREQUIREUSER')) { + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory +} +if (!defined('NOREQUIRETRAN')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; +} +if (!defined('NOREQUIRESOC')) { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +} /* * Creation objet $langs (must be before all other code) */ -if (!defined('NOREQUIRETRAN')) -{ +if (!defined('NOREQUIRETRAN')) { $langs = new Translate('', $conf); // Must be after reading conf } /* * Object $db */ -if (!defined('NOREQUIREDB')) -{ +if (!defined('NOREQUIREDB')) { $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); - if ($db->error) - { + if ($db->error) { // If we were into a website context - if (!defined('USEDOLIBARREDITOR') && !defined('USEDOLIBARRSERVER') && !empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0)) - { + if (!defined('USEDOLIBARREDITOR') && !defined('USEDOLIBARRSERVER') && !empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0)) { $sapi_type = php_sapi_name(); - if (substr($sapi_type, 0, 3) != 'cgi') http_response_code(503); // To tel search engine this is a temporary error + if (substr($sapi_type, 0, 3) != 'cgi') { + http_response_code(503); // To tel search engine this is a temporary error + } print '
'; - if (is_object($langs)) - { + if (is_object($langs)) { $langs->setDefaultLang('auto'); $langs->load("website"); print $langs->trans("SorryWebsiteIsCurrentlyOffLine"); @@ -175,10 +179,11 @@ if (session_id() && !empty($_SESSION["dol_entity"])) { } // Sanitize entity -if (!is_numeric($conf->entity)) $conf->entity = 1; +if (!is_numeric($conf->entity)) { + $conf->entity = 1; +} -if (!defined('NOREQUIREDB')) -{ +if (!defined('NOREQUIREDB')) { //print "Will work with data into entity instance number '".$conf->entity."'"; // Here we read database (llx_const table) and define $conf->global->XXX var. @@ -197,23 +202,25 @@ if (!empty($conf->file->mailing_limit_sendbycli)) { } // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. -if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) -{ +if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $mysoc = new Societe($db); $mysoc->setMysoc($conf); // For some countries, we need to invert our address with customer address - if ($mysoc->country_code == 'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1; + if ($mysoc->country_code == 'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1; + } } // Set default language (must be after the setValues setting global $conf->global->MAIN_LANG_DEFAULT. Page main.inc.php will overwrite langs->defaultlang with user value later) -if (!defined('NOREQUIRETRAN')) -{ +if (!defined('NOREQUIRETRAN')) { $langcode = (GETPOST('lang', 'aZ09') ? GETPOST('lang', 'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); - if (defined('MAIN_LANG_DEFAULT')) $langcode = constant('MAIN_LANG_DEFAULT'); + if (defined('MAIN_LANG_DEFAULT')) { + $langcode = constant('MAIN_LANG_DEFAULT'); + } $langs->setDefaultLang($langcode); } @@ -223,5 +230,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); -if (!defined('MAIN_LABEL_MENTION_NPR')) define('MAIN_LABEL_MENTION_NPR', 'NPR'); +if (!defined('MAIN_LABEL_MENTION_NPR')) { + define('MAIN_LABEL_MENTION_NPR', 'NPR'); +} //if (! defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $conf->user->dir_temp);