30define(
'ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
31include_once
'inc.php';
40$setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
41$langs->setDefaultLang($setuplang);
43$langs->load(
"install");
46$useforcedwizard =
false;
47$forcedfile =
"./install.forced.php";
48if ($conffile ==
"/etc/dolibarr/conf.php") {
49 $forcedfile =
"/etc/dolibarr/install.forced.php";
51if (@file_exists($forcedfile)) {
52 $useforcedwizard =
true;
53 include_once $forcedfile;
69print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ';
70print
'<span class="inline-block">'.$langs->trans(
"MiscellaneousChecks").
"</span></h3>\n";
73$useragent = $_SERVER[
'HTTP_USER_AGENT'];
74if (!empty($useragent)) {
76 $browserversion = $tmp[
'browserversion'];
77 $browsername = $tmp[
'browsername'];
78 if ($browsername ==
'ie' && $browserversion < 7) {
79 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"WarningBrowserTooOld").
"<br>\n";
85$arrayphpminversionerror = array(7, 0, 0);
86$arrayphpminversionwarning = array(7, 1, 0);
88 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
91 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
96if (empty($force_install_nophpinfo)) {
97 print
' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MoreInformation").
'</a>)';
102$arrayphpmaxversionwarning = array(8, 1, 0);
104 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooHigh",
versiontostring($arrayphpmaxversionwarning));
111if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"])) {
112 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETKo");
113 print
' (<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
117 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
122if (!function_exists(
"session_id")) {
123 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
126 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportSessions").
"<br>\n";
131if (!extension_loaded(
"mbstring")) {
132 $langs->load(
"errors");
133 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"MBString").
"<br>\n";
136 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"MBString").
"<br>\n";
140if (!extension_loaded(
"json")) {
141 $langs->load(
"errors");
142 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"JSON").
"<br>\n";
145 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"JSON").
"<br>\n";
149if (!function_exists(
"imagecreate")) {
150 $langs->load(
"errors");
151 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"GD").
"<br>\n";
154 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"GD").
"<br>\n";
159if (!function_exists(
"curl_init")) {
160 $langs->load(
"errors");
161 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Curl").
"<br>\n";
164 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Curl").
"<br>\n";
168if (!function_exists(
"easter_date")) {
169 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Calendar").
"<br>\n";
171 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Calendar").
"<br>\n";
175if (!function_exists(
"simplexml_load_string")) {
176 $langs->load(
"errors");
177 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Xml").
"<br>\n";
180 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Xml").
"<br>\n";
184if (!function_exists(
"utf8_encode")) {
185 $langs->load(
"errors");
186 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"UTF8").
"<br>\n";
189 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"UTF8").
"<br>\n";
193if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
194 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
195 $langs->load(
"errors");
196 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Intl").
"<br>\n";
199 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Intl").
"<br>\n";
204if (!function_exists(
"imap_open")) {
205 $langs->load(
"errors");
206 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"IMAP").
"<br>\n";
209 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"IMAP").
"<br>\n";
213if (!class_exists(
'ZipArchive')) {
214 $langs->load(
"errors");
215 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"ZIP").
"<br>\n";
218 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"ZIP").
"<br>\n";
222$memrequiredorig =
'64M';
223$memrequired = 64 * 1024 * 1024;
224$memmaxorig = @ini_get(
"memory_limit");
225$memmax = @ini_get(
"memory_limit");
226if ($memmaxorig !=
'') {
227 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
229 if (strtoupper($reg[2]) ==
'G') {
230 $memmax = $reg[1] * 1024 * 1024 * 1024;
232 if (strtoupper($reg[2]) ==
'M') {
233 $memmax = $reg[1] * 1024 * 1024;
235 if (strtoupper($reg[2]) ==
'K') {
236 $memmax = $reg[1] * 1024;
239 if ($memmax >= $memrequired || $memmax == -1) {
240 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
242 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
249if (is_readable($conffile) && filesize($conffile) > 8) {
252 include_once $conffile;
257 $allowupgrade =
true;
259 $allowupgrade =
false;
267 if (@copy($conffile.
".example", $conffile)) {
272 dolibarr_install_syslog(
"check: failed to copy file ".$conffile.
".example into ".$conffile.
". We try to create it.", LOG_WARNING);
274 $fp = @fopen($conffile,
"w");
276 @fwrite($fp,
'<?php');
280 dolibarr_install_syslog(
"check: failed to create a new file ".$conffile.
" into current dir ".getcwd().
". Please check permissions.", LOG_ERR);
285 $allowupgrade =
false;
291if (!file_exists($conffile)) {
292 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
293 print
'<br><br><div class="error">';
294 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
295 print
'</div><br><br>'.
"\n";
297 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
301 print
'<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
304 } elseif (!is_writable($conffile)) {
307 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
309 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
312 print
'<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
319 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
321 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
324 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileIsWritable", $conffiletoshow);
336 if (file_exists($conffile)) {
337 include_once $conffile;
338 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
339 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
340 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";
341 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);
343 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
346 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
347 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
348 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
349 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
350 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
352 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
357 $conf->db->type = $dolibarr_main_db_type;
358 $conf->db->host = $dolibarr_main_db_host;
359 $conf->db->port = $dolibarr_main_db_port;
360 $conf->db->name = $dolibarr_main_db_name;
361 $conf->db->user = $dolibarr_main_db_user;
362 $conf->db->pass = $dolibarr_main_db_pass;
363 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
364 if ($db->connected && $db->database_selected) {
373 if (empty($dolibarr_main_db_encryption)) {
374 $dolibarr_main_db_encryption = 0;
376 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
377 if (empty($dolibarr_main_db_cryptkey)) {
378 $dolibarr_main_db_cryptkey =
'';
380 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
382 $conf->setValues($db);
384 if (defined(
'SYSLOG_FILE')) {
385 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
387 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
391 $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 :
''));
396 if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) {
397 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).
'</span></b> - ';
398 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
407 print
'<h3><span class="soustitre">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
409 $foundrecommandedchoice = 0;
411 $available_choices = array();
412 $notavailable_choices = array();
414 if (empty($dolibarr_main_db_host)) {
415 $foundrecommandedchoice = 1;
419 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
420 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"FreshInstall").
'</b>';
422 $choice .=
'<td class="listofchoicesdesc">';
423 $choice .= $langs->trans(
"FreshInstallDesc");
424 if (empty($dolibarr_main_db_host)) {
427 $choice .=
'<div class="center"><div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div></div>';
432 $choice .=
'<td class="center">';
434 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
436 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
438 $choice .=
'</td>'.
"\n";
439 $choice .=
'</tr>'.
"\n";
441 $positionkey = ($foundrecommandedchoice ? 999 : 0);
443 $available_choices[$positionkey] = $choice;
445 $notavailable_choices[$positionkey] = $choice;
449 $allowupgrade =
true;
450 if (empty($dolibarr_main_db_host)) {
451 $allowupgrade =
false;
454 $allowupgrade =
false;
457 $allowupgrade =
true;
460 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
464 $migrationscript = array();
465 $handle = opendir($dir);
466 if (is_resource($handle)) {
467 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
468 while (($file = readdir($handle)) !==
false) {
470 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
472 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
473 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
477 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
479 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
483 foreach ($migrationscript as $migarray) {
487 $recommended_choice =
false;
488 $version = DOL_VERSION;
489 $versionfrom = $migarray[
'from'];
490 $versionto = $migarray[
'to'];
491 $versionarray = preg_split(
'/[\.-]/', $version);
492 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
493 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
495 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
496 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
497 $newversionfrombis =
'';
498 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
499 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
503 if (count($dolibarrlastupgradeversionarray) >= 2) {
505 if ($allowupgrade && empty($foundrecommandedchoice) &&
506 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
508 $foundrecommandedchoice = 1;
509 $recommended_choice =
true;
517 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
518 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
519 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"Upgrade").
'<br>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
520 $choice .=
'<td class="listofchoicesdesc">';
521 $choice .= $langs->trans(
"UpgradeDesc");
523 if ($recommended_choice) {
526 $choice .=
'<div class="center">';
527 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
528 if ($count < count($migarray)) {
529 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
535 $choice .=
'<td class="center">';
538 if ($foundrecommandedchoice == 2) {
541 if ($foundrecommandedchoice == 1) {
542 $foundrecommandedchoice = 2;
545 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
547 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'">'.$langs->trans(
"Start").
'</a>';
550 $choice .= $langs->trans(
"NotAvailable");
553 $choice .=
'</tr>'.
"\n";
556 $available_choices[$count] = $choice;
558 $notavailable_choices[$count] = $choice;
563 if (empty($available_choices)) {
564 $available_choices = $notavailable_choices;
565 $notavailable_choices = array();
569 krsort($available_choices, SORT_NATURAL);
571 print
'<table width="100%" class="listofchoices">';
572 foreach ($available_choices as $choice) {
576 print
'</table>'.
"\n";
578 if (count($notavailable_choices)) {
579 print
'<br><div id="AShowChoices" style="opacity: 0.5">';
580 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
583 print
'<div id="navail_choices" style="display:none">';
585 print
'<table width="100%" class="listofchoices">';
586 foreach ($notavailable_choices as $choice) {
590 print
'</table>'.
"\n";
596print
'<script type="text/javascript">
598$("div#AShowChoices").click(function() {
600 $("div#navail_choices").toggle();
602 if ($("div#navail_choices").css("display") == "none") {
603 $(this).text("> '.$langs->trans(
'ShowNotAvailableOptions').
'...");
605 $(this).text("'.$langs->trans(
'HideNotAvailableOptions').
'...");
611$(".runupgrade").click(function() {
612 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 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 second index function, which produces ascending (default) or descending output...
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.
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.
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.