29 include_once
'inc.php';
30 if (file_exists($conffile)) include_once $conffile;
31 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
32 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
36 $versionfrom =
GETPOST(
"versionfrom",
'alpha', 3) ?
GETPOST(
"versionfrom",
'alpha', 3) : (empty($argv[1]) ?
'' : $argv[1]);
37 $versionto =
GETPOST(
"versionto",
'alpha', 3) ?
GETPOST(
"versionto",
'alpha', 3) : (empty($argv[2]) ?
'' : $argv[2]);
38 $setuplang =
GETPOST(
'selectlang',
'aZ09', 3) ?
GETPOST(
'selectlang',
'aZ09', 3) : (empty($argv[3]) ?
'auto' : $argv[3]);
39 $langs->setDefaultLang($setuplang);
40 $action =
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') : (empty($argv[4]) ?
'' : $argv[4]);
44 $targetversion = DOL_VERSION;
45 if (!empty($action) && preg_match(
'/upgrade/i', $action))
47 $tmp = explode(
'_', $action, 2);
48 if ($tmp[0] ==
'upgrade')
50 if (!empty($tmp[1])) $targetversion = $tmp[1];
51 else $targetversion = DOL_VERSION;
55 $langs->loadLangs(array(
"admin",
"install"));
57 $login =
GETPOST(
'login',
'alpha') ?
GETPOST(
'login',
'alpha') : (empty($argv[5]) ?
'' : $argv[5]);
58 $pass =
GETPOST(
'pass',
'alpha') ?
GETPOST(
'pass',
'alpha') : (empty($argv[6]) ?
'' : $argv[6]);
59 $pass_verif =
GETPOST(
'pass_verif',
'alpha') ?
GETPOST(
'pass_verif',
'alpha') : (empty($argv[7]) ?
'' : $argv[7]);
60 $force_install_lockinstall = (int) (!empty($force_install_lockinstall) ? $force_install_lockinstall : (
GETPOST(
'installlock',
'aZ09') ?
GETPOST(
'installlock',
'aZ09') : (empty($argv[8]) ?
'' : $argv[8])));
64 $useforcedwizard =
false;
65 $forcedfile =
"./install.forced.php";
66 if ($conffile ==
"/etc/dolibarr/conf.php") $forcedfile =
"/etc/dolibarr/install.forced.php";
67 if (@file_exists($forcedfile)) {
68 $useforcedwizard =
true;
69 include_once $forcedfile;
71 if ($force_install_noedit == 2) {
72 if (!empty($force_install_dolibarrlogin)) {
73 $login = $force_install_dolibarrlogin;
87 if ($action ==
"set") {
88 if ($pass <> $pass_verif) {
89 header(
"Location: step4.php?error=1&selectlang=$setuplang".(isset($login) ?
'&login='.$login :
''));
94 header(
"Location: step4.php?error=2&selectlang=$setuplang".(isset($login) ?
'&login='.$login :
''));
99 header(
"Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ?
'&login='.$login :
''));
109 pHeader($langs->trans(
"SetupEnd"),
"step5");
113 if (empty($versionfrom) && empty($versionto) && !is_writable($conffile))
115 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
116 pFooter(1, $setuplang,
'jscheckparam');
120 if ($action ==
"set" || empty($action) || preg_match(
'/upgrade/i', $action))
125 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
127 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
128 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass))
130 $dolibarr_main_db_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
131 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_pass);
132 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
133 }
else $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
136 $conf->db->type = $dolibarr_main_db_type;
137 $conf->db->host = $dolibarr_main_db_host;
138 $conf->db->port = $dolibarr_main_db_port;
139 $conf->db->name = $dolibarr_main_db_name;
140 $conf->db->user = $dolibarr_main_db_user;
141 $conf->db->pass = $dolibarr_main_db_pass;
142 $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption :
'';
143 $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey :
'';
145 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
148 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
154 if ($action ==
"set")
157 $modName =
'modUser';
158 $file = $modName.
".class.php";
160 include_once DOL_DOCUMENT_ROOT.
"/core/modules/".$file;
161 $objMod =
new $modName($db);
162 $result = $objMod->init();
163 if (!$result) print
'ERROR in activating module file='.$file;
167 $conf->setValues($db);
169 if (defined(
'SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
170 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
173 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
176 $sql =
"SELECT u.rowid, u.pass, u.pass_crypted";
177 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
178 $resql = $db->query($sql);
181 $numrows = $db->num_rows(
$resql);
185 dolibarr_set_const($db,
"DATABASE_PWD_ENCRYPTED",
"1",
'chaine', 0,
'', $conf->entity);
187 if (function_exists(
'password_hash'))
188 dolibarr_set_const($db,
"MAIN_SECURITY_HASH_ALGO",
'password_hash',
'chaine', 0,
'', 0);
189 else dolibarr_set_const($db,
"MAIN_SECURITY_HASH_ALGO",
'sha1md5',
'chaine', 0,
'', 0);
192 dolibarr_install_syslog(
'step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.
' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO);
196 $createuser =
new User($db);
198 $createuser->admin = 1;
201 $newuser =
new User($db);
202 $newuser->lastname =
'SuperAdmin';
203 $newuser->firstname =
'';
204 $newuser->login = $login;
205 $newuser->pass = $pass;
207 $newuser->entity = 0;
209 $conf->global->USER_MAIL_REQUIRED = 0;
210 $result = $newuser->create($createuser, 1);
213 print $langs->trans(
"AdminLoginCreatedSuccessfuly", $login).
"<br>";
216 if ($newuser->error ==
'ErrorLoginAlreadyExists')
219 print
'<br><div class="warning">'.$langs->trans(
"AdminLoginAlreadyExists", $login).
"</div><br>";
223 print
'<br><div class="error">'.$langs->trans(
"FailedToCreateAdminLogin").
' '.$newuser->error.
'</div><br><br>';
232 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) values(".$db->encrypt(
'MAIN_VERSION_FIRST_INSTALL', 1).
",".$db->encrypt($targetversion, 1).
",'chaine',0,'Dolibarr version when first install',0)");
235 $conf->global->MAIN_VERSION_FIRST_INSTALL = $targetversion;
245 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
"='MAIN_VERSION_LAST_INSTALL'");
247 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) values(".$db->encrypt(
'MAIN_VERSION_LAST_INSTALL', 1).
",".$db->encrypt($targetversion, 1).
",'chaine',0,'Dolibarr version when last install',0)");
249 $conf->global->MAIN_VERSION_LAST_INSTALL = $targetversion;
251 if ($useforcedwizard)
254 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
"='MAIN_REMOVE_INSTALL_WARNING'");
256 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) values(".$db->encrypt(
'MAIN_REMOVE_INSTALL_WARNING', 1).
",".$db->encrypt(1, 1).
",'chaine',1,'Disable install warnings',0)");
258 $conf->global->MAIN_REMOVE_INSTALL_WARNING = 1;
262 if (!empty($force_install_module))
264 if (!defined(
'DOL_DOCUMENT_ROOT') && !empty($dolibarr_main_document_root)) define(
'DOL_DOCUMENT_ROOT', $dolibarr_main_document_root);
266 $tmparray = explode(
',', $force_install_module);
267 foreach ($tmparray as $modtoactivate)
269 $modtoactivatenew = preg_replace(
'/\.class\.php$/i',
'', $modtoactivate);
270 print $langs->trans(
"ActivateModule", $modtoactivatenew).
'<br>';
272 $file = $modtoactivatenew.
'.class.php';
277 if (!empty($res[
'errors'])) print
'ERROR in activating module file='.$file;
282 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
"='MAIN_NOT_INSTALLED'");
288 print $langs->trans(
"ErrorFailedToConnect").
"<br>";
292 elseif (empty($action) || preg_match(
'/upgrade/i', $action))
296 $conf->setValues($db);
298 if (defined(
'SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
299 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
302 $tagdatabase =
false;
303 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase =
true;
305 $mainversionlastupgradearray = preg_split(
'/[.-]/', $conf->global->MAIN_VERSION_LAST_UPGRADE);
306 $targetversionarray = preg_split(
'/[.-]/', $targetversion);
307 if (
versioncompare($targetversionarray, $mainversionlastupgradearray) > 0) $tagdatabase =
true;
313 $resql = $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"const WHERE ".$db->decrypt(
'name').
"='MAIN_VERSION_LAST_UPGRADE'");
315 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) VALUES (".$db->encrypt(
'MAIN_VERSION_LAST_UPGRADE', 1).
",".$db->encrypt($targetversion, 1).
",'chaine',0,'Dolibarr version for last upgrade',0)");
317 $conf->global->MAIN_VERSION_LAST_UPGRADE = $targetversion;
319 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.');
322 print $langs->trans(
"ErrorFailedToConnect").
"<br>";
329 $resql = $db->query(
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity) VALUES (".$db->encrypt(
'MAIN_LANG_DEFAULT', 1).
",".$db->encrypt($setuplang, 1).
",'chaine',0,'Default language',1)");
340 if ($action ==
"set" && $success)
342 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
345 print $langs->trans(
"SystemIsInstalled").
"<br>";
349 if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE))
352 $lockfile = DOL_DATA_ROOT.
'/install.lock';
353 $fp = @fopen($lockfile,
"w");
356 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444;
357 fwrite($fp,
"This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.
")");
359 @chmod($lockfile, octdec($force_install_lockinstall));
363 if (empty($createlock))
365 print
'<div class="warning">'.$langs->trans(
"WarningRemoveInstallDir").
"</div>";
370 print $langs->trans(
"YouNeedToPersonalizeSetup").
"<br><br><br>";
372 print
'<div class="center"><a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($login) ?
'&username='.urlencode($login) :
'').
'">';
373 print
'<span class="fas fa-external-link-alt"></span> '.$langs->trans(
"GoToSetupArea");
377 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.
'</span></b><br>';
378 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b><br>';
379 print $langs->trans(
"MigrationNotFinished").
'<br>';
382 print
'<div class="center"><a href="'.$dolibarr_main_url_root.
'/install/index.php">';
383 print
'<span class="fas fa-link-alt"></span> '.$langs->trans(
"GoToUpgradePage");
388 elseif (empty($action) || preg_match(
'/upgrade/i', $action))
390 if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
393 print $langs->trans(
"SystemIsUpgraded").
"<br>";
397 if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE))
400 $lockfile = DOL_DATA_ROOT.
'/install.lock';
401 $fp = @fopen($lockfile,
"w");
404 if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) $force_install_lockinstall = 444;
405 fwrite($fp,
"This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.
")");
407 @chmod($lockfile, octdec($force_install_lockinstall));
411 if (empty($createlock))
413 print
'<br><div class="warning">'.$langs->trans(
"WarningRemoveInstallDir").
"</div>";
418 print
'<div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ?
'&username='.urlencode($login) :
'').
'">';
419 print
'<span class="fas fa-link-alt"></span> '.$langs->trans(
"GoToDolibarr").
'...';
420 print
'</a></div><br>';
423 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.
'</span></b><br>';
424 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
428 print
'<div class="center"><a href="../install/index.php">';
429 print
'<span class="fas fa-link-alt"></span> '.$langs->trans(
"GoToUpgradePage");
440 if ($error && isset($argv[1])) $ret = 1;
448 if ($ret) exit($ret);
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.
pHeader($subtitle, $next, $action= 'set', $param= '', $forcejqueryurl= '', $csstable= 'main-inside')
Show HTML header of install pages.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dol_decode($chain, $key= '1')
Decode a base 64 encoded + specific delta change.
dol_now($mode= 'auto')
Return date for now.
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).
Class to manage Dolibarr users.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
pFooter($nonext=0, $setuplang= '', $jscheckfunction= '', $withpleasewait=0)
Print HTML footer of install pages.
print
Draft customers invoices.
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(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $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...
activateModule($value, $withdeps=1)
Enable a module.