Example #1
0
function update_commit($ip, $mac, $hostname)
{
    $ipClass = new IP();
    if (!$ipClass->isValid($ip)) {
        return;
    }
    $macZ = explode(":", $mac);
    while (list($num, $ligne) = each($macZ)) {
        if (strlen($ligne) == 1) {
            $macZ[$num] = "0{$ligne}";
        }
    }
    $mac = @implode(":", $macZ);
    if (preg_match("#^(.+?)\\.#", $hostname, $re)) {
        $hostname = $re[1];
    }
    localsyslog("Commit: IP:{$ip},{$mac},{$hostname}");
    CreateComputerLogs($ip, $mac, $hostname);
}
Example #2
0
function update_commit($ip, $mac, $hostname)
{
    if (!preg_match("#([0-9]+)\\.([0-9]+).([0-9]+)\\.([0-9]+)#", $ip, $re)) {
        localsyslog("Commit: IP:`{$ip}` invalid...");
        return;
    }
    $macZ = explode(":", $mac);
    while (list($num, $ligne) = each($macZ)) {
        if (strlen($ligne) == 1) {
            $macZ[$num] = "0{$ligne}";
        }
    }
    $mac = @implode(":", $macZ);
    if (preg_match("#^(.+?)\\.#", $hostname, $re)) {
        $hostname = $re[1];
    }
    localsyslog("Commit: IP:{$ip},{$mac},{$hostname}");
    $md5 = md5(time() . "ip,{$mac},{$hostname}");
    @mkdir("/var/log/artica-postfix/DHCP-LEASES");
    $array["IP"] = $ip;
    $array["MAC"] = $mac;
    $array["hostname"] = $hostname;
    @file_put_contents("/var/log/artica-postfix/DHCP-LEASES/{$md5}", serialize($array));
    $unix = new unix();
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$nohup} {$php5} " . __FILE__ . " --parse-leases >/dev/null 2>&1 &");
}
Example #3
0
function update_commit($ip, $mac, $hostname)
{
    $ipClass = new IP();
    if (!$ipClass->isValid($ip)) {
        return;
    }
    $macZ = explode(":", $mac);
    while (list($num, $ligne) = each($macZ)) {
        if (strlen($ligne) == 1) {
            $macZ[$num] = "0{$ligne}";
        }
    }
    $mac = @implode(":", $macZ);
    if (preg_match("#^(.+?)\\.#", $hostname, $re)) {
        $hostname = $re[1];
    }
    localsyslog("Commit: IP:{$ip},{$mac},{$hostname}");
    $influx = new influx();
    $array["tags"]["ACTION"] = "COMMIT";
    $array["tags"]["HOSTNAME"] = "{$hostname}";
    $array["tags"]["IPADDR"] = "{$ip}";
    $array["tags"]["MAC"] = "{$mac}";
    $array["fields"]["RQS"] = 1;
    $influx->insert("dhcpd", $array);
}