Clean code

This commit is contained in:
Laurent Destailleur 2023-04-29 15:46:44 +02:00
parent 4028b5d568
commit cfff62c2fa
9 changed files with 19 additions and 32 deletions

View File

@ -2101,8 +2101,6 @@ class ActionComm extends CommonObject
dol_syslog(get_class($this)."::build_exportfile select events", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
// Note: Output of sql request is encoded in $conf->file->character_set_client
// This assignment in condition is not a bug. It allows walking the results.
$diff = 0;
while ($obj = $this->db->fetch_object($resql)) {
$qualified = true;

View File

@ -41,7 +41,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
header('Cache-Control: Public, must-revalidate');
header("Content-type: text/html; charset=".$conf->file->character_set_client);
if (GETPOST('dol_hide_topmenu')) {
$conf->dol_hide_topmenu = 1;

View File

@ -36,7 +36,6 @@ if ($size > 10000) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
header('Cache-Control: Public, must-revalidate');
header("Content-type: text/html; charset=".$conf->file->character_set_client);
if (GETPOST('dol_hide_topmenu')) {
$conf->dol_hide_topmenu = 1;

View File

@ -38,7 +38,6 @@ if ($size > 10000) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
header('Cache-Control: Public, must-revalidate');
header("Content-type: text/html; charset=".$conf->file->character_set_client);
if (GETPOST('dol_hide_topmenu')) {
$conf->dol_hide_topmenu = 1;

View File

@ -41,8 +41,8 @@ if (!defined('DOL_DOCUMENT_ROOT')) {
define('DOL_DOCUMENT_ROOT', '..');
}
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -338,10 +338,6 @@ if ($islocked) { // Pages are locked
// Force usage of log file for install and upgrades
if (!isset($conf->syslog) || !is_object($conf->syslog)) {
$conf->syslog = new stdClass();
}
$conf->syslog->enabled = 1;
$conf->modules['syslog'] = 'syslog';
$conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
if (!defined('SYSLOG_HANDLERS')) {
@ -451,10 +447,6 @@ function conf($dolibarr_main_document_root)
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
// Force usage of log file for install and upgrades
if (!isset($conf->syslog) || !is_object($conf->syslog)) {
$conf->syslog = new stdClass();
}
$conf->syslog->enabled = 1;
$conf->modules['syslog'] = 'syslog';
$conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
if (!defined('SYSLOG_HANDLERS')) {

View File

@ -176,12 +176,10 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG)
dol_syslog("PBX_HASH: $PBX_HASH", LOG_DEBUG);
dol_syslog("PBX_TIME: $PBX_TIME", LOG_DEBUG);
header("Content-type: text/html; charset=".$conf->file->character_set_client);
header("X-Content-Type-Options: nosniff");
top_httphead();
print '<html>'."\n";
print '<head>'."\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$conf->file->character_set_client."\">\n";
print '</head>'."\n";
print '<body>'."\n";
print "\n";

View File

@ -29,19 +29,13 @@ if (!defined('DOL_DOCUMENT_ROOT')) {
define('DOL_DOCUMENT_ROOT', '..');
}
require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Avoid warnings with strict mode E_STRICT
$conf = new stdClass(); // instantiate $conf explicitely
$conf->global = new stdClass();
$conf->file = new stdClass();
$conf->db = new stdClass();
if (!isset($conf->syslog) || !is_object($conf->syslog)) {
$conf->syslog = new stdClass();
}
$conf = new Conf();
// Force $_REQUEST["logtohtml"]
$_REQUEST["logtohtml"] = 1;
@ -61,11 +55,12 @@ $conffiletoshowshort = "conf.php";
$conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems
/*
if (!file_exists($conffile)) {
$conffile = "/etc/dolibarr/conf.php";
$conffiletoshow = "/etc/dolibarr/conf.php";
}
*/
// Load conf file if it is already defined
if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) { // Test on filesize is to ensure that conf file is more that an empty template with just <?php in first line
@ -110,7 +105,7 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
// Create conf object
if (!empty($dolibarr_main_document_root)) {
$result = conf($dolibarr_main_document_root);
$result = loadconf($dolibarr_main_document_root);
}
// Load database driver
if ($result) {
@ -189,7 +184,7 @@ $bc[true] = ' class="bg2"';
* @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @return int <0 if KO, >0 if OK
*/
function conf($dolibarr_main_document_root)
function loadconf($dolibarr_main_document_root)
{
global $conf;
global $dolibarr_main_db_type;
@ -200,7 +195,10 @@ function conf($dolibarr_main_document_root)
global $dolibarr_main_db_pass;
global $character_set_client;
$return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
$return = 1;
if (!class_exists('Conf')) {
$return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
}
if (!$return) {
return -1;
}

View File

@ -29,6 +29,7 @@
// This is a standalone feature with no information from Dolibarr to show
// and no database access to do.
include_once 'inc.php';
$uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root);
$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') {
@ -38,7 +39,7 @@ if (!defined('DOL_URL_ROOT')) {
define('DOL_URL_ROOT', $pos); // URL racine relative
}
$langs->loadLangs(array("other", $langs->load("help")));
$langs->loadLangs(array("other", "help"));
/*
@ -65,7 +66,10 @@ if (GETPOST('dol_no_mouse_hover')) {
if (GETPOST('dol_use_jmobile')) {
$homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_use_jmobile=1';
}
print $langs->trans("ToGoBackToDolibarr", $homeurl);
// If a global var $dolibarr_main_url_root exists, install is done and complete, we can show the link to home page
if (!empty($dolibarr_main_url_root)) {
print $langs->trans("ToGoBackToDolibarr", $homeurl);
}
print '<br><br>';

View File

@ -15,7 +15,7 @@ exclude:
- htdocs/custom
- htdocs/includes
- htdocs/install/doctemplates
- htdocs/modulebuilder/template/test/functionnal
- htdocs/modulebuilder/template/test/phpunit/functionnal
- name: PhpIssetCanBeReplacedWithCoalesceInspection
- name: PhpRedundantOptionalArgumentInspection
- name: PhpLanguageLevelInspection