dolibarr 20.0.0
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
139// Ensure $modulesdir is set and array
140if (!isset($modulesdir) || !is_array($modulesdir)) {
141 $modulesdir = array();
142}
143
144if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) {
145 $error = 0;
146
147 // If password is encoded, we decode it
148 if ((!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
149 require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
150 if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
151 $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
152 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
153 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially encrypted
154 } else {
155 $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
156 }
157 }
158
159 $conf->db->type = $dolibarr_main_db_type;
160 $conf->db->host = $dolibarr_main_db_host;
161 $conf->db->port = $dolibarr_main_db_port;
162 $conf->db->name = $dolibarr_main_db_name;
163 $conf->db->user = $dolibarr_main_db_user;
164 $conf->db->pass = $dolibarr_main_db_pass;
165 $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption : 0;
166 $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey : '';
167
168 $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
169
170 // Create the global $hookmanager object
171 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
172 $hookmanager = new HookManager($db);
173
174 $ok = 0;
175
176 // If first install
177 if ($action == "set") {
178 // Active module user
179 $modName = 'modUser';
180 $file = $modName.".class.php";
181 dolibarr_install_syslog('step5: load module user '.DOL_DOCUMENT_ROOT."/core/modules/".$file, LOG_INFO);
182 include_once DOL_DOCUMENT_ROOT."/core/modules/".$file;
183 $objMod = new $modName($db);
184 $result = $objMod->init();
185 if (!$result) {
186 print "ERROR: failed to init module file = ".$file;
187 }
188
189 if ($db->connected) {
190 $conf->setValues($db);
191 // Reset forced setup after the setValues
192 if (defined('SYSLOG_FILE')) {
193 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
194 }
195 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
196
197 // Create admin user
198 include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
199
200 // Set default encryption to yes, generate a salt and set default encryption algorithm (but only if there is no user yet into database)
201 $sql = "SELECT u.rowid, u.pass, u.pass_crypted";
202 $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
203 $resql = $db->query($sql);
204 if ($resql) {
205 $numrows = $db->num_rows($resql);
206 if ($numrows == 0) {
207 // Define default setup for password encryption
208 dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity);
209 dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities
210 if (function_exists('password_hash')) {
211 dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'password_hash', 'chaine', 0, '', 0); // All entities
212 } else {
213 dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities
214 }
215 }
216
217 dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = ' . getDolGlobalString('DATABASE_PWD_ENCRYPTED').' MAIN_SECURITY_HASH_ALGO = ' . getDolGlobalString('MAIN_SECURITY_HASH_ALGO'), LOG_INFO);
218 }
219
220 // Create user used to create the admin user
221 $createuser = new User($db);
222 $createuser->id = 0;
223 $createuser->admin = 1;
224
225 // Set admin user
226 $newuser = new User($db);
227 $newuser->lastname = 'SuperAdmin';
228 $newuser->firstname = '';
229 $newuser->login = $login;
230 $newuser->pass = $pass;
231 $newuser->admin = 1;
232 $newuser->entity = 0;
233
234 $conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email
235 $conf->global->USER_PASSWORD_GENERATED = ''; // To not use any rule for password validation
236
237 $result = $newuser->create($createuser, 1);
238 if ($result > 0) {
239 print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."<br>";
240 $success = 1;
241 } else {
242 if ($result == -6) { //login or email already exists
243 dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING);
244 print '<br><div class="warning">'.$newuser->error."</div><br>";
245 $success = 1;
246 } else {
247 dolibarr_install_syslog('step5: FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
248 setEventMessages($langs->trans("FailedToCreateAdminLogin").' '.$newuser->error, null, 'errors');
249 //header("Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
250 print '<br><div class="error">'.$langs->trans("FailedToCreateAdminLogin").': '.$newuser->error.'</div><br><br>';
251 print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>';
252 }
253 }
254
255 if ($success) {
256 // 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.
257 $db->begin();
258 dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to '.$targetversion, LOG_DEBUG);
259 $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)");
260 if ($resql) {
261 $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion;
262 $db->commit();
263 } else {
264 //if (! $resql) dol_print_error($db,'Error in setup program'); // We ignore errors. Key may already exists
265 $db->commit();
266 }
267
268 $db->begin();
269
270 dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
271 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_VERSION_LAST_INSTALL'");
272 if (!$resql) {
273 dol_print_error($db, 'Error in setup program');
274 }
275 $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)");
276 if (!$resql) {
277 dol_print_error($db, 'Error in setup program');
278 }
279 $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion;
280
281 if ($useforcedwizard) {
282 dolibarr_install_syslog('step5: set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
283 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_REMOVE_INSTALL_WARNING'");
284 if (!$resql) {
285 dol_print_error($db, 'Error in setup program');
286 }
287 // 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
288 /* No need to enable this
289 $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)");
290 if (!$resql) {
291 dol_print_error($db, 'Error in setup program');
292 }
293 $conf->global->MAIN_REMOVE_INSTALL_WARNING = 1;
294 */
295 }
296
297 // List of modules to enable
298 $tmparray = array();
299
300 // If we ask to force some modules to be enabled
301 if (!empty($force_install_module)) {
302 if (!defined('DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) {
303 define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
304 }
305
306 $tmparray = explode(',', $force_install_module);
307 }
308
309 $modNameLoaded = array();
310
311 // Search modules dirs
312 $modulesdir[] = $dolibarr_main_document_root.'/core/modules/';
313
314 foreach ($modulesdir as $dir) {
315 // Load modules attributes in arrays (name, numero, orders) from dir directory
316 //print $dir."\n<br>";
317 dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
318 $handle = @opendir($dir);
319 if (is_resource($handle)) {
320 while (($file = readdir($handle)) !== false) {
321 if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
322 $modName = substr($file, 0, dol_strlen($file) - 10);
323 if ($modName) {
324 if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ?
325 $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
326 setEventMessages($mesg, null, 'warnings');
327 dol_syslog($mesg, LOG_ERR);
328 continue;
329 }
330
331 try {
332 $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
333 if (class_exists($modName)) {
334 $objMod = new $modName($db);
335 $modNameLoaded[$modName] = $dir;
336 if (!empty($objMod->enabled_bydefault) && !in_array($file, $tmparray)) {
337 $tmparray[] = $file;
338 }
339 }
340 } catch (Exception $e) {
341 dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
342 }
343 }
344 }
345 }
346 }
347 }
348
349 // Loop on each modules to activate it
350 if (!empty($tmparray)) {
351 foreach ($tmparray as $modtoactivate) {
352 $modtoactivatenew = preg_replace('/\.class\.php$/i', '', $modtoactivate);
353 //print $langs->trans("ActivateModule", $modtoactivatenew).'<br>';
354
355 $file = $modtoactivatenew.'.class.php';
356 dolibarr_install_syslog('step5: activate module file='.$file);
357 $res = dol_include_once("/core/modules/".$file);
358
359 $res = activateModule($modtoactivatenew, 1);
360 if (!empty($res['errors'])) {
361 print 'ERROR: failed to activateModule() file='.$file;
362 }
363 }
364 //print '<br>';
365 }
366
367 // Now delete the flag that say installation is not complete
368 dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const');
369 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_NOT_INSTALLED'");
370 if (!$resql) {
371 dol_print_error($db, 'Error in setup program');
372 }
373
374 // May fail if parameter already defined
375 dolibarr_install_syslog('step5: set the default language');
376 $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)");
377 //if (! $resql) dol_print_error($db,'Error in setup program');
378
379 $db->commit();
380 }
381 } else {
382 print $langs->trans("ErrorFailedToConnect")."<br>";
383 }
384 } elseif (empty($action) || preg_match('/upgrade/i', $action)) {
385 // If upgrade
386 if ($db->connected) {
387 $conf->setValues($db);
388 // Reset forced setup after the setValues
389 if (defined('SYSLOG_FILE')) {
390 $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
391 }
392 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
393
394 // Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
395 $tagdatabase = false;
396 if (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE')) {
397 $tagdatabase = true; // We don't know what it was before, so now we consider we at the chosen version.
398 } else {
399 $mainversionlastupgradearray = preg_split('/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE);
400 $targetversionarray = preg_split('/[.-]/', $targetversion);
401 if (versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) {
402 $tagdatabase = true;
403 }
404 }
405
406 if ($tagdatabase) {
407 dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion);
408 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_VERSION_LAST_UPGRADE'");
409 if (!$resql) {
410 dol_print_error($db, 'Error in setup program');
411 }
412 $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)");
413 if (!$resql) {
414 dol_print_error($db, 'Error in setup program');
415 }
416 $conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion;
417 } else {
418 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.');
419
420 // Force the delete of the flag that say installation is not complete
421 dolibarr_install_syslog('step5: remove MAIN_NOT_INSTALLED const after upgrade process (should not exists but this is a security)');
422 $resql = $db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')." = 'MAIN_NOT_INSTALLED'");
423 if (!$resql) {
424 dol_print_error($db, 'Error in setup program');
425 }
426 }
427 } else {
428 print $langs->trans("ErrorFailedToConnect")."<br>";
429 }
430 } else {
431 dol_print_error(null, 'step5.php: unknown choice of action');
432 }
433
434 $db->close();
435}
436
437
438
439// Create lock file
440
441// If first install
442if ($action == "set") {
443 if ($success) {
444 if (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
445 // Install is finished (database is on same version than files)
446 print '<br>'.$langs->trans("SystemIsInstalled")."<br>";
447
448 // Create install.lock file
449 // No need for the moment to create it automatically, creation by web assistant means permissions are given
450 // 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)
451 $createlock = 0;
452 if (!empty($force_install_lockinstall) || getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE')) {
453 // Install is finished, we create the "install.lock" file, so install won't be possible anymore.
454 // TODO Upgrade will be still be possible if a file "upgrade.unlock" is present
455 $lockfile = DOL_DATA_ROOT.'/install.lock';
456 $fp = @fopen($lockfile, "w");
457 if ($fp) {
458 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
459 $force_install_lockinstall = '444'; // For backward compatibility
460 }
461 fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")");
462 fclose($fp);
463 dolChmod($lockfile, $force_install_lockinstall);
464
465 $createlock = 1;
466 }
467 }
468 if (empty($createlock)) {
469 print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
470 }
471
472 print "<br>";
473
474 print $langs->trans("YouNeedToPersonalizeSetup")."<br><br><br>";
475
476 print '<div class="center">&gt; <a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($login) ? '&username='.urlencode($login) : '').'">';
477 print '<span class="fas fa-external-link-alt"></span> '.$langs->trans("GoToSetupArea");
478 print '</a></div><br>';
479 } else {
480 // If here MAIN_VERSION_LAST_UPGRADE is not empty
481 print $langs->trans("VersionLastUpgrade").': <b><span class="ok">' . getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'</span></b><br>';
482 print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b><br>';
483 print $langs->trans("MigrationNotFinished").'<br>';
484 print "<br>";
485
486 print '<div class="center"><a href="'.$dolibarr_main_url_root.'/install/index.php">';
487 print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
488 print '</a></div>';
489 }
490 }
491} elseif (empty($action) || preg_match('/upgrade/i', $action)) {
492 // If upgrade
493 if (!getDolGlobalString('MAIN_VERSION_LAST_UPGRADE') || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
494 // Upgrade is finished (database is on the same version than files)
495 print '<img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/checklist.svg" width="20" alt="Configuration">';
496 print ' <span class="valignmiddle">'.$langs->trans("SystemIsUpgraded")."</span><br>";
497
498 // Create install.lock file if it does not exists.
499 // Note: it should always exists. A better solution to allow upgrade will be to add an upgrade.unlock file
500 $createlock = 0;
501 if (!empty($force_install_lockinstall) || getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE')) {
502 // Upgrade is finished, we modify the lock file
503 $lockfile = DOL_DATA_ROOT.'/install.lock';
504 $fp = @fopen($lockfile, "w");
505 if ($fp) {
506 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
507 $force_install_lockinstall = '444'; // For backward compatibility
508 }
509 fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")");
510 fclose($fp);
511 dolChmod($lockfile, $force_install_lockinstall);
512
513 $createlock = 1;
514 }
515 }
516 if (empty($createlock)) {
517 print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
518 }
519
520 // Delete the upgrade.unlock file it it exists
521 $unlockupgradefile = DOL_DATA_ROOT.'/upgrade.unlock';
522 dol_delete_file($unlockupgradefile, 0, 0, 0, null, false, 0);
523
524 print "<br>";
525
526 $morehtml = '<br><div class="center"><a class="buttonGoToupgrade" href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">';
527 $morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToDolibarr").'...';
528 $morehtml .= '</a></div><br>';
529 } else {
530 // If here MAIN_VERSION_LAST_UPGRADE is not empty
531 print $langs->trans("VersionLastUpgrade").': <b><span class="ok">' . getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'</span></b><br>';
532 print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b>';
533
534 print "<br>";
535
536 $morehtml = '<br><div class="center"><a class="buttonGoToupgrade" href="../install/index.php">';
537 $morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
538 $morehtml .= '</a></div>';
539 }
540} else {
541 dol_print_error(null, 'step5.php: unknown choice of action='.$action.' in create lock file seaction');
542}
543
544// Clear cache files
545clearstatcache();
546
547$ret = 0;
548if ($error && isset($argv[1])) {
549 $ret = 1;
550}
551dolibarr_install_syslog("Exit ".$ret);
552
553dolibarr_install_syslog("--- step5: Dolibarr setup finished");
554
555pFooter(1, $setuplang, '', 0, $morehtml);
556
557// Return code if ran from command line
558if ($ret) {
559 exit($ret);
560}
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:68
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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:535
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:626
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:690
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.