31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
43 foreach ($versionarray as $key => $val) {
45 $versionarray[$key] = 0;
50 if (isset($versionarray[0])) {
51 $string = $versionarray[0];
53 if (isset($versionarray[1])) {
54 $string .=
'.'.$versionarray[1];
56 if (isset($versionarray[2])) {
57 $string .=
'.'.$versionarray[2];
83 $count1 = count($versionarray1);
84 $count2 = count($versionarray2);
85 $maxcount = max($count1, $count2);
86 while ($level < $maxcount) {
87 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
88 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
89 if (preg_match(
'/alpha|dev/i', $operande1)) {
92 if (preg_match(
'/alpha|dev/i', $operande2)) {
95 if (preg_match(
'/beta$/i', $operande1)) {
98 if (preg_match(
'/beta$/i', $operande2)) {
101 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
104 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
107 if (preg_match(
'/rc$/i', $operande1)) {
110 if (preg_match(
'/rc$/i', $operande2)) {
113 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
116 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
121 if ($operande1 < $operande2) {
125 if ($operande1 > $operande2) {
143 return explode(
'.', PHP_VERSION);
154 return preg_split(
'/[\-\.]/', DOL_VERSION);
181function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
183 global $db,
$conf, $langs;
185 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
187 if (!is_numeric($linelengthlimit)) {
188 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
199 $versionarray = $db->getVersionArray();
203 $fp = fopen($sqlfile,
"r");
207 if ($linelengthlimit > 0) {
208 $buf = fgets($fp, $linelengthlimit);
215 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
219 if (!empty($reg[1])) {
220 if (!preg_match(
'/'.preg_quote($reg[1],
'/').
'/i', $db->type)) {
227 if (!empty($reg[2])) {
228 if (is_numeric($reg[2])) {
229 $versionrequest = explode(
'.', $reg[2]);
230 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
234 $dbcollation = strtoupper(preg_replace(
'/_/',
'', (
string)
$conf->db->dolibarr_main_db_collation));
235 if (empty(
$conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
244 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
250 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
251 if (empty($nocommentremoval)) {
252 $buf = preg_replace(
'/([,;ERLT05\)])\s+--\s.*$/i',
'\1', $buf);
253 $buf = preg_replace(
'/([,;ERLT05\)])\s+--$/i',
'\1', $buf);
258 $buffer .= trim($buf);
263 if (preg_match(
'/;\s*$/', $buffer)) {
267 $arraysql[$i] = $buffer;
275 $arraysql[$i] = $buffer;
279 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
283 $listofmaxrowid = array();
284 foreach ($arraysql as $i => $sql) {
288 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
290 if (!isset($listofmaxrowid[$table])) {
292 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
293 $resql = $db->query($sqlgetrowid);
295 $obj = $db->fetch_object($resql);
296 $listofmaxrowid[$table] = $obj->max;
297 if (empty($listofmaxrowid[$table])) {
298 $listofmaxrowid[$table] = 0;
302 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
303 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
311 $from =
'__+MAX_'.$table.
'__';
312 $to =
'+'.$listofmaxrowid[$table];
313 $newsql = str_replace($from, $to, $newsql);
314 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
316 $arraysql[$i] = $newsql;
319 if ($offsetforchartofaccount > 0) {
325 $newsql = preg_replace(
'/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims',
'VALUES (__ENTITY__, \1 + '.((
int) $offsetforchartofaccount).
', \2, \3 + '.((
int) $offsetforchartofaccount), $newsql);
326 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
328 $arraysql[$i] = $newsql;
337 $listofinsertedrowid = array();
338 $keyforsqlfile = md5($sqlfile);
339 foreach ($arraysql as $i => $sql) {
342 if ($onlysqltoimportwebsite) {
343 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
346 $l = strlen($newsql);
351 $char = $newsql[$is];
358 } elseif (empty($quoteopen)) {
359 $newsqlclean .= $char;
363 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
369 if (preg_match(
'/^--/', $newsqlclean)) {
371 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
373 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
381 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
391 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
392 if ($errorphpcheck) {
396 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
406 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
407 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
413 if (MAIN_DB_PREFIX !=
'llx_') {
414 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
417 if (!empty($handler)) {
418 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
421 if (!empty($database)) {
422 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
425 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? ((
int) $entity) : (string) ((
int)
$conf->entity)), $sql);
429 print
'<tr class="trforrunsql'.$keyforsqlfile.
'"><td class="tdtop opacitymedium"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>'.$langs->trans(
"Request").
' '.($i + 1).
" sql='".
dol_htmlentities($newsql, ENT_NOQUOTES).
"'</td></tr>\n";
431 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
435 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
436 $num = count($reg[0]);
438 for ($j = 0; $j < $num; $j++) {
440 $to = $db->encrypt($reg[1][$j]);
441 $newsql = str_replace($from, $to, $newsql);
447 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
448 $num = count($reg[0]);
450 for ($j = 0; $j < $num; $j++) {
452 $to = $db->decrypt($reg[1][$j]);
453 $newsql = str_replace($from, $to, $newsql);
459 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
461 if (empty($listofinsertedrowid[$cursor])) {
463 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
464 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
471 $from =
'__'.$cursor.
'__';
472 $to = $listofinsertedrowid[$cursor];
473 $newsql = str_replace($from, $to, $newsql);
478 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
481 $result = $db->query($newsql, $usesavepoint);
484 print
'<!-- Result = OK -->'.
"\n";
487 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
491 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
492 $insertedrowid = $db->last_insert_id($table);
493 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
494 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
497 $errno = $db->errno();
499 print
'<!-- Result = '.$errno.
' -->'.
"\n";
504 'DB_ERROR_TABLE_ALREADY_EXISTS',
505 'DB_ERROR_COLUMN_ALREADY_EXISTS',
506 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
507 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
508 'DB_ERROR_RECORD_ALREADY_EXISTS',
509 'DB_ERROR_NOSUCHTABLE',
510 'DB_ERROR_NOSUCHFIELD',
511 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
512 'DB_ERROR_NO_INDEX_TO_DROP',
513 'DB_ERROR_CANNOT_CREATE',
514 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
515 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
522 if (preg_match(
'/^\s*ALTER\s+TABLE\s+[^\s]+_categorie_mo\s.*REFERENCES\s+[^\s(]+_mrp_mo\s*\(/i', $newsql)) {
523 $okerrors[] =
'DB_ERROR_CANNOT_ADD_FOREIGN_KEY_CONSTRAINT';
526 if ($okerror ==
'none') {
531 if (!in_array($errno, $okerrors)) {
533 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
534 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
535 print
'</td></tr>'.
"\n";
537 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
545 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
546 print
'<td class="right">';
548 print
'<span class="ok">'.$langs->trans(
"Success").
'</span>';
550 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
554 print
'<script type="text/javascript">
555 jQuery(document).ready(function() {
556 function init_trrunsql'.$keyforsqlfile.
'()
558 console.log("toggle .trforrunsql'.$keyforsqlfile.
'");
559 jQuery(".trforrunsql'.$keyforsqlfile.
'").toggle();
561 init_trrunsql'.$keyforsqlfile.
'();
562 jQuery(".trforrunsqlshowhide'.$keyforsqlfile.
'").click(function() {
563 init_trrunsql'.$keyforsqlfile.
'();
567 if (count($arraysql)) {
568 print
' - <a class="reposition trforrunsqlshowhide'.$keyforsqlfile.
' reposition" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
570 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
574 print
'</td></tr>'.
"\n";
599 global
$conf, $hookmanager;
602 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
605 if (! is_object($hookmanager)) {
606 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
615 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
620 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
621 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
622 if (is_numeric($name)) {
623 $sql .=
" OR rowid = ".((int) $name);
627 $sql .=
" AND entity = ".((int) $entity);
630 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
631 $resql = $db->query($sql);
633 $conf->global->$name =
'';
636 dol_print_error($db);
657 $sql =
"SELECT ".$db->sanitize($db->decrypt(
'value')).
" as value";
658 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
659 $sql .=
" WHERE name = '".$db->escape($db->encrypt($name, 0)).
"'";
660 $sql .=
" AND entity = ".((int) $entity);
662 $resql = $db->query($sql);
664 $obj = $db->fetch_object($resql);
666 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
688function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
690 global
$conf, $hookmanager, $user;
694 $value = (string) $value;
698 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
701 if (! is_object($hookmanager)) {
702 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
706 $value = (string) $value;
712 'visible' => $visible,
717 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
724 $userid = (!empty($user) && is_object($user) && $user->id > 0) ? (
int) $user->id : 0;
728 $sql =
"SELECT fk_user_creat FROM ".MAIN_DB_PREFIX.
"const";
729 $sql .=
" WHERE name = ".$db->encrypt($name);
731 $sql .=
" AND entity = ".((int) $entity);
733 $resql = $db->query($sql);
735 $obj = $db->fetch_object($resql);
736 if ($obj && $obj->fk_user_creat > 0) {
737 $fk_user_creat = (int) $obj->fk_user_creat;
740 if (empty($fk_user_creat)) {
741 $fk_user_creat = $userid;
746 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
747 $sql .=
" WHERE name = ".$db->encrypt($name);
749 $sql .=
" AND entity = ".((int) $entity);
752 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
753 $resql = $db->query($sql);
755 if (strcmp($value,
'')) {
756 $tmpname = preg_replace(
'/(_TEST|_PROD)$/',
'', $name);
757 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name)
758 && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_TOKEN|_REFRESH)$/', $tmpname))) {
762 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
768 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity, fk_user_creat, fk_user_modif)";
770 $sql .= $db->encrypt($name);
771 $sql .=
", ".$db->encrypt($newvalue);
772 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity);
773 $sql .=
", ".($fk_user_creat > 0 ? (int) $fk_user_creat :
"NULL");
774 $sql .=
", ".($userid > 0 ? (int) $userid :
"NULL").
")";
778 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
779 $resql = $db->query($sql);
785 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
787 $sql .= $db->encrypt($name);
788 $sql .=
", ".$db->encrypt($newvalue);
789 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
791 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
792 $resql = $db->query($sql);
798 $conf->global->$name = $value;
819 global $langs, $form;
821 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
822 $desc = str_replace(
'{picto}', img_picto(
'',
'switch_off'), $desc);
828 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
829 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
831 $head[$h][1] = $langs->trans(
"AvailableModules");
832 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
835 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
837 $head[$h][2] =
'modules';
840 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
841 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
842 $head[$h][2] =
'marketplace';
845 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
846 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
847 $head[$h][2] =
'deploy';
850 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
851 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
852 $head[$h][2] =
'develop';
865 global $langs,
$conf;
869 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
870 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
871 $head[$h][2] =
'other';
874 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
875 $head[$h][1] = $langs->trans(
"SkinAndColors");
876 $head[$h][2] =
'template';
879 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
880 $head[$h][1] = $langs->trans(
"Dashboard");
881 $head[$h][2] =
'dashboard';
884 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
885 $head[$h][1] = $langs->trans(
"LoginPage");
886 $head[$h][2] =
'login';
889 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
890 $head[$h][1] = $langs->trans(
"CSSPage");
891 $head[$h][2] =
'css';
917 global $db, $langs,
$conf;
921 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
922 $head[$h][1] = $langs->trans(
"Miscellaneous");
923 $head[$h][2] =
'misc';
926 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
927 $head[$h][1] = $langs->trans(
"Captcha");
928 $head[$h][2] =
'captcha';
931 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
932 $head[$h][1] = $langs->trans(
"Passwords");
933 $head[$h][2] =
'passwords';
936 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
937 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
938 $head[$h][2] =
'file';
948 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
949 $head[$h][1] = $langs->trans(
"ExternalAccess");
950 $head[$h][2] =
'proxy';
953 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
954 $head[$h][1] = $langs->trans(
"Audit");
955 $head[$h][2] =
'audit';
958 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
959 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
960 $head[$h][2] =
'openid';
966 $sql =
"SELECT COUNT(r.id) as nb";
967 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
968 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
969 $sql .=
" AND entity = ".((int)
$conf->entity);
970 $sql .=
" AND bydefault = 1";
972 $sql .=
" AND r.perms NOT LIKE '%_advance'";
974 $resql = $db->query($sql);
976 $obj = $db->fetch_object($resql);
981 dol_print_error($db);
985 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
986 $head[$h][1] = $langs->trans(
"DefaultRights");
988 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
990 $head[$h][2] =
'default';
994 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
995 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
996 $head[$h][2] =
'headers_http';
1010 global $langs,
$conf;
1017 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
1018 $head[$h][1] = $langs->trans(
"Description");
1019 $head[$h][2] =
'desc';
1022 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
1023 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
1024 $head[$h][2] =
'feature';
1027 if (
$object->isCoreOrExternalModule() ==
'external') {
1028 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
1029 $head[$h][1] = $langs->trans(
"ChangeLog");
1030 $head[$h][2] =
'changelog';
1048 global $langs,
$conf;
1052 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1053 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1054 $head[$h][2] =
'searchkey';
1057 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1058 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1059 $head[$h][2] =
'overwrite';
1078 global $langs,
$conf;
1082 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1083 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1084 $head[$h][2] =
'createform';
1087 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1088 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1089 $head[$h][2] =
'filters';
1092 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1093 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1094 $head[$h][2] =
'sortorder';
1097 if (!empty(
$conf->use_javascript_ajax)) {
1098 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1099 $head[$h][1] = $langs->trans(
"DefaultFocus");
1100 $head[$h][2] =
'focus';
1103 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1104 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1105 $head[$h][2] =
'mandatory';
1130 global
$conf, $php_session_save_handler;
1132 $arrayofSessions = array();
1134 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1135 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1140 $iniPath = ini_get(
"session.save_path");
1142 $sessPath = $iniPath;
1145 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1149 while (($file = @readdir($dh)) !==
false) {
1150 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1151 $fullpath = $sessPath.$file;
1152 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1153 $sessValues = file_get_contents($fullpath);
1159 if (preg_match(
'/dol_login/i', $sessValues) &&
1160 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1161 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1162 $tmp = explode(
'_', $file);
1165 $arrayofSessions[$idsess][
"login"] =
'';
1166 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1168 $arrayofSessions[$idsess][
"login"] = (string) $regs[1];
1170 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1171 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1172 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1173 $arrayofSessions[$idsess][
"user_agent"] =
null;
1174 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1175 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1183 return $arrayofSessions;
1196 $sessPath = ini_get(
"session.save_path").
"/";
1197 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1203 while (($file = @readdir($dh)) !==
false) {
1204 if ($file !=
"." && $file !=
"..") {
1205 $fullpath = $sessPath.$file;
1206 if (!@is_dir($fullpath)) {
1207 $sessValues = file_get_contents($fullpath);
1209 if (preg_match(
'/dol_login/i', $sessValues) &&
1210 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1211 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1212 $tmp = explode(
'_', $file);
1215 if ($idsess != $mysessionid) {
1216 $res = @unlink($fullpath);
1246function activateModule($value, $withdeps = 1, $noconfverification = 0, $options =
'')
1253 if (empty($value)) {
1254 $ret[
'errors'] = array(
'ErrorBadParameter');
1258 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1260 $modFile = $modName.
".class.php";
1267 foreach ($modulesdir as $dir) {
1268 if (file_exists($dir.$modFile)) {
1269 $found = @include_once $dir.$modFile;
1276 $objMod =
new $modName($db);
1277 '@phan-var-force DolibarrModules $objMod';
1282 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1284 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1290 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1293 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1298 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1299 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1302 $const_name = $objMod->const_name;
1303 if ($noconfverification == 0) {
1309 $result = $objMod->init($options);
1312 $ret[
'errors'][] = $objMod->error;
1315 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1318 foreach ($objMod->depends as $key => $modulestringorarray) {
1320 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1321 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1325 if (!is_array($modulestringorarray)) {
1326 $modulestringorarray = array($modulestringorarray);
1329 foreach ($modulestringorarray as $modulestring) {
1332 $resarray = array();
1333 foreach ($modulesdir as $dir) {
1334 if (file_exists($dir.$modulestring.
".class.php")) {
1335 $resarray = activateModule($modulestring, 1, 0, $options);
1336 if (empty($resarray[
'errors'])) {
1339 $activateerr = implode(
', ', $resarray[
'errors']);
1340 foreach ($resarray[
'errors'] as $errorMessage) {
1349 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1350 $ret[
'nbperms'] += $resarray[
'nbperms'];
1353 $ret[
'errors'][] = $activateerr;
1355 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1361 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1363 $num = count($objMod->conflictwith);
1364 for ($i = 0; $i < $num; $i++) {
1365 foreach ($modulesdir as $dir) {
1366 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1367 unActivateModule($objMod->conflictwith[$i], 0);
1375 if (!count($ret[
'errors'])) {
1376 $ret[
'nbmodules']++;
1377 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1392function unActivateModule($value, $requiredby = 1, $options =
'')
1396 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1399 if (empty($value)) {
1400 return 'ErrorBadParameter';
1405 $modFile = $modName.
".class.php";
1412 foreach ($modulesdir as $dir) {
1413 if (file_exists($dir.$modFile)) {
1414 $found = @include_once $dir.$modFile;
1422 $objMod =
new $modName($db);
1423 '@phan-var-force DolibarrModules $objMod';
1426 $result = $objMod->remove($options);
1428 $ret = $objMod->error;
1433 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1435 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1436 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1437 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1438 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1439 $genericMod->remove(
'');
1443 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1444 $countrb = count($objMod->requiredby);
1445 for ($i = 0; $i < $countrb; $i++) {
1447 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1473function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1477 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1484 foreach ($modulesdir as $dir) {
1487 dol_syslog(
"Scan directory ".$dir.
" for modules");
1489 if (is_resource($handle)) {
1490 while (($file = readdir($handle)) !==
false) {
1496 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1497 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1500 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1501 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1505 include_once $dir.$file;
1506 $objMod =
new $modName($db);
1507 '@phan-var-force DolibarrModules $objMod';
1510 if ($objMod->numero > 0) {
1511 $j = $objMod->numero;
1516 $modulequalified = 1;
1519 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1521 $modulequalified = 0;
1524 $modulequalified = 0;
1528 $modulequalified = 0;
1531 if ($modulequalified) {
1533 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1534 foreach ($objMod->langfiles as $langfile) {
1535 $langs->load($langfile);
1542 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1544 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1548 if (!empty($objMod->dictionaries)) {
1550 $nbtabname = $nbtablib = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = $nbtabsql = 0;
1551 $tabnamerelwithkey = array();
1552 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1553 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1555 $taborder[] = max($taborder) + 1;
1557 $tabnamerelwithkey[$key] = $val;
1558 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1560 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1561 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1564 $tabcomplete[$tmptablename][
'lib'] = $val;
1566 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1567 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1570 $tabcomplete[$tmptablename][
'sql'] = $val;
1572 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1573 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1575 $tabsqlsort[] = $val;
1576 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1578 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1579 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1582 $tabcomplete[$tmptablename][
'field'] = $val;
1584 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1585 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1587 $tabfieldvalue[] = $val;
1588 $tabcomplete[$tmptablename][
'value'] = $val;
1590 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1591 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1592 $nbtabfieldinsert++;
1593 $tabfieldinsert[] = $val;
1594 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1596 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1597 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1599 $tabrowid[] = (int) $val;
1600 $tabcomplete[$tmptablename][
'rowid'] = (int) $val;
1602 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1603 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1606 $tabcomplete[$tmptablename][
'cond'] = $val;
1608 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1609 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1610 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1613 $tabcomplete[$tmptablename][
'help'] = $val;
1616 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1617 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1618 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1620 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1624 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1625 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1635 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1642 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1657function activateModulesRequiredByCountry($country_code)
1663 foreach ($modulesdir as $dir) {
1665 dol_syslog(
"Scan directory ".$dir.
" for modules");
1667 if (is_resource($handle)) {
1668 while (($file = readdir($handle)) !==
false) {
1673 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1674 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1677 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1678 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1682 include_once $dir.$file;
1683 $objMod =
new $modName($db);
1684 '@phan-var-force DolibarrModules $objMod';
1687 $modulequalified = 1;
1690 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1692 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1693 $modulequalified = 0;
1695 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1696 $modulequalified = 0;
1699 $modulequalified = 0;
1702 if ($modulequalified) {
1704 if (isset($objMod->automatic_activation[$country_code])) {
1705 activateModule($modName, 1, 0);
1707 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1710 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1717 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1730function complete_elementList_with_modules(&$elementList)
1732 global $db, $modules,
$conf, $langs;
1735 $filename = array();
1744 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1748 foreach ($modulesdir as $dir) {
1751 dol_syslog(
"Scan directory ".$dir.
" for modules");
1753 if (is_resource($handle)) {
1754 while (($file = readdir($handle)) !==
false) {
1760 include_once $dir.$file;
1761 $objMod =
new $modName($db);
1764 if ($objMod->numero > 0) {
1765 $j = $objMod->numero;
1770 $modulequalified = 1;
1773 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1775 $modulequalified = 0;
1778 $modulequalified = 0;
1782 $modulequalified = 0;
1785 if ($modulequalified) {
1787 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1788 foreach ($objMod->langfiles as $langfile) {
1789 $langs->load($langfile);
1793 $modules[$i] = $objMod;
1794 $filename[$i] = $modName;
1795 $orders[$i] = $objMod->family.
"_".$j;
1799 if (!empty($objMod->module_parts[
'contactelement'])) {
1800 if (is_array($objMod->module_parts[
'contactelement'])) {
1801 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1802 $elementList[$elem] = $langs->trans($title);
1805 $elementList[$objMod->name] = $langs->trans($objMod->name);
1812 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1819 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1840 global $db, $langs,
$conf, $user;
1841 global $_Avery_Labels;
1843 $form =
new Form($db);
1845 print
'<div class="div-table-responsive-no-min">';
1846 print
'<table class="noborder centpercent">';
1847 print
'<tr class="liste_titre">';
1848 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1851 $text = $langs->trans($text);
1852 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1857 foreach ($tableau as $key => $const) {
1860 if (is_array($const)) {
1861 $type = $const[
'type'];
1862 $label = $const[
'label'];
1871 $sql .=
", ".$db->decrypt(
'name').
" as name";
1872 $sql .=
", ".$db->decrypt(
'value').
" as value";
1875 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1876 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1877 $sql .=
" AND entity IN (0, ".((int)
$conf->entity).
")";
1878 $sql .=
" ORDER BY name ASC, entity DESC";
1879 $result = $db->query($sql);
1884 $obj = $db->fetch_object($result);
1887 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1890 print
'<tr class="oddeven">';
1894 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1895 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1896 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1897 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1900 $tmparray = explode(
':', $obj->type);
1901 if (!empty($tmparray[1])) {
1902 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1904 print img_picto(
'', $picto,
'class="pictofixedwidth"');
1906 if (!empty($tableau[$key][
'tooltip'])) {
1907 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1909 print($label ? $label : $langs->trans(
'Desc'.$const));
1912 if ($const ==
'ADHERENT_MAILMAN_URL') {
1913 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1915 print
'<div id="example1" class="hidden">';
1916 print
'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0';
1918 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1919 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1920 print
'<div id="example2" class="hidden">';
1921 print
'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&send_unsub_ack_to_this_batch=0&send_unsub_notifications_to_list_owner=0';
1924 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1925 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1926 print
'<div id="example3" class="hidden">';
1927 print
'mymailmanlist<br>';
1928 print
'mymailmanlist1,mymailmanlist2<br>';
1929 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1931 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1935 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1936 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1942 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1945 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1946 $arrayoflabels = array();
1947 foreach (array_keys($_Avery_Labels) as $codecards) {
1948 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1950 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1951 print
'<input type="hidden" name="consttype" value="yesno">';
1952 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1956 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1957 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1958 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1959 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1961 print
"</textarea>\n";
1962 } elseif ($obj->type ==
'html') {
1963 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1964 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1965 $doleditor->Create();
1966 } elseif ($obj->type ==
'yesno') {
1967 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1968 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1969 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1972 $tmp = explode(
':', $obj->type);
1974 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1976 $arrayofmessagename = array();
1977 if (is_array($formmail->lines_model)) {
1978 foreach ($formmail->lines_model as $modelmail) {
1980 if (!empty($arrayofmessagename[$modelmail->label])) {
1981 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1984 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1988 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1990 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/mails_templates.php', [
'action' =>
'create',
'type_template' => $tmp[1],
'backtopage' =>
dolBuildUrl($_SERVER[
"PHP_SELF"])]).
'">'.img_picto(
'',
'add').
'</a>';
1991 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1992 print img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1994 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
2017 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
2021 if (!empty($modules)) {
2023 foreach ($tmpmodules as
$module) {
2024 $moduleconst =
$module->const_name;
2025 $modulename = strtolower(
$module->name);
2029 if (!in_array($modulename, $listofmodules)) {
2041 $tmptext = $langs->transnoentitiesnoconv(
'Module'.
$module->numero.
'Name');
2042 if ($tmptext !=
'Module'.
$module->numero.
'Name') {
2043 $text .= $langs->transnoentitiesnoconv(
'Module'.
$module->numero.
'Name');
2045 $text .= $langs->transnoentitiesnoconv(
$module->name);
2069 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2070 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int)
$conf->entity).
", ";
2071 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2072 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2075 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2076 $resql = $db->query($sql);
2081 dol_print_error($db);
2100 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2101 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2102 $sql .=
" AND type = '".$db->escape($type).
"'";
2103 $sql .=
" AND entity = ".((int)
$conf->entity);
2105 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2106 $resql = $db->query($sql);
2111 dol_print_error($db);
2135function printDocumentModelList($type, $moduledir, $constpdf, $title, array $features, $excludedisabled =
false, $constpdfdefault =
'', $usedefault = 1, $actionunset =
'')
2137 global $db, $langs,
$conf;
2139 $form =
new Form($db);
2140 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
2145 $sql =
"SELECT nom";
2146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
2147 $sql .=
" WHERE type = '".$db->escape($type).
"'";
2148 $sql .=
" AND entity = ".((int)
$conf->entity);
2149 $resql = $db->query($sql);
2152 $num_rows = $db->num_rows($resql);
2153 while ($i < $num_rows) {
2154 $array = $db->fetch_array($resql);
2155 if (is_array($array)) {
2156 array_push($def, $array[0]);
2161 dol_print_error($db);
2164 print
'<div class="div-table-responsive-no-min">';
2165 print
'<table class="noborder centpercent">';
2166 print
'<tr class="liste_titre">';
2167 print
'<td>'.$langs->trans(
"Name").
'</td>';
2168 print
'<td>'.$langs->trans(
"Description").
'</td>';
2169 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
2171 print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
2173 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
2174 print
'<td class="center" width="60">'.$langs->trans(
"Preview").
'</td>';
2179 foreach ($dirmodels as $reldir) {
2180 foreach (array(
'',
'/doc') as $valdir) {
2181 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
2185 $handle = opendir($dir);
2186 if (is_resource($handle)) {
2187 $filelist = array();
2188 while (($file = readdir($handle)) !==
false) {
2189 $filelist[] = $file;
2194 foreach ($filelist as $file) {
2195 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
2196 if (file_exists($dir.
'/'.$file)) {
2200 require_once $dir.
'/'.$file;
2201 $module =
new $classname($db);
2203 '@phan-var-force CommonDocGenerator $module';
2206 $modulequalified = 1;
2208 $modulequalified = 0;
2211 $modulequalified = 0;
2213 if ($excludedisabled &&
$module->version ==
'disabled') {
2214 $modulequalified = 0;
2217 if ($modulequalified) {
2218 print
'<tr class="oddeven"><td>';
2220 print
"</td><td>\n";
2221 if (method_exists(
$module,
'info')) {
2229 if (in_array($name, $def)) {
2230 print
'<td class="center">'.
"\n";
2231 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.
$module->scandir.
'&label='.urlencode(
$module->name).
'">';
2232 print img_picto($langs->trans(
"Enabled"),
'switch_on');
2237 print
'<td class="center">'.
"\n";
2238 print img_picto(
dol_escape_htmltag($langs->trans(
"ErrorModuleRequirePHPVersion", implode(
'.',
$module->phpmin))),
'switch_off',
'class="opacitymedium"');
2241 print
'<td class="center">'.
"\n";
2242 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'">'.img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
2249 print
'<td class="center">';
2252 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action='.$actionunset.
'&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'" alt="'.$langs->trans(
"Disable").
'">'.img_picto($langs->trans(
"Default"),
'on').
'</a>';
2254 print img_picto($langs->trans(
"Default"),
'on');
2257 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'" alt="'.$langs->trans(
"Default").
'">'.img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
2263 $htmltooltip =
''.$langs->trans(
"Name").
': '.
$module->name;
2264 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.(
$module->type ?
$module->type : $langs->trans(
"Unknown"));
2266 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.
$module->page_largeur.
'/'.
$module->page_hauteur;
2268 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
2270 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
2271 foreach ($features as $key => $property) {
2272 $htmltooltip .=
'<br>'.$langs->trans($key).
': '.yn(
$module->$property, 1, 1);
2275 print
'<td class="center">';
2276 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
2280 print
'<td class="center">';
2282 print
'<a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'action' =>
'specimen',
'module' => $name),
true).
'">'.img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
2284 print img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
2317function printNumberingModuleList($moduledir, $prefix, $constname, $title, $specimenobject, $actionname =
'setmod')
2321 $form =
new Form($db);
2322 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
2326 print
'<div class="div-table-responsive-no-min">';
2327 print
'<table class="noborder centpercent">';
2328 print
'<tr class="liste_titre">';
2329 print
'<td>'.$langs->trans(
"Name").
'</td>';
2330 print
'<td>'.$langs->trans(
"Description").
'</td>';
2331 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
2332 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
2333 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
2338 $arrayofmodules = array();
2340 foreach ($dirmodels as $reldir) {
2344 $handle = opendir($dir);
2345 if (is_resource($handle)) {
2346 while (($file = readdir($handle)) !==
false) {
2350 require_once $dir.
'/'.$file.
'.php';
2353 '@phan-var-force CommonNumRefGenerator $module';
2366 '@phan-var-force CommonNumRefGenerator[] $arrayofmodules';
2368 foreach ($arrayofmodules as
$module) {
2380 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td>\n";
2386 print
'<td class="nowrap">';
2388 if (preg_match(
'/^Error/', $tmp)) {
2389 $langs->load(
"errors");
2390 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
2391 } elseif ($tmp ==
'NotConfigured') {
2392 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
2398 print
'<td class="center">';
2400 print img_picto($langs->trans(
"Activated"),
'switch_on');
2402 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action='.$actionname.
'&token='.
newToken().
'&value='.urlencode($file).
'">';
2403 print img_picto($langs->trans(
"Disabled"),
'switch_off');
2410 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.
$module->getVersion().
'</b><br>';
2412 if ((
string) $nextval != $langs->trans(
"NotAvailable")) {
2413 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
2415 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
2416 $nextval = $langs->trans($nextval);
2418 $htmltooltip .= $nextval.
'<br>';
2420 $htmltooltip .= $langs->trans(
$module->error).
'<br>';
2424 print
'<td class="center">';
2425 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
2446 $phpinfostring = ob_get_contents();
2449 $info_arr = array();
2450 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2452 foreach ($info_lines as $line) {
2455 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2457 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2458 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2459 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2460 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2473 global $langs,
$conf;
2478 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2479 $head[$h][1] = $langs->trans(
"MyOrganization");
2480 $head[$h][2] =
'company';
2483 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2484 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2485 $head[$h][2] =
'socialnetworks';
2488 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2489 $head[$h][1] = $langs->trans(
"OpeningHours");
2490 $head[$h][2] =
'openinghours';
2493 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2494 $head[$h][1] = $langs->trans(
"Subcontractors");
2495 $head[$h][2] =
'subcontractors';
2512 global $langs,
$conf, $user;
2517 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2518 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2519 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2520 $head[$h][2] =
'common';
2524 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2525 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2526 $head[$h][2] =
'common_emailing';
2531 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2532 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2533 $head[$h][2] =
'common_ticket';
2537 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2538 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2539 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2540 $head[$h][2] =
'common_passwordreset';
2546 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2547 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2548 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2549 $head[$h][2] =
'senderprofiles';
2553 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2554 $head[$h][1] = $langs->trans(
"EMailTemplates");
2555 $head[$h][2] =
'templates';
2558 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2559 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2560 $head[$h][2] =
'common_ingoing';
2577 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2578 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2579 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2580 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2581 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2582 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2583 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2584 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2585 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2586 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2587 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2588 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2589 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2590 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2591 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2592 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2593 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2594 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2596 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2597 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2599 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2600 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2602 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2604 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2605 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2606 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2620 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2621 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2622 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2623 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2624 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2625 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2626 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2627 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2628 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2629 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2630 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2631 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2632 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2635 "document" => array(
2636 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2637 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2638 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2639 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2642 "navigation" => array(
2643 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2644 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2645 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2646 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2649 "reporting" => array(
2650 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2653 "require-trusted-types-for" => array(
2654 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2656 "trusted-types" => array(
2657 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2658 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2659 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2672 $forceCSPArr = array();
2674 $sourceCSPArrflatten = array();
2677 foreach ($sourceCSPArr as $key => $arr) {
2678 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2681 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2682 $securitypolicies = explode(
";", $forceCSP);
2685 foreach ($securitypolicies as $key => $securitypolicy) {
2686 if ($securitypolicy ==
"") {
2689 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2690 $securitypolicyarr = explode(
" ", $securitypolicy);
2691 $directive = array_shift($securitypolicyarr);
2693 while ($directive ==
"") {
2694 $directive = array_shift($securitypolicyarr);
2696 if (empty($directive)) {
2699 $sources = $securitypolicyarr;
2700 if (empty($sources)) {
2701 $forceCSPArr[$directive] = array();
2704 foreach ($sources as $key2 => $source) {
2705 $source = str_replace(
"'",
"", $source);
2706 if (empty($source)) {
2709 if (empty($forceCSPArr[$directive])) {
2710 $forceCSPArr[$directive] = array($source);
2712 $forceCSPArr[$directive][] = $source;
2717 return $forceCSPArr;
if(! $sortfield) if(! $sortorder) $object
versiontostring($versionarray)
Return a version in a string from a version into an array.
security_prepare_head()
Prepare array with list of tabs.
run_sql($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
Launch a sql file.
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
form_constantes($tableau, $strictw3c=2, $helptext='', $text='')
Show array with constants to edit.
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).
purgeSessions($mysessionid)
Purge existing sessions.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
versiondolibarrarray()
Return version Dolibarr.
delDocumentModel($name, $type)
Delete document model used by doc generator.
showModulesExludedForExternal($modules)
Show array with constants to edit.
versionphparray()
Return version PHP.
ihm_prepare_head()
Prepare array with list of tabs.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
modulehelp_prepare_head($object)
Prepare array with list of tabs.
listOfSessions()
Return list of session.
phpinfo_array()
Return the php_info into an array.
dolibarr_get_const($db, $name, $entity=1)
Get the value of a setup constant from database.
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
Prepare array with list of tabs.
GetContentPolicySources()
Prepare array of sources for HTTP headers.
GetContentPolicyToArray($forceCSP)
Transform a Content Security Policy to an array.
email_admin_prepare_head()
Return array head with list of tabs to view object information.
translation_prepare_head()
Prepare array with list of tabs.
company_admin_prepare_head()
Return array head with list of tabs to view object information.
defaultvalues_prepare_head()
Prepare array with list of tabs.
GetContentPolicyDirectives()
Prepare array of directives for HTTP headers.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage a WYSIWYG editor.
if(! $sortfield) if(! $sortorder) $module
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
dolListSessions()
List sessions in db.
$conf db name
Only used if Module[ID]Name translation string is not found.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='', $obfuscationmode='dolcrypt')
Encode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check that the new string $phpfullcodestring contains only php code (including <php tag)