1
0

mac.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $default_date_shift='m';
  6. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.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. Начало:&nbsp<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  20. Конец:&nbsp<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  21. 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}$" />
  22. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  23. <input type="submit" value="OK">
  24. </form>
  25. <?php
  26. $countSQL="SELECT Count(*) FROM mac_history WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' ORDER BY id DESC $mac_where";
  27. $res = mysqli_query($db_link, $countSQL);
  28. $count_records = mysqli_fetch_array($res);
  29. $total=ceil($count_records[0]/$displayed);
  30. if ($page>$total) { $page=$total; }
  31. if ($page<1) { $page=1; }
  32. $start = ($page * $displayed) - $displayed;
  33. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  34. ?>
  35. <br>
  36. <table class="data" width="850">
  37. <tr align="center">
  38. <td class="data" width=150><b>Время</b></td>
  39. <td class="data"><b>Mac</b></td>
  40. <td class="data"><b>Switch</b></td>
  41. <td class="data"><b>IP</b></td>
  42. </tr>
  43. <?php
  44. $sSQL = "SELECT * FROM mac_history WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $mac_where ORDER BY `timestamp` DESC LIMIT $start,$displayed";
  45. $maclog = get_records_sql($db_link, $sSQL);
  46. foreach ($maclog as $row) {
  47. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  48. print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
  49. print "<td class=\"data\">" . expand_mac($db_link,mac_dotted($row['mac'])) . "</td>\n";
  50. print "<td class=\"data\">" . get_port($db_link, $row['port_id']) . "</td>\n";
  51. if (isset($row['auth_id']) and $row['auth_id'] > 0) {
  52. print "<td class=\"data\"><a href=/admin/users/editauth.php?id=".$row['auth_id'].">" . $row['ip'] . "</a></td>\n";
  53. } else {
  54. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  55. }
  56. print "</tr>\n";
  57. }
  58. print "</table>\n";
  59. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  60. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  61. ?>