mac.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/cidrfilter.php");
  6. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datetimefilter.php");
  7. if (isset($_POST['mac'])) { $f_mac = mac_simplify($_POST['mac']); }
  8. if (isset($_GET['mac'])) { $f_mac = mac_simplify($_GET['mac']); }
  9. if (!isset($f_mac) and isset($_SESSION[$page_url]['mac'])) { $f_mac=$_SESSION[$page_url]['mac']; }
  10. if (!isset($f_mac)) { $f_mac=''; }
  11. $_SESSION[$page_url]['mac']=$f_mac;
  12. print_log_submenu($page_url);
  13. ?>
  14. <div id="cont">
  15. <br>
  16. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  17. <?php print_date_fields($date1,$date2,$date_shift); ?>
  18. <?php echo WEB_cell_mac; ?>:&nbsp<input type="text" name="mac" value="<?php echo mac_dotted($f_mac); ?>" pattern="^([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12}$" />
  19. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  20. <input type="submit" value="<?php echo WEB_btn_show; ?>">
  21. </form>
  22. <?php
  23. $params = [$date1, $date2];
  24. $conditions = [];
  25. if (!empty($f_mac)) {
  26. $conditions[] = "mac = ?";
  27. $params[] = $f_mac;
  28. }
  29. $whereClause = !empty($conditions) ? ' AND ' . implode(' AND ', $conditions) : '';
  30. $countSQL = "SELECT COUNT(*) FROM mac_history WHERE ts >= ? AND ts < ?" . $whereClause;
  31. $count_records = (int)get_single_field($db_link, $countSQL, $params);
  32. $total = ceil($count_records / $displayed);
  33. $page = max(1, min($page, $total));
  34. $start = ($page - 1) * $displayed;
  35. print_navigation($page_url, $page, $displayed, $count_records, $total);
  36. $dataParams = array_merge($params, [$displayed, $start]);
  37. $sSQL = "
  38. SELECT * FROM mac_history
  39. WHERE ts >= ? AND ts < ?" . $whereClause . "
  40. ORDER BY ts DESC
  41. LIMIT ? OFFSET ?
  42. ";
  43. $maclog = get_records_sql($db_link, $sSQL, $dataParams);
  44. ?>
  45. <br>
  46. <table class="data" width="850">
  47. <tr align="center">
  48. <td class="data" width=150><b><?php echo WEB_log_time; ?></b></td>
  49. <td class="data"><b><?php echo WEB_cell_mac; ?></b></td>
  50. <td class="data"><b><?php echo WEB_cell_connection; ?></b></td>
  51. <td class="data"><b><?php echo WEB_cell_ip; ?></b></td>
  52. </tr>
  53. <?php
  54. foreach ($maclog as $row) {
  55. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  56. print "<td class=\"data\">" . $row['ts'] . "</td>\n";
  57. print "<td class=\"data\">" . expand_mac($db_link,mac_dotted($row['mac'])) . "</td>\n";
  58. print "<td class=\"data\">" . get_port($db_link, $row['port_id']) . "</td>\n";
  59. if (isset($row['auth_id']) and $row['auth_id'] > 0) {
  60. print "<td class=\"data\"><a href=/admin/users/editauth.php?id=".$row['auth_id'].">" . $row['ip'] . "</a></td>\n";
  61. } else {
  62. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  63. }
  64. print "</tr>\n";
  65. }
  66. print "</table>\n";
  67. print_navigation($page_url,$page,$displayed,$count_records,$total);
  68. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  69. ?>