control.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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["clean_cache"])) {
  78. LOG_VERBOSE($db_link, "Clean dns cache");
  79. run_sql($db_link,"DELETE FROM dns_cache");
  80. header("Location: " . $_SERVER["REQUEST_URI"]);
  81. exit;
  82. }
  83. unset($_POST);
  84. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  85. print_control_submenu($page_url);
  86. ?>
  87. <div id="cont">
  88. <br>
  89. <form name="def" action="control.php" method="post">
  90. <table class="data">
  91. <?php
  92. if (get_option($db_link, 68)) {
  93. 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>";
  94. } else {
  95. print "<tr><td align=right>".WEB_control_edit_mode."&nbsp<input type=submit name='set_workmode_on' value='".WEB_btn_on."'></td></tr>";
  96. }
  97. if (is_option($db_link, 37)) {
  98. print "<tr><td align=right>".WEB_control_access."&nbsp<input type=submit name='recheck_ip' value='".WEB_btn_refresh."'></td></tr>";
  99. }
  100. if (is_option($db_link, 38)) {
  101. print "<tr><td align=right>".WEB_control_dhcp."&nbsp<input type=submit name='refresh_dhcp' value='".WEB_btn_refresh."' ></td></tr>";
  102. }
  103. if (is_option($db_link, 39)) {
  104. print "<tr><td align=right>".WEB_control_dns."&nbsp<input type=submit name='refresh_dns' value='".WEB_btn_refresh."' ></td></tr>";
  105. }
  106. if (is_option($db_link, 40)) {
  107. print "<tr><td align=right>".WEB_control_nagios."&nbsp<input type=submit name='refresh_nagios' value='".WEB_btn_refresh."'></td></tr>";
  108. print "<tr><td align=right>".WEB_control_nagios_clear_alarm."&nbsp<input type=submit name='up_nagios' value='".WEB_btn_run."'></td></tr>";
  109. }
  110. if (is_option($db_link, 41)) {
  111. print "<tr><td align=right>".WEB_control_scan_network."&nbsp<input type=submit name='discovery' value='".WEB_btn_run."'></td></tr>";
  112. }
  113. if (is_option($db_link, 41)) {
  114. print "<tr><td align=right>".WEB_control_fping_scan_network."&nbsp<input type=submit name='discovery2' value='".WEB_btn_run."'></td></tr>";
  115. }
  116. if (get_option($db_link, 23)) {
  117. print "<tr><td align=right>".WEB_control_log_traffic_on."&nbsp<input type=submit name='save_traf_all' value='".WEB_btn_run."'></td></tr>";
  118. 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>";
  119. }
  120. print "<tr><td align=right>".WEB_control_clear_dns_cache."&nbsp<input type=submit name='clean_cache' value='".WEB_btn_run."'></td></tr>";
  121. ?>
  122. <tr>
  123. <td align=right><a href="ipcam.php"><?php echo WEB_control_port_off; ?></a></td>
  124. </tr>
  125. </table>
  126. </form>
  127. <?php
  128. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  129. ?>