29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_20_all_Logevents.class.php';
38$action =
GETPOST(
'action',
'aZ09');
39$confirm =
GETPOST(
'confirm',
'alpha');
42if ($user->socid > 0) {
44 $socid = $user->socid;
48$langs->loadLangs(array(
"companies",
"admin",
"users",
"other",
"withdrawals"));
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55if (empty($page) || $page == -1) {
58$offset = $limit * $page;
62 $sortfield =
"e.rowid";
68$search_rowid =
GETPOST(
"search_rowid",
"intcomma");
69$search_code =
GETPOST(
"search_code",
"alpha");
70$search_ip =
GETPOST(
"search_ip",
"alpha");
71$search_user =
GETPOST(
"search_user",
"alpha");
72$search_desc =
GETPOST(
"search_desc",
"alpha");
73$search_ua =
GETPOST(
"search_ua",
"restricthtml");
74$search_prefix_session =
GETPOST(
"search_prefix_session",
"restricthtml");
75$optioncss =
GETPOST(
"optioncss",
"aZ");
92if ($date_start !==
'' && $date_end !==
'' && $date_start > $date_end) {
93 $date_end = $date_start + 86400;
97if (!GETPOSTISSET(
'pageplusoneold') && !GETPOSTISSET(
'page') && $date_start ===
'') {
98 $date_start =
dol_get_first_day($nowarray[
'year'], $nowarray[
'mon'],
'tzuserrel');
100if (!GETPOSTISSET(
'pageplusoneold') && !GETPOSTISSET(
'page') && $date_end ===
'') {
101 $date_end =
dol_get_last_day($nowarray[
'year'], $nowarray[
'mon'],
'tzuserrel');
106$date_startmonth =
'';
111if ($date_start !==
'') {
113 $date_startday = $tmp[
'mday'];
114 $date_startmonth = $tmp[
'mon'];
115 $date_startyear = $tmp[
'year'];
117if ($date_end !==
'') {
119 $date_endday = $tmp[
'mday'];
120 $date_endmonth = $tmp[
'mon'];
121 $date_endyear = $tmp[
'year'];
126 'e.prefix_session' => array(
127 'label' =>
'UserAgent',
142if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
147 $date_startmonth =
'';
149 $date_startyear =
'';
157 $search_prefix_session =
'';
161if ($action ==
'confirm_purge' && $confirm ==
'yes' && $user->admin) {
165 $securityevents =
new Events($db);
168 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"events";
169 $sql .=
" WHERE entity = ".$conf->entity;
172 $resql = $db->query($sql);
179 $text = $langs->trans(
"SecurityEventsPurged");
180 $securityevent =
new Events($db);
181 $securityevent->type =
'SECURITY_EVENTS_PURGE';
182 $securityevent->dateevent = $now;
183 $securityevent->description = $text;
185 $result = $securityevent->create($user);
201$title = $langs->trans(
"Audit");
202llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-tools_listevents');
204$form =
new Form($db);
206$userstatic =
new User($db);
209$sql =
"SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
210$sql .=
" e.fk_user, e.description, e.prefix_session,";
211$sql .=
" u.login, u.admin, u.entity, u.firstname, u.lastname, u.statut as status";
212$sql .=
" FROM ".MAIN_DB_PREFIX.
"events as e";
213$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = e.fk_user";
214$sql .=
" WHERE e.entity IN (".getEntity(
'event').
")";
215if ($date_start !==
'') {
216 $sql .=
" AND e.dateevent >= '".$db->idate($date_start).
"'";
218if ($date_end !==
'') {
219 $sql .=
" AND e.dateevent <= '".$db->idate($date_end).
"'";
245if ($search_prefix_session) {
247 $sql .=
natural_search(
"e.prefix_session", $search_prefix_session, 0);
249$sql .= $db->order($sortfield, $sortorder);
252$nbtotalofrecords =
'';
264$sql .= $db->plimit($limit + 1, $offset);
266$result = $db->query($sql);
268 $num = $db->num_rows($result);
272 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
273 $param .=
'&contextpage='.urlencode($contextpage);
275 if ($limit > 0 && $limit != $conf->liste_limit) {
276 $param .=
'&limit='.((int) $limit);
278 if ($optioncss !=
'') {
279 $param .=
'&optioncss='.urlencode($optioncss);
282 $param .=
'&search_rowid='.urlencode((
string) ($search_rowid));
285 $param .=
'&search_code='.urlencode($search_code);
288 $param .=
'&search_ip='.urlencode($search_ip);
291 $param .=
'&search_user='.urlencode($search_user);
294 $param .=
'&search_desc='.urlencode($search_desc);
297 $param .=
'&search_ua='.urlencode($search_ua);
299 if ($search_prefix_session) {
300 $param .=
'&search_prefix_session='.urlencode($search_prefix_session);
302 if ($date_startmonth) {
303 $param .=
"&date_startmonth=".((int) $date_startmonth);
305 if ($date_startday) {
306 $param .=
"&date_startday=".((int) $date_startday);
308 if ($date_startyear) {
309 $param .=
"&date_startyear=".((int) $date_startyear);
311 if ($date_endmonth) {
312 $param .=
"&date_endmonth=".((int) $date_endmonth);
315 $param .=
"&date_endday=".((int) $date_endday);
318 $param .=
"&date_endyear=".((int) $date_endyear);
323 $center =
'<a class="butActionDelete small" href="'.$_SERVER[
"PHP_SELF"].
'?action=purge">'.$langs->trans(
"Purge").
'</a>';
326 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
330 print_barre_liste($langs->trans(
"ListOfSecurityEvents"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords,
'setup', 0,
'',
'', $limit);
332 if ($action ==
'purge') {
333 $formquestion = array();
334 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?noparam=noparam', $langs->trans(
'PurgeAuditEvents'), $langs->trans(
'ConfirmPurgeAuditEvents'),
'confirm_purge', $formquestion,
'no', 1);
351 print
'<div class="div-table-responsive">';
352 print
'<table class="liste centpercent">';
355 print
'<tr class="liste_titre">';
359 print
'<td class="liste_titre maxwidthsearch center">';
360 $searchpicto = $form->showFilterAndCheckAddButtons(0);
366 print
'<td class="liste_titre">';
367 print
'<input class="flat maxwidth50" type="text" name="search_rowid" value="'.dol_escape_htmltag($search_rowid).
'">';
371 print
'<td class="liste_titre" width="15%">';
372 print $form->selectDate($date_start ===
'' ? -1 : $date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
373 print $form->selectDate($date_end ===
'' ? -1 : $date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
376 print
'<td class="liste_titre">';
377 print
'<input class="flat maxwidth75" type="text" name="search_code" value="'.dol_escape_htmltag($search_code).
'">';
381 print
'<td class="liste_titre">';
382 print
'<input class="flat maxwidth75" type="text" name="search_ip" value="'.dol_escape_htmltag($search_ip).
'">';
385 print
'<td class="liste_titre">';
386 print
'<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
389 print
'<td class="liste_titre">';
393 print
'<td class="liste_titre left">';
394 print
'<input class="flat maxwidth100" type="text" name="search_ua" value="'.dol_escape_htmltag($search_ua).
'">';
397 if (!empty($arrayfields[
'e.prefix_session'][
'checked'])) {
398 print
'<td class="liste_titre left">';
399 print
'<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.dol_escape_htmltag($search_prefix_session).
'">';
405 print
'<td class="liste_titre maxwidthsearch">';
406 $searchpicto = $form->showFilterAndCheckAddButtons(0);
414 print
'<tr class="liste_titre">';
424 print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"],
"e.description",
"", $param,
'', $sortfield, $sortorder);
425 print_liste_field_titre(
"UserAgent", $_SERVER[
"PHP_SELF"],
"e.user_agent",
"", $param,
'', $sortfield, $sortorder);
426 if (!empty($arrayfields[
'e.prefix_session'][
'checked'])) {
427 print_liste_field_titre(
"SuffixSessionName", $_SERVER[
"PHP_SELF"],
"e.prefix_session",
"", $param,
'', $sortfield, $sortorder);
435 while ($i < min($num, $limit)) {
436 $obj = $db->fetch_object($result);
438 print
'<tr class="oddeven">';
442 print
'<td class="center">';
443 $htmltext =
'<b>'.$langs->trans(
"UserAgent").
'</b>: '.($obj->user_agent ?
dol_string_nohtmltag($obj->user_agent) : $langs->trans(
"Unknown"));
444 $htmltext .=
'<br><b>'.$langs->trans(
"SuffixSessionName").
' (DOLSESSID_...)</b>: '.($obj->prefix_session ?
dol_string_nohtmltag($obj->prefix_session) : $langs->trans(
"Unknown"));
445 print $form->textwithpicto(
'', $htmltext);
450 print
'<td class="nowrap left">'.dol_escape_htmltag($obj->rowid).
'</td>';
453 print
'<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent),
'%Y-%m-%d %H:%M:%S',
'tzuserrel').
'</td>';
456 print
'<td>'.dol_escape_htmltag($obj->type).
'</td>';
459 print
'<td class="nowraponall">';
464 print
'<td class="tdoverflowmax125">';
465 if ($obj->fk_user > 0) {
466 $userstatic->id = $obj->fk_user;
467 $userstatic->login = $obj->login;
468 $userstatic->admin = $obj->admin;
469 $userstatic->entity = $obj->entity;
470 $userstatic->status = $obj->status;
472 print $userstatic->getLoginUrl(1);
473 if (isModEnabled(
'multicompany') && $userstatic->admin && !$userstatic->entity) {
474 print
img_picto($langs->trans(
"SuperAdministratorDesc"),
'redstar',
'class="valignmiddle paddingleft"');
475 } elseif ($userstatic->admin) {
476 print
img_picto($langs->trans(
"AdministratorDesc"),
'star',
'class="valignmiddle paddingleft"');
484 $text = $langs->trans($obj->description);
487 $val = explode(
' : ', $obj->description);
488 $text = $langs->trans($val[0], isset($val[1]) ? $val[1] :
'', isset($val[2]) ? $val[2] :
'', isset($val[3]) ? $val[3] :
'', isset($val[4]) ? $val[4] :
'');
490 if (preg_match(
'/\((.*)\)(.*)/i', $obj->description, $reg)) {
491 $val = explode(
',', $reg[1]);
492 $text = $langs->trans($val[0], isset($val[1]) ? $val[1] :
'', isset($val[2]) ? $val[2] :
'', isset($val[3]) ? $val[3] :
'', isset($val[4]) ? $val[4] :
'');
493 if (!empty($reg[2])) {
497 print
'<td class="tdoverflowmax400" title="'.dol_escape_htmltag($text).
'">';
502 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->user_agent).
'">';
507 if (!empty($arrayfields[
'e.prefix_session'][
'checked'])) {
508 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->prefix_session).
'">';
515 print
'<td class="right">';
516 $htmltext =
'<b>'.$langs->trans(
"UserAgent").
'</b>: '.($obj->user_agent ?
dol_string_nohtmltag($obj->user_agent) : $langs->trans(
"Unknown"));
517 $htmltext .=
'<br><b>'.$langs->trans(
"SuffixSessionName").
' (DOLSESSID_...)</b>: '.($obj->prefix_session ?
dol_string_nohtmltag($obj->prefix_session) : $langs->trans(
"Unknown"));
518 print $form->textwithpicto(
'', $htmltext);
529 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoEventFoundWithCriteria").
'</span></td></tr>';
531 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoEventOrNoAuditSetup").
'</span></td></tr>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static isEventActionTextKey($event_text)
Check if text contains an event action key.
Class to manage Dolibarr users.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_print_ip($ip, $mode=0)
Return an IP formatted to be shown on screen.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.