dolibarr 21.0.0-beta
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 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 // Display version / Affiche version
145 if ($ok) {
146 $version = $db->getVersion();
147 $versionarray = $db->getVersionArray();
148 print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
149 print '<td>'.$version.'</td></tr>';
150 //print '<td class="right">'.join('.',$versionarray).'</td></tr>';
151
152 print '<tr><td>'.$langs->trans("DatabaseName").'</td>';
153 print '<td>'.$db->database_name.'</td></tr>';
154 //print '<td class="right">'.join('.',$versionarray).'</td></tr>';
155 }
156
157 $requestnb = 0;
158
159 // To disable some code, so you can call step2 with url like
160 // http://localhost/dolibarrnew/install/step2.php?action=set&token='.newToken().'&createtables=0&createkeys=0&createfunctions=0&createdata=llx_20_c_departements
161 $createtables = GETPOSTISSET('createtables') ? GETPOST('createtables') : 1;
162 $createkeys = GETPOSTISSET('createkeys') ? GETPOST('createkeys') : 1;
163 $createfunctions = GETPOSTISSET('createfunctions') ? GETPOST('createfunction') : 1;
164 $createdata = GETPOSTISSET('createdata') ? GETPOST('createdata') : 1;
165
166
167 // To say that SQL we pass to query are already escaped for mysql, so we need to unescape them
168 if (property_exists($db, 'unescapeslashquot')) {
169 $db->unescapeslashquot = true;
170 }
171
172 /**************************************************************************************
173 *
174 * Load files tables/*.sql (not the *.key.sql). Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
175 * To do before the files *.key.sql
176 *
177 ***************************************************************************************/
178 if ($ok && $createtables) {
179 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
180 $dir = "mysql/tables/";
181
182 $ok = 0;
183 $handle = opendir($dir);
184 dolibarr_install_syslog("step2: open tables directory ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
185 $tablefound = 0;
186 $tabledata = array();
187 if (is_resource($handle)) {
188 while (($file = readdir($handle)) !== false) {
189 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
190 $tablefound++;
191 $tabledata[] = $file;
192 }
193 }
194 closedir($handle);
195 }
196
197 // Sort list of sql files on alphabetical order (load order is important)
198 sort($tabledata);
199 foreach ($tabledata as $file) {
200 $name = substr($file, 0, dol_strlen($file) - 4);
201 $buffer = '';
202 $fp = fopen($dir.$file, "r");
203 if ($fp) {
204 while (!feof($fp)) {
205 $buf = fgets($fp, 4096);
206 if (substr($buf, 0, 2) != '--') {
207 $buf = preg_replace('/--(.+)*/', '', $buf);
208 $buffer .= $buf;
209 }
210 }
211 fclose($fp);
212
213 $buffer = trim($buffer);
214 if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
215 $buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer);
216 } else {
217 // Keyword ENGINE is MySQL-specific, so scrub it for
218 // other database types (mssql, pgsql)
219 $buffer = preg_replace('/type=innodb/i', '', $buffer);
220 $buffer = preg_replace('/ENGINE=innodb/i', '', $buffer);
221 }
222
223 // Replace the prefix tables
224 if ($dolibarr_main_db_prefix != 'llx_') {
225 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
226 }
227
228 //print "<tr><td>Creation of table $name/td>";
229 $requestnb++;
230
231 dolibarr_install_syslog("step2: request: ".$buffer);
232 $resql = $db->query($buffer, 0, 'dml');
233 if ($resql) {
234 // print "<td>OK request ==== $buffer</td></tr>";
235 $db->free($resql);
236 } else {
237 if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
238 $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS') {
239 //print "<td>already existing</td></tr>";
240 } else {
241 print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
242 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' <br>Executed query : '.$db->lastquery;
243 print "\n</td>";
244 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
245 $error++;
246 }
247 }
248 } else {
249 print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
250 print "</td>";
251 print '<td><span class="error">'.$langs->trans("Error").' Failed to open file '.$dir.$file.'</span></td></tr>';
252 $error++;
253 dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR);
254 }
255 }
256
257 if ($tablefound) {
258 if ($error == 0) {
259 print '<tr><td>';
260 print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
261 $ok = 1;
262 }
263 } else {
264 print '<tr><td>'.$langs->trans("ErrorFailedToFindSomeFiles", $dir).'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
265 dolibarr_install_syslog("step2: failed to find files to create database in directory ".$dir, LOG_ERR);
266 }
267 }
268
269
270 /***************************************************************************************
271 *
272 * Load files tables/*.key.sql. Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
273 * To do after the files *.sql
274 *
275 ***************************************************************************************/
276 if ($ok && $createkeys) {
277 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
278 $dir = "mysql/tables/";
279
280 $okkeys = 0;
281 $handle = opendir($dir);
282 dolibarr_install_syslog("step2: open keys directory ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
283 $tablefound = 0;
284 $tabledata = array();
285 if (is_resource($handle)) {
286 while (($file = readdir($handle)) !== false) {
287 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
288 $tablefound++;
289 $tabledata[] = $file;
290 }
291 }
292 closedir($handle);
293 }
294
295 // Sort list of sql files on alphabetical order (load order is important)
296 sort($tabledata);
297 foreach ($tabledata as $file) {
298 $name = substr($file, 0, dol_strlen($file) - 4);
299 //print "<tr><td>Creation of table $name</td>";
300 $buffer = '';
301 $fp = fopen($dir.$file, "r");
302 if ($fp) {
303 while (!feof($fp)) {
304 $buf = fgets($fp, 4096);
305
306 // Special case of lines allowed for some version only
307 // MySQL
308 if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) {
309 $versioncommande = explode('.', $reg[1]);
310 //var_dump($versioncommande);
311 //var_dump($versionarray);
312 if (count($versioncommande) && count($versionarray)
313 && versioncompare($versioncommande, $versionarray) <= 0) {
314 // Version qualified, delete SQL comments
315 $buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf);
316 //print "Ligne $i qualifiee par version: ".$buf.'<br>';
317 }
318 }
319 // PGSQL
320 if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) {
321 $versioncommande = explode('.', $reg[1]);
322 //var_dump($versioncommande);
323 //var_dump($versionarray);
324 if (count($versioncommande) && count($versionarray)
325 && versioncompare($versioncommande, $versionarray) <= 0) {
326 // Version qualified, delete SQL comments
327 $buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf);
328 //print "Ligne $i qualifiee par version: ".$buf.'<br>';
329 }
330 }
331
332 // Add line if no comment
333 if (!preg_match('/^--/i', $buf)) {
334 $buffer .= $buf;
335 }
336 }
337 fclose($fp);
338
339 // If several requests, we loop on each
340 $listesql = explode(';', $buffer);
341 foreach ($listesql as $req) {
342 $buffer = trim($req);
343 if ($buffer) {
344 // Replace the prefix tables
345 if ($dolibarr_main_db_prefix != 'llx_') {
346 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
347 }
348
349 //print "<tr><td>Creation of keys and table index $name: '$buffer'</td>";
350 $requestnb++;
351
352 dolibarr_install_syslog("step2: request: ".$buffer);
353 $resql = $db->query($buffer, 0, 'dml');
354 if ($resql) {
355 //print "<td>OK request ==== $buffer</td></tr>";
356 $db->free($resql);
357 } else {
358 if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
359 $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
360 $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
361 $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
362 preg_match('/duplicate key name/i', $db->error())) {
363 //print "<td>Deja existante</td></tr>";
364 $key_exists = 1;
365 } else {
366 print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
367 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
368 print "\n</td>";
369 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
370 $error++;
371 }
372 }
373 }
374 }
375 } else {
376 print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
377 print "</td>";
378 print '<td><span class="error">'.$langs->trans("Error")." Failed to open file ".$dir.$file."</span></td></tr>";
379 $error++;
380 dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR);
381 }
382 }
383
384 if ($tablefound && $error == 0) {
385 print '<tr><td>';
386 print $langs->trans("OtherKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
387 $okkeys = 1;
388 }
389 }
390
391
392 /***************************************************************************************
393 *
394 * Load the file 'functions.sql'
395 *
396 ***************************************************************************************/
397 if ($ok && $createfunctions) {
398 // For this file, we use a directory according to database type
399 if ($choix == 1) {
400 $dir = "mysql/functions/";
401 } elseif ($choix == 2) {
402 $dir = "pgsql/functions/";
403 } elseif ($choix == 3) {
404 $dir = "mssql/functions/";
405 } elseif ($choix == 4) {
406 $dir = "sqlite3/functions/";
407 }
408
409 // Creation of data
410 $file = "functions.sql";
411 if (file_exists($dir.$file)) {
412 $fp = fopen($dir.$file, "r");
413 dolibarr_install_syslog("step2: open function file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp));
414 if ($fp) {
415 $buffer = '';
416 while (!feof($fp)) {
417 $buf = fgets($fp, 4096);
418 if (substr($buf, 0, 2) != '--') {
419 $buffer .= $buf."§";
420 }
421 }
422 fclose($fp);
423 }
424 //$buffer=preg_replace('/;\';/',";'§",$buffer);
425
426 // If several requests, we loop on each of them
427 $listesql = explode('§', $buffer);
428 foreach ($listesql as $buffer) {
429 $buffer = trim($buffer);
430 if ($buffer) {
431 // Replace the prefix in table names
432 if ($dolibarr_main_db_prefix != 'llx_') {
433 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
434 }
435 dolibarr_install_syslog("step2: request: ".$buffer);
436 print "<!-- Insert line : ".$buffer."<br>-->\n";
437 $resql = $db->query($buffer, 0, 'dml');
438 if ($resql) {
439 $ok = 1;
440 $db->free($resql);
441 } else {
442 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
443 || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') {
444 //print "Insert line : ".$buffer."<br>\n";
445 } else {
446 $ok = 0;
447
448 print "<tr><td>".$langs->trans("FunctionsCreation");
449 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
450 print "\n</td>";
451 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
452 $error++;
453 }
454 }
455 }
456 }
457
458 print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
459 if ($ok) {
460 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
461 } else {
462 print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
463 $ok = 1;
464 }
465 }
466 }
467
468
469 /***************************************************************************************
470 *
471 * Load files data/*.sql. Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
472 *
473 ***************************************************************************************/
474 if ($ok && $createdata) {
475 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
476 $dir = "mysql/data/";
477
478 // Insert data
479 $handle = opendir($dir);
480 dolibarr_install_syslog("step2: open directory data ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
481 $tablefound = 0;
482 $tabledata = array();
483 if (is_resource($handle)) {
484 while (($file = readdir($handle)) !== false) {
485 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\-/', $file)) {
486 if (preg_match('/^llx_accounting_account_/', $file)) {
487 continue; // We discard data file of chart of account. This will be loaded when a chart is selected.
488 }
489
490 //print 'x'.$file.'-'.$createdata.'<br>';
491 if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) {
492 $tablefound++;
493 $tabledata[] = $file;
494 }
495 }
496 }
497 closedir($handle);
498 }
499
500 // Sort list of data files on alphabetical order (load order is important)
501 sort($tabledata);
502 foreach ($tabledata as $file) {
503 $name = substr($file, 0, dol_strlen($file) - 4);
504 $fp = fopen($dir.$file, "r");
505 dolibarr_install_syslog("step2: open data file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp));
506 if ($fp) {
507 $arrayofrequests = array();
508 $linefound = 0;
509 $linegroup = 0;
510 $sizeofgroup = 1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
511
512 // Load all requests
513 while (!feof($fp)) {
514 $buffer = fgets($fp, 4096);
515 $buffer = trim($buffer);
516 if ($buffer) {
517 if (substr($buffer, 0, 2) == '--') {
518 continue;
519 }
520
521 if ($linefound && ($linefound % $sizeofgroup) == 0) {
522 $linegroup++;
523 }
524 if (empty($arrayofrequests[$linegroup])) {
525 $arrayofrequests[$linegroup] = $buffer;
526 } else {
527 $arrayofrequests[$linegroup] .= " ".$buffer;
528 }
529
530 $linefound++;
531 }
532 }
533 fclose($fp);
534
535 dolibarr_install_syslog("step2: found ".$linefound." records, defined ".count($arrayofrequests)." group(s).");
536
537 $okallfile = 1;
538 $db->begin();
539
540 // We loop on each requests of file
541 foreach ($arrayofrequests as $buffer) {
542 // Replace the tables prefixes
543 if ($dolibarr_main_db_prefix != 'llx_') {
544 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
545 }
546
547 // Replace __ENTITY__ tag with 1 (master entity), this is only for dictionaries.
548 $buffer = preg_replace('/__ENTITY__/i', '1', $buffer);
549
550 //dolibarr_install_syslog("step2: request: " . $buffer);
551 $resql = $db->query($buffer, 1);
552 if ($resql) {
553 //$db->free($resql); // Not required as request we launch here does not return memory needs.
554 } else {
555 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
556 //print "<tr><td>Insertion ligne : $buffer</td><td>";
557 } else {
558 $ok = 0;
559 $okallfile = 0;
560 print '<span class="error">'.$langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."</span><br>";
561 }
562 }
563 }
564
565 if ($okallfile) {
566 $db->commit();
567 } else {
568 $db->rollback();
569 }
570 }
571 }
572
573 print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
574 if ($ok) {
575 print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
576 } else {
577 print '<td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
578 $ok = 1; // Data loading are not blocking errors
579 }
580 }
581 print '</table>';
582} else {
583 print 'Parameter action=set not defined';
584}
585
586
587$ret = 0;
588if (!$ok && isset($argv[1])) {
589 $ret = 1;
590}
591dolibarr_install_syslog("Exit ".$ret);
592
593dolibarr_install_syslog("- step2: end");
594
595
596// Force here a value we need after because master.inc.php is not loaded into step2.
597// This code must be similar with the one into main.inc.php
598
599$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
600
601$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.
602
603$out = '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> ';
604$out .= '<label for="dolibarrpingno">'.$langs->trans("MakeAnonymousPing").'</label>';
605
606$out .= '<!-- Add js script to manage the uncheck of option to not send the ping -->';
607$out .= '<script type="text/javascript">';
608$out .= 'jQuery(document).ready(function(){';
609$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=0; path=/"'."\n";
610$out .= ' jQuery("#dolibarrpingno").click(function() {';
611$out .= ' if (! $(this).is(\':checked\')) {';
612$out .= ' console.log("We uncheck anonymous ping");';
613$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=1; path=/"'."\n";
614$out .= ' } else {'."\n";
615$out .= ' console.log("We check anonymous ping");';
616$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=0; path=/"'."\n";
617$out .= ' }'."\n";
618$out .= ' });';
619$out .= '});';
620$out .= '</script>';
621
622print $out;
623
624pFooter($ok ? 0 : 1, $setuplang);
625
626if (isset($db) && is_object($db)) {
627 $db->close();
628}
629
630// Return code if ran from command line
631if ($ret) {
632 exit($ret);
633}
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition admin.lib.php:69
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:535
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:628
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:692
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)
Returns a hash (non reversible encryption) of a string.