29 include_once
'inc.php';
30 if (file_exists($conffile)) {
31 include_once $conffile;
33 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
34 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
38 $versionfrom =
GETPOST(
"versionfrom",
'alpha', 3) ?
GETPOST(
"versionfrom",
'alpha', 3) : (empty($argv[1]) ?
'' : $argv[1]);
39 $versionto =
GETPOST(
"versionto",
'alpha', 3) ?
GETPOST(
"versionto",
'alpha', 3) : (empty($argv[2]) ?
'' : $argv[2]);
40 $setuplang =
GETPOST(
'selectlang',
'aZ09', 3) ?
GETPOST(
'selectlang',
'aZ09', 3) : (empty($argv[3]) ?
'auto' : $argv[3]);
41 $langs->setDefaultLang($setuplang);
42 $action =
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') : (empty($argv[4]) ?
'' : $argv[4]);
46 $targetversion = DOL_VERSION;
47 if (!empty($action) && preg_match(
'/upgrade/i', $action)) {
49 $tmp = explode(
'_', $action, 2);
50 if ($tmp[0] ==
'upgrade') {
51 if (!empty($tmp[1])) {
52 $targetversion = $tmp[1];
54 $targetversion = DOL_VERSION;
59 $langs->loadLangs(array(
"admin",
"install"));
61 $login =
GETPOST(
'login',
'alpha') ?
GETPOST(
'login',
'alpha') : (empty($argv[5]) ?
'' : $argv[5]);
62 $pass =
GETPOST(
'pass',
'alpha') ?
GETPOST(
'pass',
'alpha') : (empty($argv[6]) ?
'' : $argv[6]);
63 $pass_verif =
GETPOST(
'pass_verif',
'alpha') ?
GETPOST(
'pass_verif',
'alpha') : (empty($argv[7]) ?
'' : $argv[7]);
64 $force_install_lockinstall = (int) (!empty($force_install_lockinstall) ? $force_install_lockinstall : (
GETPOST(
'installlock',
'aZ09') ?
GETPOST(
'installlock',
'aZ09') : (empty($argv[8]) ?
'' : $argv[8])));
68 $useforcedwizard =
false;
69 $forcedfile =
"./install.forced.php";
70 if ($conffile ==
"/etc/dolibarr/conf.php") {
71 $forcedfile =
"/etc/dolibarr/install.forced.php";
73 if (@file_exists($forcedfile)) {
74 $useforcedwizard =
true;
75 include_once $forcedfile;
77 if ($force_install_noedit == 2) {
78 if (!empty($force_install_dolibarrlogin)) {
79 $login = $force_install_dolibarrlogin;
93 if ($action ==
"set") {
94 if ($pass <> $pass_verif) {
95 header(
"Location: step4.php?error=1&selectlang=$setuplang".(isset($login) ?
'&login='.$login :
''));
100 header(
"Location: step4.php?error=2&selectlang=$setuplang".(isset($login) ?
'&login='.$login :
''));
105 header(
"Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ?
'&login='.$login :
''));
117 pHeader($langs->trans(
"SetupEnd"),
"step5",
'set',
'',
'',
'main-inside main-inside-borderbottom');
121 if (empty($versionfrom) && empty($versionto) && !is_writable($conffile)) {
122 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
123 pFooter(1, $setuplang,
'jscheckparam');
127 if ($action ==
"set" || empty($action) || preg_match(
'/upgrade/i', $action)) {
131 if ((!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
132 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
133 if (!empty($dolibarr_main_db_pass) && preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
134 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
135 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
136 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
138 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
142 $conf->db->type = $dolibarr_main_db_type;
143 $conf->db->host = $dolibarr_main_db_host;
144 $conf->db->port = $dolibarr_main_db_port;
145 $conf->db->name = $dolibarr_main_db_name;
146 $conf->db->user = $dolibarr_main_db_user;
147 $conf->db->pass = $dolibarr_main_db_pass;
148 $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption :
'';
149 $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey :
'';
151 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
154 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
160 if ($action ==
"set") {
162 $modName =
'modUser';
163 $file = $modName.
".class.php";
165 include_once DOL_DOCUMENT_ROOT.
"/core/modules/".$file;
166 $objMod =
new $modName($db);
167 $result = $objMod->init();
169 print
"ERROR: failed to init module file = ".$file;
172 if ($db->connected) {
173 $conf->setValues($db);
175 if (defined(
'SYSLOG_FILE')) {
176 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
178 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
181 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
184 $sql =
"SELECT u.rowid, u.pass, u.pass_crypted";
185 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
186 $resql = $db->query($sql);
188 $numrows = $db->num_rows(
$resql);
191 dolibarr_set_const($db,
"DATABASE_PWD_ENCRYPTED",
"1",
'chaine', 0,
'', $conf->entity);
193 if (function_exists(
'password_hash')) {
194 dolibarr_set_const($db,
"MAIN_SECURITY_HASH_ALGO",
'password_hash',
'chaine', 0,
'', 0);
200 dolibarr_install_syslog(
'step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.
' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO);
204 $createuser =
new User($db);
206 $createuser->admin = 1;
209 $newuser =
new User($db);
210 $newuser->lastname =
'SuperAdmin';
211 $newuser->firstname =
'';
212 $newuser->login = $login;
213 $newuser->pass = $pass;
215 $newuser->entity = 0;
217 $conf->global->USER_MAIL_REQUIRED = 0;
218 $conf->global->USER_PASSWORD_GENERATED =
'';
220 $result = $newuser->create($createuser, 1);
222 print $langs->trans(
"AdminLoginCreatedSuccessfuly", $login).
"<br>";
227 print
'<br><div class="warning">'.$newuser->error.
"</div><br>";
231 setEventMessages($langs->trans(
"FailedToCreateAdminLogin").
' '.$newuser->error,
null,
'errors');
233 print
'<br><div class="error">'.$langs->trans(
"FailedToCreateAdminLogin").
': '.$newuser->error.
'</div><br><br>';
234 print $langs->trans(
"ErrorGoBackAndCorrectParameters").
'<br><br>';
242 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity) values(".$db->encrypt(
'MAIN_VERSION_FIRST_INSTALL').
", ".$db->encrypt($targetversion).
", 'chaine', 0, 'Dolibarr version when first install', 0)");
244 $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion;
254 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
" = 'MAIN_VERSION_LAST_INSTALL'");
258 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) values(".$db->encrypt(
'MAIN_VERSION_LAST_INSTALL').
", ".$db->encrypt($targetversion).
", 'chaine', 0, 'Dolibarr version when last install', 0)");
262 $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion;
264 if ($useforcedwizard) {
266 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
" = 'MAIN_REMOVE_INSTALL_WARNING'");
281 if (!empty($force_install_module)) {
282 if (!defined(
'DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) {
283 define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
286 $tmparray = explode(
',', $force_install_module);
287 foreach ($tmparray as $modtoactivate) {
288 $modtoactivatenew = preg_replace(
'/\.class\.php$/i',
'', $modtoactivate);
289 print $langs->trans(
"ActivateModule", $modtoactivatenew).
'<br>';
291 $file = $modtoactivatenew.
'.class.php';
296 if (!empty($res[
'errors'])) {
297 print
'ERROR: failed to activateModule() file='.$file;
303 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
" = 'MAIN_NOT_INSTALLED'");
311 print $langs->trans(
"ErrorFailedToConnect").
"<br>";
313 } elseif (empty($action) || preg_match(
'/upgrade/i', $action)) {
315 if ($db->connected) {
316 $conf->setValues($db);
318 if (defined(
'SYSLOG_FILE')) {
319 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
321 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
324 $tagdatabase =
false;
325 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) {
328 $mainversionlastupgradearray = preg_split(
'/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE);
329 $targetversionarray = preg_split(
'/[.-]/', $targetversion);
330 if (
versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) {
337 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
" = 'MAIN_VERSION_LAST_UPGRADE'");
341 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity) VALUES (".$db->encrypt(
'MAIN_VERSION_LAST_UPGRADE').
", ".$db->encrypt($targetversion).
", 'chaine', 0, 'Dolibarr version for last upgrade', 0)");
345 $conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion;
347 dolibarr_install_syslog(
'step5: we run an upgrade to version '.$targetversion.
' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.
'. We keep MAIN_VERSION_LAST_UPGRADE as it is.');
350 print $langs->trans(
"ErrorFailedToConnect").
"<br>";
357 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) VALUES (".$db->encrypt(
'MAIN_LANG_DEFAULT').
", ".$db->encrypt($setuplang).
", 'chaine', 0, 'Default language', 1)");
368 if ($action ==
"set") {
370 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
372 print
'<br>'.$langs->trans(
"SystemIsInstalled").
"<br>";
376 if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) {
378 $lockfile = DOL_DATA_ROOT.
'/install.lock';
379 $fp = @fopen($lockfile,
"w");
381 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
382 $force_install_lockinstall = 444;
384 fwrite($fp,
"This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.
")");
386 @chmod($lockfile, octdec($force_install_lockinstall));
390 if (empty($createlock)) {
391 print
'<div class="warning">'.$langs->trans(
"WarningRemoveInstallDir").
"</div>";
396 print $langs->trans(
"YouNeedToPersonalizeSetup").
"<br><br><br>";
398 print
'<div class="center">> <a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($login) ?
'&username='.urlencode($login) :
'').
'">';
399 print
'<span class="fas fa-external-link-alt"></span> '.$langs->trans(
"GoToSetupArea");
400 print
'</a></div><br>';
403 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.
'</span></b><br>';
404 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b><br>';
405 print $langs->trans(
"MigrationNotFinished").
'<br>';
408 print
'<div class="center"><a href="'.$dolibarr_main_url_root.
'/install/index.php">';
409 print
'<span class="fas fa-link-alt"></span> '.$langs->trans(
"GoToUpgradePage");
413 } elseif (empty($action) || preg_match(
'/upgrade/i', $action)) {
415 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
417 print
'<img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/checklist.svg" width="20" alt="Configuration"> <span class="valignmiddle">'.$langs->trans(
"SystemIsUpgraded").
"</span><br>";
421 if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) {
423 $lockfile = DOL_DATA_ROOT.
'/install.lock';
424 $fp = @fopen($lockfile,
"w");
426 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
427 $force_install_lockinstall = 444;
429 fwrite($fp,
"This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.
")");
431 @chmod($lockfile, octdec($force_install_lockinstall));
435 if (empty($createlock)) {
436 print
'<br><div class="warning">'.$langs->trans(
"WarningRemoveInstallDir").
"</div>";
441 $morehtml =
'<br><div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ?
'&username='.urlencode($login) :
'').
'">';
442 $morehtml .=
'<span class="fas fa-link-alt"></span> '.$langs->trans(
"GoToDolibarr").
'...';
443 $morehtml .=
'</a></div><br>';
446 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.
'</span></b><br>';
447 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
451 $morehtml =
'<br><div class="center"><a href="../install/index.php">';
452 $morehtml .=
'<span class="fas fa-link-alt"></span> '.$langs->trans(
"GoToUpgradePage");
453 $morehtml .=
'</a></div>';
456 dol_print_error(
'',
'step5.php: unknown choice of action='.$action.
' in create lock file seaction');
463 if ($error && isset($argv[1])) {
470 pFooter(1, $setuplang,
'', 0, $morehtml);
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
activateModule($value, $withdeps=1)
Enable a module.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.