31define(
'DONOTLOADCONF', 1);
37$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') : (empty($argv[1]) ?
'' : $argv[1]);
38$setuplang =
GETPOST(
'selectlang',
'aZ09', 3) ?
GETPOST(
'selectlang',
'aZ09', 3) : (empty($argv[2]) ?
'auto' : $argv[2]);
39$langs->setDefaultLang($setuplang);
41$langs->loadLangs(array(
"admin",
"install",
"errors"));
44$main_dir =
GETPOST(
'main_dir') ?
GETPOST(
'main_dir') : (empty($argv[3]) ?
'' : $argv[3]);
46$main_data_dir =
GETPOST(
'main_data_dir') ?
GETPOST(
'main_data_dir') : (empty($argv[4]) ? ($main_dir.
'/documents') : $argv[4]);
48$main_url =
GETPOST(
'main_url') ?
GETPOST(
'main_url') : (empty($argv[5]) ?
'' : $argv[5]);
50$userroot =
GETPOST(
'db_user_root',
'alpha') ?
GETPOST(
'db_user_root',
'alpha') : (empty($argv[6]) ?
'' : $argv[6]);
51$passroot =
GETPOST(
'db_pass_root',
'password') ?
GETPOST(
'db_pass_root',
'password') : (empty($argv[7]) ?
'' : $argv[7]);
53$db_type =
GETPOST(
'db_type',
'aZ09') ?
GETPOST(
'db_type',
'aZ09') : (empty($argv[8]) ?
'' : $argv[8]);
54$db_host =
GETPOST(
'db_host',
'alpha') ?
GETPOST(
'db_host',
'alpha') : (empty($argv[9]) ?
'' : $argv[9]);
55$db_name =
GETPOST(
'db_name',
'aZ09') ?
GETPOST(
'db_name',
'aZ09') : (empty($argv[10]) ?
'' : $argv[10]);
56$db_user =
GETPOST(
'db_user',
'alpha') ?
GETPOST(
'db_user',
'alpha') : (empty($argv[11]) ?
'' : $argv[11]);
57$db_pass =
GETPOST(
'db_pass',
'password') ?
GETPOST(
'db_pass',
'password') : (empty($argv[12]) ?
'' : $argv[12]);
59$db_prefix =
GETPOST(
'db_prefix',
'aZ09') ?
GETPOST(
'db_prefix',
'aZ09') : (empty($argv[14]) ?
'' : $argv[14]);
60$db_create_database =
GETPOST(
'db_create_database',
'alpha') ?
GETPOST(
'db_create_database',
'alpha') : (empty($argv[15]) ?
'' : $argv[15]);
61$db_create_user =
GETPOST(
'db_create_user',
'alpha') ?
GETPOST(
'db_create_user',
'alpha') : (empty($argv[16]) ?
'' : $argv[16]);
63$main_force_https = ((
GETPOST(
"main_force_https",
'alpha') && (
GETPOST(
"main_force_https",
'alpha') ==
"on" ||
GETPOST(
"main_force_https",
'alpha') == 1)) ?
'1' :
'0');
65$main_use_alt_dir = ((
GETPOST(
"main_use_alt_dir",
'alpha') ==
'' || (
GETPOST(
"main_use_alt_dir",
'alpha') ==
"on" ||
GETPOST(
"main_use_alt_dir",
'alpha') == 1)) ?
'' :
'//');
67$main_alt_dir_name = ((
GETPOST(
"main_alt_dir_name",
'alpha') &&
GETPOST(
"main_alt_dir_name",
'alpha') !=
'') ?
GETPOST(
"main_alt_dir_name",
'alpha') :
'custom');
69$dolibarr_main_distrib =
'standard';
74$_SESSION[
'dol_save_pass'] = $db_pass;
78$useforcedwizard =
false;
79$forcedfile =
"./install.forced.php";
80if ($conffile ==
"/etc/dolibarr/conf.php") {
81 $forcedfile =
"/etc/dolibarr/install.forced.php";
83if (@file_exists($forcedfile)) {
84 $useforcedwizard =
true;
85 include_once $forcedfile;
87 if ($force_install_noedit) {
89 if (!empty($argv[3])) {
92 if (!empty($force_install_main_data_root)) {
93 $main_data_dir = $force_install_main_data_root;
97 if (!empty($argv[4])) {
98 $main_data_dir = $argv[4];
101 if ($force_install_noedit != 3)
103 if (!empty($argv[5])) {
104 $main_url = $argv[5];
107 if (!empty($force_install_databaserootlogin)) {
110 if (!empty($argv[6])) {
111 $userroot = $argv[6];
113 if (!empty($force_install_databaserootpass)) {
116 if (!empty($argv[7])) {
117 $passroot = $argv[7];
120 if (($force_install_noedit == 2) || ($force_install_noedit == 3)) {
121 if (!empty($force_install_type)) {
122 $db_type = $force_install_type;
124 if (!empty($force_install_dbserver)) {
125 $db_host = $force_install_dbserver;
127 if (!empty($force_install_database)) {
128 $db_name = $force_install_database;
130 if (!empty($force_install_databaselogin)) {
131 $db_user = $force_install_databaselogin;
133 if (!empty($force_install_databasepass)) {
134 $db_pass = $force_install_databasepass;
136 if (!empty($force_install_port)) {
137 $db_port = $force_install_port;
139 if (!empty($force_install_prefix)) {
140 $db_prefix = $force_install_prefix;
142 if (!empty($force_install_createdatabase)) {
143 $db_create_database = $force_install_createdatabase;
145 if (!empty($force_install_createuser)) {
146 $db_create_user = $force_install_createuser;
148 if (!empty($force_install_mainforcehttps)) {
149 $main_force_https = $force_install_mainforcehttps;
153 if (!empty($force_install_distrib)) {
154 $dolibarr_main_distrib = $force_install_distrib;
175pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step2");
178if (!is_writable($conffile)) {
179 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
180 pFooter(1, $setuplang,
'jscheckparam');
187if (empty($db_type)) {
188 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseType")).
'</div>';
191 $is_sqlite = ($db_type ===
'sqlite' || $db_type ===
'sqlite3');
193if (empty($db_host) && !$is_sqlite) {
194 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Server")).
'</div>';
197if (empty($db_name)) {
198 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseName")).
'</div>';
201if (empty($db_user) && !$is_sqlite) {
202 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Login")).
'</div>';
205if (!empty($db_port) && !is_numeric($db_port)) {
206 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_port, $langs->transnoentities(
"Port")).
'</div>';
209if (!empty($db_prefix) && !preg_match(
'/^[a-z0-9]+_$/i', $db_prefix)) {
210 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_prefix, $langs->transnoentities(
"DatabasePrefix")).
'</div>';
217if (!filter_var($main_url, FILTER_VALIDATE_URL)) {
218 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_url, $langs->transnoentitiesnoconv(
"URLRoot")).
'</div>';
220 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
225if (substr($main_dir,
dol_strlen($main_dir) - 1) ==
"/") {
226 $main_dir = substr($main_dir, 0,
dol_strlen($main_dir) - 1);
230if (!empty($main_url) && substr($main_url,
dol_strlen($main_url) - 1) ==
"/") {
231 $main_url = substr($main_url, 0,
dol_strlen($main_url) - 1);
235 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'</div>';
238 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
244 $result = @include_once $main_dir.
"/core/db/".$db_type.
'.class.php';
247 if (!empty($db_create_database) && !$userroot) {
248 print
'<div class="error">'.$langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).
'</div>';
250 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
251 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
254 if (!empty($db_create_user) && !$userroot) {
255 print
'<div class="error">'.$langs->trans(
"YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).
'</div>';
257 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
258 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
263 if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
264 $databasefortest = $db_name;
265 if (!empty($db_create_database)) {
266 if ($db_type ==
'mysql' || $db_type ==
'mysqli') {
267 $databasefortest =
'mysql';
268 } elseif ($db_type ==
'pgsql') {
269 $databasefortest =
'postgres';
271 $databasefortest =
'master';
275 $db =
getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, (
int) $db_port);
277 dol_syslog(
"databasefortest=".$databasefortest.
" connected=".json_encode($db->connected).
" database_selected=".json_encode($db->database_selected), LOG_DEBUG);
279 if (empty($db_create_database) && $db->connected && !$db->database_selected) {
280 print
'<div class="error">'.$langs->trans(
"ErrorConnectedButDatabaseNotFound", $db_name).
'</div>';
282 if (!$db->connected) {
283 print $langs->trans(
"IfDatabaseNotExistsGoBackAndUncheckCreate").
'<br><br>';
285 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
287 } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
289 if ($db->error ==
"No such file or directory") {
290 print
'<div class="error">'.$langs->trans(
"ErrorToConnectToMysqlCheckInstance").
'</div>';
292 print
'<div class="error">'.$db->error.
'</div>';
294 if (!$db->connected) {
295 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
298 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
305 if (!$error && (empty($db_create_database) && empty($db_create_user))) {
306 $db =
getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, (
int) $db_port);
309 print
'<div class="error">'.$db->error.
'</div>';
310 if (!$db->connected) {
311 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
314 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
320 print
"<br>\nFailed to include_once(\"".$main_dir.
"/core/db/".$db_type.
".class.php\")<br>\n";
321 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentities(
"WebPagesDirectory")).
'</div>';
323 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
329 print $db->lasterror();
331 if (isset($db) && !$db->connected) {
332 print
'<br>'.$langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
334 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
338if (!$error && $db->connected) {
339 if (!empty($db_create_database)) {
340 $result = $db->select_db($db_name);
342 print
'<div class="error">'.$langs->trans(
"ErrorDatabaseAlreadyExists", $db_name).
'</div>';
343 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate").
'<br><br>';
344 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
351if (!$error && $db->connected) {
352 if (!empty($db_create_database)) {
355 $defaultCharacterSet = $db->forcecharset;
356 $defaultDBSortingCollation = $db->forcecollate;
358 $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
359 $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
363 if ($defaultCharacterSet ==
'utf8mb3' || $defaultDBSortingCollation ==
'utf8mb3_unicode_ci') {
364 $defaultCharacterSet =
'utf8';
365 $defaultDBSortingCollation =
'utf8_unicode_ci';
369 if ($defaultCharacterSet ==
'utf8mb4' || $defaultDBSortingCollation ==
'utf8mb4_unicode_ci') {
370 $defaultCharacterSet =
'utf8';
371 $defaultDBSortingCollation =
'utf8_unicode_ci';
374 print
'<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.
'">';
375 print
'<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.
'">';
376 $db_character_set = $defaultCharacterSet;
377 $db_collation = $defaultDBSortingCollation;
383if (!$error && $db->connected && $action ==
"set") {
385 if (is_array($_POST)) {
386 foreach ($_POST as $key => $value) {
387 if (!preg_match(
'/^db_pass/i', $key)) {
394 print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans(
"ConfigurationFile").
'</h3>';
395 print
'<table cellspacing="0" class="centpercent" cellpadding="1">';
399 if (!is_dir($main_dir)) {
403 print $langs->trans(
"ErrorDirDoesNotExists", $main_dir).
'<br>';
404 print $langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'<br>';
405 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
407 print $langs->trans(
"Error");
421 if (!is_dir($main_data_dir)) {
425 if (!is_dir($main_data_dir)) {
426 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
427 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
429 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
431 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
435 $pathhtaccess = $main_data_dir.
'/.htaccess';
436 if (!file_exists($pathhtaccess)) {
438 $handlehtaccess = @fopen($pathhtaccess,
'w');
439 if ($handlehtaccess) {
440 fwrite($handlehtaccess,
'Order allow,deny'.
"\n");
441 fwrite($handlehtaccess,
'Deny from all'.
"\n");
443 fclose($handlehtaccess);
450 $dir[] = $main_data_dir.
"/mycompany";
451 $dir[] = $main_data_dir.
"/medias";
452 $dir[] = $main_data_dir.
"/users";
453 $dir[] = $main_data_dir.
"/facture";
454 $dir[] = $main_data_dir.
"/propale";
455 $dir[] = $main_data_dir.
"/ficheinter";
456 $dir[] = $main_data_dir.
"/produit";
457 $dir[] = $main_data_dir.
"/doctemplates";
461 for ($i = 0; $i < $num; $i++) {
462 if (is_dir($dir[$i])) {
467 print
"Failed to create directory: ".$dir[$i];
469 print $langs->trans(
"Error");
478 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
481 $srcroot = $main_dir.
'/install/medias';
482 $destroot = $main_data_dir.
'/medias';
486 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
487 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
489 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
491 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
494 $srcroot = $main_dir.
'/install/doctemplates';
495 $destroot = $main_data_dir.
'/doctemplates';
497 'contracts' =>
'contract',
498 'invoices' =>
'invoice',
500 'products' =>
'product',
501 'projects' =>
'project',
502 'proposals' =>
'proposal',
503 'shipments' =>
'shipment',
504 'supplier_proposals' =>
'supplier_proposal',
505 'tasks' =>
'task_summary',
506 'thirdparties' =>
'thirdparty',
507 'usergroups' =>
'usergroups',
510 foreach ($docs as $cursordir => $cursorfile) {
511 $src = $srcroot.
'/'.$cursordir.
'/template_'.$cursorfile.
'.odt';
512 $dirodt = $destroot.
'/'.$cursordir;
513 $dest = $dirodt.
'/template_'.$cursorfile.
'.odt';
516 $result =
dol_copy($src, $dest,
'0', 0);
518 print
'<tr><td colspan="2"><br>'.$langs->trans(
'ErrorFailToCopyFile', $src, $dest).
'</td></tr>';
526 $main_db_prefix = (!empty($db_prefix) ? $db_prefix :
'llx_');
531 if (file_exists(
"$conffile")) {
535 @
dol_copy($conffile, $conffile.
'.old',
'0400');
544 conf($dolibarr_main_document_root);
547 print $langs->trans(
"ConfFileReload");
549 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
552 if (isset($db_create_user) && ($db_create_user ==
"1" || $db_create_user ==
"on")) {
556 $databasefortest = $conf->db->name;
557 if ($conf->db->type ==
'mysql' || $conf->db->type ==
'mysqli') {
558 $databasefortest =
'mysql';
559 } elseif ($conf->db->type ==
'pgsql') {
560 $databasefortest =
'postgres';
561 } elseif ($conf->db->type ==
'mssql') {
562 $databasefortest =
'master';
567 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, (
int) $conf->db->port);
570 print
'<div class="error">'.$db->error.
'</div>';
575 if ($db->connected) {
578 if (empty($dolibarr_main_db_pass)) {
581 print $langs->trans(
"UserCreation").
' : ';
582 print $dolibarr_main_db_user;
584 print
'<td>'.$langs->trans(
"Error").
": A password for database user is mandatory.</td></tr>";
587 $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
590 if ($databasefortest ==
'mysql') {
591 if (!in_array($dolibarr_main_db_host, array(
'127.0.0.1',
'::1',
'localhost',
'localhost.local'))) {
592 $resultbis = $db->DDLCreateUser(
'%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
596 if ($result > 0 && $resultbis > 0) {
598 print $langs->trans(
"UserCreation").
' : ';
599 print $dolibarr_main_db_user;
601 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
603 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS'
604 || $db->errno() ==
'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
605 || $db->errno() ==
'DB_ERROR_USER_ALREADY_EXISTS') {
608 print $langs->trans(
"UserCreation").
' : ';
609 print $dolibarr_main_db_user;
611 print
'<td>'.$langs->trans(
"LoginAlreadyExists").
'</td></tr>';
615 print $langs->trans(
"UserCreation").
' : ';
616 print $dolibarr_main_db_user;
618 print
'<td>'.$langs->trans(
"Error").
': '.$db->errno().
' '.$db->error().($db->error ?
'. '.$db->error :
'').
"</td></tr>";
626 print $langs->trans(
"UserCreation").
' : ';
627 print $dolibarr_main_db_user;
629 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
633 print
'<tr><td colspan="2"><br>';
634 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
636 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
637 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
647 if (!$error && (isset($db_create_database) && ($db_create_database ==
"1" || $db_create_database ==
"on"))) {
648 dolibarr_install_syslog(
"step1: create database: ".$dolibarr_main_db_name.
" ".$dolibarr_main_db_character_set.
" ".$dolibarr_main_db_collation.
" ".$dolibarr_main_db_user);
649 $newdb =
getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot,
'', (
int) $conf->db->port);
652 if ($newdb->connected) {
653 $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
657 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
658 print $dolibarr_main_db_name;
660 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
662 $newdb->select_db($dolibarr_main_db_name);
663 $check1 = $newdb->getDefaultCharacterSetDatabase();
664 $check2 = $newdb->getDefaultCollationDatabase();
672 print
'<tr><td colspan="2"><br>';
673 print $langs->trans(
"ErrorFailedToCreateDatabase", $dolibarr_main_db_name).
'<br>';
674 print $newdb->lasterror().
'<br>';
675 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate");
679 dolibarr_install_syslog(
'step1: failed to create database '.$dolibarr_main_db_name.
' '.$newdb->lasterrno().
' '.$newdb->lasterror(), LOG_ERR);
685 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
686 print $dolibarr_main_db_name;
688 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
692 print
'<tr><td colspan="2"><br>';
693 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
695 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
696 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
706 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);
709 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
711 if ($db->connected) {
714 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
715 print $dolibarr_main_db_host;
717 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
721 if ($db->database_selected) {
724 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
725 print $dolibarr_main_db_name;
727 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
732 dolibarr_install_syslog(
"step1: connection to database ".$conf->db->name.
" by user ".$conf->db->user.
" failed", LOG_ERR);
734 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
735 print $dolibarr_main_db_name;
737 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
741 print
'<tr><td colspan="2"><br>';
742 print $langs->trans(
'CheckThatDatabasenameIsCorrect', $dolibarr_main_db_name).
'<br>';
743 print $langs->trans(
'IfAlreadyExistsCheckOption').
'<br>';
744 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
752 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
753 print $dolibarr_main_db_host;
755 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
759 print
'<tr><td colspan="2"><br>';
760 print $langs->trans(
"ErrorConnection", $conf->db->host, $conf->db->name, $conf->db->user);
761 print $langs->trans(
'IfLoginDoesNotExistsCheckCreateUser').
'<br>';
762 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
775<script
type=
"text/javascript">
782 document.getElementById(
'nextbutton').style.visibility=
"hidden";
783 document.getElementById(
'pleasewait').style.visibility=
"visible";
792if ($error && isset($argv[1])) {
799pFooter($error ? 1 : 0, $setuplang,
'jsinfo', 1);
816 $fp = @fopen(
"$mainfile",
"w");
819 fwrite($fp,
'<?php'.
"\n");
820 fwrite($fp,
"// Wrapper to include main into htdocs\n");
821 fwrite($fp,
"include_once '".$main_dir.
"/main.inc.php';\n");
836 $fp = @fopen(
"$masterfile",
"w");
839 fwrite($fp,
'<?php'.
"\n");
840 fwrite($fp,
"// Wrapper to include master into htdocs\n");
841 fwrite($fp,
"include_once '".$main_dir.
"/master.inc.php';\n");
855 global $conf, $langs;
856 global $main_url, $main_dir, $main_data_dir, $main_force_https, $main_use_alt_dir, $main_alt_dir_name, $main_db_prefix;
857 global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host;
858 global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass;
859 global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication;
860 global $dolibarr_main_distrib;
861 global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation;
862 global $conffile, $conffiletoshow, $conffiletoshowshort;
863 global $force_dolibarr_lib_NUSOAP_PATH;
864 global $force_dolibarr_lib_FPDF_PATH, $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
865 global $force_dolibarr_lib_GEOIP_PATH;
866 global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
867 global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI;
868 global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
872 $key = md5(uniqid((
string) mt_rand(),
true));
874 $fp = fopen(
"$conffile",
"w");
878 fwrite($fp,
'<?php'.
"\n");
879 fwrite($fp,
'//'.
"\n");
880 fwrite($fp,
'// File generated by Dolibarr installer '.DOL_VERSION.
' on '.
dol_print_date(
dol_now(),
'').
"\n");
881 fwrite($fp,
'//'.
"\n");
882 fwrite($fp,
'// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.
' file'.
"\n");
883 fwrite($fp,
'// and explanations for all possibles parameters.'.
"\n");
884 fwrite($fp,
'//'.
"\n");
885 fwrite($fp,
'$dolibarr_main_url_root=\''.
dol_escape_php(trim($main_url), 1).
'\';
');
888 fwrite($fp, '$dolibarr_main_document_root=
"'.dol_escape_php(dol_sanitizePathName(trim($main_dir))).'";
');
891 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\
''.dol_escape_php(trim(
"/".$main_alt_dir_name), 1).
'\';
');
894 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=
"'.dol_escape_php(dol_sanitizePathName(trim($main_dir."/
".$main_alt_dir_name))).'";
');
897 fwrite($fp, '$dolibarr_main_data_root=
"'.dol_escape_php(dol_sanitizePathName(trim($main_data_dir))).'";
');
900 fwrite($fp, '$dolibarr_main_db_host=\
''.dol_escape_php(trim($db_host), 1).
'\';
');
903 fwrite($fp, '$dolibarr_main_db_port=\
''.((int) $db_port).
'\';
');
906 fwrite($fp, '$dolibarr_main_db_name=\
''.dol_escape_php(trim($db_name), 1).
'\';
');
909 fwrite($fp, '$dolibarr_main_db_prefix=\
''.dol_escape_php(trim($main_db_prefix), 1).
'\';
');
912 fwrite($fp, '$dolibarr_main_db_user=\
''.dol_escape_php(trim($db_user), 1).
'\';
');
914 fwrite($fp, '$dolibarr_main_db_pass=\
''.dol_escape_php(trim($db_pass), 1).
'\';
');
917 fwrite($fp, '$dolibarr_main_db_type=\
''.dol_escape_php(trim($db_type), 1).
'\';
');
920 fwrite($fp, '$dolibarr_main_db_character_set=\
''.dol_escape_php(trim($db_character_set), 1).
'\';
');
923 fwrite($fp, '$dolibarr_main_db_collation=\
''.dol_escape_php(trim($db_collation), 1).
'\';
');
930 fwrite($fp,
'$dolibarr_main_authentication=\'dolibarr\';');
933 fwrite($fp,
'//$dolibarr_main_demo=\'autologin,autopass\';');
936 fwrite($fp,
'// Security settings');
939 fwrite($fp,
'$dolibarr_main_prod=\'0\';');
942 fwrite($fp,
'$dolibarr_main_force_https=\''.
dol_escape_php($main_force_https, 1).
'\';
');
945 fwrite($fp, '$dolibarr_main_restrict_os_commands=\
'mariadb-dump, mariadb, mysqldump, mysql, pg_dump, pg_restore, clamdscan, clamdscan.exe\';');
948 fwrite($fp,
'$dolibarr_nocsrfcheck=\'0\';');
951 fwrite($fp,
'$dolibarr_main_instance_unique_id=\''.
dol_escape_php($key, 1).
'\';
');
954 fwrite($fp, '$dolibarr_mailing_limit_sendbyweb=\
'0\';');
956 fwrite($fp,
'$dolibarr_mailing_limit_sendbycli=\'0\';');
961 if (empty($force_dolibarr_lib_FPDF_PATH)) {
963 $force_dolibarr_lib_FPDF_PATH =
'';
967 if (empty($force_dolibarr_lib_TCPDF_PATH)) {
969 $force_dolibarr_lib_TCPDF_PATH =
'';
973 if (empty($force_dolibarr_lib_FPDI_PATH)) {
975 $force_dolibarr_lib_FPDI_PATH =
'';
979 if (empty($force_dolibarr_lib_TCPDI_PATH)) {
981 $force_dolibarr_lib_TCPDI_PATH =
'';
985 if (empty($force_dolibarr_lib_GEOIP_PATH)) {
987 $force_dolibarr_lib_GEOIP_PATH =
'';
991 if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
993 $force_dolibarr_lib_NUSOAP_PATH =
'';
997 if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
999 $force_dolibarr_lib_ODTPHP_PATH =
'';
1003 if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
1005 $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP =
'';
1009 if (empty($force_dolibarr_js_CKEDITOR)) {
1011 $force_dolibarr_js_CKEDITOR =
'';
1013 fwrite($fp,
'$dolibarr_js_CKEDITOR=\''.
dol_escape_php($force_dolibarr_js_CKEDITOR, 1).
'\';
');
1015 if (empty($force_dolibarr_js_JQUERY)) {
1017 $force_dolibarr_js_JQUERY =
'';
1019 fwrite($fp,
'$dolibarr_js_JQUERY=\''.
dol_escape_php($force_dolibarr_js_JQUERY, 1).
'\';
');
1021 if (empty($force_dolibarr_js_JQUERY_UI)) {
1023 $force_dolibarr_js_JQUERY_UI =
'';
1025 fwrite($fp,
'$dolibarr_js_JQUERY_UI=\''.
dol_escape_php($force_dolibarr_js_JQUERY_UI, 1).
'\';
');
1028 // Write params to overwrites default font path
1030 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
1032 $force_dolibarr_font_DOL_DEFAULT_TTF =
'';
1034 fwrite($fp,
'$dolibarr_font_DOL_DEFAULT_TTF=\''.
dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF, 1).
'\';
');
1036 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
1038 $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD =
'';
1040 fwrite($fp,
'$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.
dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD, 1).
'\';
');
1044 fwrite($fp, '$dolibarr_main_distrib=\
''.dol_escape_php(trim($dolibarr_main_distrib), 1).
'\';
');
1049 if (file_exists("$conffile")) {
1050 include $conffile; // force config reload, do not put include_once
1051 conf($dolibarr_main_document_root);
1054 print $langs->trans("SaveConfigurationFile");
1055 print ' <strong>
'.$conffile.'</strong>
';
1057 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.