1
0

dhcp.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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['dhcp_show'])) { $f_dhcp = $_POST['dhcp_show']; }
  7. else {
  8. if (isset($_SESSION[$page_url]['f_dhcp'])) { $f_dhcp=$_SESSION[$page_url]['f_dhcp']; } else { $f_dhcp = 'all'; }
  9. }
  10. $_SESSION[$page_url]['f_dhcp']=$f_dhcp;
  11. $dhcp_where = '';
  12. if ($f_dhcp != 'all') { $dhcp_where = " and action='$f_dhcp' "; }
  13. print_log_submenu($page_url);
  14. ?>
  15. <div id="cont">
  16. <br>
  17. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  18. Начало:&nbsp<input type="date" name="date_start" value="<?php echo $date1; ?>" />
  19. Конец:&nbsp<input type="date" name="date_stop" value="<?php echo $date2; ?>" />
  20. Тип события:&nbsp<?php print_dhcp_select('dhcp_show', $f_dhcp); ?>
  21. Отображать:<?php print_row_at_pages('rows',$displayed); ?>
  22. <input type="submit" value="OK">
  23. </form>
  24. <?php
  25. $countSQL="SELECT Count(*) FROM dhcp_log WHERE `timestamp`>='$date1' AND `timestamp`<'$date2' $dhcp_where";
  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="900">
  36. <tr align="center">
  37. <td class="data" width=150><b>Время</b></td>
  38. <td class="data"><b>Тип</b></td>
  39. <td class="data"><b>Mac</b></td>
  40. <td class="data"><b>IP</b></td>
  41. </tr>
  42. <?php
  43. #speedup dhcp log paging
  44. $sSQL = "SELECT `timestamp`,mac,ip,action,auth_id FROM dhcp_log as D JOIN (SELECT id FROM dhcp_log WHERE `timestamp`>='$date1' and `timestamp`<'$date2' $dhcp_where ORDER BY `timestamp` DESC LIMIT $start,$displayed) AS I ON D.id = I.id";
  45. $userlog = get_records_sql($db_link, $sSQL);
  46. foreach ($userlog as $row) {
  47. if ($row['action'] == "old") { $row['action'] = "Обновление аренды: "; }
  48. if ($row['action'] == "add") { $row['action'] = "Аренда адреса: "; }
  49. if ($row['action'] == "del") { $row['action'] = "Освобождение адреса: "; }
  50. $l_msg = $row['action'] . " " . $row['mac'] . " " . $row['ip'];
  51. print "<tr align=center align=center class=\"tr1\" onmouseover=\"className='tr2'\" onmouseout=\"className='tr1'\">\n";
  52. print "<td class=\"data\">" . $row['timestamp'] . "</td>\n";
  53. print "<td class=\"data\">" . $row['action'] . "</td>\n";
  54. print "<td class=\"data\">" . $row['mac'] . "</td>\n";
  55. if (isset($row['auth_id']) and $row['auth_id'] > 0) {
  56. print "<td class=\"data\"><a href=/admin/users/editauth.php?id=".$row['auth_id'].">" . $row['ip'] . "</a></td>\n";
  57. } else {
  58. print "<td class=\"data\">" . $row['ip'] . "</td>\n";
  59. }
  60. print "</tr>\n";
  61. }
  62. print "</table>\n";
  63. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  64. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  65. ?>