29require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
41 if (isset($versionarray[0])) {
42 $string = $versionarray[0];
44 if (isset($versionarray[1])) {
45 $string .=
'.'.$versionarray[1];
47 if (isset($versionarray[2])) {
48 $string .=
'.'.$versionarray[2];
72 $count1 = count($versionarray1);
73 $count2 = count($versionarray2);
74 $maxcount = max($count1, $count2);
75 while ($level < $maxcount) {
76 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
77 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
78 if (preg_match(
'/alpha|dev/i', $operande1)) {
81 if (preg_match(
'/alpha|dev/i', $operande2)) {
84 if (preg_match(
'/beta$/i', $operande1)) {
87 if (preg_match(
'/beta$/i', $operande2)) {
90 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
93 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
96 if (preg_match(
'/rc$/i', $operande1)) {
99 if (preg_match(
'/rc$/i', $operande2)) {
102 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
105 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
110 if ($operande1 < $operande2) {
114 if ($operande1 > $operande2) {
132 return explode(
'.', PHP_VERSION);
143 return explode(
'.', DOL_VERSION);
170function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
172 global $db, $conf, $langs, $user;
174 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
176 if (!is_numeric($linelengthlimit)) {
177 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
188 $versionarray = $db->getVersionArray();
190 $fp = fopen($sqlfile,
"r");
194 if ($linelengthlimit > 0) {
195 $buf = fgets($fp, $linelengthlimit);
202 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
206 if (!empty($reg[1])) {
207 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
214 if (!empty($reg[2])) {
215 if (is_numeric($reg[2])) {
216 $versionrequest = explode(
'.', $reg[2]);
219 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
223 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
226 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
236 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
242 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
243 if (empty($nocommentremoval)) {
244 $buf = preg_replace(
'/([,;ERLT\)])\s*--.*$/i',
'\1', $buf);
249 $buffer .= trim($buf);
254 if (preg_match(
'/;/', $buffer)) {
257 $arraysql[$i] = $buffer;
265 $arraysql[$i] = $buffer;
269 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
273 $listofmaxrowid = array();
274 foreach ($arraysql as $i => $sql) {
278 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
280 if (!isset($listofmaxrowid[$table])) {
282 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
283 $resql = $db->query($sqlgetrowid);
285 $obj = $db->fetch_object($resql);
286 $listofmaxrowid[$table] = $obj->max;
287 if (empty($listofmaxrowid[$table])) {
288 $listofmaxrowid[$table] = 0;
292 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
293 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
301 $from =
'__+MAX_'.$table.
'__';
302 $to =
'+'.$listofmaxrowid[$table];
303 $newsql = str_replace($from, $to, $newsql);
304 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
306 $arraysql[$i] = $newsql;
309 if ($offsetforchartofaccount > 0) {
315 $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);
316 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
318 $arraysql[$i] = $newsql;
327 $listofinsertedrowid = array();
328 $keyforsql = md5($sqlfile);
329 foreach ($arraysql as $i => $sql) {
332 if ($onlysqltoimportwebsite) {
333 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
336 $l = strlen($newsql);
341 $char = $newsql[$is];
348 } elseif (empty($quoteopen)) {
349 $newsqlclean .= $char;
353 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
359 if (preg_match(
'/^--/', $newsqlclean)) {
361 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
363 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
371 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
381 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
382 if ($errorphpcheck) {
386 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
396 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
397 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
403 if (MAIN_DB_PREFIX !=
'llx_') {
404 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
407 if (!empty($handler)) {
408 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
411 if (!empty($database)) {
412 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
415 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (string) $conf->entity), $sql);
419 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";
421 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
425 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
426 $num = count($reg[0]);
428 for ($j = 0; $j < $num; $j++) {
430 $to = $db->encrypt($reg[1][$j]);
431 $newsql = str_replace($from, $to, $newsql);
437 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
438 $num = count($reg[0]);
440 for ($j = 0; $j < $num; $j++) {
442 $to = $db->decrypt($reg[1][$j]);
443 $newsql = str_replace($from, $to, $newsql);
449 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
451 if (empty($listofinsertedrowid[$cursor])) {
453 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
454 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
461 $from =
'__'.$cursor.
'__';
462 $to = $listofinsertedrowid[$cursor];
463 $newsql = str_replace($from, $to, $newsql);
468 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
471 $result = $db->query($newsql, $usesavepoint);
474 print
'<!-- Result = OK -->'.
"\n";
477 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
481 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
482 $insertedrowid = $db->last_insert_id($table);
483 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
484 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
488 $errno = $db->errno();
490 print
'<!-- Result = '.$errno.
' -->'.
"\n";
495 'DB_ERROR_TABLE_ALREADY_EXISTS',
496 'DB_ERROR_COLUMN_ALREADY_EXISTS',
497 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
498 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
499 'DB_ERROR_RECORD_ALREADY_EXISTS',
500 'DB_ERROR_NOSUCHTABLE',
501 'DB_ERROR_NOSUCHFIELD',
502 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
503 'DB_ERROR_NO_INDEX_TO_DROP',
504 'DB_ERROR_CANNOT_CREATE',
505 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
506 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
509 if ($okerror ==
'none') {
514 if (!in_array($errno, $okerrors)) {
516 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
517 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
518 print
'</td></tr>'.
"\n";
520 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
528 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
529 print
'<td class="right">';
531 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
533 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
537 print
'<script type="text/javascript">
538 jQuery(document).ready(function() {
539 function init_trrunsql'.$keyforsql.
'()
541 console.log("toggle .trforrunsql'.$keyforsql.
'");
542 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
544 init_trrunsql'.$keyforsql.
'();
545 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
546 init_trrunsql'.$keyforsql.
'();
550 if (count($arraysql)) {
551 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
553 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
557 print
'</td></tr>'.
"\n";
585 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
589 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
590 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape($name).
"'";
591 if (is_numeric($name)) {
592 $sql .=
" OR rowid = ".((int) $name);
596 $sql .=
" AND entity = ".((int) $entity);
599 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
600 $resql = $db->query($sql);
602 $conf->global->$name =
'';
624 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
625 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
626 $sql .=
" WHERE name = ".$db->encrypt($name);
627 $sql .=
" AND entity = ".((int) $entity);
629 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
630 $resql = $db->query($sql);
632 $obj = $db->fetch_object($resql);
634 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
656function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
665 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
673 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
674 $sql .=
" WHERE name = ".$db->encrypt($name);
676 $sql .=
" AND entity = ".((int) $entity);
679 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
680 $resql = $db->query($sql);
682 if (strcmp($value,
'')) {
683 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))) {
688 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
694 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
696 $sql .= $db->encrypt($name);
697 $sql .=
", ".$db->encrypt($newvalue);
698 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
702 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
703 $resql = $db->query($sql);
708 $conf->global->$name = $value;
711 $error = $db->lasterror();
730 global $langs, $form;
732 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
733 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
738 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
739 if ($nbmodulesnotautoenabled <=
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
741 $head[$h][1] = $langs->trans(
"AvailableModules");
742 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
745 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
747 $head[$h][2] =
'modules';
750 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
751 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
752 $head[$h][2] =
'marketplace';
755 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
756 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
757 $head[$h][2] =
'deploy';
760 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
761 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
762 $head[$h][2] =
'develop';
775 global $langs, $conf, $user;
779 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
780 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
781 $head[$h][2] =
'other';
784 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
785 $head[$h][1] = $langs->trans(
"SkinAndColors");
786 $head[$h][2] =
'template';
789 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
790 $head[$h][1] = $langs->trans(
"Dashboard");
791 $head[$h][2] =
'dashboard';
794 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
795 $head[$h][1] = $langs->trans(
"LoginPage");
796 $head[$h][2] =
'login';
799 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=css";
800 $head[$h][1] = $langs->trans(
"CSSPage");
801 $head[$h][2] =
'css';
820 global $db, $langs, $conf, $user;
824 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
825 $head[$h][1] = $langs->trans(
"Miscellaneous");
826 $head[$h][2] =
'misc';
829 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
830 $head[$h][1] = $langs->trans(
"Passwords");
831 $head[$h][2] =
'passwords';
834 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
835 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"Upload").
')';
836 $head[$h][2] =
'file';
846 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
847 $head[$h][1] = $langs->trans(
"ExternalAccess");
848 $head[$h][2] =
'proxy';
851 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
852 $head[$h][1] = $langs->trans(
"Audit");
853 $head[$h][2] =
'audit';
859 $sql =
"SELECT COUNT(r.id) as nb";
860 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
861 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
862 $sql .=
" AND entity = ".((int) $conf->entity);
863 $sql .=
" AND bydefault = 1";
865 $sql .=
" AND r.perms NOT LIKE '%_advance'";
867 $resql = $db->query($sql);
869 $obj = $db->fetch_object($resql);
878 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
879 $head[$h][1] = $langs->trans(
"DefaultRights");
881 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
883 $head[$h][2] =
'default';
898 global $langs, $conf;
905 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=desc';
906 $head[$h][1] = $langs->trans(
"Description");
907 $head[$h][2] =
'desc';
910 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=feature';
911 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
912 $head[$h][2] =
'feature';
915 if (
$object->isCoreOrExternalModule() ==
'external') {
916 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=changelog';
917 $head[$h][1] = $langs->trans(
"ChangeLog");
918 $head[$h][2] =
'changelog';
936 global $langs, $conf;
940 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
941 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
942 $head[$h][2] =
'searchkey';
945 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
946 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
947 $head[$h][2] =
'overwrite';
966 global $langs, $conf, $user;
970 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
971 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
972 $head[$h][2] =
'createform';
975 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
976 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
977 $head[$h][2] =
'filters';
980 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
981 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
982 $head[$h][2] =
'sortorder';
985 if (!empty($conf->use_javascript_ajax)) {
986 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
987 $head[$h][1] = $langs->trans(
"DefaultFocus");
988 $head[$h][2] =
'focus';
991 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
992 $head[$h][1] = $langs->trans(
"DefaultMandatory");
993 $head[$h][2] =
'mandatory';
1020 $arrayofSessions = array();
1023 $iniPath = ini_get(
"session.save_path");
1025 $sessPath = $iniPath;
1028 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1032 while (($file = @readdir($dh)) !==
false) {
1033 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1034 $fullpath = $sessPath.$file;
1035 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1036 $sessValues = file_get_contents($fullpath);
1042 if (preg_match(
'/dol_login/i', $sessValues) &&
1043 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
1044 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1045 $tmp = explode(
'_', $file);
1048 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1050 $arrayofSessions[$idsess][
"login"] = $regs[1];
1052 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1053 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1054 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1055 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1063 return $arrayofSessions;
1076 $sessPath = ini_get(
"session.save_path").
"/";
1077 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1083 while (($file = @readdir($dh)) !==
false) {
1084 if ($file !=
"." && $file !=
"..") {
1085 $fullpath = $sessPath.$file;
1086 if (!@is_dir($fullpath)) {
1087 $sessValues = file_get_contents($fullpath);
1089 if (preg_match(
'/dol_login/i', $sessValues) &&
1090 preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues) &&
1091 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1092 $tmp = explode(
'_', $file);
1095 if ($idsess != $mysessionid) {
1096 $res = @unlink($fullpath);
1127 global $db, $langs, $conf, $mysoc;
1132 if (empty($value)) {
1133 $ret[
'errors'] = array(
'ErrorBadParameter');
1137 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1139 $modFile = $modName.
".class.php";
1146 foreach ($modulesdir as $dir) {
1147 if (file_exists($dir.$modFile)) {
1148 $found = @include_once $dir.$modFile;
1155 $objMod =
new $modName($db);
1159 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1161 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1167 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1170 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1175 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1176 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1180 $const_name = $objMod->const_name;
1181 if ($noconfverification == 0) {
1187 $result = $objMod->init();
1190 $ret[
'errors'][] = $objMod->error;
1193 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1196 foreach ($objMod->depends as $key => $modulestringorarray) {
1198 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1199 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1203 if (!is_array($modulestringorarray)) {
1204 $modulestringorarray = array($modulestringorarray);
1207 foreach ($modulestringorarray as $modulestring) {
1210 foreach ($modulesdir as $dir) {
1211 if (file_exists($dir.$modulestring.
".class.php")) {
1213 if (empty($resarray[
'errors'])) {
1216 $activateerr = implode(
', ', $resarray[
'errors']);
1217 foreach ($resarray[
'errors'] as $errorMessage) {
1226 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1227 $ret[
'nbperms'] += $resarray[
'nbperms'];
1230 $ret[
'errors'][] = $activateerr;
1232 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring);
1238 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1240 $num = count($objMod->conflictwith);
1241 for ($i = 0; $i < $num; $i++) {
1242 foreach ($modulesdir as $dir) {
1243 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1252 if (!count($ret[
'errors'])) {
1253 $ret[
'nbmodules']++;
1254 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1270 global $db, $modules, $conf;
1273 if (empty($value)) {
1274 return 'ErrorBadParameter';
1279 $modFile = $modName.
".class.php";
1286 foreach ($modulesdir as $dir) {
1287 if (file_exists($dir.$modFile)) {
1288 $found = @include_once $dir.$modFile;
1296 $objMod =
new $modName($db);
1297 $result = $objMod->remove();
1299 $ret = $objMod->error;
1304 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1306 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1307 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1308 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1309 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1310 $genericMod->remove(
'');
1314 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1315 $countrb = count($objMod->requiredby);
1316 for ($i = 0; $i < $countrb; $i++) {
1344function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1348 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1355 foreach ($modulesdir as $dir) {
1358 dol_syslog(
"Scan directory ".$dir.
" for modules");
1360 if (is_resource($handle)) {
1361 while (($file = readdir($handle)) !==
false) {
1363 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1364 $modName = substr($file, 0,
dol_strlen($file) - 10);
1367 include_once $dir.$file;
1368 $objMod =
new $modName($db);
1370 if ($objMod->numero > 0) {
1371 $j = $objMod->numero;
1376 $modulequalified = 1;
1379 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1381 $modulequalified = 0;
1384 $modulequalified = 0;
1388 $modulequalified = 0;
1391 if ($modulequalified) {
1393 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1394 foreach ($objMod->langfiles as $langfile) {
1395 $langs->load($langfile);
1401 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1402 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1406 if (!empty($objMod->dictionaries)) {
1408 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1409 $tabnamerelwithkey = array();
1410 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1411 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1413 $taborder[] = max($taborder) + 1;
1415 $tabnamerelwithkey[$key] = $val;
1416 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1418 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1419 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1422 $tabcomplete[$tmptablename][
'lib'] = $val;
1424 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1425 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1428 $tabcomplete[$tmptablename][
'sql'] = $val;
1430 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1431 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1433 $tabsqlsort[] = $val;
1434 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1436 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1437 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1440 $tabcomplete[$tmptablename][
'field'] = $val;
1442 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1443 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1445 $tabfieldvalue[] = $val;
1446 $tabcomplete[$tmptablename][
'value'] = $val;
1448 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1449 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1450 $nbtabfieldinsert++;
1451 $tabfieldinsert[] = $val;
1452 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1454 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1455 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1458 $tabcomplete[$tmptablename][
'rowid'] = $val;
1460 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1461 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1464 $tabcomplete[$tmptablename][
'cond'] = $val;
1466 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1467 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1468 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1471 $tabcomplete[$tmptablename][
'help'] = $val;
1474 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1475 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1476 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1478 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1482 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1483 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1493 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1500 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1517 global $db, $conf, $langs;
1521 foreach ($modulesdir as $dir) {
1523 dol_syslog(
"Scan directory ".$dir.
" for modules");
1525 if (is_resource($handle)) {
1526 while (($file = readdir($handle)) !==
false) {
1527 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1528 $modName = substr($file, 0,
dol_strlen($file) - 10);
1531 include_once $dir.$file;
1532 $objMod =
new $modName($db);
1534 $modulequalified = 1;
1537 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1539 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1540 $modulequalified = 0;
1542 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1543 $modulequalified = 0;
1546 $modulequalified = 0;
1549 if ($modulequalified) {
1551 if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1554 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1557 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1564 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1579 global $db, $modules, $conf, $langs;
1582 $filename = array();
1591 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1595 foreach ($modulesdir as $dir) {
1598 dol_syslog(
"Scan directory ".$dir.
" for modules");
1600 if (is_resource($handle)) {
1601 while (($file = readdir($handle)) !==
false) {
1603 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1604 $modName = substr($file, 0,
dol_strlen($file) - 10);
1607 include_once $dir.$file;
1608 $objMod =
new $modName($db);
1610 if ($objMod->numero > 0) {
1611 $j = $objMod->numero;
1616 $modulequalified = 1;
1619 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1621 $modulequalified = 0;
1624 $modulequalified = 0;
1628 $modulequalified = 0;
1631 if ($modulequalified) {
1633 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1634 foreach ($objMod->langfiles as $langfile) {
1635 $langs->load($langfile);
1639 $modules[$i] = $objMod;
1640 $filename[$i] = $modName;
1641 $orders[$i] = $objMod->family.
"_".$j;
1645 if (!empty($objMod->module_parts[
'contactelement'])) {
1646 if (is_array($objMod->module_parts[
'contactelement'])) {
1647 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1648 $elementList[$elem] = $langs->trans($title);
1651 $elementList[$objMod->name] = $langs->trans($objMod->name);
1658 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1665 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1686 global $db, $langs, $conf, $user;
1687 global $_Avery_Labels;
1689 $form =
new Form($db);
1691 if (empty($strictw3c)) {
1692 dol_syslog(
"Warning: Function 'form_constantes' was called with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_DEBUG);
1694 if (!empty($strictw3c) && $strictw3c == 1) {
1695 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1696 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1697 print
'<input type="hidden" name="action" value="updateall">';
1700 print
'<div class="div-table-responsive-no-min">';
1701 print
'<table class="noborder centpercent">';
1702 print
'<tr class="liste_titre">';
1703 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1705 $text = $langs->trans($text);
1706 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1708 if (empty($strictw3c)) {
1709 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1714 foreach ($tableau as $key => $const) {
1717 if (is_numeric($key)) {
1720 if (is_array($const)) {
1721 $type = $const[
'type'];
1722 $label = $const[
'label'];
1732 $sql .=
", ".$db->decrypt(
'name').
" as name";
1733 $sql .=
", ".$db->decrypt(
'value').
" as value";
1736 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1737 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1738 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1739 $sql .=
" ORDER BY name ASC, entity DESC";
1740 $result = $db->query($sql);
1744 $obj = $db->fetch_object($result);
1747 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1750 if (empty($strictw3c)) {
1751 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1752 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1753 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1756 print
'<tr class="oddeven">';
1760 if (empty($strictw3c)) {
1761 print
'<input type="hidden" name="action" value="update">';
1763 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1764 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1765 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1766 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1767 if (!empty($tableau[$key][
'tooltip'])) {
1768 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1770 print($label ? $label : $langs->trans(
'Desc'.$const));
1773 if ($const ==
'ADHERENT_MAILMAN_URL') {
1774 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1776 print
'<div id="example1" class="hidden">';
1777 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';
1779 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1780 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1781 print
'<div id="example2" class="hidden">';
1782 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';
1785 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1786 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1787 print
'<div id="example3" class="hidden">';
1788 print
'mymailmanlist<br>';
1789 print
'mymailmanlist1,mymailmanlist2<br>';
1790 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1791 if (isModEnabled(
'category')) {
1792 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1796 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1797 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1803 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1806 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1807 $arrayoflabels = array();
1808 foreach (array_keys($_Avery_Labels) as $codecards) {
1809 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1811 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1812 print
'<input type="hidden" name="consttype" value="yesno">';
1813 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1817 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1818 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1819 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1820 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1822 print
"</textarea>\n";
1823 } elseif ($obj->type ==
'html') {
1824 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1825 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1826 $doleditor->Create();
1827 } elseif ($obj->type ==
'yesno') {
1828 print $form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1,
false, 0, 1);
1829 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1830 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1833 $tmp = explode(
':', $obj->type);
1835 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1837 $arrayofmessagename = array();
1838 if (is_array($formmail->lines_model)) {
1839 foreach ($formmail->lines_model as $modelmail) {
1842 if (!empty($arrayofmessagename[$modelmail->label])) {
1843 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1846 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1851 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1852 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1853 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).
'">';
1855 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1861 if (empty($strictw3c)) {
1862 print
'<td class="center">';
1863 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1869 if (empty($strictw3c)) {
1877 if (!empty($strictw3c) && $strictw3c == 1) {
1878 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1892 global $conf, $langs;
1894 $text = $langs->trans(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1898 if (!empty($modules)) {
1900 foreach ($tmpmodules as $module) {
1901 $moduleconst = $module->const_name;
1902 $modulename = strtolower($module->name);
1906 if (!in_array($modulename, $listofmodules)) {
1918 $tmptext = $langs->trans(
'Module'.$module->numero.
'Name');
1919 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1920 $text .= $langs->trans(
'Module'.$module->numero.
'Name');
1922 $text .= $langs->trans($module->name);
1946 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
1947 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
1948 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
1949 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
1952 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
1953 $resql = $db->query($sql);
1977 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
1978 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
1979 $sql .=
" AND type = '".$db->escape($type).
"'";
1980 $sql .=
" AND entity = ".((int) $conf->entity);
1982 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
1983 $resql = $db->query($sql);
2004 $phpinfostring = ob_get_contents();
2007 $info_arr = array();
2008 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2010 foreach ($info_lines as $line) {
2013 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2015 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2016 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2017 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2018 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2031 global $langs, $conf;
2036 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2037 $head[$h][1] = $langs->trans(
"Company");
2038 $head[$h][2] =
'company';
2041 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2042 $head[$h][1] = $langs->trans(
"OpeningHours");
2043 $head[$h][2] =
'openinghours';
2046 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
2047 $head[$h][1] = $langs->trans(
"Accountant");
2048 $head[$h][2] =
'accountant';
2051 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2052 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2053 $head[$h][2] =
'socialnetworks';
2070 global $langs, $conf, $user;
2075 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2076 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2077 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2078 $head[$h][2] =
'common';
2081 if (isModEnabled(
'mailing')) {
2082 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2083 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2084 $head[$h][2] =
'common_emailing';
2088 if (isModEnabled(
'ticket')) {
2089 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2090 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2091 $head[$h][2] =
'common_ticket';
2097 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2098 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2099 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2100 $head[$h][2] =
'senderprofiles';
2104 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2105 $head[$h][1] = $langs->trans(
"EMailTemplates");
2106 $head[$h][2] =
'templates';
2109 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2110 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2111 $head[$h][2] =
'common_ingoing';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
security_prepare_head()
Prepare array with list of tabs.
run_sql($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
Launch a sql file.
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
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.
form_constantes($tableau, $strictw3c=2, $helptext='', $text='Value')
Show array with constants to edit.
activateModule($value, $withdeps=1, $noconfverification=0)
Enable 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.
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
Prepare array with list of tabs.
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 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.
Class to manage a WYSIWYG editor.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
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...
dolEncrypt($chain, $key='', $ciphering='AES-256-CTR', $forceseed='')
Encode a string with a symmetric encryption.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check a new string containing only php code (including <php tag)
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.