dolibarr 19.0.4
step5.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5 * Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2015-2016 Raphaƫl Doursenaud <rdoursenaud@gpcsolutions.fr>
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 <https://www.gnu.org/licenses/>.
21 */
22
39define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
40include_once 'inc.php';
41if (file_exists($conffile)) {
42 include_once $conffile;
43}
44require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
45require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash
46require_once $dolibarr_main_document_root.'/core/lib/functions2.lib.php';
47
48global $langs;
49
50$versionfrom = GETPOST("versionfrom", 'alpha', 3) ? GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]);
51$versionto = GETPOST("versionto", 'alpha', 3) ? GETPOST("versionto", 'alpha', 3) : (empty($argv[2]) ? '' : $argv[2]);
52$setuplang = GETPOST('selectlang', 'aZ09', 3) ? GETPOST('selectlang', 'aZ09', 3) : (empty($argv[3]) ? 'auto' : $argv[3]);
53$langs->setDefaultLang($setuplang);
54$action = GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : (empty($argv[4]) ? '' : $argv[4]);
55
56// Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install
57// or MAIN_VERSION_LAST_UPGRADE for upgrade.
58$targetversion = DOL_VERSION; // If it's latest upgrade
59if (!empty($action) && preg_match('/upgrade/i', $action)) {
60 // If it's an old upgrade
61 $tmp = explode('_', $action, 2);
62 if ($tmp[0] == 'upgrade') {
63 if (!empty($tmp[1])) {
64 $targetversion = $tmp[1]; // if $action = 'upgrade_6.0.0-beta', we use '6.0.0-beta'
65 } else {
66 $targetversion = DOL_VERSION; // if $action = 'upgrade', we use DOL_VERSION
67 }
68 }
69}
70
71$langs->loadLangs(array("admin", "install"));
72
73$login = GETPOST('login', 'alpha') ? GETPOST('login', 'alpha') : (empty($argv[5]) ? '' : $argv[5]);
74$pass = GETPOST('pass', 'alpha') ? GETPOST('pass', 'alpha') : (empty($argv[6]) ? '' : $argv[6]);
75$pass_verif = GETPOST('pass_verif', 'alpha') ? GETPOST('pass_verif', 'alpha') : (empty($argv[7]) ? '' : $argv[7]);
76$force_install_lockinstall = (int) (!empty($force_install_lockinstall) ? $force_install_lockinstall : (GETPOST('installlock', 'aZ09') ? GETPOST('installlock', 'aZ09') : (empty($argv[8]) ? '' : $argv[8])));
77
78$success = 0;
79
80$useforcedwizard = false;
81$forcedfile = "./install.forced.php";
82if ($conffile == "/etc/dolibarr/conf.php") {
83 $forcedfile = "/etc/dolibarr/install.forced.php";
84}
85if (@file_exists($forcedfile)) {
86 $useforcedwizard = true;
87 include_once $forcedfile;
88 // If forced install is enabled, replace post values. These are empty because form fields are disabled.
89 if ($force_install_noedit == 2) {
90 if (!empty($force_install_dolibarrlogin)) {
91 $login = $force_install_dolibarrlogin;
92 }
93 }
94}
95
96dolibarr_install_syslog("--- step5: entering step5.php page ".$versionfrom." ".$versionto);
97
98$error = 0;
99
100/*
101 * Actions
102 */
103
104// If install, check password and password_verification used to create admin account
105if ($action == "set") {
106 if ($pass != $pass_verif) {
107 header("Location: step4.php?error=1&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
108 exit;
109 }
110
111 if (dol_strlen(trim($pass)) == 0) {
112 header("Location: step4.php?error=2&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
113 exit;
114 }
115
116 if (dol_strlen(trim($login)) == 0) {
117 header("Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
118 exit;
119 }
120}
121
122
123/*
124 * View
125 */
126
127$morehtml = '';
128
129pHeader($langs->trans("SetupEnd"), "step5", 'set', '', '', 'main-inside main-inside-borderbottom');
130print '<br>';
131
132// Test if we can run a first install process
133if (empty($versionfrom) && empty($versionto) && !is_writable($conffile)) {
134 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
135 pFooter(1, $setuplang, 'jscheckparam');
136 exit;
137}
138
139if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) {
140 $error = 0;
141
142 // If password is encoded, we decode it
143 if ((!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
144 require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
145 if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
146 $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
147 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
148 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
149 } else {
150 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
151 }
152 }
153
154 $conf->db->type = $dolibarr_main_db_type;
155 $conf->db->host = $dolibarr_main_db_host;
156 $conf->db->port = $dolibarr_main_db_port;
157 $conf->db->name = $dolibarr_main_db_name;
158 $conf->db->user = $dolibarr_main_db_user;
159 $conf->db->pass = $dolibarr_main_db_pass;
160 $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption : '';
161 $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey : '';
162
163 $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
164
165 // Create the global $hookmanager object
166 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
167 $hookmanager = new HookManager($db);
168
169 $ok = 0;
170
171 // If first install
172 if ($action == "set") {
173 // Active module user
174 $modName = 'modUser';
175 $file = $modName.".class.php";
176 dolibarr_install_syslog('step5: load module user '.DOL_DOCUMENT_ROOT."/core/modules/".$file, LOG_INFO);
177 include_once DOL_DOCUMENT_ROOT."/core/modules/".$file;
178 $objMod = new $modName($db);
179 $result = $objMod->init();
180 if (!$result) {
181 print "ERROR: failed to init module file = ".$file;
182 }
183
184 if ($db->connected) {
185 $conf->setValues($db);
186 // Reset forced setup after the setValues
187 if (defined('SYSLOG_FILE')) {
188 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
189 }
190 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
191
192 // Create admin user
193 include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
194
195 // Set default encryption to yes, generate a salt and set default encryption algorythm (but only if there is no user yet into database)
196 $sql = "SELECT u.rowid, u.pass, u.pass_crypted";
197 $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
198 $resql = $db->query($sql);
199 if ($resql) {
200 $numrows = $db->num_rows($resql);
201 if ($numrows == 0) {
202 // Define default setup for password encryption
203 dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity);
204 dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities
205 if (function_exists('password_hash')) {
206 dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'password_hash', 'chaine', 0, '', 0); // All entities
207 } else {
208 dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities
209 }
210 }
211
212 dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = ' . getDolGlobalString('DATABASE_PWD_ENCRYPTED').' MAIN_SECURITY_HASH_ALGO = ' . getDolGlobalString('MAIN_SECURITY_HASH_ALGO'), LOG_INFO);
213 }
214
215 // Create user used to create the admin user
216 $createuser = new User($db);
217 $createuser->id = 0;
218 $createuser->admin = 1;
219
220 // Set admin user
221 $newuser = new User($db);
222 $newuser->lastname = 'SuperAdmin';
223 $newuser->firstname = '';
224 $newuser->login = $login;
225 $newuser->pass = $pass;
226 $newuser->admin = 1;
227 $newuser->entity = 0;
228
229 $conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email
230 $conf->global->USER_PASSWORD_GENERATED = ''; // To not use any rule for password validation
231
232 $result = $newuser->create($createuser, 1);
233 if ($result > 0) {
234 print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."<br>";
235 $success = 1;
236 } else {
237 if ($result == -6) { //login or email already exists
238 dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING);
239 print '<br><div class="warning">'.$newuser->error."</div><br>";
240 $success = 1;
241 } else {
242 dolibarr_install_syslog('step5: FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
243 setEventMessages($langs->trans("FailedToCreateAdminLogin").' '.$newuser->error, null, 'errors');
244 //header("Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
245 print '<br><div class="error">'.$langs->trans("FailedToCreateAdminLogin").': '.$newuser->error.'</div><br><br>';
246 print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
247 }
248 }
249
250 if ($success) {
251 // Insert MAIN_VERSION_FIRST_INSTALL in a dedicated transaction. So if it fails (when first install was already done), we can do other following requests.
252 $db->begin();
253 dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to '.$targetversion, LOG_DEBUG);
254 $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)");
255 if ($resql) {
256 $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion;
257 $db->commit();
258 } else {
259 //if (! $resql) dol_print_error($db,'Error in setup program'); // We ignore errors. Key may already exists
260 $db->commit();
261 }
262
263 $db->begin();
264
265 dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
266 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_VERSION_LAST_INSTALL'");
267 if (!$resql) {
268 dol_print_error($db, 'Error in setup program');
269 }
270 $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)");
271 if (!$resql) {
272 dol_print_error($db, 'Error in setup program');
273 }
274 $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion;
275
276 if ($useforcedwizard) {
277 dolibarr_install_syslog('step5: set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
278 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_REMOVE_INSTALL_WARNING'");
279 if (!$resql) {
280 dol_print_error($db, 'Error in setup program');
281 }
282 // The install.lock file is created few lines later if version is last one or if option MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE is on
283 /* No need to enable this
284 $resql = $db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING').", ".$db->encrypt(1).", 'chaine', 1, 'Disable install warnings', 0)");
285 if (!$resql) {
286 dol_print_error($db, 'Error in setup program');
287 }
288 $conf->global->MAIN_REMOVE_INSTALL_WARNING = 1;
289 */
290 }
291
292 // List of modules to enable
293 $tmparray = array();
294
295 // If we ask to force some modules to be enabled
296 if (!empty($force_install_module)) {
297 if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) {
298 define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
299 }
300
301 $tmparray = explode(',', $force_install_module);
302 }
303
304 $modNameLoaded = array();
305
306 // Search modules dirs
307 $modulesdir[] = $dolibarr_main_document_root.'/core/modules/';
308
309 foreach ($modulesdir as $dir) {
310 // Load modules attributes in arrays (name, numero, orders) from dir directory
311 //print $dir."\n<br>";
312 dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
313 $handle = @opendir($dir);
314 if (is_resource($handle)) {
315 while (($file = readdir($handle)) !== false) {
316 if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
317 $modName = substr($file, 0, dol_strlen($file) - 10);
318 if ($modName) {
319 if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ?
320 $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
321 setEventMessages($mesg, null, 'warnings');
322 dol_syslog($mesg, LOG_ERR);
323 continue;
324 }
325
326 try {
327 $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
328 if (class_exists($modName)) {
329 $objMod = new $modName($db);
330 $modNameLoaded[$modName] = $dir;
331 if (!empty($objMod->enabled_bydefault) && !in_array($file, $tmparray)) {
332 $tmparray[] = $file;
333 }
334 }
335 } catch (Exception $e) {
336 dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
337 }
338 }
339 }
340 }
341 }
342 }
343
344 // Loop on each modules to activate it
345 if (!empty($tmparray)) {
346 foreach ($tmparray as $modtoactivate) {
347 $modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate);
348 //print $langs->trans("ActivateModule", $modtoactivatenew).'<br>';
349
350 $file = $modtoactivatenew.'.class.php';
351 dolibarr_install_syslog('step5: activate module file='.$file);
352 $res = dol_include_once("/core/modules/".$file);
353
354 $res = activateModule($modtoactivatenew, 1);
355 if (!empty($res['errors'])) {
356 print 'ERROR: failed to activateModule() file='.$file;
357 }
358 }
359 //print '<br>';
360 }
361
362 // Now delete the flag that say installation is not complete
363 dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const');
364 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_NOT_INSTALLED'");
365 if (!$resql) {
366 dol_print_error($db, 'Error in setup program');
367 }
368
369 // May fail if parameter already defined
370 dolibarr_install_syslog('step5: set the default language');
371 $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)");
372 //if (! $resql) dol_print_error($db,'Error in setup program');
373
374 $db->commit();
375 }
376 } else {
377 print $langs->trans("ErrorFailedToConnect")."<br>";
378 }
379 } elseif (empty($action) || preg_match('/upgrade/i', $action)) {
380 // If upgrade
381 if ($db->connected) {
382 $conf->setValues($db);
383 // Reset forced setup after the setValues
384 if (defined('SYSLOG_FILE')) {
385 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
386 }
387 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
388
389 // Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
390 $tagdatabase = false;
391 if (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE')) {
392 $tagdatabase = true; // We don't know what it was before, so now we consider we are version choosed.
393 } else {
394 $mainversionlastupgradearray = preg_split('/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE);
395 $targetversionarray = preg_split('/[.-]/', $targetversion);
396 if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) {
397 $tagdatabase = true;
398 }
399 }
400
401 if ($tagdatabase) {
402 dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion);
403 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_VERSION_LAST_UPGRADE'");
404 if (!$resql) {
405 dol_print_error($db, 'Error in setup program');
406 }
407 $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)");
408 if (!$resql) {
409 dol_print_error($db, 'Error in setup program');
410 }
411 $conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion;
412 } else {
413 dolibarr_install_syslog('step5: we run an upgrade to version '.$targetversion.' but database was already upgraded to ' . getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'. We keep MAIN_VERSION_LAST_UPGRADE as it is.');
414
415 // Force the delete of the flag that say installation is not complete
416 dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const after upgrade process (should not exists but this is a security)');
417 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_NOT_INSTALLED'");
418 if (!$resql) {
419 dol_print_error($db, 'Error in setup program');
420 }
421 }
422 } else {
423 print $langs->trans("ErrorFailedToConnect")."<br>";
424 }
425 } else {
426 dol_print_error('', 'step5.php: unknown choice of action');
427 }
428
429 $db->close();
430}
431
432
433
434// Create lock file
435
436// If first install
437if ($action == "set") {
438 if ($success) {
439 if (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
440 // Install is finished (database is on same version than files)
441 print '<br>'.$langs->trans("SystemIsInstalled")."<br>";
442
443 // Create install.lock file
444 // No need for the moment to create it automatically, creation by web assistant means permissions are given
445 // to the web user, it is better to show a warning to say to create it manually with correct user/permission (not erasable by a web process)
446 $createlock = 0;
447 if (!empty($force_install_lockinstall) || getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE')) {
448 // Install is finished, we create the "install.lock" file, so install won't be possible anymore.
449 // TODO Upgrade will be still be possible if a file "upgrade.unlock" is present
450 $lockfile = DOL_DATA_ROOT.'/install.lock';
451 $fp = @fopen($lockfile, "w");
452 if ($fp) {
453 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
454 $force_install_lockinstall = '444'; // For backward compatibility
455 }
456 fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")");
457 fclose($fp);
458 dolChmod($lockfile, $force_install_lockinstall);
459
460 $createlock = 1;
461 }
462 }
463 if (empty($createlock)) {
464 print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
465 }
466
467 print "<br>";
468
469 print $langs->trans("YouNeedToPersonalizeSetup")."<br><br><br>";
470
471 print '<div class="center">&gt; <a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($login) ? '&username='.urlencode($login) : '').'">';
472 print '<span class="fas fa-external-link-alt"></span> '.$langs->trans("GoToSetupArea");
473 print '</a></div><br>';
474 } else {
475 // If here MAIN_VERSION_LAST_UPGRADE is not empty
476 print $langs->trans("VersionLastUpgrade").': <b><span class="ok">' . getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'</span></b><br>';
477 print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b><br>';
478 print $langs->trans("MigrationNotFinished").'<br>';
479 print "<br>";
480
481 print '<div class="center"><a href="'.$dolibarr_main_url_root.'/install/index.php">';
482 print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
483 print '</a></div>';
484 }
485 }
486} elseif (empty($action) || preg_match('/upgrade/i', $action)) {
487 // If upgrade
488 if (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
489 // Upgrade is finished (database is on the same version than files)
490 print '<img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/checklist.svg" width="20" alt="Configuration">';
491 print ' <span class="valignmiddle">'.$langs->trans("SystemIsUpgraded")."</span><br>";
492
493 // Create install.lock file if it does not exists.
494 // Note: it should always exists. A better solution to allow upgrade will be to add an upgrade.unlock file
495 $createlock = 0;
496 if (!empty($force_install_lockinstall) || getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE')) {
497 // Upgrade is finished, we modify the lock file
498 $lockfile = DOL_DATA_ROOT.'/install.lock';
499 $fp = @fopen($lockfile, "w");
500 if ($fp) {
501 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
502 $force_install_lockinstall = '444'; // For backward compatibility
503 }
504 fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")");
505 fclose($fp);
506 dolChmod($lockfile, $force_install_lockinstall);
507
508 $createlock = 1;
509 }
510 }
511 if (empty($createlock)) {
512 print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
513 }
514
515 // Delete the upgrade.unlock file it it exists
516 $unlockupgradefile = DOL_DATA_ROOT.'/upgrade.unlock';
517 dol_delete_file($unlockupgradefile, 0, 0, 0, null, false, 0);
518
519 print "<br>";
520
521 $morehtml = '<br><div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">';
522 $morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToDolibarr").'...';
523 $morehtml .= '</a></div><br>';
524 } else {
525 // If here MAIN_VERSION_LAST_UPGRADE is not empty
526 print $langs->trans("VersionLastUpgrade").': <b><span class="ok">' . getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'</span></b><br>';
527 print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b>';
528
529 print "<br>";
530
531 $morehtml = '<br><div class="center"><a href="../install/index.php">';
532 $morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
533 $morehtml .= '</a></div>';
534 }
535} else {
536 dol_print_error('', 'step5.php: unknown choice of action='.$action.' in create lock file seaction');
537}
538
539// Clear cache files
540clearstatcache();
541
542$ret = 0;
543if ($error && isset($argv[1])) {
544 $ret = 1;
545}
546dolibarr_install_syslog("Exit ".$ret);
547
548dolibarr_install_syslog("--- step5: Dolibarr setup finished");
549
550pFooter(1, $setuplang, '', 0, $morehtml);
551
552// Return code if ran from command line
553if ($ret) {
554 exit($ret);
555}
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).
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition admin.lib.php:67
Class to manage hooks.
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
Definition inc.php:516
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:605
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:666
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.