dolibarr 22.0.5
step2.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr>
5 * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28include 'inc.php';
29require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
30require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
31require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
32
33global $langs;
34
35$step = 2;
36$ok = 0;
37
38
39// This page can be long. We increase the time allowed. / Cette page peut etre longue. On augmente le delai autorise.
40// Only works if you are not in safe_mode. / Ne fonctionne que si on est pas en safe_mode.
41
42$err = error_reporting();
43error_reporting(0); // Disable all errors
44//error_reporting(E_ALL);
45@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64
46error_reporting($err);
47
48$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]);
49$setuplang = GETPOST('selectlang', 'aZ09', 3) ? GETPOST('selectlang', 'aZ09', 3) : (empty($argv[2]) ? 'auto' : $argv[2]);
50$langs->setDefaultLang($setuplang);
51
52$langs->loadLangs(array("admin", "install"));
53
54
55// Choice of DBMS
56
57$choix = 0;
58if ($dolibarr_main_db_type == "mysqli") {
59 $choix = 1;
60}
61if ($dolibarr_main_db_type == "pgsql") {
62 $choix = 2;
63}
64if ($dolibarr_main_db_type == "mssql") {
65 $choix = 3;
66}
67if ($dolibarr_main_db_type == "sqlite") {
68 $choix = 4;
69}
70if ($dolibarr_main_db_type == "sqlite3") {
71 $choix = 5;
72}
73//if (empty($choix)) dol_print_error(null,'Database type '.$dolibarr_main_db_type.' not supported into step2.php page');
74
75
76// Now we load forced values from install.forced.php file.
77
78$useforcedwizard = false;
79$forcedfile = "./install.forced.php";
80if ($conffile == "/etc/dolibarr/conf.php") {
81 $forcedfile = "/etc/dolibarr/install.forced.php";
82}
83if (@file_exists($forcedfile)) {
84 $useforcedwizard = true;
85 include_once $forcedfile;
86 // test for travis
87 if (!empty($argv[1]) && $argv[1] == "set") {
88 $action = "set";
89 }
90}
91
92dolibarr_install_syslog("--- step2: entering step2.php page");
93
94'@phan-var-force string $dolibarr_main_db_prefix'; // From configuraiotn file or install/inc.php
95
96
97/*
98 * Actions
99 */
100
101// None
102
103
104/*
105 * View
106 */
107
108pHeader($langs->trans("DolibarrSetup").' - '.$langs->trans("CreateDatabaseObjects"), "step4");
109
110// Test if we can run a first install process
111if (!is_writable($conffile)) {
112 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
113 pFooter(1, $setuplang, 'jscheckparam');
114 exit;
115}
116
117if ($action == "set") { // Test on permission not required. Already managed by test in inc.php
118 print '<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans("Database").'</h3>';
119
120 print '<table cellspacing="0" style="padding: 4px 4px 4px 0" border="0" width="100%">';
121 $error = 0;
122
123 $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
124
125 if ($db->connected) {
126 print "<tr><td>";
127 print $langs->trans("ServerConnection")." : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
128 $ok = 1;
129 } else {
130 print "<tr><td>Failed to connect to server : ".$conf->db->host.'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
131 }
132
133 if ($ok) {
134 if ($db->database_selected) {
135 dolibarr_install_syslog("step2: successful connection to database: ".$conf->db->name);
136 } else {
137 dolibarr_install_syslog("step2: failed connection to database :".$conf->db->name, LOG_ERR);
138 print "<tr><td>Failed to select database ".$conf->db->name.'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
139 $ok = 0;
140 }
141 }
142
143
144 $versionarray = array();
145 // Display version / Affiche version
146 if ($ok) {
147 $version = $db->getVersion();
148 $versionarray = $db->getVersionArray();
149 print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
150 print '<td>'.$version.'</td></tr>';
151 //print '<td class="right">'.join('.',$versionarray).'</td></tr>';
152
153 print '<tr><td>'.$langs->trans("DatabaseName").'</td>';
154 print '<td>'.$db->database_name.'</td></tr>';
155 //print '<td class="right">'.join('.',$versionarray).'</td></tr>';
156 }
157
158 $requestnb = 0;
159
160 // To disable some code, so you can call step2 with url like
161 // http://localhost/dolibarrnew/install/step2.php?action=set&token='.newToken().'&createtables=0&createkeys=0&createfunctions=0&createdata=llx_20_c_departements
162 $createtables = GETPOSTISSET('createtables') ? GETPOST('createtables') : 1;
163 $createkeys = GETPOSTISSET('createkeys') ? GETPOST('createkeys') : 1;
164 $createfunctions = GETPOSTISSET('createfunctions') ? GETPOST('createfunction') : 1;
165 $createdata = GETPOSTISSET('createdata') ? GETPOST('createdata') : 1;
166
167
168 // To say that SQL we pass to query are already escaped for mysql, so we need to unescape them
169 if (property_exists($db, 'unescapeslashquot')) {
170 $db->unescapeslashquot = true; // @phan-suppress-current-line PhanUndeclaredProperty
171 }
172
173 /**************************************************************************************
174 *
175 * Load files tables/*.sql (not the *.key.sql). Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
176 * To do before the files *.key.sql
177 *
178 ***************************************************************************************/
179 if ($ok && $createtables) {
180 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
181 $dir = "mysql/tables/";
182
183 $ok = 0;
184 $handle = opendir($dir);
185 dolibarr_install_syslog("step2: open tables directory ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
186 $tablefound = 0;
187 $tabledata = array();
188 if (is_resource($handle)) {
189 while (($file = readdir($handle)) !== false) {
190 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
191 $tablefound++;
192 $tabledata[] = $file;
193 }
194 }
195 closedir($handle);
196 }
197
198 // Sort list of sql files on alphabetical order (load order is important)
199 sort($tabledata);
200 foreach ($tabledata as $file) {
201 $name = substr($file, 0, dol_strlen($file) - 4);
202 $buffer = '';
203 $fp = fopen($dir.$file, "r");
204 if ($fp) {
205 while (!feof($fp)) {
206 $buf = fgets($fp, 4096);
207 if (substr($buf, 0, 2) != '--') {
208 $buf = preg_replace('/--(.+)*/', '', $buf);
209 $buffer .= $buf;
210 }
211 }
212 fclose($fp);
213
214 $buffer = trim($buffer);
215 if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
216 $buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer);
217 } else {
218 // Keyword ENGINE is MySQL-specific, so scrub it for
219 // other database types (mssql, pgsql)
220 $buffer = preg_replace('/type=innodb/i', '', $buffer);
221 $buffer = preg_replace('/ENGINE=innodb/i', '', $buffer);
222 }
223
224 // Replace the prefix tables
225 if ($dolibarr_main_db_prefix != 'llx_') {
226 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
227 }
228
229 //print "<tr><td>Creation of table $name/td>";
230 $requestnb++;
231
232 dolibarr_install_syslog("step2: request: ".$buffer);
233 $resql = $db->query($buffer, 0, 'dml');
234 if ($resql) {
235 // print "<td>OK request ==== $buffer</td></tr>";
236 $db->free($resql);
237 } else {
238 if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
239 $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS') {
240 //print "<td>already existing</td></tr>";
241 } else {
242 print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
243 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' <br>Executed query : '.$db->lastquery;
244 print "\n</td>";
245 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
246 $error++;
247 }
248 }
249 } else {
250 print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
251 print "</td>";
252 print '<td><span class="error">'.$langs->trans("Error").' Failed to open file '.$dir.$file.'</span></td></tr>';
253 $error++;
254 dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR);
255 }
256 }
257
258 if ($tablefound) {
259 if ($error == 0) {
260 print '<tr><td>';
261 print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
262 $ok = 1;
263 }
264 } else {
265 print '<tr><td>'.$langs->trans("ErrorFailedToFindSomeFiles", $dir).'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
266 dolibarr_install_syslog("step2: failed to find files to create database in directory ".$dir, LOG_ERR);
267 }
268 }
269
270
271 /***************************************************************************************
272 *
273 * Load files tables/*.key.sql. Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
274 * To do after the files *.sql
275 *
276 ***************************************************************************************/
277 if ($ok && $createkeys) {
278 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
279 $dir = "mysql/tables/";
280
281 $okkeys = 0;
282 $handle = opendir($dir);
283 dolibarr_install_syslog("step2: open keys directory ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
284 $tablefound = 0;
285 $tabledata = array();
286 if (is_resource($handle)) {
287 while (($file = readdir($handle)) !== false) {
288 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
289 $tablefound++;
290 $tabledata[] = $file;
291 }
292 }
293 closedir($handle);
294 }
295
296 // Sort list of sql files on alphabetical order (load order is important)
297 sort($tabledata);
298 foreach ($tabledata as $file) {
299 $name = substr($file, 0, dol_strlen($file) - 4);
300 //print "<tr><td>Creation of table $name</td>";
301 $buffer = '';
302 $fp = fopen($dir.$file, "r");
303 if ($fp) {
304 while (!feof($fp)) {
305 $buf = fgets($fp, 4096);
306
307 // Special case of lines allowed for some version only
308 // MySQL
309 if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) {
310 $versioncommande = explode('.', $reg[1]);
311 //var_dump($versioncommande);
312 //var_dump($versionarray);
313 if (count($versioncommande) && count($versionarray)
314 && versioncompare($versioncommande, $versionarray) <= 0) {
315 // Version qualified, delete SQL comments
316 $buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf);
317 //print "Ligne $i qualifiee par version: ".$buf.'<br>';
318 }
319 }
320 // PGSQL
321 if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) {
322 $versioncommande = explode('.', $reg[1]);
323 //var_dump($versioncommande);
324 //var_dump($versionarray);
325 if (count($versioncommande) && count($versionarray)
326 && versioncompare($versioncommande, $versionarray) <= 0) {
327 // Version qualified, delete SQL comments
328 $buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf);
329 //print "Ligne $i qualifiee par version: ".$buf.'<br>';
330 }
331 }
332
333 // Add line if no comment
334 if (!preg_match('/^--/i', $buf)) {
335 $buffer .= $buf;
336 }
337 }
338 fclose($fp);
339
340 // If several requests, we loop on each
341 $listesql = explode(';', $buffer);
342 foreach ($listesql as $req) {
343 $buffer = trim($req);
344 if ($buffer) {
345 // Replace the prefix tables
346 if ($dolibarr_main_db_prefix != 'llx_') {
347 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
348 }
349
350 //print "<tr><td>Creation of keys and table index $name: '$buffer'</td>";
351 $requestnb++;
352
353 dolibarr_install_syslog("step2: request: ".$buffer);
354 $resql = $db->query($buffer, 0, 'dml');
355 if ($resql) {
356 //print "<td>OK request ==== $buffer</td></tr>";
357 $db->free($resql);
358 } else {
359 if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
360 $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
361 $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
362 $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
363 preg_match('/duplicate key name/i', $db->error())) {
364 //print "<td>Deja existante</td></tr>";
365 $key_exists = 1;
366 } else {
367 print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
368 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
369 print "\n</td>";
370 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
371 $error++;
372 }
373 }
374 }
375 }
376 } else {
377 print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
378 print "</td>";
379 print '<td><span class="error">'.$langs->trans("Error")." Failed to open file ".$dir.$file."</span></td></tr>";
380 $error++;
381 dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR);
382 }
383 }
384
385 if ($tablefound && $error == 0) {
386 print '<tr><td>';
387 print $langs->trans("OtherKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
388 $okkeys = 1;
389 }
390 }
391
392
393 /***************************************************************************************
394 *
395 * Load the file 'functions.sql'
396 *
397 ***************************************************************************************/
398 if ($ok && $createfunctions) {
399 // For this file, we use a directory according to database type
400 $dir = null;
401 if ($choix == 1) {
402 $dir = "mysql/functions/";
403 } elseif ($choix == 2) {
404 $dir = "pgsql/functions/";
405 } elseif ($choix == 3) {
406 $dir = "mssql/functions/";
407 } elseif ($choix == 4) {
408 $dir = "sqlite3/functions/";
409 }
410
411 // Creation of data
412 $file = "functions.sql";
413 if ($dir !== null && file_exists($dir.$file)) {
414 $fp = fopen($dir.$file, "r");
415 dolibarr_install_syslog("step2: open function file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp));
416 $buffer = '';
417 if ($fp) {
418 while (!feof($fp)) {
419 $buf = fgets($fp, 4096);
420 if (substr($buf, 0, 2) != '--') {
421 $buffer .= $buf."§";
422 }
423 }
424 fclose($fp);
425 }
426 //$buffer=preg_replace('/;\';/',";'§",$buffer);
427
428 // If several requests, we loop on each of them
429 $listesql = explode('§', $buffer);
430 foreach ($listesql as $buffer) {
431 $buffer = trim($buffer);
432 if ($buffer) {
433 // Replace the prefix in table names
434 if ($dolibarr_main_db_prefix != 'llx_') {
435 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
436 }
437 dolibarr_install_syslog("step2: request: ".$buffer);
438 print "<!-- Insert line : ".$buffer."<br>-->\n";
439 $resql = $db->query($buffer, 0, 'dml');
440 if ($resql) {
441 $ok = 1;
442 $db->free($resql);
443 } else {
444 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
445 || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') {
446 //print "Insert line : ".$buffer."<br>\n";
447 } else {
448 $ok = 0;
449
450 print "<tr><td>".$langs->trans("FunctionsCreation");
451 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
452 print "\n</td>";
453 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
454 $error++;
455 }
456 }
457 }
458 }
459
460 print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
461 if ($ok) {
462 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
463 } else {
464 print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
465 $ok = 1;
466 }
467 }
468 }
469
470
471 /***************************************************************************************
472 *
473 * Load files data/*.sql. Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
474 *
475 ***************************************************************************************/
476 if ($ok && $createdata) {
477 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
478 $dir = "mysql/data/";
479
480 // Insert data
481 $handle = opendir($dir);
482 dolibarr_install_syslog("step2: open directory data ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
483 $tablefound = 0;
484 $tabledata = array();
485 if (is_resource($handle)) {
486 while (($file = readdir($handle)) !== false) {
487 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\-/', $file)) {
488 if (preg_match('/^llx_accounting_account_/', $file)) {
489 continue; // We discard data file of chart of account. This will be loaded when a chart is selected.
490 }
491
492 //print 'x'.$file.'-'.$createdata.'<br>';
493 if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) {
494 $tablefound++;
495 $tabledata[] = $file;
496 }
497 }
498 }
499 closedir($handle);
500 }
501
502 // Sort list of data files on alphabetical order (load order is important)
503 sort($tabledata);
504 foreach ($tabledata as $file) {
505 $name = substr($file, 0, dol_strlen($file) - 4);
506 $fp = fopen($dir.$file, "r");
507 dolibarr_install_syslog("step2: open data file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp));
508 if ($fp) {
509 $arrayofrequests = array();
510 $linefound = 0;
511 $linegroup = 0;
512 $sizeofgroup = 1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
513
514 // Load all requests
515 while (!feof($fp)) {
516 $buffer = fgets($fp, 4096);
517 $buffer = trim($buffer);
518 if ($buffer) {
519 if (substr($buffer, 0, 2) == '--') {
520 continue;
521 }
522
523 if ($linefound && ($linefound % $sizeofgroup) == 0) {
524 $linegroup++;
525 }
526 if (empty($arrayofrequests[$linegroup])) {
527 $arrayofrequests[$linegroup] = $buffer;
528 } else {
529 $arrayofrequests[$linegroup] .= " ".$buffer;
530 }
531
532 $linefound++;
533 }
534 }
535 fclose($fp);
536
537 dolibarr_install_syslog("step2: found ".$linefound." records, defined ".count($arrayofrequests)." group(s).");
538
539 $okallfile = 1;
540 $db->begin();
541
542 // We loop on each requests of file
543 foreach ($arrayofrequests as $buffer) {
544 // Replace the tables prefixes
545 if ($dolibarr_main_db_prefix != 'llx_') {
546 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
547 }
548
549 // Replace __ENTITY__ tag with 1 (master entity), this is only for dictionaries.
550 $buffer = preg_replace('/__ENTITY__/i', '1', $buffer);
551
552 //dolibarr_install_syslog("step2: request: " . $buffer);
553 $resql = $db->query($buffer, 1);
554 if ($resql) {
555 //$db->free($resql); // Not required as request we launch here does not return memory needs.
556 } else {
557 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
558 //print "<tr><td>Insertion ligne : $buffer</td><td>";
559 } else {
560 $ok = 0;
561 $okallfile = 0;
562 print '<span class="error">'.$langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."</span><br>";
563 }
564 }
565 }
566
567 if ($okallfile) {
568 $db->commit();
569 } else {
570 $db->rollback();
571 }
572 }
573 }
574
575 print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
576 if ($ok) {
577 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
578 } else {
579 print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
580 $ok = 1; // Data loading are not blocking errors
581 }
582 }
583 print '</table>';
584} else {
585 print 'Parameter action=set not defined';
586}
587
588
589$ret = 0;
590if (!$ok && isset($argv[1])) {
591 $ret = 1;
592}
593dolibarr_install_syslog("Exit ".$ret);
594
595dolibarr_install_syslog("- step2: end");
596
597
598// Force here a value we need after because master.inc.php is not loaded into step2.
599// This code must be similar with the one into main.inc.php
600
601$conf->file->instance_unique_id = (empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id); // Unique id of instance
602
603$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only.
604
605$out = '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> ';
606$out .= '<label for="dolibarrpingno">'.$langs->trans("MakeAnonymousPing").'</label>';
607
608$out .= '<!-- Add js script to manage the uncheck of option to not send the ping -->';
609$out .= '<script type="text/javascript">';
610$out .= 'jQuery(document).ready(function(){';
611$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=0; path=/"'."\n";
612$out .= ' jQuery("#dolibarrpingno").click(function() {';
613$out .= ' if (! $(this).is(\':checked\')) {';
614$out .= ' console.log("We uncheck anonymous ping");';
615$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=1; path=/"'."\n";
616$out .= ' } else {'."\n";
617$out .= ' console.log("We check anonymous ping");';
618$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=0; path=/"'."\n";
619$out .= ' }'."\n";
620$out .= ' });';
621$out .= '});';
622$out .= '</script>';
623
624print $out;
625
626pFooter($ok ? 0 : 1, $setuplang);
627
628if (isset($db) && is_object($db)) {
629 $db->close();
630}
631
632// Return code if ran from command line
633if ($ret) {
634 exit($ret);
635}
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Definition admin.lib.php:71
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:538
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:631
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:695
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.