31define(
'DONOTLOADCONF', 1);
40$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') : (empty($argv[1]) ?
'' : $argv[1]);
41$setuplang =
GETPOST(
'selectlang',
'aZ09', 3) ?
GETPOST(
'selectlang',
'aZ09', 3) : (empty($argv[2]) ?
'auto' : $argv[2]);
42$langs->setDefaultLang($setuplang);
44$langs->loadLangs(array(
"admin",
"install",
"errors"));
47$main_dir =
GETPOST(
'main_dir') ?
GETPOST(
'main_dir') : (empty($argv[3]) ?
'' : $argv[3]);
49$main_data_dir =
GETPOST(
'main_data_dir') ?
GETPOST(
'main_data_dir') : (empty($argv[4]) ? ($main_dir.
'/documents') : $argv[4]);
51$main_url =
GETPOST(
'main_url') ?
GETPOST(
'main_url') : (empty($argv[5]) ?
'' : $argv[5]);
53$userroot =
GETPOST(
'db_user_root',
'alpha') ?
GETPOST(
'db_user_root',
'alpha') : (empty($argv[6]) ?
'' : $argv[6]);
54$passroot =
GETPOST(
'db_pass_root',
'password') ?
GETPOST(
'db_pass_root',
'password') : (empty($argv[7]) ?
'' : $argv[7]);
56$db_type =
GETPOST(
'db_type',
'aZ09') ?
GETPOST(
'db_type',
'aZ09') : (empty($argv[8]) ?
'' : $argv[8]);
57$db_host =
GETPOST(
'db_host',
'alpha') ?
GETPOST(
'db_host',
'alpha') : (empty($argv[9]) ?
'' : $argv[9]);
58$db_name =
GETPOST(
'db_name',
'aZ09') ?
GETPOST(
'db_name',
'aZ09') : (empty($argv[10]) ?
'' : $argv[10]);
59$db_user =
GETPOST(
'db_user',
'alpha') ?
GETPOST(
'db_user',
'alpha') : (empty($argv[11]) ?
'' : $argv[11]);
60$db_pass =
GETPOST(
'db_pass',
'password') ?
GETPOST(
'db_pass',
'password') : (empty($argv[12]) ?
'' : $argv[12]);
62$db_prefix =
GETPOST(
'db_prefix',
'aZ09') ?
GETPOST(
'db_prefix',
'aZ09') : (empty($argv[14]) ?
'' : $argv[14]);
63$db_create_database =
GETPOST(
'db_create_database',
'alpha') ?
GETPOST(
'db_create_database',
'alpha') : (empty($argv[15]) ?
'' : $argv[15]);
64$db_create_user =
GETPOST(
'db_create_user',
'alpha') ?
GETPOST(
'db_create_user',
'alpha') : (empty($argv[16]) ?
'' : $argv[16]);
66$main_force_https = ((
GETPOST(
"main_force_https",
'alpha') && (
GETPOST(
"main_force_https",
'alpha') ==
"on" ||
GETPOST(
"main_force_https",
'alpha') == 1)) ?
'1' :
'0');
68$main_use_alt_dir = ((
GETPOST(
"main_use_alt_dir",
'alpha') ==
'' || (
GETPOST(
"main_use_alt_dir",
'alpha') ==
"on" ||
GETPOST(
"main_use_alt_dir",
'alpha') == 1)) ?
'' :
'//');
70$main_alt_dir_name = ((
GETPOST(
"main_alt_dir_name",
'alpha') &&
GETPOST(
"main_alt_dir_name",
'alpha') !=
'') ?
GETPOST(
"main_alt_dir_name",
'alpha') :
'custom');
72$dolibarr_main_distrib =
'standard';
77$_SESSION[
'dol_save_pass'] = $db_pass;
81$useforcedwizard =
false;
82$forcedfile =
"./install.forced.php";
83if ($conffile ==
"/etc/dolibarr/conf.php") {
84 $forcedfile =
"/etc/dolibarr/install.forced.php";
86if (@file_exists($forcedfile)) {
87 $useforcedwizard =
true;
88 include_once $forcedfile;
90 if ($force_install_noedit) {
92 if (!empty($argv[3])) {
95 if (!empty($force_install_main_data_root)) {
96 $main_data_dir = $force_install_main_data_root;
100 if (!empty($argv[4])) {
101 $main_data_dir = $argv[4];
104 if ($force_install_noedit != 3)
106 if (!empty($argv[5])) {
107 $main_url = $argv[5];
110 if (!empty($force_install_databaserootlogin)) {
113 if (!empty($argv[6])) {
114 $userroot = $argv[6];
116 if (!empty($force_install_databaserootpass)) {
119 if (!empty($argv[7])) {
120 $passroot = $argv[7];
123 if (($force_install_noedit == 2) || ($force_install_noedit == 3)) {
124 if (!empty($force_install_type)) {
125 $db_type = $force_install_type;
127 if (!empty($force_install_dbserver)) {
128 $db_host = $force_install_dbserver;
130 if (!empty($force_install_database)) {
131 $db_name = $force_install_database;
133 if (!empty($force_install_databaselogin)) {
134 $db_user = $force_install_databaselogin;
136 if (!empty($force_install_databasepass)) {
137 $db_pass = $force_install_databasepass;
139 if (!empty($force_install_port)) {
140 $db_port = $force_install_port;
142 if (!empty($force_install_prefix)) {
143 $db_prefix = $force_install_prefix;
145 if (!empty($force_install_createdatabase)) {
146 $db_create_database = $force_install_createdatabase;
148 if (!empty($force_install_createuser)) {
149 $db_create_user = $force_install_createuser;
151 if (!empty($force_install_mainforcehttps)) {
152 $main_force_https = $force_install_mainforcehttps;
156 if (!empty($force_install_distrib)) {
157 $dolibarr_main_distrib = $force_install_distrib;
178pHeader($langs->trans(
"DolibarrSetup").
' - '.$langs->trans(
"ConfigurationFile"),
"step2");
181if (!is_writable($conffile)) {
182 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
183 pFooter(1, $setuplang,
'jscheckparam');
190if (empty($db_type)) {
191 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseType")).
'</div>';
194 $is_sqlite = ($db_type ===
'sqlite' || $db_type ===
'sqlite3');
196if (empty($db_host) && !$is_sqlite) {
197 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Server")).
'</div>';
200if (empty($db_name)) {
201 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DatabaseName")).
'</div>';
204if (empty($db_user) && !$is_sqlite) {
205 print
'<div class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Login")).
'</div>';
208if (!empty($db_port) && !is_numeric($db_port)) {
209 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_port, $langs->transnoentities(
"Port")).
'</div>';
212if (!empty($db_prefix) && !preg_match(
'/^[a-z0-9]+_$/i', $db_prefix)) {
213 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $db_prefix, $langs->transnoentities(
"DatabasePrefix")).
'</div>';
220if (!filter_var($main_url, FILTER_VALIDATE_URL)) {
221 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_url, $langs->transnoentitiesnoconv(
"URLRoot")).
'</div>';
223 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
228if (substr($main_dir,
dol_strlen($main_dir) - 1) ==
"/") {
229 $main_dir = substr($main_dir, 0,
dol_strlen($main_dir) - 1);
233if (!empty($main_url) && substr($main_url,
dol_strlen($main_url) - 1) ==
"/") {
234 $main_url = substr($main_url, 0,
dol_strlen($main_url) - 1);
238 print
'<div class="error">'.$langs->trans(
"ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'</div>';
241 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
247 $result = @include_once $main_dir.
"/core/db/".$db_type.
'.class.php';
250 if (!empty($db_create_database) && !$userroot) {
251 print
'<div class="error">'.$langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).
'</div>';
253 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
254 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
257 if (!empty($db_create_user) && !$userroot) {
258 print
'<div class="error">'.$langs->trans(
"YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).
'</div>';
260 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
261 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
266 if (!$error && (!empty($db_create_database) || !empty($db_create_user))) {
267 $databasefortest = $db_name;
268 if (!empty($db_create_database)) {
269 if ($db_type ==
'mysql' || $db_type ==
'mysqli') {
270 $databasefortest =
'mysql';
271 } elseif ($db_type ==
'pgsql') {
272 $databasefortest =
'postgres';
274 $databasefortest =
'master';
278 $db =
getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, (
int) $db_port);
280 dol_syslog(
"databasefortest=".$databasefortest.
" connected=".json_encode($db->connected).
" database_selected=".json_encode($db->database_selected), LOG_DEBUG);
282 if (empty($db_create_database) && $db->connected && !$db->database_selected) {
283 print
'<div class="error">'.$langs->trans(
"ErrorConnectedButDatabaseNotFound", $db_name).
'</div>';
285 if (!$db->connected) {
286 print $langs->trans(
"IfDatabaseNotExistsGoBackAndUncheckCreate").
'<br><br>';
288 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
290 } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
292 if ($db->error ==
"No such file or directory") {
293 print
'<div class="error">'.$langs->trans(
"ErrorToConnectToMysqlCheckInstance").
'</div>';
295 print
'<div class="error">'.$db->error.
'</div>';
297 if (!$db->connected) {
298 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
301 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
308 if (!$error && (empty($db_create_database) && empty($db_create_user))) {
309 $db =
getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, (
int) $db_port);
312 print
'<div class="error">'.$db->error.
'</div>';
313 if (!$db->connected) {
314 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
317 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
323 print
"<br>\nFailed to include_once(\"".$main_dir.
"/core/db/".$db_type.
".class.php\")<br>\n";
324 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentities(
"WebPagesDirectory")).
'</div>';
326 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
332 print $db->lasterror();
334 if (isset($db) && !$db->connected) {
335 print
'<br>'.$langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
337 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
341if (!$error && $db->connected) {
342 if (!empty($db_create_database)) {
343 $result = $db->select_db($db_name);
345 print
'<div class="error">'.$langs->trans(
"ErrorDatabaseAlreadyExists", $db_name).
'</div>';
346 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate").
'<br><br>';
347 print $langs->trans(
"ErrorGoBackAndCorrectParameters");
354if (!$error && $db->connected) {
355 if (!empty($db_create_database)) {
358 $defaultCharacterSet = $db->forcecharset;
359 $defaultDBSortingCollation = $db->forcecollate;
361 $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
362 $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
366 if ($defaultCharacterSet ==
'utf8mb3' || $defaultDBSortingCollation ==
'utf8mb3_unicode_ci') {
367 $defaultCharacterSet =
'utf8';
368 $defaultDBSortingCollation =
'utf8_unicode_ci';
372 if ($defaultCharacterSet ==
'utf8mb4' || $defaultDBSortingCollation ==
'utf8mb4_unicode_ci') {
373 $defaultCharacterSet =
'utf8';
374 $defaultDBSortingCollation =
'utf8_unicode_ci';
377 print
'<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.
'">';
378 print
'<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.
'">';
379 $db_character_set = $defaultCharacterSet;
380 $db_collation = $defaultDBSortingCollation;
386if (!$error && $db->connected && $action ==
"set") {
388 if (is_array($_POST)) {
389 foreach ($_POST as $key => $value) {
390 if (!preg_match(
'/^db_pass/i', $key)) {
397 print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Configuration"> '.$langs->trans(
"ConfigurationFile").
'</h3>';
398 print
'<table cellspacing="0" class="centpercent" cellpadding="1">';
402 if (!is_dir($main_dir)) {
406 print $langs->trans(
"ErrorDirDoesNotExists", $main_dir).
'<br>';
407 print $langs->trans(
"ErrorWrongValueForParameter", $langs->transnoentitiesnoconv(
"WebPagesDirectory")).
'<br>';
408 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
410 print $langs->trans(
"Error");
424 if (!is_dir($main_data_dir)) {
428 if (!is_dir($main_data_dir)) {
429 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
430 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
432 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
434 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
438 $pathhtaccess = $main_data_dir.
'/.htaccess';
439 if (!file_exists($pathhtaccess)) {
441 $handlehtaccess = @fopen($pathhtaccess,
'w');
442 if ($handlehtaccess) {
443 fwrite($handlehtaccess,
'Order allow,deny'.
"\n");
444 fwrite($handlehtaccess,
'Deny from all'.
"\n");
446 fclose($handlehtaccess);
453 $dir[] = $main_data_dir.
"/mycompany";
454 $dir[] = $main_data_dir.
"/medias";
455 $dir[] = $main_data_dir.
"/users";
456 $dir[] = $main_data_dir.
"/facture";
457 $dir[] = $main_data_dir.
"/propale";
458 $dir[] = $main_data_dir.
"/ficheinter";
459 $dir[] = $main_data_dir.
"/produit";
460 $dir[] = $main_data_dir.
"/doctemplates";
464 for ($i = 0; $i < $num; $i++) {
465 if (is_dir($dir[$i])) {
470 print
"Failed to create directory: ".$dir[$i];
472 print $langs->trans(
"Error");
481 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
484 $srcroot = $main_dir.
'/install/medias';
485 $destroot = $main_data_dir.
'/medias';
489 print
"<tr><td>".$langs->trans(
"ErrorDirDoesNotExists", $main_data_dir);
490 print
' '.$langs->trans(
"YouMustCreateItAndAllowServerToWrite");
492 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
494 print
'<tr><td colspan="2"><br>'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</td></tr>';
497 $srcroot = $main_dir.
'/install/doctemplates';
498 $destroot = $main_data_dir.
'/doctemplates';
500 'contracts' =>
'contract',
501 'invoices' =>
'invoice',
503 'products' =>
'product',
504 'projects' =>
'project',
505 'proposals' =>
'proposal',
506 'shipments' =>
'shipment',
507 'supplier_proposals' =>
'supplier_proposal',
508 'tasks' =>
'task_summary',
509 'thirdparties' =>
'thirdparty',
510 'usergroups' =>
'usergroups',
513 foreach ($docs as $cursordir => $cursorfile) {
514 $src = $srcroot.
'/'.$cursordir.
'/template_'.$cursorfile.
'.odt';
515 $dirodt = $destroot.
'/'.$cursordir;
516 $dest = $dirodt.
'/template_'.$cursorfile.
'.odt';
519 $result =
dol_copy($src, $dest,
'0', 0);
521 print
'<tr><td colspan="2"><br>'.$langs->trans(
'ErrorFailToCopyFile', $src, $dest).
'</td></tr>';
529 $main_db_prefix = (!empty($db_prefix) ? $db_prefix :
'llx_');
534 if (file_exists(
"$conffile")) {
538 @
dol_copy($conffile, $conffile.
'.old',
'0400');
547 conf($dolibarr_main_document_root);
550 print $langs->trans(
"ConfFileReload");
552 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
555 if (isset($db_create_user) && ($db_create_user ==
"1" || $db_create_user ==
"on")) {
559 $databasefortest =
$conf->db->name;
560 if (
$conf->db->type ==
'mysql' ||
$conf->db->type ==
'mysqli') {
561 $databasefortest =
'mysql';
562 } elseif (
$conf->db->type ==
'pgsql') {
563 $databasefortest =
'postgres';
564 } elseif (
$conf->db->type ==
'mssql') {
565 $databasefortest =
'master';
573 print
'<div class="error">'.$db->error.
'</div>';
578 if ($db->connected) {
581 if (empty($dolibarr_main_db_pass)) {
584 print $langs->trans(
"UserCreation").
' : ';
585 print $dolibarr_main_db_user;
587 print
'<td>'.$langs->trans(
"Error").
": A password for database user is mandatory.</td></tr>";
590 $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
593 if ($databasefortest ==
'mysql') {
594 if (!in_array($dolibarr_main_db_host, array(
'127.0.0.1',
'::1',
'localhost',
'localhost.local'))) {
595 $resultbis = $db->DDLCreateUser(
'%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
599 if ($result > 0 && $resultbis > 0) {
601 print $langs->trans(
"UserCreation").
' : ';
602 print $dolibarr_main_db_user;
604 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
606 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS'
607 || $db->errno() ==
'DB_ERROR_KEY_NAME_ALREADY_EXISTS'
608 || $db->errno() ==
'DB_ERROR_USER_ALREADY_EXISTS') {
611 print $langs->trans(
"UserCreation").
' : ';
612 print $dolibarr_main_db_user;
614 print
'<td>'.$langs->trans(
"LoginAlreadyExists").
'</td></tr>';
618 print $langs->trans(
"UserCreation").
' : ';
619 print $dolibarr_main_db_user;
621 print
'<td>'.$langs->trans(
"Error").
': '.$db->errno().
' '.$db->error().($db->error ?
'. '.$db->error :
'').
"</td></tr>";
629 print $langs->trans(
"UserCreation").
' : ';
630 print $dolibarr_main_db_user;
632 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
636 print
'<tr><td colspan="2"><br>';
637 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
639 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
640 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
650 if (!$error && (isset($db_create_database) && ($db_create_database ==
"1" || $db_create_database ==
"on"))) {
651 dolibarr_install_syslog(
"step1: create database: ".$dolibarr_main_db_name.
" ".$dolibarr_main_db_character_set.
" ".$dolibarr_main_db_collation.
" ".$dolibarr_main_db_user);
655 if ($newdb->connected) {
656 $result = $newdb->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_db_user);
660 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
661 print $dolibarr_main_db_name;
663 print
'<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
665 $newdb->select_db($dolibarr_main_db_name);
666 $check1 = $newdb->getDefaultCharacterSetDatabase();
667 $check2 = $newdb->getDefaultCollationDatabase();
675 print
'<tr><td colspan="2"><br>';
676 print $langs->trans(
"ErrorFailedToCreateDatabase", $dolibarr_main_db_name).
'<br>';
677 print $newdb->lasterror().
'<br>';
678 print $langs->trans(
"IfDatabaseExistsGoBackAndCheckCreate");
682 dolibarr_install_syslog(
'step1: failed to create database '.$dolibarr_main_db_name.
' '.$newdb->lasterrno().
' '.$newdb->lasterror(), LOG_ERR);
688 print $langs->trans(
"DatabaseCreation").
" (".$langs->trans(
"User").
" ".$userroot.
") : ";
689 print $dolibarr_main_db_name;
691 print
'<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
695 print
'<tr><td colspan="2"><br>';
696 print $langs->trans(
"YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
698 print $langs->trans(
"BecauseConnectionFailedParametersMayBeWrong").
'<br><br>';
699 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
714 if ($db->connected) {
717 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".
$conf->db->user.
") : ";
718 print $dolibarr_main_db_host;
720 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
724 if ($db->database_selected) {
727 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".
$conf->db->user.
") : ";
728 print $dolibarr_main_db_name;
730 print
'<img src="../theme/eldy/img/tick.png" alt="Ok">';
737 print $langs->trans(
"DatabaseConnection").
" (".$langs->trans(
"User").
" ".
$conf->db->user.
") : ";
738 print $dolibarr_main_db_name;
740 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
744 print
'<tr><td colspan="2"><br>';
745 print $langs->trans(
'CheckThatDatabasenameIsCorrect', $dolibarr_main_db_name).
'<br>';
746 print $langs->trans(
'IfAlreadyExistsCheckOption').
'<br>';
747 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
755 print $langs->trans(
"ServerConnection").
" (".$langs->trans(
"User").
" ".
$conf->db->user.
") : ";
756 print $dolibarr_main_db_host;
758 print
'<img src="../theme/eldy/img/error.png" alt="Error">';
762 print
'<tr><td colspan="2"><br>';
763 print $langs->trans(
"ErrorConnection",
$conf->db->host,
$conf->db->name,
$conf->db->user);
764 print $langs->trans(
'IfLoginDoesNotExistsCheckCreateUser').
'<br>';
765 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
778<script
type=
"text/javascript">
785 document.getElementById(
'nextbutton').style.visibility=
"hidden";
786 document.getElementById(
'pleasewait').style.visibility=
"visible";
795if ($error && isset($argv[1])) {
802pFooter($error ? 1 : 0, $setuplang,
'jsinfo', 1);
819 $fp = @fopen(
"$mainfile",
"w");
822 fwrite($fp,
'<?php'.
"\n");
823 fwrite($fp,
"// Wrapper to include main into htdocs\n");
824 fwrite($fp,
"include_once '".$main_dir.
"/main.inc.php';\n");
839 $fp = @fopen(
"$masterfile",
"w");
842 fwrite($fp,
'<?php'.
"\n");
843 fwrite($fp,
"// Wrapper to include master into htdocs\n");
844 fwrite($fp,
"include_once '".$main_dir.
"/master.inc.php';\n");
858 global
$conf, $langs;
859 global $main_url, $main_dir, $main_data_dir, $main_force_https, $main_use_alt_dir, $main_alt_dir_name, $main_db_prefix;
860 global $dolibarr_main_url_root, $dolibarr_main_document_root, $dolibarr_main_data_root, $dolibarr_main_db_host;
861 global $dolibarr_main_db_port, $dolibarr_main_db_name, $dolibarr_main_db_user, $dolibarr_main_db_pass;
862 global $dolibarr_main_db_type, $dolibarr_main_db_character_set, $dolibarr_main_db_collation, $dolibarr_main_authentication;
863 global $dolibarr_main_distrib;
864 global $db_host, $db_port, $db_name, $db_user, $db_pass, $db_type, $db_character_set, $db_collation;
865 global $conffile, $conffiletoshow, $conffiletoshowshort;
866 global $force_dolibarr_lib_NUSOAP_PATH;
867 global $force_dolibarr_lib_FPDF_PATH, $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
868 global $force_dolibarr_lib_GEOIP_PATH;
869 global $force_dolibarr_lib_ODTPHP_PATH, $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP;
870 global $force_dolibarr_js_CKEDITOR, $force_dolibarr_js_JQUERY, $force_dolibarr_js_JQUERY_UI;
871 global $force_dolibarr_font_DOL_DEFAULT_TTF, $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD;
875 $key = md5(uniqid((
string) mt_rand(),
true));
877 $fp = fopen(
"$conffile",
"w");
881 fwrite($fp,
'<?php'.
"\n");
882 fwrite($fp,
'//'.
"\n");
883 fwrite($fp,
'// File generated by Dolibarr installer '.DOL_VERSION.
' on '.
dol_print_date(
dol_now(),
'').
"\n");
884 fwrite($fp,
'//'.
"\n");
885 fwrite($fp,
'// Take a look at conf.php.example file for an example of '.$conffiletoshowshort.
' file'.
"\n");
886 fwrite($fp,
'// and explanations for all possibles parameters.'.
"\n");
887 fwrite($fp,
'//'.
"\n");
888 fwrite($fp,
'$dolibarr_main_url_root=\''.
dol_escape_php(trim($main_url), 1).
'\';
');
891 fwrite($fp, '$dolibarr_main_document_root=
"'.dol_escape_php(dol_sanitizePathName(trim($main_dir))).'";
');
894 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\
''.dol_escape_php(trim(
"/".$main_alt_dir_name), 1).
'\';
');
897 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=
"'.dol_escape_php(dol_sanitizePathName(trim($main_dir."/
".$main_alt_dir_name))).'";
');
900 fwrite($fp, '$dolibarr_main_data_root=
"'.dol_escape_php(dol_sanitizePathName(trim($main_data_dir))).'";
');
903 fwrite($fp, '$dolibarr_main_db_host=\
''.dol_escape_php(trim($db_host), 1).
'\';
');
906 fwrite($fp, '$dolibarr_main_db_port=\
''.((int) $db_port).
'\';
');
909 fwrite($fp, '$dolibarr_main_db_name=\
''.dol_escape_php(trim($db_name), 1).
'\';
');
912 fwrite($fp, '$dolibarr_main_db_prefix=\
''.dol_escape_php(trim($main_db_prefix), 1).
'\';
');
915 fwrite($fp, '$dolibarr_main_db_user=\
''.dol_escape_php(trim($db_user), 1).
'\';
');
917 fwrite($fp, '$dolibarr_main_db_pass=\
''.dol_escape_php(trim($db_pass), 1).
'\';
');
920 fwrite($fp, '$dolibarr_main_db_type=\
''.dol_escape_php(trim($db_type), 1).
'\';
');
923 fwrite($fp, '$dolibarr_main_db_character_set=\
''.dol_escape_php(trim($db_character_set), 1).
'\';
');
926 fwrite($fp, '$dolibarr_main_db_collation=\
''.dol_escape_php(trim($db_collation), 1).
'\';
');
933 fwrite($fp,
'$dolibarr_main_authentication=\'dolibarr\';');
936 fwrite($fp,
'//$dolibarr_main_demo=\'autologin,autopass\';');
939 fwrite($fp,
'// Security settings');
942 fwrite($fp,
'$dolibarr_main_prod=\'0\';');
945 fwrite($fp,
'$dolibarr_main_force_https=\''.
dol_escape_php($main_force_https, 1).
'\';
');
948 fwrite($fp, '$dolibarr_main_restrict_os_commands=\
'mariadb-dump, mariadb, mysqldump, mysql, pg_dump, pg_restore, clamdscan, clamdscan.exe\';');
951 fwrite($fp,
'$dolibarr_nocsrfcheck=\'0\';');
954 fwrite($fp,
'$dolibarr_main_instance_unique_id=\''.
dol_escape_php($key, 1).
'\';
');
957 fwrite($fp, '$dolibarr_mailing_limit_sendbyweb=\
'0\';');
959 fwrite($fp,
'$dolibarr_mailing_limit_sendbycli=\'0\';');
964 if (empty($force_dolibarr_lib_FPDF_PATH)) {
966 $force_dolibarr_lib_FPDF_PATH =
'';
970 if (empty($force_dolibarr_lib_TCPDF_PATH)) {
972 $force_dolibarr_lib_TCPDF_PATH =
'';
976 if (empty($force_dolibarr_lib_FPDI_PATH)) {
978 $force_dolibarr_lib_FPDI_PATH =
'';
982 if (empty($force_dolibarr_lib_TCPDI_PATH)) {
984 $force_dolibarr_lib_TCPDI_PATH =
'';
988 if (empty($force_dolibarr_lib_GEOIP_PATH)) {
990 $force_dolibarr_lib_GEOIP_PATH =
'';
994 if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
996 $force_dolibarr_lib_NUSOAP_PATH =
'';
1000 if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
1002 $force_dolibarr_lib_ODTPHP_PATH =
'';
1006 if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
1008 $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP =
'';
1012 if (empty($force_dolibarr_js_CKEDITOR)) {
1014 $force_dolibarr_js_CKEDITOR =
'';
1016 fwrite($fp,
'$dolibarr_js_CKEDITOR=\''.
dol_escape_php($force_dolibarr_js_CKEDITOR, 1).
'\';
');
1018 if (empty($force_dolibarr_js_JQUERY)) {
1020 $force_dolibarr_js_JQUERY =
'';
1022 fwrite($fp,
'$dolibarr_js_JQUERY=\''.
dol_escape_php($force_dolibarr_js_JQUERY, 1).
'\';
');
1024 if (empty($force_dolibarr_js_JQUERY_UI)) {
1026 $force_dolibarr_js_JQUERY_UI =
'';
1028 fwrite($fp,
'$dolibarr_js_JQUERY_UI=\''.
dol_escape_php($force_dolibarr_js_JQUERY_UI, 1).
'\';
');
1031 // Write params to overwrites default font path
1033 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
1035 $force_dolibarr_font_DOL_DEFAULT_TTF =
'';
1037 fwrite($fp,
'$dolibarr_font_DOL_DEFAULT_TTF=\''.
dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF, 1).
'\';
');
1039 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
1041 $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD =
'';
1043 fwrite($fp,
'$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.
dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD, 1).
'\';
');
1047 fwrite($fp, '$dolibarr_main_distrib=\
''.dol_escape_php(trim($dolibarr_main_distrib), 1).
'\';
');
1052 if (file_exists("$conffile")) {
1053 include $conffile; // force config reload, do not put include_once
1054 conf($dolibarr_main_document_root);
1057 print $langs->trans("SaveConfigurationFile");
1058 print ' <strong>
'.$conffile.'</strong>
';
1060 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.