dolibarr 20.0.2
step1.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2015-2016 Raphaƫl Doursenaud <rdoursenaud@gpcsolutions.fr>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30define('DONOTLOADCONF', 1); // To avoid loading conf by file inc.php
31
32include 'inc.php';
33
34global $langs;
35
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);
39
40$langs->loadLangs(array("admin", "install", "errors"));
41
42// Dolibarr pages directory
43$main_dir = GETPOST('main_dir') ? GETPOST('main_dir') : (empty($argv[3]) ? '' : $argv[3]);
44// Directory for generated documents (invoices, orders, ecm, etc...)
45$main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : (empty($argv[4]) ? ($main_dir.'/documents') : $argv[4]);
46// Dolibarr root URL
47$main_url = GETPOST('main_url') ? GETPOST('main_url') : (empty($argv[5]) ? '' : $argv[5]);
48// Database login information
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]);
51// Database server
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]);
57$db_port = GETPOSTINT('db_port') ? GETPOSTINT('db_port') : (empty($argv[13]) ? '' : $argv[13]);
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]);
61// Force https
62$main_force_https = ((GETPOST("main_force_https", 'alpha') && (GETPOST("main_force_https", 'alpha') == "on" || GETPOST("main_force_https", 'alpha') == 1)) ? '1' : '0');
63// Use alternative directory
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)) ? '' : '//');
65// Alternative root directory name
66$main_alt_dir_name = ((GETPOST("main_alt_dir_name", 'alpha') && GETPOST("main_alt_dir_name", 'alpha') != '') ? GETPOST("main_alt_dir_name", 'alpha') : 'custom');
67
68$dolibarr_main_distrib = 'standard';
69
70session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters)
71
72// Save a flag to tell to restore input value if we go back
73$_SESSION['dol_save_pass'] = $db_pass;
74//$_SESSION['dol_save_passroot']=$passroot;
75
76// Now we load forced values from install.forced.php file.
77$useforcedwizard = false;
78$forcedfile = "./install.forced.php";
79if ($conffile == "/etc/dolibarr/conf.php") {
80 $forcedfile = "/etc/dolibarr/install.forced.php";
81}
82if (@file_exists($forcedfile)) {
83 $useforcedwizard = true;
84 include_once $forcedfile;
85 // If forced install is enabled, replace the post values. These are empty because form fields are disabled.
86 if ($force_install_noedit) {
88 if (!empty($argv[3])) {
89 $main_dir = $argv[3]; // override when executing the script in command line
90 }
91 if (!empty($force_install_main_data_root)) {
92 $main_data_dir = $force_install_main_data_root;
93 } else {
94 $main_data_dir = detect_dolibarr_main_data_root($main_dir);
95 }
96 if (!empty($argv[4])) {
97 $main_data_dir = $argv[4]; // override when executing the script in command line
98 }
100 if (!empty($argv[5])) {
101 $main_url = $argv[5]; // override when executing the script in command line
102 }
103
104 if (!empty($force_install_databaserootlogin)) {
105 $userroot = parse_database_login($force_install_databaserootlogin);
106 }
107 if (!empty($argv[6])) {
108 $userroot = $argv[6]; // override when executing the script in command line
109 }
110 if (!empty($force_install_databaserootpass)) {
111 $passroot = parse_database_pass($force_install_databaserootpass);
112 }
113 if (!empty($argv[7])) {
114 $passroot = $argv[7]; // override when executing the script in command line
115 }
116 }
117 if ($force_install_noedit == 2) {
118 if (!empty($force_install_type)) {
119 $db_type = $force_install_type;
120 }
121 if (!empty($force_install_dbserver)) {
122 $db_host = $force_install_dbserver;
123 }
124 if (!empty($force_install_database)) {
125 $db_name = $force_install_database;
126 }
127 if (!empty($force_install_databaselogin)) {
128 $db_user = $force_install_databaselogin;
129 }
130 if (!empty($force_install_databasepass)) {
131 $db_pass = $force_install_databasepass;
132 }
133 if (!empty($force_install_port)) {
134 $db_port = $force_install_port;
135 }
136 if (!empty($force_install_prefix)) {
137 $db_prefix = $force_install_prefix;
138 }
139 if (!empty($force_install_createdatabase)) {
140 $db_create_database = $force_install_createdatabase;
141 }
142 if (!empty($force_install_createuser)) {
143 $db_create_user = $force_install_createuser;
144 }
145 if (!empty($force_install_mainforcehttps)) {
146 $main_force_https = $force_install_mainforcehttps;
147 }
148 }
149
150 if (!empty($force_install_distrib)) {
151 $dolibarr_main_distrib = $force_install_distrib;
152 }
153}
154
155
156$error = 0;
157
158
159/*
160 * View
161 */
162
163dolibarr_install_syslog("--- step1: entering step1.php page");
164
165pHeader($langs->trans("DolibarrSetup").' - '.$langs->trans("ConfigurationFile"), "step2");
166
167// Test if we can run a first install process
168if (!is_writable($conffile)) {
169 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
170 pFooter(1, $setuplang, 'jscheckparam');
171 exit;
172}
173
174
175// Check parameters
176$is_sqlite = false;
177if (empty($db_type)) {
178 print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseType")).'</div>';
179 $error++;
180} else {
181 $is_sqlite = ($db_type === 'sqlite' || $db_type === 'sqlite3');
182}
183if (empty($db_host) && !$is_sqlite) {
184 print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Server")).'</div>';
185 $error++;
186}
187if (empty($db_name)) {
188 print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("DatabaseName")).'</div>';
189 $error++;
190}
191if (empty($db_user) && !$is_sqlite) {
192 print '<div class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")).'</div>';
193 $error++;
194}
195if (!empty($db_port) && !is_numeric($db_port)) {
196 print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $db_port, $langs->transnoentities("Port")).'</div>';
197 $error++;
198}
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>';
201 $error++;
202}
203
204$main_dir = dol_sanitizePathName($main_dir);
205$main_data_dir = dol_sanitizePathName($main_data_dir);
206
207if (!filter_var($main_url, FILTER_VALIDATE_URL)) {
208 print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $main_url, $langs->transnoentitiesnoconv("URLRoot")).'</div>';
209 print '<br>';
210 print $langs->trans("ErrorGoBackAndCorrectParameters");
211 $error++;
212}
213
214// Remove last / into dans main_dir
215if (substr($main_dir, dol_strlen($main_dir) - 1) == "/") {
216 $main_dir = substr($main_dir, 0, dol_strlen($main_dir) - 1);
217}
218
219// Remove last / into dans main_url
220if (!empty($main_url) && substr($main_url, dol_strlen($main_url) - 1) == "/") {
221 $main_url = substr($main_url, 0, dol_strlen($main_url) - 1);
222}
223
224if (!dol_is_dir($main_dir.'/core/db/')) {
225 print '<div class="error">'.$langs->trans("ErrorBadValueForParameter", $main_dir, $langs->transnoentitiesnoconv("WebPagesDirectory")).'</div>';
226 print '<br>';
227 //print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
228 print $langs->trans("ErrorGoBackAndCorrectParameters");
229 $error++;
230}
231
232// Test database connection
233if (!$error) {
234 $result = @include_once $main_dir."/core/db/".$db_type.'.class.php';
235 if ($result) {
236 // If we require database or user creation we need to connect as root, so we need root login credentials
237 if (!empty($db_create_database) && !$userroot) {
238 print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $db_name).'</div>';
239 print '<br>';
240 print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
241 print $langs->trans("ErrorGoBackAndCorrectParameters");
242 $error++;
243 }
244 if (!empty($db_create_user) && !$userroot) {
245 print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect", $db_user).'</div>';
246 print '<br>';
247 print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
248 print $langs->trans("ErrorGoBackAndCorrectParameters");
249 $error++;
250 }
251
252 // If we need root access
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';
260 } else {
261 $databasefortest = 'master';
262 }
263 }
264
265 $db = getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, (int) $db_port);
266
267 dol_syslog("databasefortest=".$databasefortest." connected=".json_encode($db->connected)." database_selected=".json_encode($db->database_selected), LOG_DEBUG);
268
269 if (empty($db_create_database) && $db->connected && !$db->database_selected) {
270 print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound", $db_name).'</div>';
271 print '<br>';
272 if (!$db->connected) {
273 print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
274 }
275 print $langs->trans("ErrorGoBackAndCorrectParameters");
276 $error++;
277 } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
278 // Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
279 if ($db->error == "No such file or directory") {
280 print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
281 } else {
282 print '<div class="error">'.$db->error.'</div>';
283 }
284 if (!$db->connected) {
285 print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
286 }
287 //print '<a href="#" onClick="javascript: history.back();">';
288 print $langs->trans("ErrorGoBackAndCorrectParameters");
289 //print '</a>';
290 $error++;
291 }
292 }
293
294 // If we need simple access
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);
297
298 if ($db->error) {
299 print '<div class="error">'.$db->error.'</div>';
300 if (!$db->connected) {
301 print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
302 }
303 //print '<a href="#" onClick="javascript: history.back();">';
304 print $langs->trans("ErrorGoBackAndCorrectParameters");
305 //print '</a>';
306 $error++;
307 }
308 }
309 } else {
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>';
312 //print '<a href="#" onClick="javascript: history.back();">';
313 print $langs->trans("ErrorGoBackAndCorrectParameters");
314 //print '</a>';
315 $error++;
316 }
317} else {
318 if (isset($db)) {
319 print $db->lasterror();
320 }
321 if (isset($db) && !$db->connected) {
322 print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
323 }
324 print $langs->trans("ErrorGoBackAndCorrectParameters");
325 $error++;
326}
327
328if (!$error && $db->connected) {
329 if (!empty($db_create_database)) {
330 $result = $db->select_db($db_name);
331 if ($result) {
332 print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
333 print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
334 print $langs->trans("ErrorGoBackAndCorrectParameters");
335 $error++;
336 }
337 }
338}
339
340// Define $defaultCharacterSet and $defaultDBSortingCollation
341if (!$error && $db->connected) {
342 if (!empty($db_create_database)) { // If we create database, we force default value
343 // Default values come from the database handler
344
345 $defaultCharacterSet = $db->forcecharset;
346 $defaultDBSortingCollation = $db->forcecollate;
347 } else { // If already created, we take current value
348 $defaultCharacterSet = $db->getDefaultCharacterSetDatabase();
349 $defaultDBSortingCollation = $db->getDefaultCollationDatabase();
350 }
351
352 // It seems some PHP driver mysqli does not support utf8mb3
353 if ($defaultCharacterSet == 'utf8mb3' || $defaultDBSortingCollation == 'utf8mb3_unicode_ci') {
354 $defaultCharacterSet = 'utf8';
355 $defaultDBSortingCollation = 'utf8_unicode_ci';
356 }
357 // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
358 // TODO Remove this when utf8mb4 is supported
359 if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci') {
360 $defaultCharacterSet = 'utf8';
361 $defaultDBSortingCollation = 'utf8_unicode_ci';
362 }
363
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;
368 dolibarr_install_syslog("step1: db_character_set=".$db_character_set." db_collation=".$db_collation);
369}
370
371
372// Create config file
373if (!$error && $db->connected && $action == "set") {
374 umask(0);
375 if (is_array($_POST)) {
376 foreach ($_POST as $key => $value) {
377 if (!preg_match('/^db_pass/i', $key)) {
378 dolibarr_install_syslog("step1: choice for ".$key." = ".$value);
379 }
380 }
381 }
382
383 // Show title of step
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">';
386
387 // Check parameter main_dir
388 if (!$error) {
389 if (!is_dir($main_dir)) {
390 dolibarr_install_syslog("step1: directory '".$main_dir."' is unavailable or can't be accessed");
391
392 print "<tr><td>";
393 print $langs->trans("ErrorDirDoesNotExists", $main_dir).'<br>';
394 print $langs->trans("ErrorWrongValueForParameter", $langs->transnoentitiesnoconv("WebPagesDirectory")).'<br>';
395 print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
396 print '</td><td>';
397 print $langs->trans("Error");
398 print "</td></tr>";
399 $error++;
400 }
401 }
402
403 if (!$error) {
404 dolibarr_install_syslog("step1: directory '".$main_dir."' exists");
405 }
406
407
408 // Create subdirectory main_data_dir
409 if (!$error) {
410 // Create directory for documents
411 if (!is_dir($main_data_dir)) {
412 dol_mkdir($main_data_dir);
413 }
414
415 if (!is_dir($main_data_dir)) {
416 print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
417 print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
418 print '</td><td>';
419 print '<span class="error">'.$langs->trans("Error").'</span>';
420 print "</td></tr>";
421 print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
422 $error++;
423 } else {
424 // Create .htaccess file in document directory
425 $pathhtaccess = $main_data_dir.'/.htaccess';
426 if (!file_exists($pathhtaccess)) {
427 dolibarr_install_syslog("step1: .htaccess file did not exist, we created it in '".$main_data_dir."'");
428 $handlehtaccess = @fopen($pathhtaccess, 'w');
429 if ($handlehtaccess) {
430 fwrite($handlehtaccess, 'Order allow,deny'."\n");
431 fwrite($handlehtaccess, 'Deny from all'."\n");
432
433 fclose($handlehtaccess);
434 dolibarr_install_syslog("step1: .htaccess file created");
435 }
436 }
437
438 // Documents are stored above the web pages root to prevent being downloaded without authentication
439 $dir = array();
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";
448
449 // Loop on each directory of dir [] to create them if they do not exist
450 $num = count($dir);
451 for ($i = 0; $i < $num; $i++) {
452 if (is_dir($dir[$i])) {
453 dolibarr_install_syslog("step1: directory '".$dir[$i]."' exists");
454 } else {
455 if (dol_mkdir($dir[$i]) < 0) {
456 print "<tr><td>";
457 print "Failed to create directory: ".$dir[$i];
458 print '</td><td>';
459 print $langs->trans("Error");
460 print "</td></tr>";
461 $error++;
462 } else {
463 dolibarr_install_syslog("step1: directory '".$dir[$i]."' created");
464 }
465 }
466 }
467
468 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
469
470 // Copy directory medias
471 $srcroot = $main_dir.'/install/medias';
472 $destroot = $main_data_dir.'/medias';
473 dolCopyDir($srcroot, $destroot, 0, 0);
474
475 if ($error) {
476 print "<tr><td>".$langs->trans("ErrorDirDoesNotExists", $main_data_dir);
477 print ' '.$langs->trans("YouMustCreateItAndAllowServerToWrite");
478 print '</td><td>';
479 print '<span class="error">'.$langs->trans("Error").'</span>';
480 print "</td></tr>";
481 print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
482 } else {
483 //ODT templates
484 $srcroot = $main_dir.'/install/doctemplates';
485 $destroot = $main_data_dir.'/doctemplates';
486 $docs = array(
487 'contracts' => 'contract',
488 'invoices' => 'invoice',
489 'orders' => 'order',
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',
498 'users' => 'user',
499 );
500 foreach ($docs as $cursordir => $cursorfile) {
501 $src = $srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
502 $dirodt = $destroot.'/'.$cursordir;
503 $dest = $dirodt.'/template_'.$cursorfile.'.odt';
504
505 dol_mkdir($dirodt);
506 $result = dol_copy($src, $dest, 0, 0);
507 if ($result < 0) {
508 print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile', $src, $dest).'</td></tr>';
509 }
510 }
511 }
512 }
513 }
514
515 // Table prefix
516 $main_db_prefix = (!empty($db_prefix) ? $db_prefix : 'llx_');
517
518 // Write conf file on disk
519 if (!$error) {
520 // Save old conf file on disk
521 if (file_exists("$conffile")) {
522 // We must ignore errors as an existing old file may already exist and not be replaceable or
523 // the installer (like for ubuntu) may not have permission to create another file than conf.php.
524 // Also no other process must be able to read file or we expose the new file, so content with password.
525 @dol_copy($conffile, $conffile.'.old', '0400');
526 }
527
528 $error += write_conf_file($conffile);
529 }
530
531 // Create database and admin user database
532 if (!$error) {
533 // We reload configuration file
534 conf($dolibarr_main_document_root);
535
536 print '<tr><td>';
537 print $langs->trans("ConfFileReload");
538 print '</td>';
539 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
540
541 // Create database user if requested
542 if (isset($db_create_user) && ($db_create_user == "1" || $db_create_user == "on")) {
543 dolibarr_install_syslog("step1: create database user: ".$dolibarr_main_db_user);
544
545 //print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
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';
553 }
554
555 // Check database connection
556
557 $db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, (int) $conf->db->port);
558
559 if ($db->error) {
560 print '<div class="error">'.$db->error.'</div>';
561 $error++;
562 }
563
564 if (!$error) {
565 if ($db->connected) {
566 $resultbis = 1;
567
568 if (empty($dolibarr_main_db_pass)) {
569 dolibarr_install_syslog("step1: failed to create user, password is empty", LOG_ERR);
570 print '<tr><td>';
571 print $langs->trans("UserCreation").' : ';
572 print $dolibarr_main_db_user;
573 print '</td>';
574 print '<td>'.$langs->trans("Error").": A password for database user is mandatory.</td></tr>";
575 } else {
576 // Create user
577 $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
578
579 // Create user bis
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);
583 }
584 }
585
586 if ($result > 0 && $resultbis > 0) {
587 print '<tr><td>';
588 print $langs->trans("UserCreation").' : ';
589 print $dolibarr_main_db_user;
590 print '</td>';
591 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
592 } else {
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') {
596 dolibarr_install_syslog("step1: user already exists");
597 print '<tr><td>';
598 print $langs->trans("UserCreation").' : ';
599 print $dolibarr_main_db_user;
600 print '</td>';
601 print '<td>'.$langs->trans("LoginAlreadyExists").'</td></tr>';
602 } else {
603 dolibarr_install_syslog("step1: failed to create user", LOG_ERR);
604 print '<tr><td>';
605 print $langs->trans("UserCreation").' : ';
606 print $dolibarr_main_db_user;
607 print '</td>';
608 print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '')."</td></tr>";
609 }
610 }
611 }
612
613 $db->close();
614 } else {
615 print '<tr><td>';
616 print $langs->trans("UserCreation").' : ';
617 print $dolibarr_main_db_user;
618 print '</td>';
619 print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
620 print '</tr>';
621
622 // warning message due to connection failure
623 print '<tr><td colspan="2"><br>';
624 print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
625 print '<br>';
626 print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
627 print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
628 print '</td></tr>';
629
630 $error++;
631 }
632 }
633 } // end of user account creation
634
635
636 // If database creation was asked, we create it
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);
640 //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit;
641
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);
644
645 if ($result) {
646 print '<tr><td>';
647 print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
648 print $dolibarr_main_db_name;
649 print '</td>';
650 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
651
652 $newdb->select_db($dolibarr_main_db_name);
653 $check1 = $newdb->getDefaultCharacterSetDatabase();
654 $check2 = $newdb->getDefaultCollationDatabase();
655 dolibarr_install_syslog('step1: new database is using charset='.$check1.' collation='.$check2);
656
657 // If values differs, we save conf file again
658 //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING);
659 //if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('step1: value for collation is not the one asked for database creation', LOG_WARNING);
660 } else {
661 // warning message
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");
666 print '<br>';
667 print '</td></tr>';
668
669 dolibarr_install_syslog('step1: failed to create database '.$dolibarr_main_db_name.' '.$newdb->lasterrno().' '.$newdb->lasterror(), LOG_ERR);
670 $error++;
671 }
672 $newdb->close();
673 } else {
674 print '<tr><td>';
675 print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
676 print $dolibarr_main_db_name;
677 print '</td>';
678 print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td>';
679 print '</tr>';
680
681 // warning message
682 print '<tr><td colspan="2"><br>';
683 print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect", $dolibarr_main_db_user, $dolibarr_main_db_host, $userroot);
684 print '<br>';
685 print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
686 print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
687 print '</td></tr>';
688
689 $error++;
690 }
691 } // end of create database
692
693
694 // We test access with dolibarr database user (not admin)
695 if (!$error) {
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);
697 //print "connection de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
698
699 $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
700
701 if ($db->connected) {
702 dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." ok");
703 print "<tr><td>";
704 print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
705 print $dolibarr_main_db_host;
706 print "</td><td>";
707 print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
708 print "</td></tr>";
709
710 // server access ok, basic access ok
711 if ($db->database_selected) {
712 dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." ok");
713 print "<tr><td>";
714 print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
715 print $dolibarr_main_db_name;
716 print "</td><td>";
717 print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
718 print "</td></tr>";
719
720 $error = 0;
721 } else {
722 dolibarr_install_syslog("step1: connection to database ".$conf->db->name." by user ".$conf->db->user." failed", LOG_ERR);
723 print "<tr><td>";
724 print $langs->trans("DatabaseConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
725 print $dolibarr_main_db_name;
726 print '</td><td>';
727 print '<img src="../theme/eldy/img/error.png" alt="Error">';
728 print "</td></tr>";
729
730 // warning message
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>';
735 print '</td></tr>';
736
737 $error++;
738 }
739 } else {
740 dolibarr_install_syslog("step1: connection to server by user ".$conf->db->user." failed", LOG_ERR);
741 print "<tr><td>";
742 print $langs->trans("ServerConnection")." (".$langs->trans("User")." ".$conf->db->user.") : ";
743 print $dolibarr_main_db_host;
744 print '</td><td>';
745 print '<img src="../theme/eldy/img/error.png" alt="Error">';
746 print "</td></tr>";
747
748 // warning message
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>';
753 print '</td></tr>';
754
755 $error++;
756 }
757 }
758 }
759
760 print '</table>';
761}
762
763?>
764
765<script type="text/javascript">
766function jsinfo()
767{
768 ok=true;
769
770 //alert('<?php echo dol_escape_js($langs->transnoentities("NextStepMightLastALongTime")); ?>');
771
772 document.getElementById('nextbutton').style.visibility="hidden";
773 document.getElementById('pleasewait').style.visibility="visible";
774
775 return ok;
776}
777</script>
778
779<?php
780
781$ret = 0;
782if ($error && isset($argv[1])) {
783 $ret = 1;
784}
785dolibarr_install_syslog("Exit ".$ret);
786
787dolibarr_install_syslog("--- step1: end");
788
789pFooter($error ? 1 : 0, $setuplang, 'jsinfo', 1);
790
791// Return code if ran from command line
792if ($ret) {
793 exit($ret);
794}
795
796
804function write_main_file($mainfile, $main_dir)
805{
806 $fp = @fopen("$mainfile", "w");
807 if ($fp) {
808 clearstatcache();
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");
812 fclose($fp);
813 }
814}
815
816
824function write_master_file($masterfile, $main_dir)
825{
826 $fp = @fopen("$masterfile", "w");
827 if ($fp) {
828 clearstatcache();
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");
832 fclose($fp);
833 }
834}
835
836
843function write_conf_file($conffile)
844{
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;
859
860 $error = 0;
861
862 $key = md5(uniqid((string) mt_rand(), true)); // Generate random hash
863
864 $fp = fopen("$conffile", "w");
865 if ($fp) {
866 clearstatcache();
867
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");
875
876 fwrite($fp, '$dolibarr_main_url_root=\''.dol_escape_php(trim($main_url), 1).'\';');
877 fwrite($fp, "\n");
878
879 fwrite($fp, '$dolibarr_main_document_root="'.dol_escape_php(dol_sanitizePathName(trim($main_dir))).'";');
880 fwrite($fp, "\n");
881
882 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.dol_escape_php(trim("/".$main_alt_dir_name), 1).'\';');
883 fwrite($fp, "\n");
884
885 fwrite($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt="'.dol_escape_php(dol_sanitizePathName(trim($main_dir."/".$main_alt_dir_name))).'";');
886 fwrite($fp, "\n");
887
888 fwrite($fp, '$dolibarr_main_data_root="'.dol_escape_php(dol_sanitizePathName(trim($main_data_dir))).'";');
889 fwrite($fp, "\n");
890
891 fwrite($fp, '$dolibarr_main_db_host=\''.dol_escape_php(trim($db_host), 1).'\';');
892 fwrite($fp, "\n");
893
894 fwrite($fp, '$dolibarr_main_db_port=\''.((int) $db_port).'\';');
895 fwrite($fp, "\n");
896
897 fwrite($fp, '$dolibarr_main_db_name=\''.dol_escape_php(trim($db_name), 1).'\';');
898 fwrite($fp, "\n");
899
900 fwrite($fp, '$dolibarr_main_db_prefix=\''.dol_escape_php(trim($main_db_prefix), 1).'\';');
901 fwrite($fp, "\n");
902
903 fwrite($fp, '$dolibarr_main_db_user=\''.dol_escape_php(trim($db_user), 1).'\';');
904 fwrite($fp, "\n");
905 fwrite($fp, '$dolibarr_main_db_pass=\''.dol_escape_php(trim($db_pass), 1).'\';');
906 fwrite($fp, "\n");
907
908 fwrite($fp, '$dolibarr_main_db_type=\''.dol_escape_php(trim($db_type), 1).'\';');
909 fwrite($fp, "\n");
910
911 fwrite($fp, '$dolibarr_main_db_character_set=\''.dol_escape_php(trim($db_character_set), 1).'\';');
912 fwrite($fp, "\n");
913
914 fwrite($fp, '$dolibarr_main_db_collation=\''.dol_escape_php(trim($db_collation), 1).'\';');
915 fwrite($fp, "\n");
916
917 // Authentication
918 fwrite($fp, '// Authentication settings');
919 fwrite($fp, "\n");
920
921 fwrite($fp, '$dolibarr_main_authentication=\'dolibarr\';');
922 fwrite($fp, "\n\n");
923
924 fwrite($fp, '//$dolibarr_main_demo=\'autologin,autopass\';');
925 fwrite($fp, "\n");
926
927 fwrite($fp, '// Security settings');
928 fwrite($fp, "\n");
929
930 fwrite($fp, '$dolibarr_main_prod=\'0\';');
931 fwrite($fp, "\n");
932
933 fwrite($fp, '$dolibarr_main_force_https=\''.dol_escape_php($main_force_https, 1).'\';');
934 fwrite($fp, "\n");
935
936 fwrite($fp, '$dolibarr_main_restrict_os_commands=\'mariadb-dump, mariadb, mysqldump, mysql, pg_dump, pg_restore, clamdscan, clamdscan.exe\';');
937 fwrite($fp, "\n");
938
939 fwrite($fp, '$dolibarr_nocsrfcheck=\'0\';');
940 fwrite($fp, "\n");
941
942 fwrite($fp, '$dolibarr_main_instance_unique_id=\''.dol_escape_php($key, 1).'\';');
943 fwrite($fp, "\n");
944
945 fwrite($fp, '$dolibarr_mailing_limit_sendbyweb=\'0\';');
946 fwrite($fp, "\n");
947 fwrite($fp, '$dolibarr_mailing_limit_sendbycli=\'0\';');
948 fwrite($fp, "\n");
949
950 // Write params to overwrites default lib path
951 fwrite($fp, "\n");
952 if (empty($force_dolibarr_lib_FPDF_PATH)) {
953 fwrite($fp, '//');
954 $force_dolibarr_lib_FPDF_PATH = '';
955 }
956 fwrite($fp, '$dolibarr_lib_FPDF_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_FPDF_PATH)).'";');
957 fwrite($fp, "\n");
958 if (empty($force_dolibarr_lib_TCPDF_PATH)) {
959 fwrite($fp, '//');
960 $force_dolibarr_lib_TCPDF_PATH = '';
961 }
962 fwrite($fp, '$dolibarr_lib_TCPDF_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_TCPDF_PATH)).'";');
963 fwrite($fp, "\n");
964 if (empty($force_dolibarr_lib_FPDI_PATH)) {
965 fwrite($fp, '//');
966 $force_dolibarr_lib_FPDI_PATH = '';
967 }
968 fwrite($fp, '$dolibarr_lib_FPDI_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_FPDI_PATH)).'";');
969 fwrite($fp, "\n");
970 if (empty($force_dolibarr_lib_TCPDI_PATH)) {
971 fwrite($fp, '//');
972 $force_dolibarr_lib_TCPDI_PATH = '';
973 }
974 fwrite($fp, '$dolibarr_lib_TCPDI_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_TCPDI_PATH)).'";');
975 fwrite($fp, "\n");
976 if (empty($force_dolibarr_lib_GEOIP_PATH)) {
977 fwrite($fp, '//');
978 $force_dolibarr_lib_GEOIP_PATH = '';
979 }
980 fwrite($fp, '$dolibarr_lib_GEOIP_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_GEOIP_PATH)).'";');
981 fwrite($fp, "\n");
982 if (empty($force_dolibarr_lib_NUSOAP_PATH)) {
983 fwrite($fp, '//');
984 $force_dolibarr_lib_NUSOAP_PATH = '';
985 }
986 fwrite($fp, '$dolibarr_lib_NUSOAP_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_NUSOAP_PATH)).'";');
987 fwrite($fp, "\n");
988 if (empty($force_dolibarr_lib_ODTPHP_PATH)) {
989 fwrite($fp, '//');
990 $force_dolibarr_lib_ODTPHP_PATH = '';
991 }
992 fwrite($fp, '$dolibarr_lib_ODTPHP_PATH="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_ODTPHP_PATH)).'";');
993 fwrite($fp, "\n");
994 if (empty($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)) {
995 fwrite($fp, '//');
996 $force_dolibarr_lib_ODTPHP_PATHTOPCLZIP = '';
997 }
998 fwrite($fp, '$dolibarr_lib_ODTPHP_PATHTOPCLZIP="'.dol_escape_php(dol_sanitizePathName($force_dolibarr_lib_ODTPHP_PATHTOPCLZIP)).'";');
999 fwrite($fp, "\n");
1000 if (empty($force_dolibarr_js_CKEDITOR)) {
1001 fwrite($fp, '//');
1002 $force_dolibarr_js_CKEDITOR = '';
1003 }
1004 fwrite($fp, '$dolibarr_js_CKEDITOR=\''.dol_escape_php($force_dolibarr_js_CKEDITOR, 1).'\';');
1005 fwrite($fp, "\n");
1006 if (empty($force_dolibarr_js_JQUERY)) {
1007 fwrite($fp, '//');
1008 $force_dolibarr_js_JQUERY = '';
1009 }
1010 fwrite($fp, '$dolibarr_js_JQUERY=\''.dol_escape_php($force_dolibarr_js_JQUERY, 1).'\';');
1011 fwrite($fp, "\n");
1012 if (empty($force_dolibarr_js_JQUERY_UI)) {
1013 fwrite($fp, '//');
1014 $force_dolibarr_js_JQUERY_UI = '';
1015 }
1016 fwrite($fp, '$dolibarr_js_JQUERY_UI=\''.dol_escape_php($force_dolibarr_js_JQUERY_UI, 1).'\';');
1017 fwrite($fp, "\n");
1018
1019 // Write params to overwrites default font path
1020 fwrite($fp, "\n");
1021 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF)) {
1022 fwrite($fp, '//');
1023 $force_dolibarr_font_DOL_DEFAULT_TTF = '';
1024 }
1025 fwrite($fp, '$dolibarr_font_DOL_DEFAULT_TTF=\''.dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF, 1).'\';');
1026 fwrite($fp, "\n");
1027 if (empty($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD)) {
1028 fwrite($fp, '//');
1029 $force_dolibarr_font_DOL_DEFAULT_TTF_BOLD = '';
1030 }
1031 fwrite($fp, '$dolibarr_font_DOL_DEFAULT_TTF_BOLD=\''.dol_escape_php($force_dolibarr_font_DOL_DEFAULT_TTF_BOLD, 1).'\';');
1032 fwrite($fp, "\n");
1033
1034 // Other
1035 fwrite($fp, '$dolibarr_main_distrib=\''.dol_escape_php(trim($dolibarr_main_distrib), 1).'\';');
1036 fwrite($fp, "\n");
1037
1038 fclose($fp);
1039
1040 if (file_exists("$conffile")) {
1041 include $conffile; // force config reload, do not put include_once
1042 conf($dolibarr_main_document_root);
1043
1044 print "<tr><td>";
1045 print $langs->trans("SaveConfigurationFile");
1046 print ' <strong>'.$conffile.'</strong>';
1047 print "</td><td>";
1048 print '<img src="../theme/eldy/img/tick.png" alt="Ok">';
1049 print "</td></tr>";
1050 } else {
1051 $error++;
1052 }
1053 }
1054
1055 return $error;
1056}
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)
Definition inc.php:420
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
Definition inc.php:535
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
Definition inc.php:729
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:628
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
Definition inc.php:774
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
Definition inc.php:785
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:692
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
Definition inc.php:741
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
Definition inc.php:705
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
if( $ret) write_main_file($mainfile, $main_dir)
Create main file.
Definition step1.php:804
write_conf_file($conffile)
Save configuration file.
Definition step1.php:843
write_master_file($masterfile, $main_dir)
Create master file.
Definition step1.php:824