step4.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  4. * Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
  5. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/install/step4.php
  23. * \ingroup install
  24. * \brief Ask login and password of Dolibarr admin user
  25. */
  26. include_once 'inc.php';
  27. require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
  28. require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
  29. global $langs;
  30. $setuplang = GETPOST('selectlang', 'aZ09', 3) ?GETPOST('selectlang', 'aZ09', 3) : (empty($argv[1]) ? 'auto' : $argv[1]);
  31. $langs->setDefaultLang($setuplang);
  32. $langs->loadLangs(array("admin", "install"));
  33. // Now we load forced value from install.forced.php file.
  34. $useforcedwizard = false;
  35. $forcedfile = "./install.forced.php";
  36. if ($conffile == "/etc/dolibarr/conf.php") {
  37. $forcedfile = "/etc/dolibarr/install.forced.php";
  38. }
  39. if (@file_exists($forcedfile)) {
  40. $useforcedwizard = true;
  41. include_once $forcedfile;
  42. }
  43. dolibarr_install_syslog("- step4: entering step4.php page");
  44. $error = 0;
  45. $ok = 0;
  46. /*
  47. * View
  48. */
  49. pHeader($langs->trans("AdminAccountCreation"), "step5");
  50. // Test if we can run a first install process
  51. if (!is_writable($conffile)) {
  52. print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
  53. pFooter(1, $setuplang, 'jscheckparam');
  54. exit;
  55. }
  56. print '<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/key.svg" width="20" alt="Database"> '.$langs->trans("DolibarrAdminLogin").'</h3>';
  57. print $langs->trans("LastStepDesc").'<br><br>';
  58. print '<table cellspacing="0" cellpadding="2">';
  59. $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
  60. if ($db->ok) {
  61. print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
  62. print '<input id="login" name="login" type="text" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alpha') : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')).'"'.(@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '').' autofocus></td></tr>';
  63. print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
  64. print '<input type="password" id="pass" name="pass" autocomplete="new-password" minlength="8"></td></tr>';
  65. print '<tr><td><label for="pass_verif">'.$langs->trans("PasswordRetype").' :</label></td><td>';
  66. print '<input type="password" id="pass_verif" name="pass_verif" autocomplete="new-password" minlength="8"></td></tr>';
  67. print '</table>';
  68. if (isset($_GET["error"]) && $_GET["error"] == 1) {
  69. print '<br>';
  70. print '<div class="error">'.$langs->trans("PasswordsMismatch").'</div>';
  71. $error = 0; // We show button
  72. }
  73. if (isset($_GET["error"]) && $_GET["error"] == 2) {
  74. print '<br>';
  75. print '<div class="error">';
  76. print $langs->trans("PleaseTypePassword");
  77. print '</div>';
  78. $error = 0; // We show button
  79. }
  80. if (isset($_GET["error"]) && $_GET["error"] == 3) {
  81. print '<br>';
  82. print '<div class="error">'.$langs->trans("PleaseTypeALogin").'</div>';
  83. $error = 0; // We show button
  84. }
  85. }
  86. $ret = 0;
  87. if ($error && isset($argv[1])) {
  88. $ret = 1;
  89. }
  90. dolibarr_install_syslog("Exit ".$ret);
  91. dolibarr_install_syslog("- step4: end");
  92. pFooter($error, $setuplang);
  93. $db->close();
  94. // Return code if ran from command line
  95. if ($ret) {
  96. exit($ret);
  97. }