ip.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/datetimefilter.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. <?php echo WEB_log_mac_history_hint; ?>
  21. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  22. <?php print_date_fields($date1,$date2,$date_shift); ?>
  23. <?php echo WEB_log_select_ip_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})$"/>
  24. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  25. <input type="submit" value="<?php echo WEB_btn_show; ?>">
  26. </form>
  27. <?php
  28. $countSQL="SELECT Count(*) FROM user_auth WHERE ts>='$date1' AND ts<'$date2' $ip_where";
  29. $count_records = get_single_field($db_link,$countSQL);
  30. $total=ceil($count_records/$displayed);
  31. if ($page>$total) { $page=$total; }
  32. if ($page<1) { $page=1; }
  33. $start = ($page * $displayed) - $displayed;
  34. print_navigation($page_url,$page,$displayed,$count_records,$total);
  35. ?>
  36. <br>
  37. <table class="data">
  38. <tr align="center">
  39. <td class="data"><b>id</b></td>
  40. <td class="data" width=150><b><?php echo WEB_cell_created; ?></b></td>
  41. <td class="data" width=150><b><?php echo WEB_cell_last_found; ?></b></td>
  42. <td class="data"><b><?php echo WEB_cell_ip; ?></b></td>
  43. <td class="data"><b><?php echo WEB_cell_mac; ?></b></td>
  44. <td class="data"><b><?php echo WEB_cell_dhcp_hostname; ?></b></td>
  45. <td class="data"><b><?php echo WEB_cell_dns_name; ?></b></td>
  46. </tr>
  47. <?php
  48. $sSQL = "SELECT * FROM user_auth WHERE ts>='$date1' AND ts<'$date2' $ip_where ORDER BY id DESC LIMIT $displayed OFFSET $start";
  49. $iplog = get_records_sql($db_link, $sSQL);
  50. foreach ($iplog as $row) {
  51. print "<tr align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  52. print "<td class=\"data\">" . $row['id'] . "</td>\n";
  53. print "<td class=\"data\">" . $row['ts'] . "</td>\n";
  54. print "<td class=\"data\">" . $row['last_found'] . "</td>\n";
  55. if (isset($row['id']) and $row['id'] > 0) {
  56. print "<td class=\"data\"><a href=/admin/users/editauth.php?id=".$row['id'].">" . $row['ip'] . "</a></td>\n";
  57. } else {
  58. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  59. }
  60. print "<td class=\"data\">" . expand_mac($db_link,mac_dotted($row['mac'])) . "</td>\n";
  61. print "<td class=\"data\">" . $row['dhcp_hostname'] . "</td>\n";
  62. print "<td class=\"data\">" . $row['dns_name'] . "</td>\n";
  63. print "</tr>\n";
  64. }
  65. print "</table>\n";
  66. print_navigation($page_url,$page,$displayed,$count_records,$total);
  67. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  68. ?>