control.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. if (isset($_POST["recheck_ip"]) and is_option($db_link, 37)) {
  5. $run_cmd = get_option($db_link, 37);
  6. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." >/dev/null 2>/dev/null &");
  7. LOG_INFO($db_link, "Run command: $run_cmd ");
  8. header("Location: " . $_SERVER["REQUEST_URI"]);
  9. exit;
  10. }
  11. if (isset($_POST["refresh_dhcp"]) and is_option($db_link, 38)) {
  12. $run_cmd = get_option($db_link, 38);
  13. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." >/dev/null 2>/dev/null &");
  14. LOG_INFO($db_link, "Run command: $run_cmd ");
  15. header("Location: " . $_SERVER["REQUEST_URI"]);
  16. exit;
  17. }
  18. if (isset($_POST["refresh_nagios"]) and is_option($db_link, 40)) {
  19. $run_cmd = get_option($db_link, 40);
  20. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." >/dev/null 2>/dev/null &");
  21. LOG_INFO($db_link, "Run command: $run_cmd ");
  22. header("Location: " . $_SERVER["REQUEST_URI"]);
  23. exit;
  24. }
  25. if (isset($_POST["up_nagios"])) {
  26. run_sql($db_link,"UPDATE User_auth SET nagios_status='UP'");
  27. run_sql($db_link,"UPDATE devices SET nagios_status='UP'");
  28. header("Location: " . $_SERVER["REQUEST_URI"]);
  29. exit;
  30. }
  31. if (isset($_POST["refresh_dns"]) and is_option($db_link, 39)) {
  32. $run_cmd = get_option($db_link, 39);
  33. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." >/dev/null 2>/dev/null &");
  34. LOG_INFO($db_link, "Run command: $run_cmd ");
  35. header("Location: " . $_SERVER["REQUEST_URI"]);
  36. exit;
  37. }
  38. if (isset($_POST["discovery"]) and is_option($db_link, 41)) {
  39. $run_cmd = get_option($db_link, 41);
  40. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." >/dev/null 2>/dev/null &");
  41. LOG_INFO($db_link, "Run command: $run_cmd ");
  42. header("Location: " . $_SERVER["REQUEST_URI"]);
  43. exit;
  44. }
  45. if (isset($_POST["discovery2"]) and is_option($db_link, 41)) {
  46. $run_cmd = get_option($db_link, 41);
  47. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." force >/dev/null 2>/dev/null &");
  48. LOG_INFO($db_link, "Run command: $run_cmd force");
  49. header("Location: " . $_SERVER["REQUEST_URI"]);
  50. exit;
  51. }
  52. if (!empty($_POST["save_traf_all"]) and $_POST["save_traf_all"]) {
  53. run_sql($db_link, 'Update User_auth SET save_traf=1');
  54. LOG_INFO($db_link, "Enable save traffic for all!");
  55. header("Location: " . $_SERVER["REQUEST_URI"]);
  56. exit;
  57. }
  58. if (!empty($_POST["not_save_traf_all"]) and $_POST["not_save_traf_all"]) {
  59. run_sql($db_link, 'Update User_auth SET save_traf=0');
  60. LOG_INFO($db_link, "Disable save traffic for all!");
  61. header("Location: " . $_SERVER["REQUEST_URI"]);
  62. exit;
  63. }
  64. if (isset($_POST["s_remove"])) {
  65. $s_id = $_POST["s_id"];
  66. foreach ($s_id as $key => $val) {
  67. if (isset($val)) {
  68. LOG_INFO($db_link, "Remove subnet id: $val");
  69. delete_record($db_link, "subnets", "id=" . $val);
  70. }
  71. }
  72. header("Location: " . $_SERVER["REQUEST_URI"]);
  73. exit;
  74. }
  75. if (isset($_POST["clean_cache"])) {
  76. LOG_INFO($db_link, "Clean dns cache");
  77. run_sql($db_link,"DELETE FROM dns_cache");
  78. header("Location: " . $_SERVER["REQUEST_URI"]);
  79. exit;
  80. }
  81. unset($_POST);
  82. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  83. print_control_submenu($page_url);
  84. ?>
  85. <div id="cont">
  86. <br>
  87. <form name="def" action="control.php" method="post">
  88. <table class="data">
  89. <?php
  90. if (is_option($db_link, 37)) {
  91. print "<tr><td align=right>".WEB_control_access."&nbsp<input type=submit name='recheck_ip' value='".WEB_btn_refresh."'></td></tr>";
  92. }
  93. if (is_option($db_link, 38)) {
  94. print "<tr><td align=right>".WEB_control_dhcp."&nbsp<input type=submit name='refresh_dhcp' value='".WEB_btn_refresh."' ></td></tr>";
  95. }
  96. if (is_option($db_link, 39)) {
  97. print "<tr><td align=right>".WEB_control_dns."&nbsp<input type=submit name='refresh_dns' value='".WEB_btn_refresh."' ></td></tr>";
  98. }
  99. if (is_option($db_link, 40)) {
  100. print "<tr><td align=right>".WEB_control_nagios."&nbsp<input type=submit name='refresh_nagios' value='".WEB_btn_refresh."'></td></tr>";
  101. print "<tr><td align=right>".WEB_control_nagios_clear_alarm."&nbsp<input type=submit name='up_nagios' value='".WEB_btn_run."'></td></tr>";
  102. }
  103. if (is_option($db_link, 41)) {
  104. print "<tr><td align=right>".WEB_control_scan_network."&nbsp<input type=submit name='discovery' value='".WEB_btn_run."'></td></tr>";
  105. }
  106. if (is_option($db_link, 41)) {
  107. print "<tr><td align=right>".WEB_control_fping_scan_network."&nbsp<input type=submit name='discovery2' value='".WEB_btn_run."'></td></tr>";
  108. }
  109. if (get_option($db_link, 23)) {
  110. print "<tr><td align=right>".WEB_control_log_traffic_on."&nbsp<input type=submit name='save_traf_all' value='".WEB_btn_run."'></td></tr>";
  111. print "<tr><td align=right>".WEB_control_log_traffic_off."&nbsp<input type=submit name='not_save_traf_all' value='".WEB_btn_run."'></td></tr>";
  112. }
  113. print "<tr><td align=right>".WEB_control_clear_dns_cache."&nbsp<input type=submit name='clean_cache' value='".WEB_btn_run."'></td></tr>";
  114. ?>
  115. <tr>
  116. <td align=right><a href="ipcam.php"><?php echo WEB_control_port_off; ?></a></td>
  117. </tr>
  118. </table>
  119. </form>
  120. <?php
  121. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  122. ?>