1
0

add_dhcp.php 929 B

12345678910111213141516171819202122232425262728
  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"])) {
  8. $dhcp_hostname = trim($_GET["hostname"]);
  9. }
  10. $faction = $_GET["action"] * 1;
  11. $action = 'add';
  12. if ($faction == 1) {
  13. $action = 'add';
  14. }
  15. if ($faction == 0) {
  16. $action = 'del';
  17. }
  18. LOG_VERBOSE($db_link, "external dhcp request for $ip [$mac] $action");
  19. if (checkValidIp($ip) and is_our_network($db_link, $ip)) {
  20. $run_cmd = "/opt/Eye/scripts/dnsmasq-hook.sh '" . $action . "' '" . $mac . "' '" . $ip . "' '" . $dhcp_hostname . "'";
  21. $result = shell_exec("/usr/bin/sudo " . escapeshellcmd($run_cmd) . " >/dev/null 2>/dev/null &");
  22. LOG_VERBOSE($db_link, "Run command: $run_cmd ");
  23. } else {
  24. LOG_ERROR($db_link, "$ip - wrong network!");
  25. }
  26. }
  27. unset($_GET);