authlog.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
  6. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/loglevelfilter.php");
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/logfilter.php");
  8. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/authidfilter.php");
  9. if (!isset($auth_id)) { header('Location: /admin/logs/index.php', true, 301); exit; }
  10. ?>
  11. <div id="cont">
  12. <br>
  13. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  14. <input name="auth_id" value="<?php print $auth_id; ?>" hidden=true>
  15. <?php print_date_fields($date1,$date2,$date_shift); ?>
  16. <?php echo WEB_log_level_display; ?>:<?php print_loglevel_select('display_log_level',$display_log_level); ?>
  17. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  18. <input type="submit" value="<?php echo WEB_btn_show; ?>"><br><br>
  19. <?php echo WEB_log_filter_source; ?>:<input name="customer" value="<?php echo $fcustomer; ?>" />
  20. <?php echo WEB_log_message; ?>:<input name="message" value="<?php echo $fmessage; ?>" />
  21. </form>
  22. <?php
  23. $log_filter ='';
  24. if ($display_log_level == L_ERROR) { $log_filter = " and level=". L_ERROR." "; }
  25. if ($display_log_level == L_WARNING) { $log_filter = " and level<=".L_WARNING." "; }
  26. if ($display_log_level == L_INFO) { $log_filter = " and level<=".L_INFO." "; }
  27. if ($display_log_level == L_VERBOSE) { $log_filter = " and level<=".L_VERBOSE." "; }
  28. if ($display_log_level == L_DEBUG) { $log_filter = ""; }
  29. if (!empty($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; } else { $log_filter = " and auth_id=".$auth_id; }
  30. if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
  31. if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
  32. $countSQL="SELECT Count(*) FROM worklog WHERE ts>='$date1' AND ts<'$date2' $log_filter";
  33. $count_records = get_single_field($db_link,$countSQL);
  34. $total=ceil($count_records/$displayed);
  35. if ($page>$total) { $page=$total; }
  36. if ($page<1) { $page=1; }
  37. $start = ($page * $displayed) - $displayed;
  38. print_navigation($page_url,$page,$displayed,$count_records,$total);
  39. ?>
  40. <br>
  41. <table class="data" width="90%">
  42. <tr align="center">
  43. <td class="data" width=150><b><?php echo WEB_log_time; ?></b></td>
  44. <td class="data"><b><?php echo WEB_log_manager; ?></b></td>
  45. <td class="data"><b><?php echo WEB_log_level; ?></b></td>
  46. <td class="data"><b><?php echo WEB_log_event; ?></b></td>
  47. </tr>
  48. <?php
  49. #speedup paging
  50. $sSQL = "SELECT ts,customer,message,level FROM worklog as S JOIN (SELECT id FROM worklog WHERE ts>='$date1' AND ts<'$date2' $log_filter ORDER BY id DESC LIMIT $displayed OFFSET $start) AS I ON S.id = I.id";
  51. $userlog = get_records_sql($db_link, $sSQL);
  52. foreach ($userlog as $row) {
  53. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  54. print "<td class=\"data\">" . $row['ts'] . "</td>\n";
  55. print "<td class=\"data\">" . $row['customer'] . "</td>\n";
  56. $msg_level = 'INFO';
  57. if ($row['level'] == L_ERROR) { $msg_level='ERROR'; }
  58. if ($row['level'] == L_DEBUG) { $msg_level='DEBUG'; }
  59. if ($row['level'] == L_VERBOSE) { $msg_level='VERBOSE'; }
  60. print "<td class=\"data\">" . $msg_level . "</td>\n";
  61. $print_msg = expand_log_str($db_link, $row['message']);
  62. print "<td class=\"data\" align=left>" . $print_msg . "</td>\n";
  63. print "</tr>\n";
  64. }
  65. print "</table>\n";
  66. print_navigation($page_url,$page,$displayed,$count_records,$total);
  67. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  68. ?>