31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
43 if (isset($versionarray[0])) {
44 $string = $versionarray[0];
46 if (isset($versionarray[1])) {
47 $string .=
'.'.$versionarray[1];
49 if (isset($versionarray[2])) {
50 $string .=
'.'.$versionarray[2];
76 $count1 = count($versionarray1);
77 $count2 = count($versionarray2);
78 $maxcount = max($count1, $count2);
79 while ($level < $maxcount) {
80 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
81 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
82 if (preg_match(
'/alpha|dev/i', $operande1)) {
85 if (preg_match(
'/alpha|dev/i', $operande2)) {
88 if (preg_match(
'/beta$/i', $operande1)) {
91 if (preg_match(
'/beta$/i', $operande2)) {
94 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
97 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
100 if (preg_match(
'/rc$/i', $operande1)) {
103 if (preg_match(
'/rc$/i', $operande2)) {
106 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
109 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
114 if ($operande1 < $operande2) {
118 if ($operande1 > $operande2) {
136 return explode(
'.', PHP_VERSION);
147 return preg_split(
'/[\-\.]/', DOL_VERSION);
174function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
178 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
180 if (!is_numeric($linelengthlimit)) {
181 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
192 $versionarray =
$db->getVersionArray();
196 $fp = fopen($sqlfile,
"r");
200 if ($linelengthlimit > 0) {
201 $buf = fgets($fp, $linelengthlimit);
208 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
212 if (!empty($reg[1])) {
213 if (!preg_match(
'/'.preg_quote($reg[1],
'/').
'/i',
$db->type)) {
220 if (!empty($reg[2])) {
221 if (is_numeric($reg[2])) {
222 $versionrequest = explode(
'.', $reg[2]);
223 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
227 $dbcollation = strtoupper(preg_replace(
'/_/',
'',
$conf->db->dolibarr_main_db_collation));
228 if (empty(
$conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
237 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
243 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
244 if (empty($nocommentremoval)) {
245 $buf = preg_replace(
'/([,;ERLT0\)])\s+--.*$/i',
'\1', $buf);
250 $buffer .= trim($buf);
255 if (preg_match(
'/;\s*$/', $buffer)) {
259 $arraysql[$i] = $buffer;
267 $arraysql[$i] = $buffer;
271 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
275 $listofmaxrowid = array();
276 foreach ($arraysql as $i => $sql) {
280 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
282 if (!isset($listofmaxrowid[$table])) {
284 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
285 $resql =
$db->query($sqlgetrowid);
287 $obj =
$db->fetch_object($resql);
288 $listofmaxrowid[$table] = $obj->max;
289 if (empty($listofmaxrowid[$table])) {
290 $listofmaxrowid[$table] = 0;
294 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
295 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
303 $from =
'__+MAX_'.$table.
'__';
304 $to =
'+'.$listofmaxrowid[$table];
305 $newsql = str_replace($from, $to, $newsql);
306 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
308 $arraysql[$i] = $newsql;
311 if ($offsetforchartofaccount > 0) {
317 $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);
318 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
320 $arraysql[$i] = $newsql;
329 $listofinsertedrowid = array();
330 $keyforsql = md5($sqlfile);
331 foreach ($arraysql as $i => $sql) {
334 if ($onlysqltoimportwebsite) {
335 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
338 $l = strlen($newsql);
343 $char = $newsql[$is];
350 } elseif (empty($quoteopen)) {
351 $newsqlclean .= $char;
355 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
361 if (preg_match(
'/^--/', $newsqlclean)) {
363 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
365 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
373 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
383 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
384 if ($errorphpcheck) {
388 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
398 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
399 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
405 if (MAIN_DB_PREFIX !=
'llx_') {
406 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
409 if (!empty($handler)) {
410 $sql = preg_replace(
'/__HANDLER__/i',
"'".
$db->escape($handler).
"'", $sql);
413 if (!empty($database)) {
414 $sql = preg_replace(
'/__DATABASE__/i',
$db->escape($database), $sql);
417 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (
string)
$conf->entity), $sql);
421 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";
423 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
427 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
428 $num = count($reg[0]);
430 for ($j = 0; $j < $num; $j++) {
432 $to =
$db->encrypt($reg[1][$j]);
433 $newsql = str_replace($from, $to, $newsql);
439 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
440 $num = count($reg[0]);
442 for ($j = 0; $j < $num; $j++) {
444 $to =
$db->decrypt($reg[1][$j]);
445 $newsql = str_replace($from, $to, $newsql);
451 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
453 if (empty($listofinsertedrowid[$cursor])) {
455 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
456 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
463 $from =
'__'.$cursor.
'__';
464 $to = $listofinsertedrowid[$cursor];
465 $newsql = str_replace($from, $to, $newsql);
470 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
473 $result =
$db->query($newsql, $usesavepoint);
476 print
'<!-- Result = OK -->'.
"\n";
479 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
483 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
484 $insertedrowid =
$db->last_insert_id($table);
485 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
486 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
489 $errno =
$db->errno();
491 print
'<!-- Result = '.$errno.
' -->'.
"\n";
496 'DB_ERROR_TABLE_ALREADY_EXISTS',
497 'DB_ERROR_COLUMN_ALREADY_EXISTS',
498 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
499 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
500 'DB_ERROR_RECORD_ALREADY_EXISTS',
501 'DB_ERROR_NOSUCHTABLE',
502 'DB_ERROR_NOSUCHFIELD',
503 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
504 'DB_ERROR_NO_INDEX_TO_DROP',
505 'DB_ERROR_CANNOT_CREATE',
506 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
507 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
510 if ($okerror ==
'none') {
515 if (!in_array($errno, $okerrors)) {
517 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
518 print
'<div class="error">'.$langs->trans(
"Error").
" ".
$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".
$db->error().
"</div>";
519 print
'</td></tr>'.
"\n";
521 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".
$db->errno().
" ".$newsql.
"<br>".
$db->error(), LOG_ERR);
529 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
530 print
'<td class="right">';
532 print
'<span class="ok">'.$langs->trans(
"Success").
'</span>';
534 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
538 print
'<script type="text/javascript">
539 jQuery(document).ready(function() {
540 function init_trrunsql'.$keyforsql.
'()
542 console.log("toggle .trforrunsql'.$keyforsql.
'");
543 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
545 init_trrunsql'.$keyforsql.
'();
546 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
547 init_trrunsql'.$keyforsql.
'();
551 if (count($arraysql)) {
552 print
' - <a class="reposition trforrunsqlshowhide'.$keyforsql.
' reposition" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
554 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
558 print
'</td></tr>'.
"\n";
583 global
$conf, $hookmanager;
586 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
589 if (! is_object($hookmanager)) {
590 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
599 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
604 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
605 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".
$db->escape((
string) $name).
"'";
606 if (is_numeric($name)) {
607 $sql .=
" OR rowid = ".((int) $name);
611 $sql .=
" AND entity = ".((int) $entity);
614 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
615 $resql =
$db->query($sql);
617 $conf->global->$name =
'';
641 $sql =
"SELECT ".$db->sanitize(
$db->decrypt(
'value')).
" as value";
642 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
643 $sql .=
" WHERE name = '".$db->escape(
$db->encrypt($name, 0)).
"'";
644 $sql .=
" AND entity = ".((int) $entity);
646 $resql =
$db->query($sql);
648 $obj =
$db->fetch_object($resql);
650 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
674 global
$conf, $hookmanager;
682 dol_print_error(
$db,
"Error: Call to function dolibarr_set_const with wrong parameters");
685 if (! is_object($hookmanager)) {
686 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
696 'visible' => $visible,
701 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
710 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
711 $sql .=
" WHERE name = ".$db->encrypt($name);
713 $sql .=
" AND entity = ".((int) $entity);
716 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
717 $resql =
$db->query($sql);
719 if (strcmp($value,
'')) {
720 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
725 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
731 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
733 $sql .=
$db->encrypt($name);
734 $sql .=
", ".$db->encrypt($newvalue);
735 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".
$db->escape($note).
"', ".((int) $entity).
")";
739 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
740 $resql =
$db->query($sql);
745 $conf->global->$name = $value;
766 global $langs, $form;
768 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
769 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
775 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
776 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
778 $head[$h][1] = $langs->trans(
"AvailableModules");
779 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
782 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
784 $head[$h][2] =
'modules';
787 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
788 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
789 $head[$h][2] =
'marketplace';
792 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
793 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
794 $head[$h][2] =
'deploy';
797 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
798 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
799 $head[$h][2] =
'develop';
812 global $langs,
$conf;
816 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
817 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
818 $head[$h][2] =
'other';
821 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
822 $head[$h][1] = $langs->trans(
"SkinAndColors");
823 $head[$h][2] =
'template';
826 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
827 $head[$h][1] = $langs->trans(
"Dashboard");
828 $head[$h][2] =
'dashboard';
831 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
832 $head[$h][1] = $langs->trans(
"LoginPage");
833 $head[$h][2] =
'login';
836 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
837 $head[$h][1] = $langs->trans(
"CSSPage");
838 $head[$h][2] =
'css';
868 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
869 $head[$h][1] = $langs->trans(
"Miscellaneous");
870 $head[$h][2] =
'misc';
873 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
874 $head[$h][1] = $langs->trans(
"Captcha");
875 $head[$h][2] =
'captcha';
878 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
879 $head[$h][1] = $langs->trans(
"Passwords");
880 $head[$h][2] =
'passwords';
883 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
884 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
885 $head[$h][2] =
'file';
895 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
896 $head[$h][1] = $langs->trans(
"ExternalAccess");
897 $head[$h][2] =
'proxy';
900 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
901 $head[$h][1] = $langs->trans(
"Audit");
902 $head[$h][2] =
'audit';
905 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
906 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
907 $head[$h][2] =
'openid';
913 $sql =
"SELECT COUNT(r.id) as nb";
914 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
915 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
916 $sql .=
" AND entity = ".((int)
$conf->entity);
917 $sql .=
" AND bydefault = 1";
919 $sql .=
" AND r.perms NOT LIKE '%_advance'";
921 $resql =
$db->query($sql);
923 $obj =
$db->fetch_object($resql);
932 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
933 $head[$h][1] = $langs->trans(
"DefaultRights");
935 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
937 $head[$h][2] =
'default';
941 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
942 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
943 $head[$h][2] =
'headers_http';
957 global $langs,
$conf;
964 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
965 $head[$h][1] = $langs->trans(
"Description");
966 $head[$h][2] =
'desc';
969 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
970 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
971 $head[$h][2] =
'feature';
974 if (
$object->isCoreOrExternalModule() ==
'external') {
975 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
976 $head[$h][1] = $langs->trans(
"ChangeLog");
977 $head[$h][2] =
'changelog';
995 global $langs,
$conf;
999 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1000 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1001 $head[$h][2] =
'searchkey';
1004 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1005 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1006 $head[$h][2] =
'overwrite';
1025 global $langs,
$conf;
1029 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1030 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1031 $head[$h][2] =
'createform';
1034 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1035 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1036 $head[$h][2] =
'filters';
1039 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1040 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1041 $head[$h][2] =
'sortorder';
1044 if (!empty(
$conf->use_javascript_ajax)) {
1045 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1046 $head[$h][1] = $langs->trans(
"DefaultFocus");
1047 $head[$h][2] =
'focus';
1050 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1051 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1052 $head[$h][2] =
'mandatory';
1077 global
$conf, $php_session_save_handler;
1079 $arrayofSessions = array();
1081 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1082 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1087 $iniPath = ini_get(
"session.save_path");
1089 $sessPath = $iniPath;
1092 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1096 while (($file = @readdir($dh)) !==
false) {
1097 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1098 $fullpath = $sessPath.$file;
1099 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1100 $sessValues = file_get_contents($fullpath);
1106 if (preg_match(
'/dol_login/i', $sessValues) &&
1107 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1108 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1109 $tmp = explode(
'_', $file);
1112 $arrayofSessions[$idsess][
"login"] =
'';
1113 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1115 $arrayofSessions[$idsess][
"login"] = (
string) $regs[1];
1117 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1118 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1119 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1120 $arrayofSessions[$idsess][
"user_agent"] =
null;
1121 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1122 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1130 return $arrayofSessions;
1143 $sessPath = ini_get(
"session.save_path").
"/";
1144 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1150 while (($file = @readdir($dh)) !==
false) {
1151 if ($file !=
"." && $file !=
"..") {
1152 $fullpath = $sessPath.$file;
1153 if (!@is_dir($fullpath)) {
1154 $sessValues = file_get_contents($fullpath);
1156 if (preg_match(
'/dol_login/i', $sessValues) &&
1157 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1158 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1159 $tmp = explode(
'_', $file);
1162 if ($idsess != $mysessionid) {
1163 $res = @unlink($fullpath);
1193function activateModule($value, $withdeps = 1, $noconfverification = 0, $options =
'')
1200 if (empty($value)) {
1201 $ret[
'errors'] = array(
'ErrorBadParameter');
1205 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1207 $modFile = $modName.
".class.php";
1214 foreach ($modulesdir as $dir) {
1215 if (file_exists($dir.$modFile)) {
1216 $found = @include_once $dir.$modFile;
1223 $objMod =
new $modName(
$db);
1224 '@phan-var-force DolibarrModules $objMod';
1229 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1231 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1237 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1240 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1245 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1246 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1249 $const_name = $objMod->const_name;
1250 if ($noconfverification == 0) {
1256 $result = $objMod->init($options);
1259 $ret[
'errors'][] = $objMod->error;
1262 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1265 foreach ($objMod->depends as $key => $modulestringorarray) {
1267 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1268 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1272 if (!is_array($modulestringorarray)) {
1273 $modulestringorarray = array($modulestringorarray);
1276 foreach ($modulestringorarray as $modulestring) {
1279 $resarray = array();
1280 foreach ($modulesdir as $dir) {
1281 if (file_exists($dir.$modulestring.
".class.php")) {
1282 $resarray = activateModule($modulestring, 1, 0, $options);
1283 if (empty($resarray[
'errors'])) {
1286 $activateerr = implode(
', ', $resarray[
'errors']);
1287 foreach ($resarray[
'errors'] as $errorMessage) {
1296 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1297 $ret[
'nbperms'] += $resarray[
'nbperms'];
1300 $ret[
'errors'][] = $activateerr;
1302 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1308 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1310 $num = count($objMod->conflictwith);
1311 for ($i = 0; $i < $num; $i++) {
1312 foreach ($modulesdir as $dir) {
1313 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1314 unActivateModule($objMod->conflictwith[$i], 0);
1322 if (!count($ret[
'errors'])) {
1323 $ret[
'nbmodules']++;
1324 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1339function unActivateModule($value, $requiredby = 1, $options =
'')
1343 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1346 if (empty($value)) {
1347 return 'ErrorBadParameter';
1352 $modFile = $modName.
".class.php";
1359 foreach ($modulesdir as $dir) {
1360 if (file_exists($dir.$modFile)) {
1361 $found = @include_once $dir.$modFile;
1369 $objMod =
new $modName(
$db);
1370 '@phan-var-force DolibarrModules $objMod';
1373 $result = $objMod->remove($options);
1375 $ret = $objMod->error;
1380 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1382 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1383 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1384 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1385 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1386 $genericMod->remove(
'');
1390 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1391 $countrb = count($objMod->requiredby);
1392 for ($i = 0; $i < $countrb; $i++) {
1394 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1420function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1424 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1431 foreach ($modulesdir as $dir) {
1434 dol_syslog(
"Scan directory ".$dir.
" for modules");
1436 if (is_resource($handle)) {
1437 while (($file = readdir($handle)) !==
false) {
1439 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1440 $modName = substr($file, 0,
dol_strlen($file) - 10);
1443 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1444 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1447 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1448 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1452 include_once $dir.$file;
1453 $objMod =
new $modName(
$db);
1454 '@phan-var-force DolibarrModules $objMod';
1457 if ($objMod->numero > 0) {
1458 $j = $objMod->numero;
1463 $modulequalified = 1;
1466 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1468 $modulequalified = 0;
1471 $modulequalified = 0;
1475 $modulequalified = 0;
1478 if ($modulequalified) {
1480 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1481 foreach ($objMod->langfiles as $langfile) {
1482 $langs->load($langfile);
1489 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1491 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1495 if (!empty($objMod->dictionaries)) {
1497 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1498 $tabnamerelwithkey = array();
1499 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1500 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1502 $taborder[] = max($taborder) + 1;
1504 $tabnamerelwithkey[$key] = $val;
1505 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1507 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1508 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1511 $tabcomplete[$tmptablename][
'lib'] = $val;
1513 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1514 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1517 $tabcomplete[$tmptablename][
'sql'] = $val;
1519 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1520 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1522 $tabsqlsort[] = $val;
1523 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1525 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1526 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1529 $tabcomplete[$tmptablename][
'field'] = $val;
1531 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1532 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1534 $tabfieldvalue[] = $val;
1535 $tabcomplete[$tmptablename][
'value'] = $val;
1537 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1538 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1539 $nbtabfieldinsert++;
1540 $tabfieldinsert[] = $val;
1541 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1543 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1544 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1547 $tabcomplete[$tmptablename][
'rowid'] = $val;
1549 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1550 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1553 $tabcomplete[$tmptablename][
'cond'] = $val;
1555 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1556 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1557 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1560 $tabcomplete[$tmptablename][
'help'] = $val;
1563 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1564 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1565 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1567 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1571 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1572 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1582 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1589 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1604function activateModulesRequiredByCountry($country_code)
1610 foreach ($modulesdir as $dir) {
1612 dol_syslog(
"Scan directory ".$dir.
" for modules");
1614 if (is_resource($handle)) {
1615 while (($file = readdir($handle)) !==
false) {
1616 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1617 $modName = substr($file, 0,
dol_strlen($file) - 10);
1620 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1621 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1624 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1625 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1629 include_once $dir.$file;
1630 $objMod =
new $modName(
$db);
1631 '@phan-var-force DolibarrModules $objMod';
1634 $modulequalified = 1;
1637 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1639 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1640 $modulequalified = 0;
1642 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1643 $modulequalified = 0;
1646 $modulequalified = 0;
1649 if ($modulequalified) {
1651 if (isset($objMod->automatic_activation[$country_code])) {
1652 activateModule($modName, 1, 0);
1654 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1657 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1664 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1677function complete_elementList_with_modules(&$elementList)
1679 global
$db, $modules,
$conf, $langs;
1682 $filename = array();
1691 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1695 foreach ($modulesdir as $dir) {
1698 dol_syslog(
"Scan directory ".$dir.
" for modules");
1700 if (is_resource($handle)) {
1701 while (($file = readdir($handle)) !==
false) {
1703 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1704 $modName = substr($file, 0,
dol_strlen($file) - 10);
1707 include_once $dir.$file;
1708 $objMod =
new $modName(
$db);
1711 if ($objMod->numero > 0) {
1712 $j = $objMod->numero;
1717 $modulequalified = 1;
1720 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1722 $modulequalified = 0;
1725 $modulequalified = 0;
1729 $modulequalified = 0;
1732 if ($modulequalified) {
1734 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1735 foreach ($objMod->langfiles as $langfile) {
1736 $langs->load($langfile);
1740 $modules[$i] = $objMod;
1741 $filename[$i] = $modName;
1742 $orders[$i] = $objMod->family.
"_".$j;
1746 if (!empty($objMod->module_parts[
'contactelement'])) {
1747 if (is_array($objMod->module_parts[
'contactelement'])) {
1748 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1749 $elementList[$elem] = $langs->trans($title);
1752 $elementList[$objMod->name] = $langs->trans($objMod->name);
1759 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1766 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1788 global $_Avery_Labels;
1792 print
'<div class="div-table-responsive-no-min">';
1793 print
'<table class="noborder centpercent">';
1794 print
'<tr class="liste_titre">';
1795 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1798 $text = $langs->trans($text);
1799 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1804 foreach ($tableau as $key => $const) {
1807 if (is_array($const)) {
1808 $type = $const[
'type'];
1809 $label = $const[
'label'];
1818 $sql .=
", ".$db->decrypt(
'name').
" as name";
1819 $sql .=
", ".$db->decrypt(
'value').
" as value";
1822 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1823 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".
$db->escape($const).
"'";
1824 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1825 $sql .=
" ORDER BY name ASC, entity DESC";
1826 $result =
$db->query($sql);
1831 $obj =
$db->fetch_object($result);
1834 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1837 print
'<tr class="oddeven">';
1841 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1842 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1843 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1844 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1847 $tmparray = explode(
':', $obj->type);
1848 if (!empty($tmparray[1])) {
1849 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1851 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1853 if (!empty($tableau[$key][
'tooltip'])) {
1854 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1856 print($label ? $label : $langs->trans(
'Desc'.$const));
1859 if ($const ==
'ADHERENT_MAILMAN_URL') {
1860 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1862 print
'<div id="example1" class="hidden">';
1863 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';
1865 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1866 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1867 print
'<div id="example2" class="hidden">';
1868 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';
1871 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1872 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1873 print
'<div id="example3" class="hidden">';
1874 print
'mymailmanlist<br>';
1875 print
'mymailmanlist1,mymailmanlist2<br>';
1876 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1878 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1882 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1883 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1889 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1892 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1893 $arrayoflabels = array();
1894 foreach (array_keys($_Avery_Labels) as $codecards) {
1895 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1897 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1898 print
'<input type="hidden" name="consttype" value="yesno">';
1899 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1903 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1904 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1905 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1906 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1908 print
"</textarea>\n";
1909 } elseif ($obj->type ==
'html') {
1910 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1911 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1912 $doleditor->Create();
1913 } elseif ($obj->type ==
'yesno') {
1914 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1915 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1916 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1919 $tmp = explode(
':', $obj->type);
1921 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1923 $arrayofmessagename = array();
1924 if (is_array($formmail->lines_model)) {
1925 foreach ($formmail->lines_model as $modelmail) {
1927 if (!empty($arrayofmessagename[$modelmail->label])) {
1928 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1931 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1935 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1937 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>';
1938 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1939 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1941 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1964 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1968 if (!empty($modules)) {
1970 foreach ($tmpmodules as $module) {
1971 $moduleconst = $module->const_name;
1972 $modulename = strtolower($module->name);
1976 if (!in_array($modulename, $listofmodules)) {
1988 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1989 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1990 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1992 $text .= $langs->transnoentitiesnoconv($module->name);
2016 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2017 $sql .=
" VALUES ('".$db->escape($name).
"','".
$db->escape($type).
"',".((int)
$conf->entity).
", ";
2018 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2019 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2022 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2023 $resql =
$db->query($sql);
2047 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2048 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2049 $sql .=
" AND type = '".$db->escape($type).
"'";
2050 $sql .=
" AND entity = ".((int)
$conf->entity);
2052 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2053 $resql =
$db->query($sql);
2074 $phpinfostring = ob_get_contents();
2077 $info_arr = array();
2078 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2080 foreach ($info_lines as $line) {
2083 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2085 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2086 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2087 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2088 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2101 global $langs,
$conf;
2106 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2107 $head[$h][1] = $langs->trans(
"MyOrganization");
2108 $head[$h][2] =
'company';
2111 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2112 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2113 $head[$h][2] =
'socialnetworks';
2116 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2117 $head[$h][1] = $langs->trans(
"OpeningHours");
2118 $head[$h][2] =
'openinghours';
2121 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2122 $head[$h][1] = $langs->trans(
"Subcontractors");
2123 $head[$h][2] =
'subcontractors';
2140 global $langs,
$conf, $user;
2145 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2146 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2147 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2148 $head[$h][2] =
'common';
2152 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2153 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2154 $head[$h][2] =
'common_emailing';
2159 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2160 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2161 $head[$h][2] =
'common_ticket';
2165 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2166 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2167 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2168 $head[$h][2] =
'common_passwordreset';
2174 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2175 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2176 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2177 $head[$h][2] =
'senderprofiles';
2181 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2182 $head[$h][1] = $langs->trans(
"EMailTemplates");
2183 $head[$h][2] =
'templates';
2186 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2187 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2188 $head[$h][2] =
'common_ingoing';
2205 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2206 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2207 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2208 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2209 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2210 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2211 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2212 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2213 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2214 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2215 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2216 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2217 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2218 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2219 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2220 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2221 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2222 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2224 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2225 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2227 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2228 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2230 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2232 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2233 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2234 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2248 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2249 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2250 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2251 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2252 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2253 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2254 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2255 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2256 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2257 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2258 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2259 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2260 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2263 "document" => array(
2264 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2265 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2266 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2267 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2270 "navigation" => array(
2271 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2272 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2273 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2274 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2277 "reporting" => array(
2278 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2281 "require-trusted-types-for" => array(
2282 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2284 "trusted-types" => array(
2285 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2286 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2287 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2300 $forceCSPArr = array();
2302 $sourceCSPArrflatten = array();
2305 foreach ($sourceCSPArr as $key => $arr) {
2306 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2309 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2310 $securitypolicies = explode(
";", $forceCSP);
2313 foreach ($securitypolicies as $key => $securitypolicy) {
2314 if ($securitypolicy ==
"") {
2317 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2318 $securitypolicyarr = explode(
" ", $securitypolicy);
2319 $directive = array_shift($securitypolicyarr);
2321 while ($directive ==
"") {
2322 $directive = array_shift($securitypolicyarr);
2324 if (empty($directive)) {
2327 $sources = $securitypolicyarr;
2328 if (empty($sources)) {
2329 $forceCSPArr[$directive] = array();
2332 foreach ($sources as $key2 => $source) {
2333 $source = str_replace(
"'",
"", $source);
2334 if (empty($source)) {
2337 if (empty($forceCSPArr[$directive])) {
2338 $forceCSPArr[$directive] = array($source);
2340 $forceCSPArr[$directive][] = $source;
2345 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.
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)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
dolListSessions()
List sessions in db.
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)