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