control.php 6.3 KB

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