32define(
'ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
33include_once
'inc.php';
49$setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
50$langs->setDefaultLang($setuplang);
52$langs->load(
"install");
55$useforcedwizard =
false;
56$forcedfile =
"./install.forced.php";
57if ($conffile ==
"/etc/dolibarr/conf.php") {
58 $forcedfile =
"/etc/dolibarr/install.forced.php";
60if (@file_exists($forcedfile)) {
61 $useforcedwizard =
true;
62 include_once $forcedfile;
78print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ';
79print
'<span class="inline-block">'.$langs->trans(
"MiscellaneousChecks").
"</span></h3>\n";
82$useragent = $_SERVER[
'HTTP_USER_AGENT'];
83if (!empty($useragent)) {
85 $browserversion = $tmp[
'browserversion'];
86 $browsername = $tmp[
'browsername'];
87 if ($browsername ==
'ie' && $browserversion < 7) {
88 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"WarningBrowserTooOld").
"<br>\n";
94$arrayphpminversionerror = array(7, 0, 0);
95$arrayphpminversionwarning = array(7, 1, 0);
97 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
100 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
105if (empty($force_install_nophpinfo)) {
106 print
' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MoreInformation").
'</a>)';
111$arrayphpmaxversionwarning = array(8, 3, 0);
113 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooHigh",
versiontostring($arrayphpmaxversionwarning));
120if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"])) {
121 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETKo");
122 print
' (<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
126 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
131if (!function_exists(
"session_id")) {
132 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
135 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportSessions").
"<br>\n";
140if (!extension_loaded(
"mbstring")) {
141 $langs->load(
"errors");
142 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"MBString").
"<br>\n";
145 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"MBString").
"<br>\n";
149if (!extension_loaded(
"json")) {
150 $langs->load(
"errors");
151 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"JSON").
"<br>\n";
154 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"JSON").
"<br>\n";
158if (!function_exists(
"imagecreate")) {
159 $langs->load(
"errors");
160 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"GD").
"<br>\n";
163 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"GD").
"<br>\n";
167if (!function_exists(
"curl_init")) {
168 $langs->load(
"errors");
169 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Curl").
"<br>\n";
172 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Curl").
"<br>\n";
176if (!function_exists(
"easter_date")) {
177 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Calendar").
"<br>\n";
179 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Calendar").
"<br>\n";
183if (!function_exists(
"simplexml_load_string")) {
184 $langs->load(
"errors");
185 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Xml").
"<br>\n";
188 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Xml").
"<br>\n";
192if (!function_exists(
"utf8_encode")) {
193 $langs->load(
"errors");
194 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"UTF8").
"<br>\n";
197 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"UTF8").
"<br>\n";
201if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
202 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
203 $langs->load(
"errors");
204 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Intl").
"<br>\n";
207 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Intl").
"<br>\n";
212if (PHP_VERSION_ID <= 80300) {
213 if (!function_exists(
"imap_open")) {
214 $langs->load(
"errors");
215 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"IMAP").
"<br>\n";
218 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"IMAP").
"<br>\n";
223if (!class_exists(
'ZipArchive')) {
224 $langs->load(
"errors");
225 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"ZIP").
"<br>\n";
228 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"ZIP").
"<br>\n";
232$memrequiredorig =
'64M';
233$memrequired = 64 * 1024 * 1024;
234$memmaxorig = @ini_get(
"memory_limit");
235$memmax = @ini_get(
"memory_limit");
236if ($memmaxorig !=
'') {
237 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
239 if (strtoupper($reg[2]) ==
'G') {
240 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
242 if (strtoupper($reg[2]) ==
'M') {
243 $memmax = (int) $reg[1] * 1024 * 1024;
245 if (strtoupper($reg[2]) ==
'K') {
246 $memmax = (int) $reg[1] * 1024;
249 if ($memmax >= $memrequired || $memmax == -1) {
250 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
252 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
259if (is_readable($conffile) && filesize($conffile) > 8) {
262 include_once $conffile;
267 $allowupgrade =
true;
269 $allowupgrade =
false;
277 if (@copy($conffile.
".example", $conffile)) {
282 dolibarr_install_syslog(
"check: failed to copy file ".$conffile.
".example into ".$conffile.
". We try to create it.", LOG_WARNING);
284 $fp = @fopen($conffile,
"w");
286 @fwrite($fp,
'<?php');
290 dolibarr_install_syslog(
"check: failed to create a new file ".$conffile.
" into current dir ".getcwd().
". Please check permissions.", LOG_ERR);
295 $allowupgrade =
false;
301if (!file_exists($conffile)) {
302 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
303 print
'<br><br><div class="error">';
304 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
305 print
'</div><br><br>'.
"\n";
307 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
311 print
'<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
314 } elseif (!is_writable($conffile)) {
317 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
319 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
322 print
'<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
329 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
331 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
334 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileIsWritable", $conffiletoshow);
346 if (file_exists($conffile)) {
347 include_once $conffile;
348 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
349 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
350 print
'<span class="error">A '.$conffiletoshow.
' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.
' that seems wrong. Try to fix or remove the '.$conffiletoshow.
' file.</span><br>'.
"\n";
351 dol_syslog(
"A '".$conffiletoshow.
"' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root.
" that seems wrong. Try to fix or remove the '".$conffiletoshow.
"' file.", LOG_WARNING);
353 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
356 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
357 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
358 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
359 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
360 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
362 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
367 $conf->db->type = $dolibarr_main_db_type;
368 $conf->db->host = $dolibarr_main_db_host;
369 $conf->db->port = $dolibarr_main_db_port;
370 $conf->db->name = $dolibarr_main_db_name;
371 $conf->db->user = $dolibarr_main_db_user;
372 $conf->db->pass = $dolibarr_main_db_pass;
374 if ($db->connected && $db->database_selected) {
383 if (empty($dolibarr_main_db_encryption)) {
384 $dolibarr_main_db_encryption = 0;
386 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
387 if (empty($dolibarr_main_db_cryptkey)) {
388 $dolibarr_main_db_cryptkey =
'';
390 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
392 $conf->setValues($db);
394 if (defined(
'SYSLOG_FILE')) {
395 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
397 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
401 $dolibarrlastupgradeversionarray = preg_split(
'/[\.-]/', isset(
$conf->global->MAIN_VERSION_LAST_UPGRADE) ?
$conf->global->MAIN_VERSION_LAST_UPGRADE : (isset(
$conf->global->MAIN_VERSION_LAST_INSTALL) ?
$conf->global->MAIN_VERSION_LAST_INSTALL :
''));
407 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.(!
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE') ?
$conf->global->MAIN_VERSION_LAST_INSTALL :
$conf->global->MAIN_VERSION_LAST_UPGRADE).
'</span></b> - ';
408 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
417 print
'<h3><span class="soustitre">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
419 $foundrecommandedchoice = 0;
421 $available_choices = array();
422 $notavailable_choices = array();
424 if (empty($dolibarr_main_db_host)) {
425 $foundrecommandedchoice = 1;
429 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
430 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"FreshInstall").
'</b>';
432 $choice .=
'<td class="listofchoicesdesc">';
433 $choice .= $langs->trans(
"FreshInstallDesc");
434 if (empty($dolibarr_main_db_host)) {
437 $choice .=
'<div class="center"><div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div></div>';
442 $choice .=
'<td class="center">';
444 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
446 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
448 $choice .=
'</td>'.
"\n";
449 $choice .=
'</tr>'.
"\n";
451 $positionkey = ($foundrecommandedchoice ? 999 : 0);
453 $available_choices[$positionkey] = $choice;
455 $notavailable_choices[$positionkey] = $choice;
459 $allowupgrade =
true;
460 if (empty($dolibarr_main_db_host)) {
461 $allowupgrade =
false;
464 $allowupgrade =
false;
467 $allowupgrade =
true;
470 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
474 $migrationscript = array();
475 $handle = opendir($dir);
476 if (is_resource($handle)) {
477 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
478 while (($file = readdir($handle)) !==
false) {
480 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
482 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
483 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
487 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
489 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
493 foreach ($migrationscript as $migarray) {
497 $recommended_choice =
false;
498 $version = DOL_VERSION;
499 $versionfrom = $migarray[
'from'];
500 $versionto = $migarray[
'to'];
501 $versionarray = preg_split(
'/[\.-]/', $version);
502 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
503 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
505 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
506 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
507 $newversionfrombis =
'';
508 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
509 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
513 if (count($dolibarrlastupgradeversionarray) >= 2) {
515 if ($allowupgrade && empty($foundrecommandedchoice) &&
516 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
518 $foundrecommandedchoice = 1;
519 $recommended_choice =
true;
527 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
528 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
529 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"Upgrade").
'<br>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
530 $choice .=
'<td class="listofchoicesdesc">';
531 $choice .= $langs->trans(
"UpgradeDesc");
533 if ($recommended_choice) {
536 $choice .=
'<div class="center">';
537 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
538 if ($count < count($migarray)) {
539 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
545 $choice .=
'<td class="center">';
548 if ($foundrecommandedchoice == 2) {
551 if ($foundrecommandedchoice == 1) {
552 $foundrecommandedchoice = 2;
555 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
557 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'">'.$langs->trans(
"Start").
'</a>';
560 $choice .= $langs->trans(
"NotAvailable");
563 $choice .=
'</tr>'.
"\n";
566 $available_choices[$count] = $choice;
568 $notavailable_choices[$count] = $choice;
573 if (empty($available_choices)) {
574 $available_choices = $notavailable_choices;
575 $notavailable_choices = array();
579 krsort($available_choices, SORT_NATURAL);
581 print
'<table width="100%" class="listofchoices">';
582 foreach ($available_choices as $choice) {
586 print
'</table>'.
"\n";
588 if (count($notavailable_choices)) {
589 print
'<br><div id="AShowChoices" style="opacity: 0.5">';
590 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
593 print
'<div id="navail_choices" style="display:none">';
595 print
'<table width="100%" class="listofchoices">';
596 foreach ($notavailable_choices as $choice) {
600 print
'</table>'.
"\n";
606print
'<script type="text/javascript">
608$("div#AShowChoices").click(function() {
610 $("div#navail_choices").toggle();
612 if ($("div#navail_choices").css("display") == "none") {
613 $(this).text("> '.$langs->trans(
'ShowNotAvailableOptions').
'...");
615 $(this).text("'.$langs->trans(
'HideNotAvailableOptions').
'...");
621$(".runupgrade").click(function() {
622 return confirm("'.
dol_escape_js($langs->transnoentitiesnoconv(
"WarningUpgrade"), 0, 1).
'");
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
versiondolibarrarray()
Return version Dolibarr.
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
dol_is_dir($folder)
Test if filename is a directory.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getBrowserInfo($user_agent)
Return information about user browser.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a 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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.