step4.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 <http://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") $forcedfile="/etc/dolibarr/install.forced.php";
  37. if (@file_exists($forcedfile)) {
  38. $useforcedwizard = true;
  39. include_once $forcedfile;
  40. }
  41. dolibarr_install_syslog("- step4: entering step4.php page");
  42. $error=0;
  43. $ok = 0;
  44. /*
  45. * View
  46. */
  47. pHeader($langs->trans("AdminAccountCreation"),"step5");
  48. // Test if we can run a first install process
  49. if (! is_writable($conffile))
  50. {
  51. print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
  52. pFooter(1,$setuplang,'jscheckparam');
  53. exit;
  54. }
  55. print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/key.svg" width="20" alt="Database"> '.$langs->trans("DolibarrAdminLogin").'</h3>';
  56. print $langs->trans("LastStepDesc").'<br><br>';
  57. print '<table cellspacing="0" cellpadding="2">';
  58. $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
  59. if ($db->ok)
  60. {
  61. print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
  62. print '<input id="login" name="login" type="text" value="' . (!empty($_GET["login"]) ? GETPOST("login") : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')) . '"' . (@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '') . '></td></tr>';
  63. print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
  64. print '<input type="password" id="pass" name="pass"></td></tr>';
  65. print '<tr><td><label for="pass_verif">'.$langs->trans("PasswordAgain").' :</label></td><td>';
  66. print '<input type="password" id="pass_verif" name="pass_verif"></td></tr>';
  67. print '</table>';
  68. if (isset($_GET["error"]) && $_GET["error"] == 1)
  69. {
  70. print '<br>';
  71. print '<div class="error">'.$langs->trans("PasswordsMismatch").'</div>';
  72. $error=0; // We show button
  73. }
  74. if (isset($_GET["error"]) && $_GET["error"] == 2)
  75. {
  76. print '<br>';
  77. print '<div class="error">';
  78. print $langs->trans("PleaseTypePassword");
  79. print '</div>';
  80. $error=0; // We show button
  81. }
  82. if (isset($_GET["error"]) && $_GET["error"] == 3)
  83. {
  84. print '<br>';
  85. print '<div class="error">'.$langs->trans("PleaseTypeALogin").'</div>';
  86. $error=0; // We show button
  87. }
  88. }
  89. $ret=0;
  90. if ($error && isset($argv[1])) $ret=1;
  91. dolibarr_install_syslog("Exit ".$ret);
  92. dolibarr_install_syslog("- step4: end");
  93. pFooter($error,$setuplang);
  94. $db->close();
  95. // Return code if ran from command line
  96. if ($ret) exit($ret);