29 define(
'DONOTLOADCONF', 1);
35 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') : (empty($argv[1]) ?
'' : $argv[1]);
36 $setuplang =
GETPOST(
'selectlang',
'aZ09', 3) ?
GETPOST(
'selectlang',
'aZ09', 3) : (empty($argv[2]) ?
'auto' : $argv[2]);
37 $langs->setDefaultLang($setuplang);
39 $langs->loadLangs(array(
"admin",
"install",
"errors"));
42 $main_dir =
GETPOST(
'main_dir') ?
GETPOST(
'main_dir') : (empty($argv[3]) ?
'' : $argv[3]);
44 $main_data_dir =
GETPOST(
'main_data_dir') ?
GETPOST(
'main_data_dir') : (empty($argv[4]) ? ($main_dir.
'/documents') : $argv[4]);
46 $main_url =
GETPOST(
'main_url') ?
GETPOST(
'main_url') : (empty($argv[5]) ?
'' : $argv[5]);
48 $userroot =
GETPOST(
'db_user_root',
'alpha') ?
GETPOST(
'db_user_root',
'alpha') : (empty($argv[6]) ?
'' : $argv[6]);
49 $passroot =
GETPOST(
'db_pass_root',
'none') ?
GETPOST(
'db_pass_root',
'none') : (empty($argv[7]) ?
'' : $argv[7]);
51 $db_type =
GETPOST(
'db_type',
'aZ09') ?
GETPOST(
'db_type',
'aZ09') : (empty($argv[8]) ?
'' : $argv[8]);
52 $db_host =
GETPOST(
'db_host',
'alpha') ?
GETPOST(
'db_host',
'alpha') : (empty($argv[9]) ?
'' : $argv[9]);
53 $db_name =
GETPOST(
'db_name',
'aZ09') ?
GETPOST(
'db_name',
'aZ09') : (empty($argv[10]) ?
'' : $argv[10]);
54 $db_user =
GETPOST(
'db_user',
'alpha') ?
GETPOST(
'db_user',
'alpha') : (empty($argv[11]) ?
'' : $argv[11]);
55 $db_pass =
GETPOST(
'db_pass',
'none') ?
GETPOST(
'db_pass',
'none') : (empty($argv[12]) ?
'' : $argv[12]);
56 $db_port =
GETPOST(
'db_port',
'int') ?
GETPOST(
'db_port',
'int') : (empty($argv[13]) ?
'' : $argv[13]);
57 $db_prefix =
GETPOST(
'db_prefix',
'aZ09') ?
GETPOST(
'db_prefix',
'aZ09') : (empty($argv[14]) ?
'' : $argv[14]);
58 $db_create_database =
GETPOST(
'db_create_database',
'alpha') ?
GETPOST(
'db_create_database',
'alpha') : (empty($argv[15]) ?
'' : $argv[15]);
59 $db_create_user =
GETPOST(
'db_create_user',
'alpha') ?
GETPOST(
'db_create_user',
'alpha') : (empty($argv[16]) ?
'' : $argv[16]);
61 $main_force_https = ((
GETPOST(
"main_force_https",
'alpha') && (
GETPOST(
"main_force_https",
'alpha') ==
"on" ||
GETPOST(
"main_force_https",
'alpha') == 1)) ?
'1' :
'0');
63 $main_use_alt_dir = ((
GETPOST(
"main_use_alt_dir",
'alpha') ==
'' || (
GETPOST(
"main_use_alt_dir",
'alpha') ==
"on" ||
GETPOST(
"main_use_alt_dir",
'alpha') == 1)) ?
'' :
'//');
65 $main_alt_dir_name = ((
GETPOST(
"main_alt_dir_name",
'alpha') &&
GETPOST(
"main_alt_dir_name",
'alpha') !=
'') ?
GETPOST(
"main_alt_dir_name",
'alpha') :
'custom');
67 $dolibarr_main_distrib =
'standard';
72 $_SESSION[
'dol_save_pass'] = $db_pass;
76 $useforcedwizard =
false;
77 $forcedfile =
"./install.forced.php";
78 if ($conffile ==
"/etc/dolibarr/conf.php") {
79 $forcedfile =
"/etc/dolibarr/install.forced.php";
81 if (@file_exists($forcedfile)) {
82 $useforcedwizard =
true;
83 include_once $forcedfile;
85 if ($force_install_noedit) {
87 if (!empty($argv[1])) {
90 if (!empty($force_install_main_data_root)) {
91 $main_data_dir = $force_install_main_data_root;
97 if (!empty($force_install_databaserootlogin)) {
100 if (!empty($force_install_databaserootpass)) {
104 if ($force_install_noedit == 2) {
105 if (!empty($force_install_type)) {
106 $db_type = $force_install_type;
108 if (!empty($force_install_dbserver)) {
109 $db_host = $force_install_dbserver;
111 if (!empty($force_install_database)) {
112 $db_name = $force_install_database;
114 if (!empty($force_install_databaselogin)) {
115 $db_user = $force_install_databaselogin;
117 if (!empty($force_install_databasepass)) {
118 $db_pass = $force_install_databasepass;
120 if (!empty($force_install_port)) {
121 $db_port = $force_install_port;
123 if (!empty($force_install_prefix)) {
124 $db_prefix = $force_install_prefix;
126 if (!empty($force_install_createdatabase)) {
127 $db_create_database = $force_install_createdatabase;
129 if (!empty($force_install_createuser)) {
130 $db_create_user = $force_install_createuser;
132 if (!empty($force_install_mainforcehttps)) {
133 $main_force_https = $force_install_mainforcehttps;
137 if (!empty($force_install_distrib)) {
138 $dolibarr_main_distrib = $force_install_distrib;
152 pHeader($langs->trans(
"ConfigurationFile"),
"step2");
155 if (!is_writable($conffile)) {
156 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
157 pFooter(1, $setuplang,
'jscheckparam');
164 if (empty($db_type)) {
165 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseType")).
'</div>';
168 $is_sqlite = ($db_type ===
'sqlite' || $db_type ===
'sqlite3');
170 if (empty($db_host) && !$is_sqlite) {
171 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Server")).
'</div>';
174 if (empty($db_name)) {
175 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseName")).
'</div>';
178 if (empty($db_user) && !$is_sqlite) {
179 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Login")).
'</div>';
182 if (!empty($db_port) && !is_numeric($db_port)) {
183 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_port, $langs->transnoentities(
"Port")).
'</div>';
186 if (!empty($db_prefix) && !preg_match(
'/^[a-z0-9]+_$/i', $db_prefix)) {
187 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_prefix, $langs->transnoentities(
"DatabasePrefix")).
'</div>';
193 if (substr($main_dir,
dol_strlen($main_dir) - 1) ==
"/") {
194 $main_dir = substr($main_dir, 0,
dol_strlen($main_dir) - 1);
198 if (!empty($main_url) && substr($main_url,
dol_strlen($main_url) - 1) ==
"/") {
199 $main_url = substr($main_url, 0,
dol_strlen($main_url) - 1);
203 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'</div>';
206 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
212 $result = @include_once $main_dir.
"/core/db/".$db_type.
'.class.php';
215 if (!empty($db_create_database) && !$userroot) {
216 print
'<div class="error">'.$langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).
'</div>';
218 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
219 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
222 if (!empty($db_create_user) && !$userroot) {
223 print
'<div class="error">'.$langs->trans(
"YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).
'</div>';
225 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
226 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
231 if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
232 $databasefortest = $db_name;
233 if (!empty($db_create_database)) {
234 if ($db_type ==
'mysql' || $db_type ==
'mysqli') {
235 $databasefortest =
'mysql';
236 } elseif ($db_type ==
'pgsql') {
237 $databasefortest =
'postgres';
239 $databasefortest =
'master';
243 $db =
getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port);
245 dol_syslog(
"databasefortest=".$databasefortest.
" connected=".$db->connected.
" database_selected=".$db->database_selected, LOG_DEBUG);
248 if (empty($db_create_database) && $db->connected && !$db->database_selected) {
249 print
'<div class="error">'.$langs->trans(
"ErrorConnectedButDatabaseNotFound", $db_name).
'</div>';
251 if (!$db->connected) {
252 print $langs->trans(
"IfDatabaseNotExistsGoBackAndUncheckCreate").
'<br><br>';
254 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
256 } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
258 if ($db->error ==
"No such file or directory") {
259 print
'<div class="error">'.$langs->trans(
"ErrorToConnectToMysqlCheckInstance").
'</div>';
261 print
'<div class="error">'.$db->error.
'</div>';
263 if (!$db->connected) {
264 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
267 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
274 if (!$error && (empty($db_create_database) && empty($db_create_user))) {
275 $db =
getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
278 print
'<div class="error">'.$db->error.
'</div>';
279 if (!$db->connected) {
280 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
283 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
289 print
"<br>\nFailed to include_once(\"".$main_dir.
"/core/db/".$db_type.
".class.php\")<br>\n";
290 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentities(
"WebPagesDirectory")).
'</div>';
292 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
298 print $db->lasterror();
300 if (isset($db) && !$db->connected) {
301 print
'<br>'.$langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
303 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
307 if (!$error && $db->connected) {
308 if (!empty($db_create_database)) {
309 $result = $db->select_db($db_name);
311 print
'<div class="error">'.$langs->trans(
"ErrorDatabaseAlreadyExists", $db_name).
'</div>';
312 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate").
'<br><br>';
313 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
320 if (!$error && $db->connected) {
321 if (!empty($db_create_database)) {
324 $defaultCharacterSet = $db->forcecharset;
325 $defaultDBSortingCollation = $db->forcecollate;
328 $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
329 $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
334 if ($defaultCharacterSet ==
'utf8mb4' || $defaultDBSortingCollation ==
'utf8mb4_unicode_ci') {
335 $defaultCharacterSet =
'utf8';
336 $defaultDBSortingCollation =
'utf8_unicode_ci';
339 print
'<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.
'">';
340 print
'<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.
'">';
341 $db_character_set = $defaultCharacterSet;
342 $db_collation = $defaultDBSortingCollation;
348 if (!$error && $db->connected && $action ==
"set") {
350 if (is_array($_POST)) {
351 foreach ($_POST as $key => $value) {
352 if (!preg_match(
'/^db_pass/i', $key)) {
359 print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans(
"ConfigurationFile").
'</h3>';
360 print
'<table cellspacing="0" width="100%" cellpadding="1" border="0">';
364 if (!is_dir($main_dir)) {
368 print $langs->trans(
"ErrorDirDoesNotExists", $main_dir).
'<br>';
369 print $langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'<br>';
370 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
372 print $langs->trans(
"Error");
386 if (!is_dir($main_data_dir)) {
390 if (!is_dir($main_data_dir)) {
391 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
392 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
394 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
396 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
400 $pathhtaccess = $main_data_dir.
'/.htaccess';
401 if (!file_exists($pathhtaccess)) {
403 $handlehtaccess = @fopen($pathhtaccess,
'w');
404 if ($handlehtaccess) {
405 fwrite($handlehtaccess,
'Order allow,deny'.
"\n");
406 fwrite($handlehtaccess,
'Deny from all'.
"\n");
408 fclose($handlehtaccess);
415 $dir[] = $main_data_dir.
"/mycompany";
416 $dir[] = $main_data_dir.
"/medias";
417 $dir[] = $main_data_dir.
"/users";
418 $dir[] = $main_data_dir.
"/facture";
419 $dir[] = $main_data_dir.
"/propale";
420 $dir[] = $main_data_dir.
"/ficheinter";
421 $dir[] = $main_data_dir.
"/produit";
422 $dir[] = $main_data_dir.
"/doctemplates";
426 for ($i = 0; $i < $num; $i++) {
427 if (is_dir($dir[$i])) {
432 print
"Failed to create directory: ".$dir[$i];
434 print $langs->trans(
"Error");
443 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
446 $srcroot = $main_dir.
'/install/medias';
447 $destroot = $main_data_dir.
'/medias';
451 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
452 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
454 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
456 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
459 $srcroot = $main_dir.
'/install/doctemplates';
460 $destroot = $main_data_dir.
'/doctemplates';
462 'contracts' =>
'contract',
463 'invoices' =>
'invoice',
465 'products' =>
'product',
466 'projects' =>
'project',
467 'proposals' =>
'proposal',
468 'shipments' =>
'shipment',
469 'supplier_proposals' =>
'supplier_proposal',
470 'tasks' =>
'task_summary',
471 'thirdparties' =>
'thirdparty',
472 'usergroups' =>
'usergroups',
475 foreach ($docs as $cursordir => $cursorfile) {
476 $src = $srcroot.
'/'.$cursordir.
'/template_'.$cursorfile.
'.odt';
477 $dirodt = $destroot.
'/'.$cursordir;
478 $dest = $dirodt.
'/template_'.$cursorfile.
'.odt';
481 $result =
dol_copy($src, $dest, 0, 0);
483 print
'<tr><td colspan="2"><br>'.$langs->trans(
'ErrorFailToCopyFile', $src, $dest).
'</td></tr>';
491 $main_db_prefix = (!empty($db_prefix) ? $db_prefix :
'llx_');
496 if (file_exists(
"$conffile")) {
500 @
dol_copy($conffile, $conffile.
'.old',
'0400');
509 conf($dolibarr_main_document_root);
512 print $langs->trans(
"ConfFileReload");
514 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
517 if (isset($db_create_user) && ($db_create_user ==
"1" || $db_create_user ==
"on")) {
521 $databasefortest = $conf->db->name;
522 if ($conf->db->type ==
'mysql' || $conf->db->type ==
'mysqli') {
523 $databasefortest =
'mysql';
524 } elseif ($conf->db->type ==
'pgsql') {
525 $databasefortest =
'postgres';
526 } elseif ($conf->db->type ==
'mssql') {
527 $databasefortest =
'master';
532 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, $conf->db->port);
535 print
'<div class="error">'.$db->error.
'</div>';
540 if ($db->connected) {
543 if (empty($dolibarr_main_db_pass)) {
546 print $langs->trans(
"UserCreation").
' : ';
547 print $dolibarr_main_db_user;
549 print
'<td>'.$langs->trans(
"Error").
": A password for database user is mandatory.</td></tr>";
552 $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
555 if ($databasefortest ==
'mysql') {
556 if (!in_array($dolibarr_main_db_host, array(
'127.0.0.1',
'::1',
'localhost',
'localhost.local'))) {
557 $resultbis = $db->DDLCreateUser(
'%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
561 if ($result > 0 && $resultbis > 0) {
563 print $langs->trans(
"UserCreation").
' : ';
564 print $dolibarr_main_db_user;
566 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
568 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS'
569 || $db->errno() ==
'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
570 || $db->errno() ==
'DB_ERROR_USER_ALREADY_EXISTS') {
573 print $langs->trans(
"UserCreation").
' : ';
574 print $dolibarr_main_db_user;
576 print
'<td>'.$langs->trans(
"LoginAlreadyExists").
'</td></tr>';
580 print $langs->trans(
"UserCreation").
' : ';
581 print $dolibarr_main_db_user;
583 print
'<td>'.$langs->trans(
"Error").
': '.$db->errno().
' '.$db->error().($db->error ?
'. '.$db->error :
'').
"</td></tr>";
591 print $langs->trans(
"UserCreation").
' : ';
592 print $dolibarr_main_db_user;
594 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
598 print
'<tr><td colspan="2"><br>';
599 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
601 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
602 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
612 if (!$error && (isset($db_create_database) && ($db_create_database ==
"1" || $db_create_database ==
"on"))) {
613 dolibarr_install_syslog(
"step1: create database: ".$dolibarr_main_db_name.
" ".$dolibarr_main_db_character_set.
" ".$dolibarr_main_db_collation.
" ".$dolibarr_main_db_user);
614 $newdb =
getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot,
'', $conf->db->port);
617 if ($newdb->connected) {
618 $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
622 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
623 print $dolibarr_main_db_name;
625 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
627 $newdb->select_db($dolibarr_main_db_name);
628 $check1 = $newdb->getDefaultCharacterSetDatabase();
629 $check2 = $newdb->getDefaultCollationDatabase();
637 print
'<tr><td colspan="2"><br>';
638 print $langs->trans(
"ErrorFailedToCreateDatabase", $dolibarr_main_db_name).
'<br>';
639 print $newdb->lasterror().
'<br>';
640 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate");
644 dolibarr_install_syslog(
'step1: failed to create database '.$dolibarr_main_db_name.
' '.$newdb->lasterrno().
' '.$newdb->lasterror(), LOG_ERR);
650 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
651 print $dolibarr_main_db_name;
653 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
657 print
'<tr><td colspan="2"><br>';
658 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
660 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
661 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
671 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);
674 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
676 if ($db->connected) {
679 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
680 print $dolibarr_main_db_host;
682 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
686 if ($db->database_selected) {
689 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
690 print $dolibarr_main_db_name;
692 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
697 dolibarr_install_syslog(
"step1: connection to database ".$conf->db->name.
" by user ".$conf->db->user.
" failed", LOG_ERR);
699 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
700 print $dolibarr_main_db_name;
702 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
706 print
'<tr><td colspan="2"><br>';
707 print $langs->trans(
'CheckThatDatabasenameIsCorrect', $dolibarr_main_db_name).
'<br>';
708 print $langs->trans(
'IfAlreadyExistsCheckOption').
'<br>';
709 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
717 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".$conf->db->user.
") : ";
718 print $dolibarr_main_db_host;
720 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
724 print
'<tr><td colspan="2"><br>';
725 print $langs->trans(
"ErrorConnection", $conf->db->host, $conf->db->name, $conf->db->user);
726 print $langs->trans(
'IfLoginDoesNotExistsCheckCreateUser').
'<br>';
727 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
740 <script
type=
"text/javascript">
747 document.getElementById(
'nextbutton').style.visibility=
"hidden";
748 document.getElementById(
'pleasewait').style.visibility=
"visible";
757 if ($error && isset($argv[1])) {
764 pFooter($error ? 1 : 0, $setuplang,
'jsinfo', 1);
781 $fp = @fopen(
"$mainfile",
"w");
784 fputs($fp,
'<?php'.
"\n");
785 fputs($fp,
"// Wrapper to include main into htdocs\n");
786 fputs($fp,
"include_once '".$main_dir.
"/main.inc.php';\n");
801 $fp = @fopen(
"$masterfile",
"w");
804 fputs($fp,
'<?php'.
"\n");
805 fputs($fp,
"// Wrapper to include master into htdocs\n");
806 fputs($fp,
"include_once '".$main_dir.
"/master.inc.php';\n");
820 global $conf, $langs;
821 global $main_url, $main_dir, $main_data_dir, $main_force_https, $main_use_alt_dir, $main_alt_dir_name, $main_db_prefix;
822 global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host;
823 global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass;
824 global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication;
825 global $dolibarr_main_distrib;
826 global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation;
827 global $conffile, $conffiletoshow, $conffiletoshowshort;
828 global $force_dolibarr_lib_NUSOAP_PATH;
829 global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
830 global $force_dolibarr_lib_GEOIP_PATH;
831 global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
832 global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI;
833 global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
837 $key = md5(uniqid(mt_rand(),
true));
839 $fp = fopen(
"$conffile",
"w");
843 fputs($fp,
'<?php'.
"\n");
844 fputs($fp,
'//'.
"\n");
845 fputs($fp,
'// File generated by Dolibarr installer '.DOL_VERSION.
' on '.
dol_print_date(
dol_now(),
'').
"\n");
846 fputs($fp,
'//'.
"\n");
847 fputs($fp,
'// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.
' file'.
"\n");
848 fputs($fp,
'// and explanations for all possibles parameters.'.
"\n");
849 fputs($fp,
'//'.
"\n");
851 fputs($fp,
'$dolibarr_main_url_root=\''.str_replace(
"'",
"\'", trim($main_url)).
'\';
');
854 fputs($fp, '$dolibarr_main_document_root=\
''.str_replace(
"'",
"\'", trim($main_dir)).
'\';
');
857 fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\
''.str_replace(
"'",
"\'", trim(
"/".$main_alt_dir_name)).
'\';
');
860 fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\
''.str_replace(
"'",
"\'", trim($main_dir.
"/".$main_alt_dir_name)).
'\';
');
863 fputs($fp, '$dolibarr_main_data_root=\
''.str_replace(
"'",
"\'", trim($main_data_dir)).
'\';
');
866 fputs($fp, '$dolibarr_main_db_host=\
''.str_replace(
"'",
"\'", trim($db_host)).
'\';
');
869 fputs($fp, '$dolibarr_main_db_port=\
''.str_replace(
"'",
"\'", trim($db_port)).
'\';
');
872 fputs($fp, '$dolibarr_main_db_name=\
''.str_replace(
"'",
"\'", trim($db_name)).
'\';
');
875 fputs($fp, '$dolibarr_main_db_prefix=\
''.str_replace(
"'",
"\'", trim($main_db_prefix)).
'\';
');
878 fputs($fp, '$dolibarr_main_db_user=\
''.str_replace(
"'",
"\'", trim($db_user)).
'\';
');
880 fputs($fp, '$dolibarr_main_db_pass=\
''.str_replace(
"'",
"\'", trim($db_pass)).
'\';
');
883 fputs($fp, '$dolibarr_main_db_type=\
''.str_replace(
"'",
"\'", trim($db_type)).
'\';
');
886 fputs($fp, '$dolibarr_main_db_character_set=\
''.str_replace(
"'",
"\'", trim($db_character_set)).
'\';
');
889 fputs($fp, '$dolibarr_main_db_collation=\
''.str_replace(
"'",
"\'", trim($db_collation)).
'\';
');
896 fputs($fp,
'$dolibarr_main_authentication=\'dolibarr\';');
899 fputs($fp,
'//$dolibarr_main_demo=\'autologin,autopass\';');
902 fputs($fp,
'// Security settings');
905 fputs($fp,
'$dolibarr_main_prod=\'0\';');
908 fputs($fp,
'$dolibarr_main_force_https=\''.$main_force_https.
'\';
');
911 fputs($fp, '$dolibarr_main_restrict_os_commands=\
'mysqldump, mysql, pg_dump, pgrestore\';');
914 fputs($fp,
'$dolibarr_nocsrfcheck=\'0\';');
917 fputs($fp,
'$dolibarr_main_instance_unique_id=\''.$key.
'\';
');
920 fputs($fp, '$dolibarr_mailing_limit_sendbyweb=\
'0\';');
922 fputs($fp,
'$dolibarr_mailing_limit_sendbycli=\'0\';');
927 if (empty($force_dolibarr_lib_FPDF_PATH)) {
928 fputs($fp,
'//'); $force_dolibarr_lib_FPDF_PATH =
'';
930 fputs($fp,
'$dolibarr_lib_FPDF_PATH=\''.$force_dolibarr_lib_FPDF_PATH.
'\';
');
932 if (empty($force_dolibarr_lib_TCPDF_PATH)) {
935 fputs($fp,
'$dolibarr_lib_TCPDF_PATH=\''.$force_dolibarr_lib_TCPDF_PATH.
'\';
');
937 if (empty($force_dolibarr_lib_FPDI_PATH)) {
940 fputs($fp,
'$dolibarr_lib_FPDI_PATH=\''.$force_dolibarr_lib_FPDI_PATH.
'\';
');
942 if (empty($force_dolibarr_lib_TCPDI_PATH)) {
945 fputs($fp,
'$dolibarr_lib_TCPDI_PATH=\''.$force_dolibarr_lib_TCPDI_PATH.
'\';
');
947 if (empty($force_dolibarr_lib_GEOIP_PATH)) {
950 fputs($fp,
'$dolibarr_lib_GEOIP_PATH=\''.$force_dolibarr_lib_GEOIP_PATH.
'\';
');
952 if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
955 fputs($fp,
'$dolibarr_lib_NUSOAP_PATH=\''.$force_dolibarr_lib_NUSOAP_PATH.
'\';
');
957 if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
960 fputs($fp,
'$dolibarr_lib_ODTPHP_PATH=\''.$force_dolibarr_lib_ODTPHP_PATH.
'\';
');
962 if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
965 fputs($fp,
'$dolibarr_lib_ODTPHP_PATHTOPCLZIP=\''.$force_dolibarr_lib_ODTPHP_PATHTOPCLZIP.
'\';
');
967 if (empty($force_dolibarr_js_CKEDITOR)) {
970 fputs($fp,
'$dolibarr_js_CKEDITOR=\''.$force_dolibarr_js_CKEDITOR.
'\';
');
972 if (empty($force_dolibarr_js_JQUERY)) {
975 fputs($fp,
'$dolibarr_js_JQUERY=\''.$force_dolibarr_js_JQUERY.
'\';
');
977 if (empty($force_dolibarr_js_JQUERY_UI)) {
980 fputs($fp,
'$dolibarr_js_JQUERY_UI=\''.$force_dolibarr_js_JQUERY_UI.
'\';
');
983 // Write params to overwrites default font path
985 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
988 fputs($fp,
'$dolibarr_font_DOL_DEFAULT_TTF=\''.$force_dolibarr_font_DOL_DEFAULT_TTF.
'\';
');
990 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
993 fputs($fp,
'$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.$force_dolibarr_font_DOL_DEFAULT_TTF_BOLD.
'\';
');
997 fputs($fp, '$dolibarr_main_distrib=\
''.str_replace(
"'",
"\'", trim($dolibarr_main_distrib)).
'\';
');
1002 if (file_exists("$conffile")) {
1003 include $conffile; // force config reload, do not put include_once
1004 conf($dolibarr_main_document_root);
1007 print $langs->trans("SaveConfigurationFile");
1008 print ' <strong>
'.$conffile.'</strong>
';
1010 print '<img src=
"../theme/eldy/img/tick.png" alt=
"Ok">
';
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null)
Copy a dir to another dir.
dol_is_dir($folder)
Test if filename is a directory.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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_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.