index.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if (isset($_POST['user_ip'])) { $fuser_ip = $_POST['user_ip']; }
  9. if (isset($_GET['user_ip'])) { $fuser_ip = $_GET['user_ip']; }
  10. if (!isset($fuser_ip) and isset($_SESSION[$page_url]['user_ip'])) { $fuser_ip=$_SESSION[$page_url]['user_ip']; }
  11. if (!isset($fuser_ip)) { $fuser_ip=''; }
  12. $_SESSION[$page_url]['user_ip']=$fuser_ip;
  13. print_log_submenu($page_url);
  14. ?>
  15. <div id="cont">
  16. <br>
  17. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  18. <?php print_date_fields($date1,$date2,$date_shift); ?>
  19. <?php echo WEB_log_level_display; ?>:<?php print_loglevel_select('display_log_level',$display_log_level); ?>
  20. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  21. <input type="submit" value="<?php echo WEB_btn_show; ?>"><br><br>
  22. <?php echo WEB_log_filter_source; ?>:&nbsp<input name="customer" value="<?php echo $fcustomer; ?>" /> &nbsp
  23. <?php echo WEB_log_event; ?>:&nbsp<input name="message" value="<?php echo $fmessage; ?>" /> &nbsp
  24. <?php echo WEB_msg_IP; ?>:&nbsp<input name="user_ip" value="<?php echo $fuser_ip; ?>" /><br>
  25. </form>
  26. <?php
  27. $log_filter ='';
  28. if ($display_log_level == L_ERROR) { $log_filter = " and `level`=". L_ERROR." "; }
  29. if ($display_log_level == L_WARNING) { $log_filter = " and `level`<=".L_WARNING." "; }
  30. if ($display_log_level == L_INFO) { $log_filter = " and `level`<=".L_INFO." "; }
  31. if ($display_log_level == L_VERBOSE) { $log_filter = " and `level`<=".L_VERBOSE." "; }
  32. if ($display_log_level == L_DEBUG) { $log_filter = ""; }
  33. if (!empty($fcustomer)) { $log_filter = $log_filter." and customer LIKE '".$fcustomer."'"; }
  34. if (!empty($fmessage)) { $log_filter = $log_filter." and message LIKE '".$fmessage."'"; }
  35. if (!empty($fuser_ip)) { $log_filter = $log_filter." and ip LIKE '".$fuser_ip."'"; }
  36. $countSQL="SELECT Count(*) FROM worklog WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $log_filter";
  37. $count_records = get_single_field($db_link,$countSQL);
  38. $total=ceil($count_records/$displayed);
  39. if ($page>$total) { $page=$total; }
  40. if ($page<1) { $page=1; }
  41. $start = ($page * $displayed) - $displayed;
  42. print_navigation($page_url,$page,$displayed,$count_records,$total);
  43. #speedup paging
  44. $sSQL = "SELECT * FROM (SELECT * FROM worklog WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $log_filter ) AS W ORDER BY timestamp DESC LIMIT $start,$displayed";
  45. ?>
  46. <br>
  47. <table class="data">
  48. <tr align="center">
  49. <td class="data" width=150><b><?php echo WEB_log_time; ?></b></td>
  50. <td class="data"><b><?php echo WEB_log_filter_source; ?></b></td>
  51. <td class="data"><b><?php echo WEB_msg_IP; ?></b></td>
  52. <td class="data"><b><?php echo WEB_log_level; ?></b></td>
  53. <td class="data"><b><?php echo WEB_log_event; ?></b></td>
  54. </tr>
  55. <?php
  56. $userlog = get_records_sql($db_link, $sSQL);
  57. foreach ($userlog as $row) {
  58. print "<tr 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_WARNING) { $msg_level='WARNING'; }
  64. if ($row['level'] == L_DEBUG) { $msg_level='DEBUG'; }
  65. if ($row['level'] == L_VERBOSE) { $msg_level='VERBOSE'; }
  66. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  67. print "<td class=\"data\">" . $msg_level . "</td>\n";
  68. $print_msg = expand_log_str($db_link, $row['message']);
  69. print "<td class=\"data\" align=left>" . $print_msg . "</td>\n";
  70. print "</tr>\n";
  71. }
  72. print "</table>\n";
  73. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  74. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  75. ?>