fix phpcs

This commit is contained in:
Frédéric FRANCE 2020-12-20 10:28:06 +01:00
parent 8d21eab6ab
commit f9ea75df3d
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
4 changed files with 219 additions and 130 deletions

View File

@ -15,6 +15,9 @@ function faaa()
return 'faaa'; return 'faaa';
} }
/**
* Class Aaa
*/
class Aaa class Aaa
{ {
const AAA='aaa'; const AAA='aaa';

View File

@ -12,6 +12,9 @@ function fbbb()
return 'fbbb'; return 'fbbb';
} }
/**
* Class Bbb
*/
class Bbb class Bbb
{ {
const BBB='bbb'; const BBB='bbb';

View File

@ -161,7 +161,6 @@ if (!count($listofmethods)) {
} }
if ($action == 'edit') { if ($action == 'edit') {
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';

View File

@ -44,21 +44,45 @@ dolibarr_install_syslog("- fileconf: entering fileconf.php page");
// install.forced.php into directory htdocs/install (This is the case with some wizard // install.forced.php into directory htdocs/install (This is the case with some wizard
// installer like DoliWamp, DoliMamp or DoliBuntu). // installer like DoliWamp, DoliMamp or DoliBuntu).
// We first init "forced values" to nothing. // We first init "forced values" to nothing.
if (!isset($force_install_noedit)) $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters if (!isset($force_install_noedit)) {
if (!isset($force_install_type)) $force_install_type = ''; $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters
if (!isset($force_install_dbserver)) $force_install_dbserver = ''; }
if (!isset($force_install_port)) $force_install_port = ''; if (!isset($force_install_type)) {
if (!isset($force_install_database)) $force_install_database = ''; $force_install_type = '';
if (!isset($force_install_prefix)) $force_install_prefix = ''; }
if (!isset($force_install_createdatabase)) $force_install_createdatabase = ''; if (!isset($force_install_dbserver)) {
if (!isset($force_install_databaselogin)) $force_install_databaselogin = ''; $force_install_dbserver = '';
if (!isset($force_install_databasepass)) $force_install_databasepass = ''; }
if (!isset($force_install_databaserootlogin)) $force_install_databaserootlogin = ''; if (!isset($force_install_port)) {
if (!isset($force_install_databaserootpass)) $force_install_databaserootpass = ''; $force_install_port = '';
}
if (!isset($force_install_database)) {
$force_install_database = '';
}
if (!isset($force_install_prefix)) {
$force_install_prefix = '';
}
if (!isset($force_install_createdatabase)) {
$force_install_createdatabase = '';
}
if (!isset($force_install_databaselogin)) {
$force_install_databaselogin = '';
}
if (!isset($force_install_databasepass)) {
$force_install_databasepass = '';
}
if (!isset($force_install_databaserootlogin)) {
$force_install_databaserootlogin = '';
}
if (!isset($force_install_databaserootpass)) {
$force_install_databaserootpass = '';
}
// Now we load forced values from install.forced.php file. // Now we load forced values from install.forced.php file.
$useforcedwizard = false; $useforcedwizard = false;
$forcedfile = "./install.forced.php"; $forcedfile = "./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php if ($conffile == "/etc/dolibarr/conf.php") {
$forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php
}
if (@file_exists($forcedfile)) { if (@file_exists($forcedfile)) {
$useforcedwizard = true; $useforcedwizard = true;
include_once $forcedfile; include_once $forcedfile;
@ -75,8 +99,7 @@ session_start(); // To be able to keep info into session (used for not losing pa
pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis'); pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis');
// Test if we can run a first install process // Test if we can run a first install process
if (!is_writable($conffile)) if (!is_writable($conffile)) {
{
print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING); dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
dolibarr_install_syslog("- fileconf: end"); dolibarr_install_syslog("- fileconf: end");
@ -84,8 +107,7 @@ if (!is_writable($conffile))
exit; exit;
} }
if (!empty($force_install_message)) if (!empty($force_install_message)) {
{
print '<div><br>'.$langs->trans($force_install_message).'</div>'; print '<div><br>'.$langs->trans($force_install_message).'</div>';
/*print '<script type="text/javascript">'; /*print '<script type="text/javascript">';
@ -106,7 +128,9 @@ if (!empty($force_install_message))
<div> <div>
<table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>"> <table class="nobordernopadding<?php if ($force_install_noedit) {
print ' hidewhennoedit';
} ?>">
<tr> <tr>
<td colspan="3" class="label"> <td colspan="3" class="label">
@ -217,8 +241,12 @@ if (!empty($force_install_noedit)) {
<input type="checkbox" <input type="checkbox"
id="main_force_https" id="main_force_https"
name="main_force_https" name="main_force_https"
<?php if (!empty($force_install_mainforcehttps)) { print ' checked'; } ?> <?php if (!empty($force_install_mainforcehttps)) {
<?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) { print ' disabled'; } ?> print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_mainforcehttps !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?> <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
@ -244,7 +272,9 @@ if (!empty($force_install_noedit)) {
id="db_name" id="db_name"
name="db_name" name="db_name"
value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>" value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
<?php if ($force_install_noedit == 2 && $force_install_database !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_database !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td> <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
@ -252,8 +282,7 @@ if (!empty($force_install_noedit)) {
<?php <?php
if (!isset($dolibarr_main_db_host)) if (!isset($dolibarr_main_db_host)) {
{
$dolibarr_main_db_host = "localhost"; $dolibarr_main_db_host = "localhost";
} }
?> ?>
@ -273,47 +302,76 @@ if (!empty($force_install_noedit)) {
// Scan les drivers // Scan les drivers
$dir = DOL_DOCUMENT_ROOT.'/core/db'; $dir = DOL_DOCUMENT_ROOT.'/core/db';
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg)) {
{
if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg))
{
$type = $reg[1]; $type = $reg[1];
if ($type === 'DoliDB') continue; // Skip abstract class if ($type === 'DoliDB') {
continue; // Skip abstract class
}
$class = 'DoliDB'.ucfirst($type); $class = 'DoliDB'.ucfirst($type);
include_once $dir."/".$file; include_once $dir."/".$file;
if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) if ($type == 'sqlite') {
if ($type == 'sqlite3') continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
}
if ($type == 'sqlite3') {
continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
}
// Version min of database // Version min of database
$versionbasemin = explode('.', $class::VERSIONMIN); $versionbasemin = explode('.', $class::VERSIONMIN);
$note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')'; $note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
// Switch to mysql if mysqli is not present // Switch to mysql if mysqli is not present
if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) {
$defaultype = 'mysql';
}
// Show line into list // Show line into list
if ($type == 'mysql') { $testfunction = 'mysql_connect'; $testclass = ''; } if ($type == 'mysql') {
if ($type == 'mysqli') { $testfunction = 'mysqli_connect'; $testclass = ''; } $testfunction = 'mysql_connect'; $testclass = '';
if ($type == 'pgsql') { $testfunction = 'pg_connect'; $testclass = ''; } }
if ($type == 'mssql') { $testfunction = 'mssql_connect'; $testclass = ''; } if ($type == 'mysqli') {
if ($type == 'sqlite') { $testfunction = ''; $testclass = 'PDO'; } $testfunction = 'mysqli_connect'; $testclass = '';
if ($type == 'sqlite3') { $testfunction = ''; $testclass = 'SQLite3'; } }
if ($type == 'pgsql') {
$testfunction = 'pg_connect'; $testclass = '';
}
if ($type == 'mssql') {
$testfunction = 'mssql_connect'; $testclass = '';
}
if ($type == 'sqlite') {
$testfunction = ''; $testclass = 'PDO';
}
if ($type == 'sqlite3') {
$testfunction = ''; $testclass = 'SQLite3';
}
$option .= '<option value="'.$type.'"'.($defaultype == $type ? ' selected' : ''); $option .= '<option value="'.$type.'"'.($defaultype == $type ? ' selected' : '');
if ($testfunction && !function_exists($testfunction)) $option .= ' disabled'; if ($testfunction && !function_exists($testfunction)) {
if ($testclass && !class_exists($testclass)) $option .= ' disabled'; $option .= ' disabled';
}
if ($testclass && !class_exists($testclass)) {
$option .= ' disabled';
}
$option .= '>'; $option .= '>';
$option .= $type.'&nbsp; &nbsp;'; $option .= $type.'&nbsp; &nbsp;';
if ($note) $option .= ' '.$note; if ($note) {
$option .= ' '.$note;
}
// Deprecated and experimental // Deprecated and experimental
if ($type == 'mysql') $option .= ' '.$langs->trans("Deprecated"); if ($type == 'mysql') {
elseif ($type == 'mssql') $option .= ' '.$langs->trans("VersionExperimental"); $option .= ' '.$langs->trans("Deprecated");
elseif ($type == 'sqlite') $option .= ' '.$langs->trans("VersionExperimental"); } elseif ($type == 'mssql') {
elseif ($type == 'sqlite3') $option .= ' '.$langs->trans("VersionExperimental"); $option .= ' '.$langs->trans("VersionExperimental");
} elseif ($type == 'sqlite') {
$option .= ' '.$langs->trans("VersionExperimental");
} elseif ($type == 'sqlite3') {
$option .= ' '.$langs->trans("VersionExperimental");
} elseif (!function_exists($testfunction)) {
// No available // No available
elseif (!function_exists($testfunction)) $option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP"); $option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP");
}
$option .= '</option>'; $option .= '</option>';
} }
} }
@ -321,7 +379,9 @@ if (!empty($force_install_noedit)) {
?> ?>
<select id="db_type" <select id="db_type"
name="db_type" name="db_type"
<?php if ($force_install_noedit == 2 && $force_install_type !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_type !== null) {
print ' disabled';
} ?>
> >
<?php print $option; ?> <?php print $option; ?>
</select> </select>
@ -338,7 +398,9 @@ if (!empty($force_install_noedit)) {
id="db_host" id="db_host"
name="db_host" name="db_host"
value="<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>" value="<?php print (!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
<?php if ($force_install_noedit == 2 && $force_install_dbserver !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_dbserver !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?> <td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
@ -353,7 +415,9 @@ if (!empty($force_install_noedit)) {
name="db_port" name="db_port"
id="db_port" id="db_port"
value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>" value="<?php print (!empty($force_install_port)) ? $force_install_port : $dolibarr_main_db_port; ?>"
<?php if ($force_install_noedit == 2 && $force_install_port !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_port !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?> <td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
@ -368,7 +432,9 @@ if (!empty($force_install_noedit)) {
id="db_prefix" id="db_prefix"
name="db_prefix" name="db_prefix"
value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>" value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
<?php if ($force_install_noedit == 2 && $force_install_prefix !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_prefix !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("DatabasePrefixDescription"); ?></td> <td class="comment"><?php echo $langs->trans("DatabasePrefixDescription"); ?></td>
@ -380,8 +446,12 @@ if (!empty($force_install_noedit)) {
<input type="checkbox" <input type="checkbox"
id="db_create_database" id="db_create_database"
name="db_create_database" name="db_create_database"
<?php if ($force_install_createdatabase) { print ' checked'; } ?> <?php if ($force_install_createdatabase) {
<?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) { print ' disabled'; } ?> print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?> <td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?>
@ -395,7 +465,9 @@ if (!empty($force_install_noedit)) {
id="db_user" id="db_user"
name="db_user" name="db_user"
value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>" value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
<?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_databaselogin !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td> <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
@ -415,7 +487,9 @@ if (!empty($force_install_noedit)) {
} }
print dol_escape_htmltag($autofill); print dol_escape_htmltag($autofill);
?>" ?>"
<?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) { print ' disabled'; } ?> <?php if ($force_install_noedit == 2 && $force_install_databasepass !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td> <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
@ -427,8 +501,12 @@ if (!empty($force_install_noedit)) {
<input type="checkbox" <input type="checkbox"
id="db_create_user" id="db_create_user"
name="db_create_user" name="db_create_user"
<?php if (!empty($force_install_createuser)) { print ' checked'; } ?> <?php if (!empty($force_install_createuser)) {
<?php if ($force_install_noedit == 2 && $force_install_createuser !== null) { print ' disabled'; } ?> print ' checked';
} ?>
<?php if ($force_install_noedit == 2 && $force_install_createuser !== null) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?> <td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
@ -455,7 +533,9 @@ if (!empty($force_install_noedit)) {
name="db_user_root" name="db_user_root"
class="needroot" class="needroot"
value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>" value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>"
<?php if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) { print ' disabled'; } ?> <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
print ' disabled';
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?> <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
@ -484,14 +564,18 @@ if (!empty($force_install_noedit)) {
$autofill = ''; $autofill = '';
} }
// Do not autofill password if instance is a production instance // Do not autofill password if instance is a production instance
if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"], if (!empty($_SERVER["SERVER_NAME"]) && !in_array(
array('127.0.0.1', 'localhost', 'localhostgit')) $_SERVER["SERVER_NAME"],
array('127.0.0.1', 'localhost', 'localhostgit')
)
) { ) {
$autofill = ''; $autofill = '';
} // Do not autofill password for remote access } // Do not autofill password for remote access
print dol_escape_htmltag($autofill); print dol_escape_htmltag($autofill);
?>" ?>"
<?php if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) { print ' disabled'; /* May be removed by javascript*/ } ?> <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
print ' disabled'; /* May be removed by javascript*/
} ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?> <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>