function host_add() { $dhcp = new dhcpd(0, 1); $cmp = new computers(); if (!$dhcp->IsPhysicalAddress($_POST["mac"])) { echo "Wrong value {$_POST["mac"]}\n"; return; } $_POST["uid"] = str_replace("\$", "", $_POST["uid"]); $_POST["ipaddr"] = str_replace("\$", "", $_POST["ipaddr"]); $q = new mysql(); $sql = "SELECT hostname FROM dhcpd_fixed WHERE mac='{$_POST["mac"]}'"; $ligneCK = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if ($ligneCK["hostname"] != null) { $tpl = new templates(); echo $tpl->javascript_parse_text("{this_computer_already_exists}\n{hostname}:{$ligneCK["hostname"]} ({$_POST["mac"]})", 1); return; } if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $_POST["ipaddr"])) { echo "Wrong value {$_POST["ipaddr"]}\n"; return; } $uid = $cmp->ComputerIDFromMAC($_POST["mac"]); if ($uid != null) { $cmp = new computers($uid); $domain = $cmp->DnsZoneName; if ($cmp->ComputerRealName != null) { $_POST["hostname"] = $cmp->ComputerRealName; } } if ($domain != null) { $domain = $dhcp->ddns_domainname; } $sql = "INSERT INTO dhcpd_fixed (mac,ipaddr,hostname,domain) VALUES \n\t('{$_POST["mac"]}','{$_POST["ipaddr"]}','{$_POST["hostname"]}','{$domain}')"; $q = new mysql(); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error; return; } if (!isset($GLOBALS["APPLY_DHCP"])) { $GLOBALS["APPLY_DHCP"] = true; $sock = new sockets(); $sock->getFrameWork("cmd.php?apply-dhcpd=yes"); } }