ip.php 3.6 KB

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