1
0

authlog.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.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. Начало:<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  16. Конец:<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  17. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  18. Уровень логов:<?php print_loglevel_select('log_level',$log_level); ?>
  19. <input type="submit" value="OK"><br><br>
  20. Фильтр Источник:<input name="customer" value="<?php echo $fcustomer; ?>" />
  21. Сообщение:<input name="message" value="<?php echo $fmessage; ?>" />
  22. </form>
  23. <?php
  24. $log_filter ='';
  25. global $L_INFO;
  26. global $L_ERROR;
  27. global $L_VERBOSE;
  28. global $L_DEBUG;
  29. if ($log_level == $L_INFO) { $log_filter = " and `level`=$L_INFO "; }
  30. if ($log_level == $L_ERROR) { $log_filter = " and (`level`=$L_INFO or `level`=$L_ERROR) "; }
  31. if ($log_level == $L_VERBOSE) { $log_filter = " and (`level`=$L_INFO or `level`=$L_ERROR or `level`=$L_VERBOSE) "; }
  32. if ($log_level == $L_DEBUG) { $log_filter = ""; }
  33. if (isset($log_filter)) { $log_filter = $log_filter." and auth_id=".$auth_id; } else { $log_filter = "auth_id=".$auth_id; }
  34. if (isset($fcustomer)) { $log_filter = $log_filter." and customer LIKE '%".$fcustomer."%'"; }
  35. if (isset($fmessage)) { $log_filter = $log_filter." and message LIKE '%".$fmessage."%'"; }
  36. $countSQL="SELECT Count(*) FROM syslog WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $log_filter";
  37. $res = mysqli_query($db_link, $countSQL);
  38. $count_records = mysqli_fetch_array($res);
  39. $total=ceil($count_records[0]/$displayed);
  40. if ($page>$total) { $page=$total; }
  41. if ($page<1) { $page=1; }
  42. $start = ($page * $displayed) - $displayed;
  43. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  44. ?>
  45. <br>
  46. <table class="data" width="90%">
  47. <tr align="center">
  48. <td class="data" width=150><b>Время</b></td>
  49. <td class="data"><b>Менеджер</b></td>
  50. <td class="data"><b>Level</b></td>
  51. <td class="data"><b>Лог</b></td>
  52. </tr>
  53. <?php
  54. #speedup paging
  55. $sSQL = "SELECT timestamp,customer,message,level FROM syslog as S JOIN (SELECT id FROM syslog WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $log_filter ORDER BY id DESC LIMIT $start,$displayed) AS I ON S.id = I.id";
  56. $userlog = get_records_sql($db_link, $sSQL);
  57. foreach ($userlog as $row) {
  58. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  59. print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
  60. print "<td class=\"data\">" . $row['customer'] . "</td>\n";
  61. $msg_level = 'INFO';
  62. if ($row['level'] == $L_ERROR) { $msg_level='ERROR'; }
  63. if ($row['level'] == $L_DEBUG) { $msg_level='DEBUG'; }
  64. if ($row['level'] == $L_VERBOSE) { $msg_level='VERBOSE'; }
  65. print "<td class=\"data\">" . $msg_level . "</td>\n";
  66. $print_msg = expand_log_str($db_link, $row['message']);
  67. print "<td class=\"data\" align=left>" . $print_msg . "</td>\n";
  68. print "</tr>\n";
  69. }
  70. print "</table>\n";
  71. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  72. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  73. ?>