30require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
42 if (isset($versionarray[0])) {
43 $string = $versionarray[0];
45 if (isset($versionarray[1])) {
46 $string .=
'.'.$versionarray[1];
48 if (isset($versionarray[2])) {
49 $string .=
'.'.$versionarray[2];
75 $count1 = count($versionarray1);
76 $count2 = count($versionarray2);
77 $maxcount = max($count1, $count2);
78 while ($level < $maxcount) {
79 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
80 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
81 if (preg_match(
'/alpha|dev/i', $operande1)) {
84 if (preg_match(
'/alpha|dev/i', $operande2)) {
87 if (preg_match(
'/beta$/i', $operande1)) {
90 if (preg_match(
'/beta$/i', $operande2)) {
93 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
96 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
99 if (preg_match(
'/rc$/i', $operande1)) {
102 if (preg_match(
'/rc$/i', $operande2)) {
105 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
108 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
113 if ($operande1 < $operande2) {
117 if ($operande1 > $operande2) {
135 return explode(
'.', PHP_VERSION);
146 return preg_split(
'/[\-\.]/', DOL_VERSION);
173function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
175 global $db, $conf, $langs;
177 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
179 if (!is_numeric($linelengthlimit)) {
180 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
191 $versionarray = $db->getVersionArray();
195 $fp = fopen($sqlfile,
"r");
199 if ($linelengthlimit > 0) {
200 $buf = fgets($fp, $linelengthlimit);
207 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
211 if (!empty($reg[1])) {
212 if (!preg_match(
'/'.preg_quote($reg[1],
'/').
'/i', $db->type)) {
219 if (!empty($reg[2])) {
220 if (is_numeric($reg[2])) {
221 $versionrequest = explode(
'.', $reg[2]);
224 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
228 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
231 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
241 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
247 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
248 if (empty($nocommentremoval)) {
249 $buf = preg_replace(
'/([,;ERLT05\)])\s+--\s.*$/i',
'\1', $buf);
250 $buf = preg_replace(
'/([,;ERLT05\)])\s+--$/i',
'\1', $buf);
255 $buffer .= trim($buf);
260 if (preg_match(
'/;\s*$/', $buffer)) {
264 $arraysql[$i] = $buffer;
272 $arraysql[$i] = $buffer;
276 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
280 $listofmaxrowid = array();
281 foreach ($arraysql as $i => $sql) {
285 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
287 if (!isset($listofmaxrowid[$table])) {
289 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
290 $resql = $db->query($sqlgetrowid);
292 $obj = $db->fetch_object($resql);
293 $listofmaxrowid[$table] = $obj->max;
294 if (empty($listofmaxrowid[$table])) {
295 $listofmaxrowid[$table] = 0;
299 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
300 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
308 $from =
'__+MAX_'.$table.
'__';
309 $to =
'+'.$listofmaxrowid[$table];
310 $newsql = str_replace($from, $to, $newsql);
311 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
313 $arraysql[$i] = $newsql;
316 if ($offsetforchartofaccount > 0) {
322 $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);
323 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
325 $arraysql[$i] = $newsql;
334 $listofinsertedrowid = array();
335 $keyforsql = md5($sqlfile);
336 foreach ($arraysql as $i => $sql) {
339 if ($onlysqltoimportwebsite) {
340 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
343 $l = strlen($newsql);
348 $char = $newsql[$is];
355 } elseif (empty($quoteopen)) {
356 $newsqlclean .= $char;
360 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
366 if (preg_match(
'/^--/', $newsqlclean)) {
368 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
370 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
378 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
388 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
389 if ($errorphpcheck) {
393 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
403 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
404 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
410 if (MAIN_DB_PREFIX !=
'llx_') {
411 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
414 if (!empty($handler)) {
415 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
418 if (!empty($database)) {
419 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
422 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (string) $conf->entity), $sql);
426 print
'<tr class="trforrunsql'.$keyforsql.
'"><td class="tdtop opacitymedium"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>'.$langs->trans(
"Request").
' '.($i + 1).
" sql='".
dol_htmlentities($newsql, ENT_NOQUOTES).
"'</td></tr>\n";
428 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
432 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
433 $num = count($reg[0]);
435 for ($j = 0; $j < $num; $j++) {
437 $to = $db->encrypt($reg[1][$j]);
438 $newsql = str_replace($from, $to, $newsql);
444 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
445 $num = count($reg[0]);
447 for ($j = 0; $j < $num; $j++) {
449 $to = $db->decrypt($reg[1][$j]);
450 $newsql = str_replace($from, $to, $newsql);
456 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
458 if (empty($listofinsertedrowid[$cursor])) {
460 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
461 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
468 $from =
'__'.$cursor.
'__';
469 $to = $listofinsertedrowid[$cursor];
470 $newsql = str_replace($from, $to, $newsql);
475 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
478 $result = $db->query($newsql, $usesavepoint);
481 print
'<!-- Result = OK -->'.
"\n";
484 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
488 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
489 $insertedrowid = $db->last_insert_id($table);
490 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
491 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
494 $errno = $db->errno();
496 print
'<!-- Result = '.$errno.
' -->'.
"\n";
501 'DB_ERROR_TABLE_ALREADY_EXISTS',
502 'DB_ERROR_COLUMN_ALREADY_EXISTS',
503 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
504 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
505 'DB_ERROR_RECORD_ALREADY_EXISTS',
506 'DB_ERROR_NOSUCHTABLE',
507 'DB_ERROR_NOSUCHFIELD',
508 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
509 'DB_ERROR_NO_INDEX_TO_DROP',
510 'DB_ERROR_CANNOT_CREATE',
511 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
512 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
515 if ($okerror ==
'none') {
520 if (!in_array($errno, $okerrors)) {
522 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
523 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
524 print
'</td></tr>'.
"\n";
526 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
534 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
535 print
'<td class="right">';
537 print
'<span class="ok">'.$langs->trans(
"Success").
'</span>';
539 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
543 print
'<script type="text/javascript">
544 jQuery(document).ready(function() {
545 function init_trrunsql'.$keyforsql.
'()
547 console.log("toggle .trforrunsql'.$keyforsql.
'");
548 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
550 init_trrunsql'.$keyforsql.
'();
551 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
552 init_trrunsql'.$keyforsql.
'();
556 if (count($arraysql)) {
557 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
' reposition" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
559 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
563 print
'</td></tr>'.
"\n";
588 global $conf, $hookmanager;
591 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
594 if (! is_object($hookmanager)) {
595 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
604 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
609 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
610 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
611 if (is_numeric($name)) {
612 $sql .=
" OR rowid = ".((int) $name);
616 $sql .=
" AND entity = ".((int) $entity);
619 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
620 $resql = $db->query($sql);
622 $conf->global->$name =
'';
644 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
645 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
646 $sql .=
" WHERE name = ".$db->encrypt($name);
647 $sql .=
" AND entity = ".((int) $entity);
649 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
650 $resql = $db->query($sql);
652 $obj = $db->fetch_object($resql);
654 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
676function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
678 global $conf, $hookmanager;
682 $value = (string) $value;
686 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
689 if (! is_object($hookmanager)) {
690 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
694 $value = (string) $value;
700 'visible' => $visible,
705 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
714 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
715 $sql .=
" WHERE name = ".$db->encrypt($name);
717 $sql .=
" AND entity = ".((int) $entity);
720 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
721 $resql = $db->query($sql);
723 if (strcmp($value,
'')) {
724 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECRET_.*|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
729 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
735 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
737 $sql .= $db->encrypt($name);
738 $sql .=
", ".$db->encrypt($newvalue);
739 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
743 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
744 $resql = $db->query($sql);
749 $conf->global->$name = $value;
770 global $langs, $form;
772 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
773 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
779 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
780 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
782 $head[$h][1] = $langs->trans(
"AvailableModules");
783 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
786 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
788 $head[$h][2] =
'modules';
791 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
792 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
793 $head[$h][2] =
'marketplace';
796 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
797 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
798 $head[$h][2] =
'deploy';
801 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
802 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
803 $head[$h][2] =
'develop';
816 global $langs, $conf;
820 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
821 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
822 $head[$h][2] =
'other';
825 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
826 $head[$h][1] = $langs->trans(
"SkinAndColors");
827 $head[$h][2] =
'template';
830 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
831 $head[$h][1] = $langs->trans(
"Dashboard");
832 $head[$h][2] =
'dashboard';
835 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
836 $head[$h][1] = $langs->trans(
"LoginPage");
837 $head[$h][2] =
'login';
840 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
841 $head[$h][1] = $langs->trans(
"CSSPage");
842 $head[$h][2] =
'css';
868 global $db, $langs, $conf;
872 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
873 $head[$h][1] = $langs->trans(
"Miscellaneous");
874 $head[$h][2] =
'misc';
877 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
878 $head[$h][1] = $langs->trans(
"Captcha");
879 $head[$h][2] =
'captcha';
882 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
883 $head[$h][1] = $langs->trans(
"Passwords");
884 $head[$h][2] =
'passwords';
887 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
888 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
889 $head[$h][2] =
'file';
899 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
900 $head[$h][1] = $langs->trans(
"ExternalAccess");
901 $head[$h][2] =
'proxy';
904 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
905 $head[$h][1] = $langs->trans(
"Audit");
906 $head[$h][2] =
'audit';
909 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
910 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
911 $head[$h][2] =
'openid';
917 $sql =
"SELECT COUNT(r.id) as nb";
918 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
919 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
920 $sql .=
" AND entity = ".((int) $conf->entity);
921 $sql .=
" AND bydefault = 1";
923 $sql .=
" AND r.perms NOT LIKE '%_advance'";
925 $resql = $db->query($sql);
927 $obj = $db->fetch_object($resql);
936 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
937 $head[$h][1] = $langs->trans(
"DefaultRights");
939 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
941 $head[$h][2] =
'default';
945 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
946 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
947 $head[$h][2] =
'headers_http';
961 global $langs, $conf;
968 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
969 $head[$h][1] = $langs->trans(
"Description");
970 $head[$h][2] =
'desc';
973 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
974 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
975 $head[$h][2] =
'feature';
978 if (
$object->isCoreOrExternalModule() ==
'external') {
979 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
980 $head[$h][1] = $langs->trans(
"ChangeLog");
981 $head[$h][2] =
'changelog';
999 global $langs, $conf;
1003 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1004 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1005 $head[$h][2] =
'searchkey';
1008 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1009 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1010 $head[$h][2] =
'overwrite';
1029 global $langs, $conf;
1033 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1034 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1035 $head[$h][2] =
'createform';
1038 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1039 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1040 $head[$h][2] =
'filters';
1043 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1044 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1045 $head[$h][2] =
'sortorder';
1048 if (!empty($conf->use_javascript_ajax)) {
1049 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1050 $head[$h][1] = $langs->trans(
"DefaultFocus");
1051 $head[$h][2] =
'focus';
1054 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1055 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1056 $head[$h][2] =
'mandatory';
1081 global $conf, $php_session_save_handler;
1083 $arrayofSessions = array();
1085 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1086 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1091 $iniPath = ini_get(
"session.save_path");
1093 $sessPath = $iniPath;
1096 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1100 while (($file = @readdir($dh)) !==
false) {
1101 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1102 $fullpath = $sessPath.$file;
1103 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1104 $sessValues = file_get_contents($fullpath);
1110 if (preg_match(
'/dol_login/i', $sessValues) &&
1111 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
1112 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1113 $tmp = explode(
'_', $file);
1116 $arrayofSessions[$idsess][
"login"] =
'';
1117 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1119 $arrayofSessions[$idsess][
"login"] = (string) $regs[1];
1121 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1122 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1123 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1124 $arrayofSessions[$idsess][
"user_agent"] =
null;
1125 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1126 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1134 return $arrayofSessions;
1147 $sessPath = ini_get(
"session.save_path").
"/";
1148 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1154 while (($file = @readdir($dh)) !==
false) {
1155 if ($file !=
"." && $file !=
"..") {
1156 $fullpath = $sessPath.$file;
1157 if (!@is_dir($fullpath)) {
1158 $sessValues = file_get_contents($fullpath);
1160 if (preg_match(
'/dol_login/i', $sessValues) &&
1161 (preg_match(
'/dol_entity\|i:('.$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues)) &&
1162 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1163 $tmp = explode(
'_', $file);
1166 if ($idsess != $mysessionid) {
1167 $res = @unlink($fullpath);
1196function activateModule($value, $withdeps = 1, $noconfverification = 0)
1198 global $db, $langs, $conf,
$mysoc;
1203 if (empty($value)) {
1204 $ret[
'errors'] = array(
'ErrorBadParameter');
1208 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1210 $modFile = $modName.
".class.php";
1217 foreach ($modulesdir as $dir) {
1218 if (file_exists($dir.$modFile)) {
1219 $found = @include_once $dir.$modFile;
1226 $objMod =
new $modName($db);
1227 '@phan-var-force DolibarrModules $objMod';
1232 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1234 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1240 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1243 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1248 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1249 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1252 $const_name = $objMod->const_name;
1253 if ($noconfverification == 0) {
1259 $result = $objMod->init();
1262 $ret[
'errors'][] = $objMod->error;
1265 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1268 foreach ($objMod->depends as $key => $modulestringorarray) {
1270 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1271 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1275 if (!is_array($modulestringorarray)) {
1276 $modulestringorarray = array($modulestringorarray);
1279 foreach ($modulestringorarray as $modulestring) {
1282 foreach ($modulesdir as $dir) {
1283 if (file_exists($dir.$modulestring.
".class.php")) {
1284 $resarray = activateModule($modulestring);
1285 if (empty($resarray[
'errors'])) {
1288 $activateerr = implode(
', ', $resarray[
'errors']);
1289 foreach ($resarray[
'errors'] as $errorMessage) {
1298 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1299 $ret[
'nbperms'] += $resarray[
'nbperms'];
1302 $ret[
'errors'][] = $activateerr;
1304 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1310 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1312 $num = count($objMod->conflictwith);
1313 for ($i = 0; $i < $num; $i++) {
1314 foreach ($modulesdir as $dir) {
1315 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1316 unActivateModule($objMod->conflictwith[$i], 0);
1324 if (!count($ret[
'errors'])) {
1325 $ret[
'nbmodules']++;
1326 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1341function unActivateModule($value, $requiredby = 1, $options =
'')
1345 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1348 if (empty($value)) {
1349 return 'ErrorBadParameter';
1354 $modFile = $modName.
".class.php";
1361 foreach ($modulesdir as $dir) {
1362 if (file_exists($dir.$modFile)) {
1363 $found = @include_once $dir.$modFile;
1371 $objMod =
new $modName($db);
1372 '@phan-var-force DolibarrModules $objMod';
1375 $result = $objMod->remove($options);
1377 $ret = $objMod->error;
1382 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1384 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1385 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1386 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1387 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1388 $genericMod->remove(
'');
1392 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1393 $countrb = count($objMod->requiredby);
1394 for ($i = 0; $i < $countrb; $i++) {
1396 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1422function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1426 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1433 foreach ($modulesdir as $dir) {
1436 dol_syslog(
"Scan directory ".$dir.
" for modules");
1438 if (is_resource($handle)) {
1439 while (($file = readdir($handle)) !==
false) {
1441 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1442 $modName = substr($file, 0,
dol_strlen($file) - 10);
1445 include_once $dir.$file;
1446 $objMod =
new $modName($db);
1447 '@phan-var-force DolibarrModules $objMod';
1450 if ($objMod->numero > 0) {
1451 $j = $objMod->numero;
1456 $modulequalified = 1;
1459 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1461 $modulequalified = 0;
1464 $modulequalified = 0;
1468 $modulequalified = 0;
1471 if ($modulequalified) {
1473 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1474 foreach ($objMod->langfiles as $langfile) {
1475 $langs->load($langfile);
1482 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1484 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1488 if (!empty($objMod->dictionaries)) {
1490 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1491 $tabnamerelwithkey = array();
1492 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1493 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1495 $taborder[] = max($taborder) + 1;
1497 $tabnamerelwithkey[$key] = $val;
1498 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1500 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1501 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1504 $tabcomplete[$tmptablename][
'lib'] = $val;
1506 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1507 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1510 $tabcomplete[$tmptablename][
'sql'] = $val;
1512 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1513 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1515 $tabsqlsort[] = $val;
1516 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1518 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1519 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1522 $tabcomplete[$tmptablename][
'field'] = $val;
1524 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1525 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1527 $tabfieldvalue[] = $val;
1528 $tabcomplete[$tmptablename][
'value'] = $val;
1530 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1531 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1532 $nbtabfieldinsert++;
1533 $tabfieldinsert[] = $val;
1534 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1536 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1537 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1540 $tabcomplete[$tmptablename][
'rowid'] = $val;
1542 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1543 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1546 $tabcomplete[$tmptablename][
'cond'] = $val;
1548 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1549 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1550 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1553 $tabcomplete[$tmptablename][
'help'] = $val;
1556 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1557 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1558 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1560 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1564 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1565 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1575 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1582 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1597function activateModulesRequiredByCountry($country_code)
1603 foreach ($modulesdir as $dir) {
1605 dol_syslog(
"Scan directory ".$dir.
" for modules");
1607 if (is_resource($handle)) {
1608 while (($file = readdir($handle)) !==
false) {
1609 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1610 $modName = substr($file, 0,
dol_strlen($file) - 10);
1613 include_once $dir.$file;
1614 $objMod =
new $modName($db);
1615 '@phan-var-force DolibarrModules $objMod';
1618 $modulequalified = 1;
1621 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1623 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1624 $modulequalified = 0;
1626 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1627 $modulequalified = 0;
1630 $modulequalified = 0;
1633 if ($modulequalified) {
1635 if (isset($objMod->automatic_activation[$country_code])) {
1636 activateModule($modName);
1638 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1641 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1648 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1661function complete_elementList_with_modules(&$elementList)
1663 global $db, $modules, $conf, $langs;
1666 $filename = array();
1675 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1679 foreach ($modulesdir as $dir) {
1682 dol_syslog(
"Scan directory ".$dir.
" for modules");
1684 if (is_resource($handle)) {
1685 while (($file = readdir($handle)) !==
false) {
1687 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1688 $modName = substr($file, 0,
dol_strlen($file) - 10);
1691 include_once $dir.$file;
1692 $objMod =
new $modName($db);
1695 if ($objMod->numero > 0) {
1696 $j = $objMod->numero;
1701 $modulequalified = 1;
1704 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1706 $modulequalified = 0;
1709 $modulequalified = 0;
1713 $modulequalified = 0;
1716 if ($modulequalified) {
1718 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1719 foreach ($objMod->langfiles as $langfile) {
1720 $langs->load($langfile);
1724 $modules[$i] = $objMod;
1725 $filename[$i] = $modName;
1726 $orders[$i] = $objMod->family.
"_".$j;
1730 if (!empty($objMod->module_parts[
'contactelement'])) {
1731 if (is_array($objMod->module_parts[
'contactelement'])) {
1732 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1733 $elementList[$elem] = $langs->trans($title);
1736 $elementList[$objMod->name] = $langs->trans($objMod->name);
1743 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1750 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1771 global $db, $langs, $conf, $user;
1772 global $_Avery_Labels;
1774 $form =
new Form($db);
1776 print
'<div class="div-table-responsive-no-min">';
1777 print
'<table class="noborder centpercent">';
1778 print
'<tr class="liste_titre">';
1779 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1782 $text = $langs->trans($text);
1783 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1788 foreach ($tableau as $key => $const) {
1791 if (is_array($const)) {
1792 $type = $const[
'type'];
1793 $label = $const[
'label'];
1802 $sql .=
", ".$db->decrypt(
'name').
" as name";
1803 $sql .=
", ".$db->decrypt(
'value').
" as value";
1806 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1807 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1808 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1809 $sql .=
" ORDER BY name ASC, entity DESC";
1810 $result = $db->query($sql);
1815 $obj = $db->fetch_object($result);
1818 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1821 print
'<tr class="oddeven">';
1825 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1826 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1827 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1828 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1831 $tmparray = explode(
':', $obj->type);
1832 if (!empty($tmparray[1])) {
1833 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1835 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1837 if (!empty($tableau[$key][
'tooltip'])) {
1838 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1840 print($label ? $label : $langs->trans(
'Desc'.$const));
1843 if ($const ==
'ADHERENT_MAILMAN_URL') {
1844 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1846 print
'<div id="example1" class="hidden">';
1847 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';
1849 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1850 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1851 print
'<div id="example2" class="hidden">';
1852 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';
1855 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1856 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1857 print
'<div id="example3" class="hidden">';
1858 print
'mymailmanlist<br>';
1859 print
'mymailmanlist1,mymailmanlist2<br>';
1860 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1862 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1866 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1867 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1873 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1876 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1877 $arrayoflabels = array();
1878 foreach (array_keys($_Avery_Labels) as $codecards) {
1879 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1881 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1882 print
'<input type="hidden" name="consttype" value="yesno">';
1883 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1887 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1888 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1889 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1890 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1892 print
"</textarea>\n";
1893 } elseif ($obj->type ==
'html') {
1894 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1895 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1896 $doleditor->Create();
1897 } elseif ($obj->type ==
'yesno') {
1898 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1899 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1900 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1903 $tmp = explode(
':', $obj->type);
1905 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1907 $arrayofmessagename = array();
1908 if (is_array($formmail->lines_model)) {
1909 foreach ($formmail->lines_model as $modelmail) {
1911 if (!empty($arrayofmessagename[$modelmail->label])) {
1912 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1915 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1919 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1921 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>';
1922 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1923 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1925 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1948 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1952 if (!empty($modules)) {
1954 foreach ($tmpmodules as $module) {
1955 $moduleconst = $module->const_name;
1956 $modulename = strtolower($module->name);
1960 if (!in_array($modulename, $listofmodules)) {
1972 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1973 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1974 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1976 $text .= $langs->transnoentitiesnoconv($module->name);
2000 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2001 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
2002 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2003 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2006 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2007 $resql = $db->query($sql);
2031 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2032 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2033 $sql .=
" AND type = '".$db->escape($type).
"'";
2034 $sql .=
" AND entity = ".((int) $conf->entity);
2036 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2037 $resql = $db->query($sql);
2058 $phpinfostring = ob_get_contents();
2061 $info_arr = array();
2062 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2064 foreach ($info_lines as $line) {
2067 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2069 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2070 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2071 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2072 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2085 global $langs, $conf;
2090 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2091 $head[$h][1] = $langs->trans(
"MyOrganization");
2092 $head[$h][2] =
'company';
2095 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2096 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2097 $head[$h][2] =
'socialnetworks';
2100 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2101 $head[$h][1] = $langs->trans(
"OpeningHours");
2102 $head[$h][2] =
'openinghours';
2105 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2106 $head[$h][1] = $langs->trans(
"Subcontractors");
2107 $head[$h][2] =
'subcontractors';
2124 global $langs, $conf, $user;
2129 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2130 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2131 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2132 $head[$h][2] =
'common';
2136 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2137 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2138 $head[$h][2] =
'common_emailing';
2143 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2144 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2145 $head[$h][2] =
'common_ticket';
2149 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2150 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2151 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2152 $head[$h][2] =
'common_passwordreset';
2158 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2159 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2160 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2161 $head[$h][2] =
'senderprofiles';
2165 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2166 $head[$h][1] = $langs->trans(
"EMailTemplates");
2167 $head[$h][2] =
'templates';
2170 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2171 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2172 $head[$h][2] =
'common_ingoing';
2189 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2190 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2191 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2192 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2193 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2194 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2195 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2196 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2197 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2198 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2199 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2200 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2201 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2202 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2203 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2204 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2205 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2206 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2208 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2209 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2211 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2212 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2214 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2216 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2217 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2218 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2232 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2233 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2234 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2235 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2236 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2237 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2238 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2239 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2240 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2241 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2242 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2243 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2244 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2247 "document" => array(
2248 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2249 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2250 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2251 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2254 "navigation" => array(
2255 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2256 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2257 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2258 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2261 "reporting" => array(
2262 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2265 "require-trusted-types-for" => array(
2266 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2268 "trusted-types" => array(
2269 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2270 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2271 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2284 $forceCSPArr = array();
2286 $sourceCSPArrflatten = array();
2289 foreach ($sourceCSPArr as $key => $arr) {
2290 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2293 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2294 $securitypolicies = explode(
";", $forceCSP);
2297 foreach ($securitypolicies as $key => $securitypolicy) {
2298 if ($securitypolicy ==
"") {
2301 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2302 $securitypolicyarr = explode(
" ", $securitypolicy);
2303 $directive = array_shift($securitypolicyarr);
2305 while ($directive ==
"") {
2306 $directive = array_shift($securitypolicyarr);
2308 if (empty($directive)) {
2311 $sources = $securitypolicyarr;
2312 if (empty($sources)) {
2313 $forceCSPArr[$directive] = array();
2316 foreach ($sources as $key2 => $source) {
2317 $source = str_replace(
"'",
"", $source);
2318 if (empty($source)) {
2321 if (empty($forceCSPArr[$directive])) {
2322 $forceCSPArr[$directive] = array($source);
2324 $forceCSPArr[$directive][] = $source;
2329 return $forceCSPArr;
if(! $sortfield) if(! $sortorder) $object
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
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.
Class to manage a WYSIWYG editor.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
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...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
dolListSessions()
List sessions in db.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='')
Encode a string with a symmetric encryption.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check that the new string $phpfullcodestring contains only php code (including <php tag)