dolibarr 24.0.0-beta
fileconf.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
7 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33include_once 'inc.php';
47'
48@phan-var-force string $dolibarr_main_db_host
49@phan-var-force string $dolibarr_main_db_port
50@phan-var-force string $dolibarr_main_db_name
51@phan-var-force string $dolibarr_main_db_user
52@phan-var-force string $dolibarr_main_db_pass
53@phan-var-force string $dolibarr_main_db_encrypted_pass
54@phan-var-force string $conffile
55@phan-var-force string $conffiletoshow
56@phan-var-force ?bool $force_install_
57@phan-var-force ?string $force_install_packager
58@phan-var-force ?string $force_install_message
59@phan-var-force ?string $force_install_main_data_root
60@phan-var-force ?int<0,2> $force_install_noedit
61@phan-var-force ?string $force_install_type
62@phan-var-force ?string $force_install_dbserver
63@phan-var-force ?string $force_install_port
64@phan-var-force ?string $force_install_database
65@phan-var-force ?string $force_install_prefix
66@phan-var-force ?string $force_install_createdatabase
67@phan-var-force ?string $force_install_databaselogin
68@phan-var-force ?string $force_install_databasepass
69@phan-var-force ?string $force_install_databaserootlogin
70@phan-var-force ?string $force_install_databaserootpass
71@phan-var-force ?string $force_install_dolibarrlogin
72@phan-var-force ?string $force_install_nophpinfo
73@phan-var-force ?string $force_install_lockinstall
74@phan-var-force ?string $force_install_distrib
75@phan-var-force ?string $db_user_root
76@phan-var-force ?string $db_pass_root
77';
78
79$err = 0;
80
81$setuplang = GETPOST("selectlang", 'alpha', 3) ? GETPOST("selectlang", 'alpha', 3) : (GETPOST('lang', 'alpha', 1) ? GETPOST('lang', 'alpha', 1) : 'auto');
82$langs->setDefaultLang($setuplang);
83
84$langs->loadLangs(array("install", "errors", "admin"));
85
86dolibarr_install_syslog("- fileconf: entering fileconf.php page");
87
88// You can force preselected values of the config step of Dolibarr by adding a file
89// install.forced.php into directory htdocs/install (This is the case with some wizard
90// installer like DoliWamp, DoliMamp or DoliBuntu).
91// We first init "forced values" to nothing.
92if (!isset($force_install_distrib)) {
93 $force_install_distrib = 'undefined';
94}
95if (!isset($force_install_noedit)) {
96 $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters, 3 to block all technical parameters excepted main_url
97}
98if (!isset($force_install_type)) {
99 $force_install_type = '';
100}
101if (!isset($force_install_dbserver)) {
102 $force_install_dbserver = '';
103}
104if (!isset($force_install_port)) {
105 $force_install_port = '';
106}
107if (!isset($force_install_database)) {
108 $force_install_database = '';
109}
110if (!isset($force_install_prefix)) {
111 $force_install_prefix = '';
112}
113if (!isset($force_install_createdatabase)) {
114 $force_install_createdatabase = '';
115}
116if (!isset($force_install_databaselogin)) {
117 $force_install_databaselogin = '';
118}
119if (!isset($force_install_databasepass)) {
120 $force_install_databasepass = '';
121}
122if (!isset($force_install_databaserootlogin)) {
123 $force_install_databaserootlogin = '';
124}
125if (!isset($force_install_databaserootpass)) {
126 $force_install_databaserootpass = '';
127}
128// Now we load forced values from install.forced.php file.
129$useforcedwizard = false;
130$forcedfile = "./install.forced.php";
131if ($conffile == "/etc/dolibarr/conf.php") {
132 $forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php
133}
134if (@file_exists($forcedfile)) {
135 $useforcedwizard = true;
136 include_once $forcedfile;
137}
138
139
140
141/*
142 * View
143 */
144
145session_start(); // To be able to keep info into session (used for not losing pass during navigation. pass must not transit through parameters)
146
147pHeader($langs->trans("DolibarrSetup").' - '.$langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis');
148
149// Test if we can run a first install process
150if (!is_writable($conffile)) {
151 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
152 dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
153 dolibarr_install_syslog("- fileconf: end");
154 pFooter(1, $setuplang, 'jscheckparam');
155 exit;
156}
157
158if (!empty($force_install_distrib)) {
159 print '<!-- $force_install_distrib = '.dol_escape_htmltag($force_install_distrib).' -->';
160}
161
162if (!empty($force_install_message)) {
163 print '<div><br>'.$langs->trans($force_install_message).'</div>';
164
165 /*print '<script type="text/javascript">';
166 print ' jQuery(document).ready(function() {
167 jQuery("#linktoshowtechnicalparam").click(function() {
168 jQuery(".hidewhenedit").hide();
169 jQuery(".hidewhennoedit").show();
170 });';
171 if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();';
172 print '});';
173 print '</script>';
174
175 print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>';
176 */
177}
178
179?>
180<div>
181
182
183<table class="nobordernopadding<?php if ($force_install_noedit) {
184 print ' hidewhennoedit';
185 } ?>">
186
187 <tr>
188 <td colspan="3" class="label">
189 <h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/globe.svg" width="20" alt="webserver"> <?php echo $langs->trans("WebServer"); ?></h3>
190 </td>
191 </tr>
192
193 <!-- Documents root $dolibarr_main_document_root -->
194 <tr>
195 <td class="label"><label for="main_dir"><b><?php print $langs->trans("WebPagesDirectory"); ?></b></label></td>
196<?php
197if (empty($dolibarr_main_document_root)) {
198 $dolibarr_main_document_root = GETPOSTISSET('main_dir') ? GETPOST('main_dir') : detect_dolibarr_main_document_root();
199}
200?>
201 <td class="label">
202 <input type="text" class="minwidth300" id="main_dir"
203 name="main_dir"
204 value="<?php print $dolibarr_main_document_root ?>"
205<?php
206if (!empty($force_install_noedit)) {
207 print ' disabled';
208}
209?>
210 >
211 </td>
212 <td class="comment"><?php
213 print '<span class="opacitymedium">'.$langs->trans("WithNoSlashAtTheEnd")."</span><br>";
214 print $langs->trans("Examples").":<br>";
215 ?>
216 <ul>
217 <li>/var/www/dolibarr/htdocs</li>
218 <li>C:/wwwroot/dolibarr/htdocs</li>
219 </ul>
220 </td>
221 </tr>
222
223 <!-- Documents URL $dolibarr_main_data_root -->
224 <tr>
225 <td class="label"><label for="main_data_dir"><b><?php print $langs->trans("DocumentsDirectory"); ?></b></label></td>
226 <?php
227 if (!empty($force_install_main_data_root)) {
228 $dolibarr_main_data_root = @$force_install_main_data_root;
229 }
230 if (empty($dolibarr_main_data_root)) {
231 $dolibarr_main_data_root = GETPOSTISSET('main_data_dir') ? GETPOST('main_data_dir') : detect_dolibarr_main_data_root($dolibarr_main_document_root);
232 }
233 // Correct value if dolibarr_main_data_root contains '..'
234 if (strpos($dolibarr_main_data_root, '..') !== false) {
235 $dolibarr_main_data_root = dirname($dolibarr_main_document_root).'/documents';
236 }
237
238 ?>
239 <td class="label">
240 <input type="text"
241 class="minwidth300"
242 id="main_data_dir"
243 name="main_data_dir"
244 value="<?php print $dolibarr_main_data_root ?>"
245<?php if (!empty($force_install_noedit)) {
246 print ' disabled';
247} ?>
248 >
249 </td>
250 <td class="comment"><?php
251 print '<span class="opacitymedium">'.$langs->trans("WithNoSlashAtTheEnd")."</span><br>";
252 print $langs->trans("DirectoryRecommendation")."<br>";
253 print $langs->trans("Examples").":<br>";
254 ?>
255 <ul>
256 <li>/var/lib/dolibarr/documents</li>
257 <li>C:/My Documents/dolibarr/documents</li>
258 </ul>
259 </td>
260 </tr>
261
262 <!-- Root URL $dolibarr_main_url_root -->
263 <?php
264 if (empty($dolibarr_main_url_root)) {
265 $dolibarr_main_url_root = GETPOSTISSET('main_url') ? GETPOST('main_url') : detect_dolibarr_main_url_root();
267 }
268 ?>
269 <tr>
270 <td class="label"><label for="main_url"><b><?php echo $langs->trans("URLRoot"); ?></b></label>
271 </td>
272 <td class="label">
273 <input type="text"
274 class="minwidth300"
275 id="main_url"
276 name="main_url"
277 value="<?php print $dolibarr_main_url_root; ?>"
278<?php if (!empty($force_install_noedit) && $force_install_noedit != 3) {
279 print ' disabled';
280}
281?>
282 >
283 </td>
284 <td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
285 <ul>
286 <li>http://localhost/</li>
287 <li>http://www.myserver.com:8180/dolibarr</li>
288 <li>https://www.myvirtualfordolibarr.com/</li>
289 </ul>
290 </td>
291 </tr>
292
293 <?php
294 if (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
295 ?>
296 <tr>
297 <td class="label"><label for="main_force_https"><?php echo $langs->trans("ForceHttps"); ?></label></td>
298 <td class="label">
299 <input type="checkbox"
300 id="main_force_https"
301 name="main_force_https"
302 <?php if (!empty($force_install_mainforcehttps)) {
303 print ' checked';
304 } ?>
305 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_mainforcehttps !== null) {
306 print ' disabled';
307 } ?>
308 >
309 </td>
310 <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
311 </td>
312
313 </tr>
314 <?php
315 }
316 ?>
317
318 <!-- Dolibarr database -->
319
320 <tr>
321 <td colspan="3" class="label"><br>
322 <h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/database.svg" width="20" alt="webserver"> <?php echo $langs->trans("DolibarrDatabase"); ?></h3>
323 </td>
324 </tr>
325
326 <tr>
327 <td class="label"><label for="db_name"><b><?php echo $langs->trans("DatabaseName"); ?></b></label></td>
328 <td class="label">
329 <input type="text"
330 id="db_name"
331 name="db_name"
332 value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
333 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_database !== null) {
334 print ' disabled';
335 } ?>
336 >
337 </td>
338 <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
339 </tr>
340
341
342 <?php
343 if (!isset($dolibarr_main_db_host)) {
344 $dolibarr_main_db_host = "localhost";
345 }
346 if (!isset($dolibarr_main_db_port)) {
347 $dolibarr_main_db_port = "";
348 }
349 if (!isset($dolibarr_main_db_user)) {
350 $dolibarr_main_db_user = "";
351 }
352
353 ?>
354 <tr>
355 <!-- Driver type -->
356 <td class="label"><label for="db_type"><b><?php echo $langs->trans("DriverType"); ?></b></label></td>
357
358 <td class="label">
359 <?php
360
361 $defaultype = !empty($dolibarr_main_db_type) ? $dolibarr_main_db_type : (empty($force_install_type) ? 'mysqli' : $force_install_type);
362
363 $modules = array();
364 $nbok = $nbko = 0;
365 $option = '';
366
367 // Scan les drivers
368 $dir = DOL_DOCUMENT_ROOT.'/core/db';
369 $handle = opendir($dir);
370 if (is_resource($handle)) {
371 while (($file = readdir($handle)) !== false) {
372 if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg)) {
373 $type = $reg[1];
374 if ($type === 'DoliDB') {
375 continue; // Skip abstract class
376 }
377 $class = 'DoliDB'.ucfirst($type);
378 include_once $dir."/".$file;
379
380 if ($type == 'sqlite') {
381 continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
382 }
383 if ($type == 'sqlite3') {
384 continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported)
385 }
386
387 // Version min of database
388 $note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
389
390 // Switch to mysql if mysqli is not present
391 if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) {
392 $defaultype = 'mysql';
393 }
394
395 $testclass = '';
396 $testfunction = null;
397 // Show line into list
398 if ($type == 'mysql') {
399 $testfunction = 'mysql_connect';
400 $testclass = '';
401 }
402 if ($type == 'mysqli') {
403 $testfunction = 'mysqli_connect';
404 $testclass = '';
405 }
406 if ($type == 'pgsql') {
407 $testfunction = 'pg_connect';
408 $testclass = '';
409 }
410 if ($type == 'mssql') {
411 $testfunction = 'mssql_connect';
412 $testclass = '';
413 }
414 if ($type == 'sqlite') {
415 $testfunction = '';
416 $testclass = 'PDO';
417 }
418 if ($type == 'sqlite3') {
419 $testfunction = '';
420 $testclass = 'SQLite3';
421 }
422 $option .= '<option value="'.$type.'"'.($defaultype == $type ? ' selected' : '');
423 if ($testfunction && !function_exists($testfunction)) {
424 $option .= ' disabled';
425 }
426 if ($testclass && !class_exists($testclass)) {
427 $option .= ' disabled';
428 }
429 $option .= '>';
430 $option .= $type.'&nbsp; &nbsp;';
431 if ($note) {
432 $option .= ' '.$note;
433 }
434 // Deprecated and experimental
435 if ($type == 'mysql') {
436 $option .= ' '.$langs->trans("Deprecated");
437 } elseif ($type == 'mssql') {
438 $option .= ' '.$langs->trans("VersionExperimental");
439 } elseif ($type == 'sqlite') {
440 $option .= ' '.$langs->trans("VersionExperimental");
441 } elseif ($type == 'sqlite3') {
442 $option .= ' '.$langs->trans("VersionExperimental");
443 } elseif ($testfunction === null || !function_exists($testfunction)) {
444 // None available
445 $option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP");
446 }
447 $option .= '</option>';
448 }
449 }
450 }
451 ?>
452 <select id="db_type"
453 name="db_type"
454 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_type !== null) {
455 print ' disabled';
456 } ?>
457 >
458 <?php print $option; ?>
459 </select>
460
461 </td>
462 <td class="comment"><?php echo $langs->trans("DatabaseType"); ?></td>
463
464 </tr>
465
466 <tr class="hidesqlite">
467 <td class="label"><label for="db_host"><b><?php echo $langs->trans("DatabaseServer"); ?></b></label></td>
468 <td class="label">
469 <input type="text"
470 id="db_host"
471 name="db_host"
472 value="<?php print(!empty($force_install_dbserver) ? $force_install_dbserver : (!empty($dolibarr_main_db_host) ? $dolibarr_main_db_host : 'localhost')); ?>"
473 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_dbserver !== null) {
474 print ' disabled';
475 } ?>
476 >
477 </td>
478 <td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
479 </td>
480
481 </tr>
482
483 <tr class="hidesqlite">
484 <td class="label"><label for="db_port"><?php echo $langs->trans("Port"); ?></label></td>
485 <td class="label">
486 <input type="text" class="width75"
487 name="db_port"
488 id="db_port"
489 value="<?php print (!empty($force_install_port)) ? (int) $force_install_port : (empty($dolibarr_main_db_port) ? "" : $dolibarr_main_db_port); ?>"
490 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_port !== null) {
491 print ' disabled';
492 } ?>
493 >
494 </td>
495 <td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
496 </td>
497
498 </tr>
499
500 <tr class="hidesqlite">
501 <td class="label"><label for="db_prefix"><?php echo $langs->trans("DatabasePrefix"); ?></label></td>
502 <td class="label">
503 <input type="text"
504 id="db_prefix"
505 name="db_prefix"
506 value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
507 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_prefix !== null) {
508 print ' disabled';
509 } ?>
510 >
511 </td>
512 <td class="comment"><?php echo $langs->trans("DatabasePrefixDescription"); ?></td>
513 </tr>
514
515 <tr class="hidesqlite">
516 <td class="label"><label for="db_create_database"><?php echo $langs->trans("CreateDatabase"); ?></label></td>
517 <td class="label">
518 <input type="checkbox"
519 id="db_create_database"
520 name="db_create_database"
521 value="on"
522 <?php
523 $checked = 0;
524 if ($force_install_createdatabase) {
525 $checked = 1;
526 print ' checked';
527 } ?>
528 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createdatabase !== null) {
529 print ' disabled';
530 } ?>
531 >
532 </td>
533 <td class="comment">
534 <?php echo $langs->trans("CheckToCreateDatabase"); ?>
535 </td>
536 </tr>
537
538 <tr class="hidesqlite">
539 <td class="label"><label for="db_user"><b><?php echo $langs->trans("Login"); ?></b></label></td>
540 <td class="label">
541 <input type="text"
542 id="db_user"
543 name="db_user"
544 value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
545 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databaselogin !== null) {
546 print ' disabled';
547 } ?>
548 >
549 </td>
550 <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
551 </tr>
552
553 <tr class="hidesqlite">
554 <td class="label"><label for="db_pass"><b><?php echo $langs->trans("Password"); ?></b></label></td>
555 <td class="label">
556 <input type="password" class="text-security"
557 id="db_pass" autocomplete="off"
558 name="db_pass"
559 value="<?php
560 // If $force_install_databasepass is on, we don't want to set password, we just show '***'. Real value will be extracted from the forced install file at step1.
561 // @phan-suppress-next-line PhanParamSuspiciousOrder
562 $autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
563 if (!empty($dolibarr_main_prod) && empty($_SESSION['dol_save_pass'])) { // So value can't be found if install page still accessible
564 $autofill = '';
565 }
566 print dol_escape_htmltag($autofill);
567 ?>"
568 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_databasepass !== null) {
569 print ' disabled';
570 } ?>
571 >
572 </td>
573 <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
574 </tr>
575
576 <tr class="hidesqlite">
577 <td class="label"><label for="db_create_user"><?php echo $langs->trans("CreateUser"); ?></label></td>
578 <td class="label">
579 <input type="checkbox"
580 id="db_create_user"
581 name="db_create_user"
582 value="on"
583 <?php
584 $checked = 0;
585 if (!empty($force_install_createuser)) {
586 $checked = 1;
587 print ' checked';
588 } ?>
589 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && $force_install_createuser !== null) {
590 print ' disabled';
591 } ?>
592 >
593 </td>
594 <td class="comment">
595 <?php echo $langs->trans("CheckToCreateUser"); ?>
596 </td>
597 </tr>
598
599
600 <!-- Super access -->
601 <?php
602 $force_install_databaserootlogin = parse_database_login($force_install_databaserootlogin);
603 $force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
604 ?>
605 <tr class="hidesqlite hideroot">
606 <td colspan="3" class="label"><br>
607 <h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/shield.svg" width="20" alt="webserver"> <?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
608 </td>
609 </tr>
610
611 <tr class="hidesqlite hideroot">
612 <td class="label"><label for="db_user_root"><b><?php echo $langs->trans("Login"); ?></b></label></td>
613 <td class="label">
614 <input type="text"
615 id="db_user_root"
616 name="db_user_root"
617 class="needroot"
618 value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : (GETPOSTISSET('db_user_root') ? GETPOST('db_user_root') : (isset($db_user_root) ? $db_user_root : '')); ?>"
619 <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootlogin)) {
620 print ' disabled';
621 } ?>
622 >
623 </td>
624 <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
625 <!--
626 <?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
627 <ul>
628 <li>root (Mysql)</li>
629 <li>postgres (PostgreSql)</li>
630 </ul>
631 </td>
632 -->
633
634 </tr>
635 <tr class="hidesqlite hideroot">
636 <td class="label"><label for="db_pass_root"><b><?php echo $langs->trans("Password"); ?></b></label></td>
637 <td class="label">
638 <input type="password"
639 autocomplete="off"
640 id="db_pass_root"
641 name="db_pass_root"
642 class="needroot text-security"
643 value="<?php
644 // If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
645 // @phan-suppress-next-line PhanParamSuspiciousOrder
646 $autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : (isset($db_pass_root) ? $db_pass_root : ''));
647 if (!empty($dolibarr_main_prod)) {
648 $autofill = '';
649 }
650 // Do not autofill password if instance is a production instance
651 if (!empty($_SERVER["SERVER_NAME"]) && !in_array(
652 $_SERVER["SERVER_NAME"],
653 array('127.0.0.1', 'localhost', 'localhostgit')
654 )
655 ) {
656 $autofill = '';
657 } // Do not autofill password for remote access
658 print dol_escape_htmltag($autofill);
659 ?>"
660 <?php if ($force_install_noedit > 0 && !empty($force_install_databaserootpass)) {
661 print ' disabled'; /* May be removed by javascript*/
662 } ?>
663 >
664 </td>
665 <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
666 </td>
667 </tr>
668
669</table>
670</div>
671
672
673<script type="text/javascript">
674function init_needroot()
675{
676 console.log("init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
677 console.log(jQuery("#db_create_database").is(":checked"));
678 console.log(jQuery("#db_create_user").is(":checked"));
679
680 if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
681 {
682 console.log("init_needroot show root section");
683 jQuery(".hideroot").show();
684 <?php
685 if (empty($force_install_noedit)) { ?>
686 jQuery(".needroot").removeAttr('disabled');
687 <?php } ?>
688 }
689 else
690 {
691 console.log("init_needroot hide root section");
692 jQuery(".hideroot").hide();
693 jQuery(".needroot").prop('disabled', true);
694 }
695}
696
697function checkDatabaseName(databasename) {
698 if (databasename.match(/[;\.]/)) { return false; }
699 return true;
700}
701
702function jscheckparam()
703{
704 console.log("Click on jscheckparam");
705
706 var ok = true;
707
708 if (document.forminstall.main_dir.value == '')
709 {
710 ok=false;
711 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
712 }
713 else if (document.forminstall.main_data_dir.value == '')
714 {
715 ok=false;
716 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
717 }
718 else if (document.forminstall.main_url.value == '')
719 {
720 ok=false;
721 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("URLRoot"))); ?>');
722 }
723 else if (document.forminstall.db_host.value == '')
724 {
725 ok=false;
726 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server"))); ?>');
727 }
728 else if (document.forminstall.db_name.value == '')
729 {
730 ok=false;
731 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
732 }
733 else if (! checkDatabaseName(document.forminstall.db_name.value))
734 {
735 ok=false;
736 alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentitiesnoconv("DatabaseName"))); ?>');
737 }
738 // If create database asked
739 else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
740 {
741 ok=false;
742 alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
743 init_needroot();
744 }
745 // If create user asked
746 else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
747 {
748 ok=false;
749 alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
750 init_needroot();
751 }
752
753 return ok;
754}
755
756
757jQuery(document).ready(function() { // TODO Test $( window ).load(function() to see if the init_needroot work better after a back
758
759 var dbtype = jQuery("#db_type");
760
761 dbtype.change(function () {
762 if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
763 jQuery(".hidesqlite").hide();
764 } else {
765 jQuery(".hidesqlite").show();
766 }
767
768 // Automatically set default database ports and admin user
769 if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
770 jQuery("#db_port").val(3306);
771 jQuery("#db_user_root").val('root');
772 } else if (dbtype.val() == 'pgsql') {
773 jQuery("#db_port").val(5432);
774 jQuery("#db_user_root").val('postgres');
775 } else if (dbtype.val() == 'mssql') {
776 jQuery("#db_port").val(1433);
777 jQuery("#db_user_root").val('sa');
778 }
779
780 });
781
782 jQuery("#db_create_database").click(function() {
783 console.log("click on db_create_database");
784 init_needroot();
785 });
786 jQuery("#db_create_user").click(function() {
787 console.log("click on db_create_user");
788 init_needroot();
789 });
790 <?php if (($force_install_noedit == 2 || $force_install_noedit == 3) && empty($force_install_databasepass)) { ?>
791 jQuery("#db_pass").focus();
792 <?php } ?>
793
794 init_needroot();
795});
796</script>
797
798
799<?php
800
801// $db->close(); Not database connection yet
802
803dolibarr_install_syslog("- fileconf: end");
804
805pFooter($err, $setuplang, 'jscheckparam');
global $dolibarr_main_url_root
API class for receive files.
$conffile
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
treeview li table
No Email.
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
Definition inc.php:541
detect_dolibarr_main_data_root($dolibarr_main_document_root)
Automatically detect Dolibarr's main data root.
Definition inc.php:736
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:635
parse_database_login($force_install_databaserootlogin)
Replaces automatic database login by actual value.
Definition inc.php:780
parse_database_pass($force_install_databaserootpass)
Replaces automatic database password by actual value.
Definition inc.php:791
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:699
detect_dolibarr_main_url_root()
Automatically detect Dolibarr's main URL root.
Definition inc.php:747
detect_dolibarr_main_document_root()
Automatically detect Dolibarr's main document root.
Definition inc.php:712
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Abort invoice creation with a given error message.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133