1
0

ip.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/datefilter.php");
  6. if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
  7. if (isset($_GET['ip'])) { $f_ip = $_GET['ip']; }
  8. if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
  9. if (!isset($f_ip)) { $f_ip=''; }
  10. $_SESSION[$page_url]['ip']=$f_ip;
  11. print_log_submenu($page_url);
  12. $ip_where = '';
  13. if (!empty($f_ip)) {
  14. if (checkValidIp($f_ip)) { $ip_where = " and ip_int=inet_aton('" . $f_ip . "') "; }
  15. if (checkValidMac($f_ip)) { $ip_where = " and mac='" . mac_dotted($f_ip) . "' "; }
  16. }
  17. ?>
  18. <div id="cont">
  19. <br>
  20. Здесь находится история всех работавших когда-то маков/ip.<br>
  21. Если нужно найти место подключения - смотреть приключения маков!<br>
  22. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  23. Начало:&nbsp<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  24. Конец:&nbsp<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  25. ip or mac:&nbsp<input type="text" name="ip" value="<?php echo $f_ip; ?>" pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([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})$"/>
  26. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  27. <input type="submit" value="OK">
  28. </form>
  29. <?php
  30. $countSQL="SELECT Count(*) FROM User_auth WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $ip_where";
  31. $res = mysqli_query($db_link, $countSQL);
  32. $count_records = mysqli_fetch_array($res);
  33. $total=ceil($count_records[0]/$displayed);
  34. if ($page>$total) { $page=$total; }
  35. if ($page<1) { $page=1; }
  36. $start = ($page * $displayed) - $displayed;
  37. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  38. ?>
  39. <br>
  40. <table class="data">
  41. <tr align="center">
  42. <td class="data"><b>id</b></td>
  43. <td class="data" width=150><b>Время создания</b></td>
  44. <td class="data" width=150><b>Последняя работа</b></td>
  45. <td class="data"><b>IP</b></td>
  46. <td class="data"><b>mac</b></td>
  47. <td class="data"><b>dhcp hostname</b></td>
  48. <td class="data"><b>dns name</b></td>
  49. </tr>
  50. <?php
  51. $sSQL = "SELECT * FROM User_auth WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $ip_where ORDER BY id DESC LIMIT $start,$displayed";
  52. $iplog = get_records_sql($db_link, $sSQL);
  53. foreach ($iplog as $row) {
  54. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  55. print "<td class=\"data\">" . $row['id'] . "</td>\n";
  56. print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
  57. print "<td class=\"data\">" . $row['last_found'] . "</td>\n";
  58. if (isset($row['id']) and $row['id'] > 0) {
  59. print "<td class=\"data\"><a href=/admin/users/editauth.php?id=".$row['id'].">" . $row['ip'] . "</a></td>\n";
  60. } else {
  61. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  62. }
  63. print "<td class=\"data\">" . expand_mac($db_link,mac_dotted($row['mac'])) . "</td>\n";
  64. print "<td class=\"data\">" . $row['dhcp_hostname'] . "</td>\n";
  65. print "<td class=\"data\">" . $row['dns_name'] . "</td>\n";
  66. print "</tr>\n";
  67. }
  68. print "</table>\n";
  69. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  70. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  71. ?>