1
0

mac.php 2.9 KB

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