fileconf.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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@capnetworks.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/install/fileconf.php
  24. * \ingroup install
  25. * \brief Ask all informations required to build Dolibarr htdocs/conf/conf.php file (will be wrote on disk on next page)
  26. */
  27. include_once 'inc.php';
  28. $err=0;
  29. $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):(isset($_GET["lang"])?$_GET["lang"]:'auto');
  30. $langs->setDefaultLang($setuplang);
  31. $langs->load("install");
  32. $langs->load("errors");
  33. dolibarr_install_syslog("--- fileconf: entering fileconf.php page");
  34. // You can force preselected values of the config step of Dolibarr by adding a file
  35. // install.forced.php into directory htdocs/install (This is the case with some wizard
  36. // installer like DoliWamp, DoliMamp or DoliBuntu).
  37. // We first init "forced values" to nothing.
  38. if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block var specific to distrib, 2 to block all technical parameters
  39. if (! isset($force_install_type)) $force_install_type='';
  40. if (! isset($force_install_dbserver)) $force_install_dbserver='';
  41. if (! isset($force_install_port)) $force_install_port='';
  42. if (! isset($force_install_database)) $force_install_database='';
  43. if (! isset($force_install_prefix)) $force_install_prefix='';
  44. if (! isset($force_install_createdatabase)) $force_install_createdatabase='';
  45. if (! isset($force_install_databaselogin)) $force_install_databaselogin='';
  46. if (! isset($force_install_databasepass)) $force_install_databasepass='';
  47. if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin='';
  48. if (! isset($force_install_databaserootpass)) $force_install_databaserootpass='';
  49. // Now we load forced value from install.forced.php file.
  50. $useforcedwizard=false;
  51. $forcedfile="./install.forced.php";
  52. if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php
  53. if (@file_exists($forcedfile)) {
  54. $useforcedwizard=true; include_once $forcedfile;
  55. }
  56. //$force_install_message='This is the message';
  57. //$force_install_noedit=1;
  58. /*
  59. * View
  60. */
  61. session_start(); // To be able to keep info into session (used for not loosing pass during navigation. pass must not transit throug parmaeters)
  62. pHeader($langs->trans("ConfigurationFile"),"step1","set","",(empty($force_dolibarr_js_JQUERY)?'':$force_dolibarr_js_JQUERY.'/'));
  63. // Test if we can run a first install process
  64. if (! is_writable($conffile))
  65. {
  66. print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
  67. dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING);
  68. dolibarr_install_syslog("--- fileconf: end");
  69. pFooter(1,$setuplang,'jscheckparam');
  70. exit;
  71. }
  72. if (! empty($force_install_message))
  73. {
  74. print '<div><table><tr><td valign="middle"><img src="../theme/common/information.png" style="height:40px;"></td><td valign="middle">'.$langs->trans($force_install_message).'</td></tr></table>';
  75. /*print '<script type="text/javascript">';
  76. print ' jQuery(document).ready(function() {
  77. jQuery("#linktoshowtechnicalparam").click(function() {
  78. jQuery(".hidewhenedit").hide();
  79. jQuery(".hidewhennoedit").show();
  80. });';
  81. if ($force_install_noedit) print 'jQuery(".hidewhennoedit").hide();';
  82. print '});';
  83. print '</script>';
  84. print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">'.$langs->trans("ShowEditTechnicalParameters").'</a><br>';
  85. */
  86. }
  87. ?>
  88. <div>
  89. <table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>">
  90. <tr>
  91. <td colspan="3" class="label" align="center">
  92. <h3><?php echo $langs->trans("WebServer"); ?></h3>
  93. </td>
  94. </tr>
  95. <!-- Documents root $dolibarr_main_document_root -->
  96. <tr>
  97. <?php
  98. print '<td valign="top" class="label"><b>';
  99. print $langs->trans("WebPagesDirectory");
  100. print "</b></td>";
  101. if(! isset($dolibarr_main_url_root) || dol_strlen($dolibarr_main_url_root) == 0)
  102. {
  103. //print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
  104. // Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
  105. // ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
  106. if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
  107. {
  108. $dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
  109. if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
  110. {
  111. $dolibarr_main_document_root.="/dolibarr/htdocs";
  112. }
  113. }
  114. else
  115. {
  116. $dolibarr_main_document_root = substr($_SERVER["SCRIPT_FILENAME"],0,dol_strlen($_SERVER["SCRIPT_FILENAME"]) - 21);
  117. // Nettoyage du path propose
  118. // Gere les chemins windows avec double "\"
  119. $dolibarr_main_document_root = str_replace('\\\\','/',$dolibarr_main_document_root);
  120. // Supprime les slash ou antislash de fins
  121. $dolibarr_main_document_root = preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
  122. }
  123. }
  124. ?>
  125. <td class="label" valign="top"><?php
  126. if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_document_root.'" name="main_dir">';
  127. print '<input type="text" size="60" value="'.$dolibarr_main_document_root.'"'.(empty($force_install_noedit)?'':' disabled').' name="main_dir'.(empty($force_install_noedit)?'':'_bis').'">';
  128. ?></td>
  129. <td class="comment"><?php
  130. print $langs->trans("WithNoSlashAtTheEnd")."<br>";
  131. print $langs->trans("Examples").":<br>";
  132. ?>
  133. <ul>
  134. <li>/var/www/dolibarr/htdocs</li>
  135. <li>C:/wwwroot/dolibarr/htdocs</li>
  136. </ul>
  137. </td>
  138. </tr>
  139. <!-- Documents URL $dolibarr_main_data_root -->
  140. <tr>
  141. <td valign="top" class="label"><b> <?php print $langs->trans("DocumentsDirectory"); ?></b>
  142. </td>
  143. <?php
  144. if (empty($dolibarr_main_data_root))
  145. {
  146. // Si le repertoire documents non defini, on en propose un par defaut
  147. if (empty($force_install_main_data_root))
  148. {
  149. $dolibarr_main_data_root=preg_replace("/\/htdocs$/","",$dolibarr_main_document_root);
  150. $dolibarr_main_data_root.="/documents";
  151. }
  152. else
  153. {
  154. $dolibarr_main_data_root=$force_install_main_data_root;
  155. }
  156. }
  157. ?>
  158. <td class="label" valign="top"><?php
  159. if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_data_root.'" name="main_data_dir">';
  160. print '<input type="text" size="60" value="'.$dolibarr_main_data_root.'"'.(empty($force_install_noedit)?'':' disabled').' name="main_data_dir'.(empty($force_install_noedit)?'':'_bis').'">';
  161. ?></td>
  162. <td class="comment"><?php
  163. print $langs->trans("WithNoSlashAtTheEnd")."<br>";
  164. print $langs->trans("DirectoryRecommendation")."<br>";
  165. print $langs->trans("Examples").":<br>";
  166. ?>
  167. <ul>
  168. <li>/var/lib/dolibarr/documents</li>
  169. <li>C:/My Documents/dolibarr/</li>
  170. </ul>
  171. </td>
  172. </tr>
  173. <!-- Root URL $dolibarr_main_url_root -->
  174. <?php
  175. if (! empty($main_url)) $dolibarr_main_url_root=$main_url;
  176. if (empty($dolibarr_main_url_root))
  177. {
  178. // If defined (Ie: Apache with Linux)
  179. if (isset($_SERVER["SCRIPT_URI"])) {
  180. $dolibarr_main_url_root=$_SERVER["SCRIPT_URI"];
  181. }
  182. // If defined (Ie: Apache with Caudium)
  183. elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
  184. $dolibarr_main_url_root=$_SERVER["SERVER_URL"].$_SERVER["DOCUMENT_URI"];
  185. }
  186. // If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
  187. else
  188. {
  189. $proto='http';
  190. if (! empty($_SERVER["HTTP_HOST"])) $serverport=$_SERVER["HTTP_HOST"];
  191. else $serverport=$_SERVER["SERVER_NAME"];
  192. $dolibarr_main_url_root=$proto."://".$serverport.$_SERVER["SCRIPT_NAME"];
  193. }
  194. // Clean proposed URL
  195. $dolibarr_main_url_root = preg_replace('/\/fileconf\.php$/','',$dolibarr_main_url_root); // Remove the /fileconf.php
  196. $dolibarr_main_url_root = preg_replace('/\/$/','',$dolibarr_main_url_root); // Remove the /
  197. $dolibarr_main_url_root = preg_replace('/\/index\.php$/','',$dolibarr_main_url_root); // Remove the /index.php
  198. $dolibarr_main_url_root = preg_replace('/\/install$/','',$dolibarr_main_url_root); // Remove the /install
  199. }
  200. ?>
  201. <tr>
  202. <td valign="top" class="label"><b> <?php echo $langs->trans("URLRoot"); ?></b>
  203. </td>
  204. <td valign="top" class="label"><?php
  205. if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_url_root.'" name="main_url">';
  206. print '<input type="text" size="60" value="'.$dolibarr_main_url_root.'"'.(empty($force_install_noedit)?'':' disabled').' name="main_url'.(empty($force_install_noedit)?'':'_bis').'">';
  207. ?></td>
  208. <td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
  209. <ul>
  210. <li>http://localhost/</li>
  211. <li>http://www.myserver.com:8180/dolibarr</li>
  212. </ul>
  213. </td>
  214. </tr>
  215. <?php
  216. if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
  217. ?>
  218. <tr>
  219. <td valign="top" class="label"><?php echo $langs->trans("ForceHttps"); ?></td>
  220. <td class="label" valign="top"><input type="checkbox"
  221. name="main_force_https"
  222. <?php if (! empty($force_install_mainforcehttps)) print ' checked'; ?>></td>
  223. <td class="comment"><?php echo $langs->trans("CheckToForceHttps"); ?>
  224. </td>
  225. </tr>
  226. <?php
  227. }
  228. ?>
  229. <!-- Dolibarr database -->
  230. <tr>
  231. <td colspan="3" class="label" align="center"><br>
  232. <h3><?php echo $langs->trans("DolibarrDatabase"); ?></h3>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td class="label" valign="top"><b> <?php echo $langs->trans("DatabaseName"); ?>
  237. </b></td>
  238. <td class="label" valign="top"><input type="text" id="db_name"
  239. name="db_name"
  240. value="<?php echo (! empty($dolibarr_main_db_name))?$dolibarr_main_db_name:($force_install_database?$force_install_database:'dolibarr'); ?>"></td>
  241. <td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
  242. </tr>
  243. <?php
  244. if (!isset($dolibarr_main_db_host))
  245. {
  246. $dolibarr_main_db_host = "localhost";
  247. }
  248. ?>
  249. <tr>
  250. <!-- Driver type -->
  251. <td valign="top" class="label"><b> <?php echo $langs->trans("DriverType"); ?>
  252. </b></td>
  253. <td class="label"><?php
  254. $defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli');
  255. $modules = array();
  256. $nbok = $nbko = 0;
  257. $option='';
  258. // Scan les drivers
  259. $dir=DOL_DOCUMENT_ROOT.'/core/db';
  260. $handle=opendir($dir);
  261. if (is_resource($handle))
  262. {
  263. while (($file = readdir($handle))!==false)
  264. {
  265. if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i',$file,$reg))
  266. {
  267. $type=$reg[1];
  268. if ($type === 'DoliDB') continue; // Skip abstract class
  269. $class='DoliDB'.ucfirst($type);
  270. include_once $dir."/".$file;
  271. if ($type == 'sqlite') 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)
  272. if ($type == 'sqlite3') 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)
  273. // Version min of database
  274. $versionbasemin=explode('.',$class::VERSIONMIN);
  275. $note='('.$class::LABEL.' >= '.$class::VERSIONMIN.')';
  276. // Switch to mysql if mysqli is not present
  277. if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
  278. // Show line into list
  279. if ($type=='mysql') { $testfunction='mysql_connect'; $testclass=''; }
  280. if ($type=='mysqli') { $testfunction='mysqli_connect'; $testclass=''; }
  281. if ($type=='pgsql') { $testfunction='pg_connect'; $testclass=''; }
  282. if ($type=='mssql') { $testfunction='mssql_connect'; $testclass=''; }
  283. if ($type=='sqlite') { $testfunction=''; $testclass='PDO'; }
  284. if ($type=='sqlite3') { $testfunction=''; $testclass='SQLite3'; }
  285. $option.='<option value="'.$type.'"'.($defaultype == $type?' selected':'');
  286. if ($testfunction && ! function_exists($testfunction)) $option.=' disabled';
  287. if ($testclass && ! class_exists($testclass)) $option.=' disabled';
  288. $option.='>';
  289. $option.=$type.'&nbsp; &nbsp;';
  290. if ($note) $option.=' '.$note;
  291. // Deprecated and experimental
  292. if ($type=='mysql') $option.=' ' . $langs->trans("Deprecated");
  293. elseif ($type=='mssql') $option.=' '.$langs->trans("VersionExperimental");
  294. elseif ($type=='sqlite') $option.=' '.$langs->trans("VersionExperimental");
  295. elseif ($type=='sqlite3') $option.=' '.$langs->trans("VersionExperimental");
  296. // No available
  297. elseif (! function_exists($testfunction)) $option.=' - '.$langs->trans("FunctionNotAvailableInThisPHP");
  298. $option.='</option>';
  299. }
  300. }
  301. }
  302. if ($force_install_noedit && $force_install_type) print '<input id="db_type" type="hidden" value="'.$force_install_type.'" name="db_type">';
  303. print '<select id="db_type" name="db_type'.(empty($force_install_noedit) || empty($force_install_type)?'':'_bis').'"'.($force_install_noedit && $force_install_type?' disabled':'').'>';
  304. print $option;
  305. print '</select>';
  306. ?></td>
  307. <td class="comment"><?php echo $langs->trans("DatabaseType"); ?></td>
  308. </tr>
  309. <tr class="hidesqlite">
  310. <td valign="top" class="label"><b> <?php echo $langs->trans("Server"); ?>
  311. </b></td>
  312. <td valign="top" class="label"><input type="text"
  313. name="db_host<?php print ($force_install_noedit==2 && $force_install_dbserver)?'_bis':''; ?>"
  314. <?php if ($force_install_noedit==2 && $force_install_dbserver) print ' disabled'; ?>
  315. value="<?php print (! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:(empty($force_install_dbserver)?'localhost':$force_install_dbserver); ?>">
  316. <?php if ($force_install_noedit==2 && $force_install_dbserver) print '<input type="hidden" name="db_host" value="'.((! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:$force_install_dbserver).'">'; ?>
  317. </td>
  318. <td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
  319. </td>
  320. </tr>
  321. <tr class="hidesqlite">
  322. <td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td>
  323. <td valign="top" class="label"><input type="text" id="db_port"
  324. name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
  325. <?php if ($force_install_noedit==2 && $force_install_port) print ' disabled'; ?>
  326. value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>">
  327. <?php if ($force_install_noedit==2 && $force_install_port) print '<input type="hidden" name="db_port" value="'.((! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port).'">'; ?>
  328. </td>
  329. <td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
  330. </td>
  331. </tr>
  332. <tr class="hidesqlite">
  333. <td class="label" valign="top"><?php echo $langs->trans("DatabasePrefix"); ?>
  334. </td>
  335. <td class="label" valign="top"><input type="text" id="db_prefix"
  336. name="db_prefix"
  337. value="<?php echo (! empty($dolibarr_main_db_prefix))?$dolibarr_main_db_prefix:($force_install_prefix?$force_install_prefix:'llx_'); ?>"></td>
  338. <td class="comment"><?php echo $langs->trans("DatabasePrefix"); ?></td>
  339. </tr>
  340. <tr class="hidesqlite">
  341. <td class="label" valign="top"><?php echo $langs->trans("CreateDatabase"); ?>
  342. </td>
  343. <td class="label" valign="top"><input type="checkbox"
  344. id="db_create_database" name="db_create_database"
  345. <?php if ($force_install_createdatabase) print ' checked'; ?>></td>
  346. <td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?>
  347. </td>
  348. </tr>
  349. <tr class="hidesqlite">
  350. <td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b>
  351. </td>
  352. <td class="label" valign="top"><input type="text" id="db_user"
  353. name="db_user"
  354. value="<?php print (! empty($dolibarr_main_db_user))?$dolibarr_main_db_user:$force_install_databaselogin; ?>"></td>
  355. <td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
  356. </tr>
  357. <tr class="hidesqlite">
  358. <td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
  359. </td>
  360. <td class="label" valign="top"><input type="password" id="db_pass" autocomplete="off"
  361. name="db_pass"
  362. value="<?php
  363. //$autofill=((! empty($dolibarr_main_db_pass))?$dolibarr_main_db_pass:$force_install_databasepass);
  364. $autofill=((! empty($_SESSION['dol_save_pass']))?$_SESSION['dol_save_pass']:$force_install_databasepass);
  365. if (! empty($dolibarr_main_prod)) $autofill='';
  366. print dol_escape_htmltag($autofill);
  367. ?>"></td>
  368. <td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
  369. </tr>
  370. <tr class="hidesqlite">
  371. <td class="label" valign="top"><?php echo $langs->trans("CreateUser"); ?>
  372. </td>
  373. <td class="label" valign="top"><input type="checkbox"
  374. id="db_create_user" name="db_create_user"
  375. <?php if (! empty($force_install_createuser)) print ' checked'; ?>></td>
  376. <td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
  377. </td>
  378. </tr>
  379. <!-- Super access -->
  380. <?php
  381. $force_install_databaserootlogin=preg_replace('/__SUPERUSERLOGIN__/','root',$force_install_databaserootlogin);
  382. $force_install_databaserootpass=preg_replace('/__SUPERUSERPASSWORD__/','',$force_install_databaserootpass);
  383. ?>
  384. <tr class="hidesqlite hideroot">
  385. <td colspan="3" class="label" align="center"><br>
  386. <h3><?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
  387. </td>
  388. </tr>
  389. <tr class="hidesqlite hideroot">
  390. <td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b></td>
  391. <td class="label" valign="top"><input type="text" id="db_user_root"
  392. name="db_user_root" class="needroot"
  393. value="<?php print (! empty($db_user_root))?$db_user_root:$force_install_databaserootlogin; ?>"></td>
  394. <td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
  395. <!--
  396. <?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
  397. <ul>
  398. <li>root (Mysql)</li>
  399. <li>postgres (PostgreSql)</li>
  400. </ul>
  401. </td>
  402. -->
  403. </tr>
  404. <tr class="hidesqlite hideroot">
  405. <td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
  406. </td>
  407. <td class="label" valign="top"><input type="password" autocomplete="off"
  408. id="db_pass_root" name="db_pass_root" class="needroot"
  409. value="<?php
  410. $autofill=((! empty($db_pass_root))?$db_pass_root:$force_install_databaserootpass);
  411. if (! empty($dolibarr_main_prod)) $autofill=''; // Do not autofill password if instance is a production instance
  412. if (! empty($_SERVER["SERVER_NAME"]) && ! in_array($_SERVER["SERVER_NAME"], array('127.0.0.1', 'localhost'))) $autofill=''; // Do not autofill password for remote access
  413. print dol_escape_htmltag($autofill);
  414. ?>"></td>
  415. <td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
  416. </td>
  417. </tr>
  418. </table>
  419. </div>
  420. <script type="text/javascript">
  421. jQuery(document).ready(function() {
  422. var dbtype = jQuery("#db_type");
  423. dbtype.change(function () {
  424. if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
  425. jQuery(".hidesqlite").hide();
  426. } else {
  427. jQuery(".hidesqlite").show();
  428. }
  429. // Automatically set default database ports and admin user
  430. if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
  431. jQuery("#db_port").val(3306);
  432. jQuery("#db_user_root").val('root');
  433. } else if (dbtype.val() == 'pgsql') {
  434. jQuery("#db_port").val(5432);
  435. jQuery("#db_user_root").val('postgres');
  436. } else if (dbtype.val() == 'mssql') {
  437. jQuery("#db_port").val(1433);
  438. jQuery("#db_user_root").val('sa');
  439. }
  440. });
  441. function init_needroot()
  442. {
  443. /*alert(jQuery("#db_create_database").prop("checked")); */
  444. if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
  445. {
  446. jQuery(".hideroot").show();
  447. jQuery(".needroot").removeAttr('disabled');
  448. }
  449. else
  450. {
  451. jQuery(".hideroot").hide();
  452. jQuery(".needroot").prop('disabled', true);
  453. }
  454. }
  455. init_needroot();
  456. jQuery("#db_create_database").click(function() {
  457. init_needroot();
  458. });
  459. jQuery("#db_create_user").click(function() {
  460. init_needroot();
  461. });
  462. <?php if ($force_install_noedit && empty($force_install_databasepass)) { ?>
  463. jQuery("#db_pass").focus();
  464. <?php } ?>
  465. });
  466. function checkDatabaseName(databasename) {
  467. if (databasename.match(/[;\.]/)) { return false; }
  468. return true;
  469. }
  470. function jscheckparam()
  471. {
  472. ok=true;
  473. if (document.forminstall.main_dir.value == '')
  474. {
  475. ok=false;
  476. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>');
  477. }
  478. else if (document.forminstall.main_data_dir.value == '')
  479. {
  480. ok=false;
  481. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>');
  482. }
  483. else if (document.forminstall.main_url.value == '')
  484. {
  485. ok=false;
  486. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("URLRoot"))); ?>');
  487. }
  488. else if (document.forminstall.db_host.value == '')
  489. {
  490. ok=false;
  491. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("Server"))); ?>');
  492. }
  493. else if (document.forminstall.db_name.value == '')
  494. {
  495. ok=false;
  496. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
  497. }
  498. else if (! checkDatabaseName(document.forminstall.db_name.value))
  499. {
  500. ok=false;
  501. alert('<?php echo dol_escape_js($langs->transnoentities("ErrorSpecialCharNotAllowedForField",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
  502. }
  503. // If create database asked
  504. else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
  505. {
  506. ok=false;
  507. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
  508. }
  509. else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
  510. {
  511. ok=false;
  512. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
  513. }
  514. // If create user asked
  515. else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
  516. {
  517. ok=false;
  518. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
  519. }
  520. else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
  521. {
  522. ok=false;
  523. alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
  524. }
  525. return ok;
  526. }
  527. </script>
  528. <?php
  529. // $db->close(); Not database connexion yet
  530. dolibarr_install_syslog("--- fileconf: end");
  531. pFooter($err,$setuplang,'jscheckparam');