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