mac.php 3.0 KB

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