$macPtn(,$macPtn)*)(id:[^,]+)*(?:,(?:tag|set):(?$namePtn))?(?:,(?$ipPtn))?(?:,(?$domainPtn(,$domainPtn)*))?(?:,(?$timePtn|infinite))?([ \t]+#services:(?\w[,\w]*))?$commentPtn$/", $line, $host, PREG_UNMATCHED_AS_NULL )) { $hosts[ip2long($host["ipaddr"])] = [ "hwaddrs" => $host["hwaddrs"] ? explode(',', $host["hwaddrs"]) : [], "tag" => $host["tag"] ?? "local", "hostnames" => $host["hostnames"] ? explode(',', $host["hostnames"]) : [], "lease_time" => $host["lease_time"], "services" => $host["services"]? explode(',', $host["services"]) : [], "comment" => $host["comment"], ]; } } } if(isset($conf["dhcp-leasefile"]) && file_exists($conf["dhcp-leasefile"])) { foreach(file($conf["dhcp-leasefile"]) as $line) { if (preg_match( "/^(?\d+) (?$macPtn) (?$ipPtn) (?:\*|(?\$domainPtn)) (?[^ ]+)(?: (?.*))?$/", $line, $lease, PREG_UNMATCHED_AS_NULL )) { $hosts[ip2long($lease["ipaddr"])] = [ "hwaddrs" => [$lease["hwaddr"]], "tag" => $host["tag"] ?? "local", "hostnames" => [$lease["hostname"]], "lease_time" => null, "services" => [], "comment" => "DHCP dynamique", ]; } } }