27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
39 if (isset($versionarray[0])) {
40 $string = $versionarray[0];
42 if (isset($versionarray[1])) {
43 $string .=
'.'.$versionarray[1];
45 if (isset($versionarray[2])) {
46 $string .=
'.'.$versionarray[2];
70 $count1 = count($versionarray1);
71 $count2 = count($versionarray2);
72 $maxcount = max($count1, $count2);
73 while ($level < $maxcount) {
74 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
75 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
76 if (preg_match(
'/alpha|dev/i', $operande1)) {
79 if (preg_match(
'/alpha|dev/i', $operande2)) {
82 if (preg_match(
'/beta$/i', $operande1)) {
85 if (preg_match(
'/beta$/i', $operande2)) {
88 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
91 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
94 if (preg_match(
'/rc$/i', $operande1)) {
97 if (preg_match(
'/rc$/i', $operande2)) {
100 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
103 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
108 if ($operande1 < $operande2) {
112 if ($operande1 > $operande2) {
130 return explode(
'.', PHP_VERSION);
141 return explode(
'.', DOL_VERSION);
167 function run_sql($sqlfile, $silent = 1, $entity =
'', $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0)
169 global $db, $conf, $langs, $user;
171 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
173 if (!is_numeric($linelengthlimit)) {
174 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
185 $versionarray = $db->getVersionArray();
187 $fp = fopen($sqlfile,
"r");
191 if ($linelengthlimit > 0) {
192 $buf = fgets($fp, $linelengthlimit);
199 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
203 if (!empty($reg[1])) {
204 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
211 if (!empty($reg[2])) {
212 if (is_numeric($reg[2])) {
213 $versionrequest = explode(
'.', $reg[2]);
216 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
221 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
224 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
234 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
240 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
241 if (empty($nocommentremoval)) {
242 $buf = preg_replace(
'/([,;ERLT\)])\s*--.*$/i',
'\1', $buf);
244 if ($buffer) $buffer .=
' ';
245 $buffer .= trim($buf);
250 if (preg_match(
'/;/', $buffer)) {
253 $arraysql[$i] = $buffer;
261 $arraysql[$i] = $buffer;
265 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
269 $listofmaxrowid = array();
270 foreach ($arraysql as $i => $sql) {
274 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
276 if (!isset($listofmaxrowid[$table])) {
278 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
279 $resql = $db->query($sqlgetrowid);
281 $obj = $db->fetch_object(
$resql);
282 $listofmaxrowid[$table] = $obj->max;
283 if (empty($listofmaxrowid[$table])) {
284 $listofmaxrowid[$table] = 0;
288 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
289 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
297 $from =
'__+MAX_'.$table.
'__';
298 $to =
'+'.$listofmaxrowid[$table];
299 $newsql = str_replace($from, $to, $newsql);
300 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
302 $arraysql[$i] = $newsql;
305 if ($offsetforchartofaccount > 0) {
311 $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);
312 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
314 $arraysql[$i] = $newsql;
323 $listofinsertedrowid = array();
324 $keyforsql = md5($sqlfile);
325 foreach ($arraysql as $i => $sql) {
328 if ($onlysqltoimportwebsite) {
329 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
332 $l = strlen($newsql);
337 $char = $newsql[$is];
344 } elseif (empty($quoteopen)) {
345 $newsqlclean .= $char;
349 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
355 if (preg_match(
'/^--/', $newsqlclean)) {
357 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
359 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
367 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
376 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
377 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
383 if (MAIN_DB_PREFIX !=
'llx_') {
384 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
387 if (!empty($handler)) {
388 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
391 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql);
395 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";
397 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
401 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
402 $num = count($reg[0]);
404 for ($j = 0; $j < $num; $j++) {
406 $to = $db->encrypt($reg[1][$j]);
407 $newsql = str_replace($from, $to, $newsql);
413 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
414 $num = count($reg[0]);
416 for ($j = 0; $j < $num; $j++) {
418 $to = $db->decrypt($reg[1][$j]);
419 $newsql = str_replace($from, $to, $newsql);
425 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
427 if (empty($listofinsertedrowid[$cursor])) {
429 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
430 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
437 $from =
'__'.$cursor.
'__';
438 $to = $listofinsertedrowid[$cursor];
439 $newsql = str_replace($from, $to, $newsql);
444 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
447 $result = $db->query($newsql, $usesavepoint);
450 print
'<!-- Result = OK -->'.
"\n";
453 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
457 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
458 $insertedrowid = $db->last_insert_id($table);
459 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
460 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
464 $errno = $db->errno();
466 print
'<!-- Result = '.$errno.
' -->'.
"\n";
471 'DB_ERROR_TABLE_ALREADY_EXISTS',
472 'DB_ERROR_COLUMN_ALREADY_EXISTS',
473 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
474 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
475 'DB_ERROR_RECORD_ALREADY_EXISTS',
476 'DB_ERROR_NOSUCHTABLE',
477 'DB_ERROR_NOSUCHFIELD',
478 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
479 'DB_ERROR_NO_INDEX_TO_DROP',
480 'DB_ERROR_CANNOT_CREATE',
481 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
482 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
485 if ($okerror ==
'none') {
490 if (!in_array($errno, $okerrors)) {
492 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
493 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
": ".$newsql.
"<br>".$db->error().
"</div>";
494 print
'</td></tr>'.
"\n";
496 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
504 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
505 print
'<td class="right">';
507 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
509 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
513 print
'<script type="text/javascript">
514 jQuery(document).ready(function() {
515 function init_trrunsql'.$keyforsql.
'()
517 console.log("toggle .trforrunsql'.$keyforsql.
'");
518 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
520 init_trrunsql'.$keyforsql.
'();
521 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
522 init_trrunsql'.$keyforsql.
'();
526 if (count($arraysql)) {
527 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
529 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
533 print
'</td></tr>'.
"\n";
561 dol_print_error(
'',
'Error call dolibar_del_const with parameter name empty');
565 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
566 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape($name).
"'";
567 if (is_numeric($name)) {
568 $sql .=
" OR rowid = ".((int) $name);
572 $sql .=
" AND entity = ".((int) $entity);
575 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
576 $resql = $db->query($sql);
578 $conf->global->$name =
'';
600 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
601 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
602 $sql .=
" WHERE name = ".$db->encrypt($name);
603 $sql .=
" AND entity = ".((int) $entity);
605 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
606 $resql = $db->query($sql);
608 $obj = $db->fetch_object(
$resql);
610 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
632 function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
641 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters", LOG_ERR);
649 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
650 $sql .=
" WHERE name = ".$db->encrypt($name);
652 $sql .=
" AND entity = ".((int) $entity);
655 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
656 $resql = $db->query($sql);
658 if (strcmp($value,
'')) {
659 if (!preg_match(
'/^MAIN_LOGEVENTS/', $name) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
664 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
670 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
672 $sql .= $db->encrypt($name);
673 $sql .=
", ".$db->encrypt($newvalue);
674 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
678 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
679 $resql = $db->query($sql);
684 $conf->global->$name = $value;
687 $error = $db->lasterror();
705 global $langs, $conf, $user,
$form;
707 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
708 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
712 $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ?
'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT;
713 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
714 if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) {
716 $head[$h][1] = $langs->trans(
"AvailableModules");
717 $head[$h][1] .=
$form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
720 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
722 $head[$h][2] =
'modules';
725 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
726 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
727 $head[$h][2] =
'marketplace';
730 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
731 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
732 $head[$h][2] =
'deploy';
735 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
736 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
737 $head[$h][2] =
'develop';
750 global $langs, $conf, $user;
754 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
755 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
756 $head[$h][2] =
'other';
759 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
760 $head[$h][1] = $langs->trans(
"SkinAndColors");
761 $head[$h][2] =
'template';
764 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
765 $head[$h][1] = $langs->trans(
"Dashboard");
766 $head[$h][2] =
'dashboard';
769 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
770 $head[$h][1] = $langs->trans(
"LoginPage");
771 $head[$h][2] =
'login';
790 global $db, $langs, $conf, $user;
794 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
795 $head[$h][1] = $langs->trans(
"Miscellaneous");
796 $head[$h][2] =
'misc';
799 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
800 $head[$h][1] = $langs->trans(
"Passwords");
801 $head[$h][2] =
'passwords';
804 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
805 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"Upload").
')';
806 $head[$h][2] =
'file';
816 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
817 $head[$h][1] = $langs->trans(
"ExternalAccess");
818 $head[$h][2] =
'proxy';
821 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
822 $head[$h][1] = $langs->trans(
"Audit");
823 $head[$h][2] =
'audit';
829 $sql =
"SELECT COUNT(r.id) as nb";
830 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
831 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
832 $sql .=
" AND entity = ".((int) $conf->entity);
833 $sql .=
" AND bydefault = 1";
834 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
835 $sql .=
" AND r.perms NOT LIKE '%_advance'";
837 $resql = $db->query($sql);
839 $obj = $db->fetch_object(
$resql);
847 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
848 $head[$h][1] = $langs->trans(
"DefaultRights");
850 $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
852 $head[$h][2] =
'default';
865 global $langs, $conf, $user;
870 $object->id = $object->numero;
872 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=desc';
873 $head[$h][1] = $langs->trans(
"Description");
874 $head[$h][2] =
'desc';
877 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=feature';
878 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
879 $head[$h][2] =
'feature';
882 if ($object->isCoreOrExternalModule() ==
'external') {
883 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=changelog';
884 $head[$h][1] = $langs->trans(
"ChangeLog");
885 $head[$h][2] =
'changelog';
903 global $langs, $conf, $user;
907 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
908 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
909 $head[$h][2] =
'searchkey';
912 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
913 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
914 $head[$h][2] =
'overwrite';
933 global $langs, $conf, $user;
937 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
938 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
939 $head[$h][2] =
'createform';
942 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
943 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
944 $head[$h][2] =
'filters';
947 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
948 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
949 $head[$h][2] =
'sortorder';
952 if (!empty($conf->use_javascript_ajax)) {
953 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
954 $head[$h][1] = $langs->trans(
"DefaultFocus");
955 $head[$h][2] =
'focus';
958 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
959 $head[$h][1] = $langs->trans(
"DefaultMandatory");
960 $head[$h][2] =
'mandatory';
987 $arrayofSessions = array();
990 $iniPath = ini_get(
"session.save_path");
992 $sessPath = $iniPath;
995 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
999 while (($file = @readdir($dh)) !==
false) {
1000 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1001 $fullpath = $sessPath.$file;
1002 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1003 $sessValues = file_get_contents($fullpath);
1009 if (preg_match(
'/dol_login/i', $sessValues) &&
1010 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
1011 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1012 $tmp = explode(
'_', $file);
1015 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1017 $arrayofSessions[$idsess][
"login"] = $regs[1];
1019 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1020 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1021 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1022 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1030 return $arrayofSessions;
1043 $sessPath = ini_get(
"session.save_path").
"/";
1044 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1050 while (($file = @readdir($dh)) !==
false) {
1051 if ($file !=
"." && $file !=
"..") {
1052 $fullpath = $sessPath.$file;
1053 if (!@is_dir($fullpath)) {
1054 $sessValues = file_get_contents($fullpath);
1056 if (preg_match(
'/dol_login/i', $sessValues) &&
1057 preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues) &&
1058 preg_match(
'/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.
')"/i', $sessValues)) {
1059 $tmp = explode(
'_', $file);
1062 if ($idsess != $mysessionid) {
1063 $res = @unlink($fullpath);
1093 global $db, $langs, $conf, $mysoc;
1098 if (empty($value)) {
1099 $ret[
'errors'][] =
'ErrorBadParameter';
1103 $ret = array(
'nbmodules'=>0,
'errors'=>array(),
'nbperms'=>0);
1105 $modFile = $modName.
".class.php";
1112 foreach ($modulesdir as $dir) {
1113 if (file_exists($dir.$modFile)) {
1114 $found = @include_once $dir.$modFile;
1121 $objMod =
new $modName($db);
1125 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1127 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1133 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1136 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1141 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1142 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1146 $const_name = $objMod->const_name;
1147 if (!empty($conf->global->$const_name)) {
1151 $result = $objMod->init();
1154 $ret[
'errors'][] = $objMod->error;
1157 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1160 foreach ($objMod->depends as $key => $modulestring) {
1162 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1163 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1167 foreach ($modulesdir as $dir) {
1168 if (file_exists($dir.$modulestring.
".class.php")) {
1170 if (empty($resarray[
'errors'])) {
1173 foreach ($resarray[
'errors'] as $errorMessage) {
1182 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1183 $ret[
'nbperms'] += $resarray[
'nbperms'];
1185 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring);
1190 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1192 $num = count($objMod->conflictwith);
1193 for ($i = 0; $i < $num; $i++) {
1194 foreach ($modulesdir as $dir) {
1195 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1204 if (!count($ret[
'errors'])) {
1205 $ret[
'nbmodules']++;
1206 $ret[
'nbperms'] += (is_array($objMod->rights)?count($objMod->rights):0);
1222 global $db, $modules, $conf;
1225 if (empty($value)) {
1226 return 'ErrorBadParameter';
1231 $modFile = $modName.
".class.php";
1238 foreach ($modulesdir as $dir) {
1239 if (file_exists($dir.$modFile)) {
1240 $found = @include_once $dir.$modFile;
1248 $objMod =
new $modName($db);
1249 $result = $objMod->remove();
1251 $ret = $objMod->error;
1257 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1259 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1260 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1261 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1262 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1263 $genericMod->remove(
'');
1267 if (!$ret && $requiredby && is_object($objMod) && is_array($objMod->requiredby)) {
1268 $countrb = count($objMod->requiredby);
1269 for ($i = 0; $i < $countrb; $i++) {
1297 function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1299 global $db, $modules, $conf, $langs;
1301 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionnary tables", LOG_DEBUG, 1);
1308 foreach ($modulesdir as $dir) {
1311 dol_syslog(
"Scan directory ".$dir.
" for modules");
1313 if (is_resource($handle)) {
1314 while (($file = readdir($handle)) !==
false) {
1316 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1317 $modName = substr($file, 0,
dol_strlen($file) - 10);
1320 include_once $dir.$file;
1321 $objMod =
new $modName($db);
1323 if ($objMod->numero > 0) {
1324 $j = $objMod->numero;
1329 $modulequalified = 1;
1332 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1334 $modulequalified = 0;
1337 $modulequalified = 0;
1341 $modulequalified = 0;
1344 if ($modulequalified) {
1346 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1347 foreach ($objMod->langfiles as $langfile) {
1348 $langs->load($langfile);
1353 if (empty($objMod->dictionaries) && !empty($objMod->dictionnaries)) {
1354 $objMod->dictionaries = $objMod->dictionnaries;
1357 if (!empty($objMod->dictionaries)) {
1359 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1360 $tabnamerelwithkey = array();
1361 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1362 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1364 $taborder[] = max($taborder) + 1;
1366 $tabnamerelwithkey[$key] = $val;
1367 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1369 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1370 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1373 $tabcomplete[$tmptablename][
'lib'] = $val;
1375 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1376 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1379 $tabcomplete[$tmptablename][
'sql'] = $val;
1381 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1382 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1384 $tabsqlsort[] = $val;
1385 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1387 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1388 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1391 $tabcomplete[$tmptablename][
'field'] = $val;
1393 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1394 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1396 $tabfieldvalue[] = $val;
1397 $tabcomplete[$tmptablename][
'value'] = $val;
1399 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1400 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1401 $nbtabfieldinsert++;
1402 $tabfieldinsert[] = $val;
1403 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1405 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1406 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1409 $tabcomplete[$tmptablename][
'rowid'] = $val;
1411 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1412 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1415 $tabcomplete[$tmptablename][
'rowid'] = $val;
1417 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1418 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1419 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1422 $tabcomplete[$tmptablename][
'help'] = $val;
1425 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1426 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1427 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1429 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1433 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1434 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1444 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1451 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1468 global $db, $conf, $langs;
1472 foreach ($modulesdir as $dir) {
1474 dol_syslog(
"Scan directory ".$dir.
" for modules");
1476 if (is_resource($handle)) {
1477 while (($file = readdir($handle)) !==
false) {
1478 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1479 $modName = substr($file, 0,
dol_strlen($file) - 10);
1482 include_once $dir.$file;
1483 $objMod =
new $modName($db);
1485 $modulequalified = 1;
1488 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1490 if ($objMod->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
1491 $modulequalified = 0;
1493 if ($objMod->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
1494 $modulequalified = 0;
1496 if (!empty($conf->global->$const_name)) {
1497 $modulequalified = 0;
1500 if ($modulequalified) {
1502 if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1505 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1508 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1515 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1530 global $db, $modules, $conf, $langs;
1533 $filename = array();
1542 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1546 foreach ($modulesdir as $dir) {
1549 dol_syslog(
"Scan directory ".$dir.
" for modules");
1551 if (is_resource($handle)) {
1552 while (($file = readdir($handle)) !==
false) {
1554 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1555 $modName = substr($file, 0,
dol_strlen($file) - 10);
1558 include_once $dir.$file;
1559 $objMod =
new $modName($db);
1561 if ($objMod->numero > 0) {
1562 $j = $objMod->numero;
1567 $modulequalified = 1;
1570 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1571 if ($objMod->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 &&
getDolGlobalString($const_name)) {
1572 $modulequalified = 0;
1574 if ($objMod->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 &&
getDolGlobalString($const_name)) {
1575 $modulequalified = 0;
1578 if (empty($conf->global->$const_name)) {
1579 $modulequalified = 0;
1582 if ($modulequalified) {
1584 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1585 foreach ($objMod->langfiles as $langfile) {
1586 $langs->load($langfile);
1590 $modules[$i] = $objMod;
1591 $filename[$i] = $modName;
1592 $orders[$i] = $objMod->family.
"_".$j;
1596 if (!empty($objMod->module_parts[
'contactelement'])) {
1597 if (is_array($objMod->module_parts[
'contactelement'])) {
1598 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1599 $elementList[$elem] = $langs->trans($title);
1602 $elementList[$objMod->name] = $langs->trans($objMod->name);
1609 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1616 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1637 global $db, $langs, $conf, $user;
1638 global $_Avery_Labels;
1642 if (empty($strictw3c)) {
1643 dol_syslog(
"Warning: Function form_constantes is calle with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_DEBUG);
1645 if (!empty($strictw3c) && $strictw3c == 1) {
1646 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1647 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1648 print
'<input type="hidden" name="action" value="updateall">';
1651 print
'<div class="div-table-responsive-no-min">';
1652 print
'<table class="noborder centpercent">';
1653 print
'<tr class="liste_titre">';
1654 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1656 $text = $langs->trans($text);
1657 print
$form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1659 if (empty($strictw3c)) {
1660 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1665 foreach ($tableau as $key => $const) {
1668 if (is_numeric($key)) {
1671 if (is_array($const)) {
1672 $type = $const[
'type'];
1673 $label = $const[
'label'];
1683 $sql .=
", ".$db->decrypt(
'name').
" as name";
1684 $sql .=
", ".$db->decrypt(
'value').
" as value";
1687 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1688 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1689 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1690 $sql .=
" ORDER BY name ASC, entity DESC";
1691 $result = $db->query($sql);
1695 $obj = $db->fetch_object($result);
1698 $obj = (object) array(
'rowid'=>
'',
'name'=>$const,
'value'=>
'',
'type'=>$type,
'note'=>
'');
1701 if (empty($strictw3c)) {
1702 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1703 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1704 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1707 print
'<tr class="oddeven">';
1711 if (empty($strictw3c)) {
1712 print
'<input type="hidden" name="action" value="update">';
1714 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1715 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1716 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1717 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1719 print ($label ? $label : $langs->trans(
'Desc'.$const));
1721 if ($const ==
'ADHERENT_MAILMAN_URL') {
1722 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1724 print
'<div id="example1" class="hidden">';
1725 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';
1727 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1728 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1729 print
'<div id="example2" class="hidden">';
1730 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';
1733 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1734 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1735 print
'<div id="example3" class="hidden">';
1736 print
'mymailmanlist<br>';
1737 print
'mymailmanlist1,mymailmanlist2<br>';
1738 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1740 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1744 } elseif ($const ==
'ADHERENT_MAIL_FROM') {
1745 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1751 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1754 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1755 $arrayoflabels = array();
1756 foreach (array_keys($_Avery_Labels) as $codecards) {
1757 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1759 print
$form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1760 print
'<input type="hidden" name="consttype" value="yesno">';
1761 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1765 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1766 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1767 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1768 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1770 print
"</textarea>\n";
1771 } elseif ($obj->type ==
'html') {
1772 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1773 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1774 $doleditor->Create();
1775 } elseif ($obj->type ==
'yesno') {
1776 print
$form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1);
1777 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1778 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1781 $tmp = explode(
':', $obj->type);
1783 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1785 $arrayofmessagename = array();
1786 if (is_array($formmail->lines_model)) {
1787 foreach ($formmail->lines_model as $modelmail) {
1790 if (!empty($arrayofmessagename[$modelmail->label])) {
1791 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1794 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1799 print
$form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1800 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1801 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1803 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1809 if (empty($strictw3c)) {
1810 print
'<td class="center">';
1811 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1817 if (empty($strictw3c)) {
1825 if (!empty($strictw3c) && $strictw3c == 1) {
1826 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1840 global $conf, $langs;
1842 $text = $langs->trans(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1843 $listofmodules = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
1846 if (!empty($modules)) {
1848 foreach ($tmpmodules as $module) {
1849 $moduleconst = $module->const_name;
1850 $modulename = strtolower($module->name);
1854 if (!in_array($modulename, $listofmodules)) {
1866 $tmptext = $langs->trans(
'Module'.$module->numero.
'Name');
1867 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1868 $text .= $langs->trans(
'Module'.$module->numero.
'Name');
1870 $text .= $langs->trans($module->name);
1894 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
1895 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
1896 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
1897 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
1900 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
1901 $resql = $db->query($sql);
1925 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
1926 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
1927 $sql .=
" AND type = '".$db->escape($type).
"'";
1928 $sql .=
" AND entity = ".((int) $conf->entity);
1930 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
1931 $resql = $db->query($sql);
1952 $phpinfostring = ob_get_contents();
1955 $info_arr = array();
1956 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
1958 foreach ($info_lines as $line) {
1961 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
1963 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
1964 $info_arr[trim($cat)][trim($val[1])] = $val[2];
1965 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
1966 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
1979 global $langs, $conf;
1984 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
1985 $head[$h][1] = $langs->trans(
"Company");
1986 $head[$h][2] =
'company';
1989 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
1990 $head[$h][1] = $langs->trans(
"OpeningHours");
1991 $head[$h][2] =
'openinghours';
1994 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
1995 $head[$h][1] = $langs->trans(
"Accountant");
1996 $head[$h][2] =
'accountant';
1999 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2000 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2001 $head[$h][2] =
'socialnetworks';
2018 global $langs, $conf, $user;
2023 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2024 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2025 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2026 $head[$h][2] =
'common';
2030 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2031 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2032 $head[$h][2] =
'common_emailing';
2037 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2038 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2039 $head[$h][2] =
'common_ticket';
2045 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2046 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2047 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2048 $head[$h][2] =
'senderprofiles';
2052 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2053 $head[$h][1] = $langs->trans(
"EMailTemplates");
2054 $head[$h][2] =
'templates';
run_sql($sqlfile, $silent=1, $entity='', $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0)
Launch a sql file.
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
security_prepare_head()
Prepare array with list of tabs.
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
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.
unActivateModule($value, $requiredby=1)
Disable a module.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
Add external modules to list of dictionaries.
versiondolibarrarray()
Return version Dolibarr.
activateModulesRequiredByCountry($country_code)
Activate external modules mandatory when country is country_code.
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).
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.
activateModule($value, $withdeps=1)
Enable a module.
form_constantes($tableau, $strictw3c=0, $helptext='', $text='Value')
Show array with constants to edit.
complete_elementList_with_modules(&$elementList)
Search external modules to complete the list of contact element.
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules)
Prepare array with list of tabs.
translation_prepare_head()
Prepare array with list of tabs.
company_admin_prepare_head()
Return array head with list of tabs to view object informations.
defaultvalues_prepare_head()
Prepare array with list of tabs.
Class to manage a WYSIWYG editor.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dolGetModulesDirs($subdir='')
Return list of modules directories.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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).
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dolEncrypt($chain, $key='', $ciphering="AES-256-CTR")
Encode a string with a symetric encryption.
dolDecrypt($chain, $key='')
Decode a string with a symetric encryption.