30define(
'DONOTLOADCONF', 1);
36$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') : (empty($argv[1]) ?
'' : $argv[1]);
37$setuplang =
GETPOST(
'selectlang',
'aZ09', 3) ?
GETPOST(
'selectlang',
'aZ09', 3) : (empty($argv[2]) ?
'auto' : $argv[2]);
38$langs->setDefaultLang($setuplang);
40$langs->loadLangs(array(
"admin",
"install",
"errors"));
43$main_dir =
GETPOST(
'main_dir') ?
GETPOST(
'main_dir') : (empty($argv[3]) ?
'' : $argv[3]);
45$main_data_dir =
GETPOST(
'main_data_dir') ?
GETPOST(
'main_data_dir') : (empty($argv[4]) ? ($main_dir.
'/documents') : $argv[4]);
47$main_url =
GETPOST(
'main_url') ?
GETPOST(
'main_url') : (empty($argv[5]) ?
'' : $argv[5]);
49$userroot =
GETPOST(
'db_user_root',
'alpha') ?
GETPOST(
'db_user_root',
'alpha') : (empty($argv[6]) ?
'' : $argv[6]);
50$passroot =
GETPOST(
'db_pass_root',
'none') ?
GETPOST(
'db_pass_root',
'none') : (empty($argv[7]) ?
'' : $argv[7]);
52$db_type =
GETPOST(
'db_type',
'aZ09') ?
GETPOST(
'db_type',
'aZ09') : (empty($argv[8]) ?
'' : $argv[8]);
53$db_host =
GETPOST(
'db_host',
'alpha') ?
GETPOST(
'db_host',
'alpha') : (empty($argv[9]) ?
'' : $argv[9]);
54$db_name =
GETPOST(
'db_name',
'aZ09') ?
GETPOST(
'db_name',
'aZ09') : (empty($argv[10]) ?
'' : $argv[10]);
55$db_user =
GETPOST(
'db_user',
'alpha') ?
GETPOST(
'db_user',
'alpha') : (empty($argv[11]) ?
'' : $argv[11]);
56$db_pass =
GETPOST(
'db_pass',
'none') ?
GETPOST(
'db_pass',
'none') : (empty($argv[12]) ?
'' : $argv[12]);
58$db_prefix =
GETPOST(
'db_prefix',
'aZ09') ?
GETPOST(
'db_prefix',
'aZ09') : (empty($argv[14]) ?
'' : $argv[14]);
59$db_create_database =
GETPOST(
'db_create_database',
'alpha') ?
GETPOST(
'db_create_database',
'alpha') : (empty($argv[15]) ?
'' : $argv[15]);
60$db_create_user =
GETPOST(
'db_create_user',
'alpha') ?
GETPOST(
'db_create_user',
'alpha') : (empty($argv[16]) ?
'' : $argv[16]);
62$main_force_https = ((
GETPOST(
"main_force_https",
'alpha') && (
GETPOST(
"main_force_https",
'alpha') ==
"on" ||
GETPOST(
"main_force_https",
'alpha') == 1)) ?
'1' :
'0');
64$main_use_alt_dir = ((
GETPOST(
"main_use_alt_dir",
'alpha') ==
'' || (
GETPOST(
"main_use_alt_dir",
'alpha') ==
"on" ||
GETPOST(
"main_use_alt_dir",
'alpha') == 1)) ?
'' :
'//');
66$main_alt_dir_name = ((
GETPOST(
"main_alt_dir_name",
'alpha') &&
GETPOST(
"main_alt_dir_name",
'alpha') !=
'') ?
GETPOST(
"main_alt_dir_name",
'alpha') :
'custom');
68$dolibarr_main_distrib =
'standard';
73$_SESSION[
'dol_save_pass'] = $db_pass;
77$useforcedwizard =
false;
78$forcedfile =
"./install.forced.php";
79if ($conffile ==
"/etc/dolibarr/conf.php") {
80 $forcedfile =
"/etc/dolibarr/install.forced.php";
82if (@file_exists($forcedfile)) {
83 $useforcedwizard =
true;
84 include_once $forcedfile;
86 if ($force_install_noedit) {
88 if (!empty($argv[3])) {
91 if (!empty($force_install_main_data_root)) {
92 $main_data_dir = $force_install_main_data_root;
96 if (!empty($argv[4])) {
97 $main_data_dir = $argv[4];
100 if (!empty($argv[5])) {
101 $main_url = $argv[5];
104 if (!empty($force_install_databaserootlogin)) {
107 if (!empty($argv[6])) {
108 $userroot = $argv[6];
110 if (!empty($force_install_databaserootpass)) {
113 if (!empty($argv[7])) {
114 $passroot = $argv[7];
117 if ($force_install_noedit == 2) {
118 if (!empty($force_install_type)) {
119 $db_type = $force_install_type;
121 if (!empty($force_install_dbserver)) {
122 $db_host = $force_install_dbserver;
124 if (!empty($force_install_database)) {
125 $db_name = $force_install_database;
127 if (!empty($force_install_databaselogin)) {
128 $db_user = $force_install_databaselogin;
130 if (!empty($force_install_databasepass)) {
131 $db_pass = $force_install_databasepass;
133 if (!empty($force_install_port)) {
134 $db_port = $force_install_port;
136 if (!empty($force_install_prefix)) {
137 $db_prefix = $force_install_prefix;
139 if (!empty($force_install_createdatabase)) {
140 $db_create_database = $force_install_createdatabase;
142 if (!empty($force_install_createuser)) {
143 $db_create_user = $force_install_createuser;
145 if (!empty($force_install_mainforcehttps)) {
146 $main_force_https = $force_install_mainforcehttps;
150 if (!empty($force_install_distrib)) {
151 $dolibarr_main_distrib = $force_install_distrib;
165pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step2");
168if (!is_writable($conffile)) {
169 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
170 pFooter(1, $setuplang,
'jscheckparam');
177if (empty($db_type)) {
178 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseType")).
'</div>';
181 $is_sqlite = ($db_type ===
'sqlite' || $db_type ===
'sqlite3');
183if (empty($db_host) && !$is_sqlite) {
184 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Server")).
'</div>';
187if (empty($db_name)) {
188 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseName")).
'</div>';
191if (empty($db_user) && !$is_sqlite) {
192 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Login")).
'</div>';
195if (!empty($db_port) && !is_numeric($db_port)) {
196 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_port, $langs->transnoentities(
"Port")).
'</div>';
199if (!empty($db_prefix) && !preg_match(
'/^[a-z0-9]+_$/i', $db_prefix)) {
200 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_prefix, $langs->transnoentities(
"DatabasePrefix")).
'</div>';
207if (!filter_var($main_url, FILTER_VALIDATE_URL)) {
208 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_url, $langs->transnoentitiesnoconv(
"URLRoot")).
'</div>';
210 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
215if (substr($main_dir,
dol_strlen($main_dir) - 1) ==
"/") {
216 $main_dir = substr($main_dir, 0,
dol_strlen($main_dir) - 1);
220if (!empty($main_url) && substr($main_url,
dol_strlen($main_url) - 1) ==
"/") {
221 $main_url = substr($main_url, 0,
dol_strlen($main_url) - 1);
225 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'</div>';
228 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
234 $result = @include_once $main_dir.
"/core/db/".$db_type.
'.class.php';
237 if (!empty($db_create_database) && !$userroot) {
238 print
'<div class="error">'.$langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).
'</div>';
240 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
241 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
244 if (!empty($db_create_user) && !$userroot) {
245 print
'<div class="error">'.$langs->trans(
"YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).
'</div>';
247 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
248 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
253 if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
254 $databasefortest = $db_name;
255 if (!empty($db_create_database)) {
256 if ($db_type ==
'mysql' || $db_type ==
'mysqli') {
257 $databasefortest =
'mysql';
258 } elseif ($db_type ==
'pgsql') {
259 $databasefortest =
'postgres';
261 $databasefortest =
'master';
265 $db =
getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, (
int) $db_port);
267 dol_syslog(
"databasefortest=".$databasefortest.
" connected=".json_encode($db->connected).
" database_selected=".json_encode($db->database_selected), LOG_DEBUG);
269 if (empty($db_create_database) && $db->connected && !$db->database_selected) {
270 print
'<div class="error">'.$langs->trans(
"ErrorConnectedButDatabaseNotFound", $db_name).
'</div>';
272 if (!$db->connected) {
273 print $langs->trans(
"IfDatabaseNotExistsGoBackAndUncheckCreate").
'<br><br>';
275 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
277 } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
279 if ($db->error ==
"No such file or directory") {
280 print
'<div class="error">'.$langs->trans(
"ErrorToConnectToMysqlCheckInstance").
'</div>';
282 print
'<div class="error">'.$db->error.
'</div>';
284 if (!$db->connected) {
285 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
288 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
295 if (!$error && (empty($db_create_database) && empty($db_create_user))) {
296 $db =
getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, (
int) $db_port);
299 print
'<div class="error">'.$db->error.
'</div>';
300 if (!$db->connected) {
301 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
304 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
310 print
"<br>\nFailed to include_once(\"".$main_dir.
"/core/db/".$db_type.
".class.php\")<br>\n";
311 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentities(
"WebPagesDirectory")).
'</div>';
313 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
319 print $db->lasterror();
321 if (isset($db) && !$db->connected) {
322 print
'<br>'.$langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
324 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
328if (!$error && $db->connected) {
329 if (!empty($db_create_database)) {
330 $result = $db->select_db($db_name);
332 print
'<div class="error">'.$langs->trans(
"ErrorDatabaseAlreadyExists", $db_name).
'</div>';
333 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate").
'<br><br>';
334 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
341if (!$error && $db->connected) {
342 if (!empty($db_create_database)) {
345 $defaultCharacterSet = $db->forcecharset;
346 $defaultDBSortingCollation = $db->forcecollate;
348 $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
349 $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
353 if ($defaultCharacterSet ==
'utf8mb3' || $defaultDBSortingCollation ==
'utf8mb3_unicode_ci') {
354 $defaultCharacterSet =
'utf8';
355 $defaultDBSortingCollation =
'utf8_unicode_ci';
359 if ($defaultCharacterSet ==
'utf8mb4' || $defaultDBSortingCollation ==
'utf8mb4_unicode_ci') {
360 $defaultCharacterSet =
'utf8';
361 $defaultDBSortingCollation =
'utf8_unicode_ci';
364 print
'<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.
'">';
365 print
'<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.
'">';
366 $db_character_set = $defaultCharacterSet;
367 $db_collation = $defaultDBSortingCollation;
373if (!$error && $db->connected && $action ==
"set") {
375 if (is_array($_POST)) {
376 foreach ($_POST as $key => $value) {
377 if (!preg_match(
'/^db_pass/i', $key)) {
384 print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans(
"ConfigurationFile").
'</h3>';
385 print
'<table cellspacing="0" width="100%" cellpadding="1" border="0">';
389 if (!is_dir($main_dir)) {
393 print $langs->trans(
"ErrorDirDoesNotExists", $main_dir).
'<br>';
394 print $langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'<br>';
395 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
397 print $langs->trans(
"Error");
411 if (!is_dir($main_data_dir)) {
415 if (!is_dir($main_data_dir)) {
416 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
417 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
419 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
421 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
425 $pathhtaccess = $main_data_dir.
'/.htaccess';
426 if (!file_exists($pathhtaccess)) {
428 $handlehtaccess = @fopen($pathhtaccess,
'w');
429 if ($handlehtaccess) {
430 fwrite($handlehtaccess,
'Order allow,deny'.
"\n");
431 fwrite($handlehtaccess,
'Deny from all'.
"\n");
433 fclose($handlehtaccess);
440 $dir[] = $main_data_dir.
"/mycompany";
441 $dir[] = $main_data_dir.
"/medias";
442 $dir[] = $main_data_dir.
"/users";
443 $dir[] = $main_data_dir.
"/facture";
444 $dir[] = $main_data_dir.
"/propale";
445 $dir[] = $main_data_dir.
"/ficheinter";
446 $dir[] = $main_data_dir.
"/produit";
447 $dir[] = $main_data_dir.
"/doctemplates";
451 for ($i = 0; $i < $num; $i++) {
452 if (is_dir($dir[$i])) {
457 print
"Failed to create directory: ".$dir[$i];
459 print $langs->trans(
"Error");
468 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
471 $srcroot = $main_dir.
'/install/medias';
472 $destroot = $main_data_dir.
'/medias';
476 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
477 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
479 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
481 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
484 $srcroot = $main_dir.
'/install/doctemplates';
485 $destroot = $main_data_dir.
'/doctemplates';
487 'contracts' =>
'contract',
488 'invoices' =>
'invoice',
490 'products' =>
'product',
491 'projects' =>
'project',
492 'proposals' =>
'proposal',
493 'shipments' =>
'shipment',
494 'supplier_proposals' =>
'supplier_proposal',
495 'tasks' =>
'task_summary',
496 'thirdparties' =>
'thirdparty',
497 'usergroups' =>
'usergroups',
500 foreach ($docs as $cursordir => $cursorfile) {
501 $src = $srcroot.
'/'.$cursordir.
'/template_'.$cursorfile.
'.odt';
502 $dirodt = $destroot.
'/'.$cursordir;
503 $dest = $dirodt.
'/template_'.$cursorfile.
'.odt';
506 $result =
dol_copy($src, $dest, 0, 0);
508 print
'<tr><td colspan="2"><br>'.$langs->trans(
'ErrorFailToCopyFile', $src, $dest).
'</td></tr>';
516 $main_db_prefix = (!empty($db_prefix) ? $db_prefix :
'llx_');
521 if (file_exists(
"$conffile")) {
525 @
dol_copy($conffile, $conffile.
'.old',
'0400');
534 conf($dolibarr_main_document_root);
537 print $langs->trans(
"ConfFileReload");
539 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
542 if (isset($db_create_user) && ($db_create_user ==
"1" || $db_create_user ==
"on")) {
546 $databasefortest = $conf->db->name;
547 if ($conf->db->type ==
'mysql' || $conf->db->type ==
'mysqli') {
548 $databasefortest =
'mysql';
549 } elseif ($conf->db->type ==
'pgsql') {
550 $databasefortest =
'postgres';
551 } elseif ($conf->db->type ==
'mssql') {
552 $databasefortest =
'master';
557 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, (
int) $conf->db->port);
560 print
'<div class="error">'.$db->error.
'</div>';
565 if ($db->connected) {
568 if (empty($dolibarr_main_db_pass)) {
571 print $langs->trans(
"UserCreation").
' : ';
572 print $dolibarr_main_db_user;
574 print
'<td>'.$langs->trans(
"Error").
": A password for database user is mandatory.</td></tr>";
577 $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
580 if ($databasefortest ==
'mysql') {
581 if (!in_array($dolibarr_main_db_host, array(
'127.0.0.1',
'::1',
'localhost',
'localhost.local'))) {
582 $resultbis = $db->DDLCreateUser(
'%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
586 if ($result > 0 && $resultbis > 0) {
588 print $langs->trans(
"UserCreation").
' : ';
589 print $dolibarr_main_db_user;
591 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
593 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS'
594 || $db->errno() ==
'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
595 || $db->errno() ==
'DB_ERROR_USER_ALREADY_EXISTS') {
598 print $langs->trans(
"UserCreation").
' : ';
599 print $dolibarr_main_db_user;
601 print
'<td>'.$langs->trans(
"LoginAlreadyExists").
'</td></tr>';
605 print $langs->trans(
"UserCreation").
' : ';
606 print $dolibarr_main_db_user;
608 print
'<td>'.$langs->trans(
"Error").
': '.$db->errno().
' '.$db->error().($db->error ?
'. '.$db->error :
'').
"</td></tr>";
616 print $langs->trans(
"UserCreation").
' : ';
617 print $dolibarr_main_db_user;
619 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
623 print
'<tr><td colspan="2"><br>';
624 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
626 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
627 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
637 if (!$error && (isset($db_create_database) && ($db_create_database ==
"1" || $db_create_database ==
"on"))) {
638 dolibarr_install_syslog(
"step1: create database: ".$dolibarr_main_db_name.
" ".$dolibarr_main_db_character_set.
" ".$dolibarr_main_db_collation.
" ".$dolibarr_main_db_user);
639 $newdb =
getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot,
'', (
int) $conf->db->port);
642 if ($newdb->connected) {
643 $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
647 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
648 print $dolibarr_main_db_name;
650 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
652 $newdb->select_db($dolibarr_main_db_name);
653 $check1 = $newdb->getDefaultCharacterSetDatabase();
654 $check2 = $newdb->getDefaultCollationDatabase();
662 print
'<tr><td colspan="2"><br>';
663 print $langs->trans(
"ErrorFailedToCreateDatabase", $dolibarr_main_db_name).
'<br>';
664 print $newdb->lasterror().
'<br>';
665 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate");
669 dolibarr_install_syslog(
'step1: failed to create database '.$dolibarr_main_db_name.
' '.$newdb->lasterrno().
' '.$newdb->lasterror(), LOG_ERR);
675 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
676 print $dolibarr_main_db_name;
678 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
682 print
'<tr><td colspan="2"><br>';
683 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
685 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
686 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
696 dolibarr_install_syslog(
"step1: connection type=".$conf->db->type.
" on host=".$conf->db->host.
" port=".$conf->db->port.
" user=".$conf->db->user.
" name=".$conf->db->name);
699 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
701 if ($db->connected) {
704 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
705 print $dolibarr_main_db_host;
707 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
711 if ($db->database_selected) {
714 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
715 print $dolibarr_main_db_name;
717 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
722 dolibarr_install_syslog(
"step1: connection to database ".$conf->db->name.
" by user ".$conf->db->user.
" failed", LOG_ERR);
724 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
725 print $dolibarr_main_db_name;
727 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
731 print
'<tr><td colspan="2"><br>';
732 print $langs->trans(
'CheckThatDatabasenameIsCorrect', $dolibarr_main_db_name).
'<br>';
733 print $langs->trans(
'IfAlreadyExistsCheckOption').
'<br>';
734 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
742 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
743 print $dolibarr_main_db_host;
745 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
749 print
'<tr><td colspan="2"><br>';
750 print $langs->trans(
"ErrorConnection", $conf->db->host, $conf->db->name, $conf->db->user);
751 print $langs->trans(
'IfLoginDoesNotExistsCheckCreateUser').
'<br>';
752 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
765<script
type=
"text/javascript">
772 document.getElementById(
'nextbutton').style.visibility=
"hidden";
773 document.getElementById(
'pleasewait').style.visibility=
"visible";
782if ($error && isset($argv[1])) {
789pFooter($error ? 1 : 0, $setuplang,
'jsinfo', 1);
806 $fp = @fopen(
"$mainfile",
"w");
809 fwrite($fp,
'<?php'.
"\n");
810 fwrite($fp,
"// Wrapper to include main into htdocs\n");
811 fwrite($fp,
"include_once '".$main_dir.
"/main.inc.php';\n");
826 $fp = @fopen(
"$masterfile",
"w");
829 fwrite($fp,
'<?php'.
"\n");
830 fwrite($fp,
"// Wrapper to include master into htdocs\n");
831 fwrite($fp,
"include_once '".$main_dir.
"/master.inc.php';\n");
845 global $conf, $langs;
846 global $main_url, $main_dir, $main_data_dir, $main_force_https, $main_use_alt_dir, $main_alt_dir_name, $main_db_prefix;
847 global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host;
848 global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass;
849 global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication;
850 global $dolibarr_main_distrib;
851 global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation;
852 global $conffile, $conffiletoshow, $conffiletoshowshort;
853 global $force_dolibarr_lib_NUSOAP_PATH;
854 global $force_dolibarr_lib_FPDF_PATH, $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
855 global $force_dolibarr_lib_GEOIP_PATH;
856 global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
857 global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI;
858 global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
862 $key = md5(uniqid((
string) mt_rand(),
true));
864 $fp = fopen(
"$conffile",
"w");
868 fwrite($fp,
'<?php'.
"\n");
869 fwrite($fp,
'//'.
"\n");
870 fwrite($fp,
'// File generated by Dolibarr installer '.DOL_VERSION.
' on '.
dol_print_date(
dol_now(),
'').
"\n");
871 fwrite($fp,
'//'.
"\n");
872 fwrite($fp,
'// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.
' file'.
"\n");
873 fwrite($fp,
'// and explanations for all possibles parameters.'.
"\n");
874 fwrite($fp,
'//'.
"\n");
876 fwrite($fp,
'$dolibarr_main_url_root=\''.
dol_escape_php(trim($main_url), 1).
'\';
');
879 fwrite($fp, '$dolibarr_main_document_root=
"'.dol_escape_php(dol_sanitizePathName(trim($main_dir))).'";
');
882 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\
''.dol_escape_php(trim(
"/".$main_alt_dir_name), 1).
'\';
');
885 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=
"'.dol_escape_php(dol_sanitizePathName(trim($main_dir."/
".$main_alt_dir_name))).'";
');
888 fwrite($fp, '$dolibarr_main_data_root=
"'.dol_escape_php(dol_sanitizePathName(trim($main_data_dir))).'";
');
891 fwrite($fp, '$dolibarr_main_db_host=\
''.dol_escape_php(trim($db_host), 1).
'\';
');
894 fwrite($fp, '$dolibarr_main_db_port=\
''.((int) $db_port).
'\';
');
897 fwrite($fp, '$dolibarr_main_db_name=\
''.dol_escape_php(trim($db_name), 1).
'\';
');
900 fwrite($fp, '$dolibarr_main_db_prefix=\
''.dol_escape_php(trim($main_db_prefix), 1).
'\';
');
903 fwrite($fp, '$dolibarr_main_db_user=\
''.dol_escape_php(trim($db_user), 1).
'\';
');
905 fwrite($fp, '$dolibarr_main_db_pass=\
''.dol_escape_php(trim($db_pass), 1).
'\';
');
908 fwrite($fp, '$dolibarr_main_db_type=\
''.dol_escape_php(trim($db_type), 1).
'\';
');
911 fwrite($fp, '$dolibarr_main_db_character_set=\
''.dol_escape_php(trim($db_character_set), 1).
'\';
');
914 fwrite($fp, '$dolibarr_main_db_collation=\
''.dol_escape_php(trim($db_collation), 1).
'\';
');
921 fwrite($fp,
'$dolibarr_main_authentication=\'dolibarr\';');
924 fwrite($fp,
'//$dolibarr_main_demo=\'autologin,autopass\';');
927 fwrite($fp,
'// Security settings');
930 fwrite($fp,
'$dolibarr_main_prod=\'0\';');
933 fwrite($fp,
'$dolibarr_main_force_https=\''.
dol_escape_php($main_force_https, 1).
'\';
');
936 fwrite($fp, '$dolibarr_main_restrict_os_commands=\
'mariadb-dump, mariadb, mysqldump, mysql, pg_dump, pg_restore, clamdscan, clamdscan.exe\';');
939 fwrite($fp,
'$dolibarr_nocsrfcheck=\'0\';');
942 fwrite($fp,
'$dolibarr_main_instance_unique_id=\''.
dol_escape_php($key, 1).
'\';
');
945 fwrite($fp, '$dolibarr_mailing_limit_sendbyweb=\
'0\';');
947 fwrite($fp,
'$dolibarr_mailing_limit_sendbycli=\'0\';');
952 if (empty($force_dolibarr_lib_FPDF_PATH)) {
954 $force_dolibarr_lib_FPDF_PATH =
'';
958 if (empty($force_dolibarr_lib_TCPDF_PATH)) {
960 $force_dolibarr_lib_TCPDF_PATH =
'';
964 if (empty($force_dolibarr_lib_FPDI_PATH)) {
966 $force_dolibarr_lib_FPDI_PATH =
'';
970 if (empty($force_dolibarr_lib_TCPDI_PATH)) {
972 $force_dolibarr_lib_TCPDI_PATH =
'';
976 if (empty($force_dolibarr_lib_GEOIP_PATH)) {
978 $force_dolibarr_lib_GEOIP_PATH =
'';
982 if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
984 $force_dolibarr_lib_NUSOAP_PATH =
'';
988 if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
990 $force_dolibarr_lib_ODTPHP_PATH =
'';
994 if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
996 $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP =
'';
1000 if (empty($force_dolibarr_js_CKEDITOR)) {
1002 $force_dolibarr_js_CKEDITOR =
'';
1004 fwrite($fp,
'$dolibarr_js_CKEDITOR=\''.
dol_escape_php($force_dolibarr_js_CKEDITOR, 1).
'\';
');
1006 if (empty($force_dolibarr_js_JQUERY)) {
1008 $force_dolibarr_js_JQUERY =
'';
1010 fwrite($fp,
'$dolibarr_js_JQUERY=\''.
dol_escape_php($force_dolibarr_js_JQUERY, 1).
'\';
');
1012 if (empty($force_dolibarr_js_JQUERY_UI)) {
1014 $force_dolibarr_js_JQUERY_UI =
'';
1016 fwrite($fp,
'$dolibarr_js_JQUERY_UI=\''.
dol_escape_php($force_dolibarr_js_JQUERY_UI, 1).
'\';
');
1019 // Write params to overwrites default font path
1021 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
1023 $force_dolibarr_font_DOL_DEFAULT_TTF =
'';
1025 fwrite($fp,
'$dolibarr_font_DOL_DEFAULT_TTF=\''.
dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF, 1).
'\';
');
1027 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
1029 $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD =
'';
1031 fwrite($fp,
'$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.
dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD, 1).
'\';
');
1035 fwrite($fp, '$dolibarr_main_distrib=\
''.dol_escape_php(trim($dolibarr_main_distrib), 1).
'\';
');
1040 if (file_exists("$conffile")) {
1041 include $conffile; // force config reload, do not put include_once
1042 conf($dolibarr_main_document_root);
1045 print $langs->trans("SaveConfigurationFile");
1046 print ' <strong>
'.$conffile.'</strong>
';
1048 print '<img src=
"../theme/eldy/img/tick.png" alt=
"Ok">
';
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null, $excludearchivefiles=0)
Copy a dir to another dir.
dol_is_dir($folder)
Test if filename is a directory.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
dol_escape_php($stringtoescape, $stringforquotes=2)
Returns text escaped for inclusion into a php string, build with double quotes " or '.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
conf($dolibarr_main_document_root)
Load conf file (file must exists)
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
if( $ret) write_main_file($mainfile, $main_dir)
Create main file.
write_conf_file($conffile)
Save configuration file.
write_master_file($masterfile, $main_dir)
Create master file.