add_dhcp.php 905 B

123456789101112131415161718192021
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/qauth.php");
  3. if (!empty($_GET["ip"]) and !empty($_GET["mac"])) {
  4. $ip = $_GET["ip"];
  5. $mac = mac_dotted(trim($_GET["mac"]));
  6. $dhcp_hostname = '';
  7. if (!empty($_GET["hostname"])) { $dhcp_hostname = trim($_GET["hostname"]); }
  8. $faction = $_GET["action"] * 1;
  9. $action = 'add';
  10. if ($faction == 1) { $action = 'add'; }
  11. if ($faction == 0) { $action = 'del'; }
  12. LOG_VERBOSE($db_link, "external dhcp request for $ip [$mac] $action");
  13. if (checkValidIp($ip) and is_our_network($db_link, $ip)) {
  14. $run_cmd = "/opt/Eye/scripts/dnsmasq-hook.sh '".$action."' '".$mac."' '".$ip."' '".$dhcp_hostname."'";
  15. $result = shell_exec("/usr/bin/sudo ".escapeshellcmd($run_cmd)." >/dev/null 2>/dev/null &");
  16. LOG_INFO($db_link, "Run command: $run_cmd ");
  17. } else { LOG_ERROR($db_link, "$ip - wrong network!"); }
  18. }
  19. unset($_GET);
  20. ?>