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