Exemple #1
0
function BuildDHCP()
{
    $ldap = new clladp();
    if ($ldap->ldapFailed) {
        echo "Starting......: DHCP SERVER ldap connection failed,aborting\n";
        return;
    }
    if (!$ldap->ExistsDN("dc=organizations,{$ldap->suffix}")) {
        echo "Starting......: DHCP SERVER dc=organizations,{$ldap->suffix} no such branch, aborting\n";
        return;
    }
    echo "Starting......: DHCP SERVER ldap connection success\n";
    $dhcpd = new dhcpd();
    $conf = $dhcpd->BuildConf();
    $confpath = dhcp3Config();
    $unix = new unix();
    @mkdir(dirname($confpath), null, true);
    @file_put_contents($confpath, $conf);
    echo "Starting......: DHCP SERVER saving \"{$confpath}\" (" . strlen($conf) . " bytes) done\n";
    if (is_dir("/var/lib/dhcp3")) {
        shell_exec("/bin/chown -R dhcpd:dhcpd /var/lib/dhcp3");
        shell_exec("/bin/chmod 755 /var/lib/dhcp3");
    }
    $complain = $unix->find_program("aa-complain");
    if (is_file($complain)) {
        $dhcpd3 = $unix->find_program("dhcpd3");
        if (is_file($dhcpd3)) {
            shell_exec("{$complain} {$dhcpd3} >/dev/null 2>&1");
        }
    }
}
function BuildDHCP(){
	$dhcpd=new dhcpd();
	$conf=$dhcpd->BuildConf();
	$confpath=dhcp3Config();
	$unix=new unix();
	@mkdir(dirname($confpath),null,true);
	@file_put_contents($confpath,$conf);
	echo "Starting......: DHCP SERVER saving \"$confpath\" (". strlen($conf)." bytes) done\n";
	
	if(is_dir("/var/lib/dhcp3")){
		shell_exec("/bin/chown -R dhcpd:dhcpd /var/lib/dhcp3");
		shell_exec("/bin/chmod 755 /var/lib/dhcp3");
	
	}
	$complain=$unix->find_program("aa-complain");
	
	if(is_file($complain)){
		$dhcpd3=$unix->find_program("dhcpd3");
		if(is_file($dhcpd3)){shell_exec("$complain $dhcpd3 >/dev/null 2>&1");}
	}
	
}
Exemple #3
0
function save()
{
    $sock = new sockets();
    $sock->SET_INFO("EnableDHCPServer", $_GET["EnableDHCPServer"]);
    $dhcp = new dhcpd();
    $pxe_enable = $_GET["pxe_enable"];
    if ($dhcp->listen_nic == null) {
        $eth = GetMyNicDefault();
        $dhcp->listen_nic = $eth;
    } else {
        $eth = $dhcp->listen_nic;
    }
    if ($pxe_enable == 1) {
        if ($dhcp->pxe_server == null) {
            $dhcp->pxe_server = GetMyIpDefault($eth);
            $dhcp->pxe_file = "/pxe/pxelinux.0";
        }
    }
    $dhcp->pxe_enable = $pxe_enable;
    $sock->SET_INFO("EnableDHCPFixPxeThinClient", $pxe_enable);
    if ($dhcp->gateway == null) {
        $dhcp->gateway = GetMyDefaultGateway($eth);
    }
    if ($dhcp->range1 == null) {
        $dhcp->range1 = GetMyRange($eth) . ".10";
    }
    if ($dhcp->range2 == null) {
        $dhcp->range1 = GetMyRange($eth) . ".250";
    }
    $dnss = unserialize(base64_decode($sock->getFrameWork("cmd.php?ip-get-default-dns=yes")));
    if ($dhcp->DNS_1 == null) {
        $dhcp->DNS_1 = $dnss[0];
    }
    if ($dhcp->DNS_2 == null) {
        $dhcp->DNS_2 = $dnss[1];
    }
    $dhcp->Save();
}
Exemple #4
0
function popup_delete()
{
    $dhcp = new dhcpd(1);
    $dhcp->DelRoute($_GET["delip"]);
}
function BuildDHCP()
{
    $dhcpd = new dhcpd();
    $dhcpd->BuildConf();
    $dhcpd->Save();
}
Exemple #6
0
function gateway_save()
{
    $sock = new sockets();
    $tpl = new templates();
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement");
    if ($DisableNetworksManagement == null) {
        $DisableNetworksManagement = 0;
    }
    if ($DisableNetworksManagement == 1) {
        echo $ERROR_NO_PRIVS;
        return;
    }
    $sock = new sockets();
    $sock->SET_INFO("EnableArticaAsGateway", $_GET["EnableArticaAsGateway"]);
    if ($_GET["EnableArticaAsGateway"] == 1) {
        $sock->getFrameWork("cmd.php?sysctl-setvalue=1&key=" . base64_encode("net.ipv4.ip_forward"));
    }
    $dhcp = new dhcpd();
    $dhcp->Save();
}
function BuildDHCP($nopid = false)
{
    $LOGBIN = "DHCP Server";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $unix = new unix();
    if (!$nopid) {
        if (!$GLOBALS["FORCE"]) {
            if ($unix->file_time_min($timefile) < 2) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$timefile} -> is less than 2mn\n";
                }
                return;
            }
        }
    }
    build_progress("{starting_service}", 65);
    $dhcpd = new dhcpd();
    $conf = $dhcpd->BuildConf();
    $confpath = dhcp3Config();
    $unix = new unix();
    @mkdir(dirname($confpath), null, true);
    @file_put_contents($confpath, $conf);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} saving \"{$confpath}\" (" . strlen($conf) . " bytes) done\n";
    if (!$unix->UnixUserExists("dhcpd")) {
        $unix->CreateUnixUser("dhcpd", "dhcpd");
    }
    if (!is_dir("/var/lib/dhcp3")) {
        @mkdir("/var/lib/dhcp3", 0755, true);
    }
    $unix->chown_func("dhcpd", "dhcpd", "/var/lib/dhcp3/*");
    $unix->chmod_func(0755, "/var/lib/dhcp3");
    $complain = $unix->find_program("aa-complain");
    if (is_file($complain)) {
        $dhcpd3 = $unix->DHCPD_BIN_PATH();
        if (is_file($dhcpd3)) {
            shell_exec("{$complain} {$dhcpd3} >/dev/null 2>&1");
        }
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    if ($GLOBALS["PROGRESS"]) {
        build_progress("{starting_service}", 70);
        $sock = new sockets();
        $sock->getFrameWork("dnsmasq.php?restart=yes");
        $sock->getFrameWork("services.php?restart-monit=yes");
        $sock->getFrameWork("cmd.php?restart-artica-status=yes");
    }
}
function import_vpn_remotes_sites($datas)
{
    $datas = unserialize(base64_decode($datas));
    if (!is_array($datas["VPN"])) {
        return null;
    }
    $router = $_SERVER['REMOTE_ADDR'];
    $dhcp = new dhcpd();
    while (list($index, $line) = each($datas["VPN"])) {
        if ($line == null) {
            continue;
        }
        $tbl = explode(";", $line);
        if ($tbl[0] == null) {
            continue;
        }
        if ($tbl[1] == null) {
            continue;
        }
        $dhcp->AddRoute($tbl[0], $tbl[1], $router);
    }
}
Exemple #9
0
function gateway_save(){
	
	$sock=new sockets();
	$tpl=new templates();
	$ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
	$DisableNetworksManagement=$sock->GET_INFO("DisableNetworksManagement");
	if($DisableNetworksManagement==null){$DisableNetworksManagement=0;}		
	if($DisableNetworksManagement==1){echo $ERROR_NO_PRIVS;return;}		
	
	$artica=new artica_general();
	$artica->EnableArticaAsGateway=$_GET["EnableArticaAsGateway"];
	$artica->Save();
	$dhcp=new dhcpd();
	$dhcp->Save();
	
}
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");
    }
}
Exemple #11
0
function dhcp_save()
{
    $sock = new sockets();
    $tpl = new templates();
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement");
    if ($DisableNetworksManagement == null) {
        $DisableNetworksManagement = 0;
    }
    if ($DisableNetworksManagement == 1) {
        echo $ERROR_NO_PRIVS;
        return;
    }
    $dhcp = new dhcpd(0, 1);
    $sock = new sockets();
    $sock->SET_INFO('EnableDHCPServer', $_GET["EnableDHCPServer"]);
    $sock->SET_INFO('EnableDHCPUseHostnameOnFixed', $_GET["EnableDHCPUseHostnameOnFixed"]);
    $sock->SET_INFO("IncludeDHCPLdapDatabase", $_GET["IncludeDHCPLdapDatabase"]);
    $dhcp->deny_unkown_clients = $_GET["deny_unkown_clients"];
    $dhcp->ddns_domainname = $_GET["ddns_domainname"];
    $dhcp->max_lease_time = $_GET["max_lease_time"];
    $dhcp->get_lease_hostnames = $_GET["get_lease_hostnames"];
    $dhcp->netmask = $_GET["netmask"];
    $dhcp->range1 = $_GET["range1"];
    $dhcp->range2 = $_GET["range2"];
    $dhcp->subnet = $_GET["subnet"];
    $dhcp->broadcast = $_GET["broadcast"];
    $dhcp->WINS = $_GET["WINS"];
    $dhcp->ping_check = $_GET["DHCPPing_check"];
    $dhcp->authoritative = $_GET["DHCPauthoritative"];
    $dhcp->local_pac_server = $_GET["local-pac-server"];
    $dhcp->browser_portal_page = $_GET["browser-portal-page"];
    $tpl = new templates();
    $dhcp->gateway = $_GET["gateway"];
    $dhcp->DNS_1 = $_GET["DNS_1"];
    $dhcp->DNS_2 = $_GET["DNS_2"];
    $dhcp->ntp_server = $_GET["ntp_server"];
    $dhcp->EnableArticaAsDNSFirst = $_GET["EnableArticaAsDNSFirst"];
    $dhcp->do_no_verify_range = $_GET["do_no_verify_range"];
    $dhcp->Save();
}
Exemple #12
0
function gateway_save()
{
    $artica = new artica_general();
    $artica->EnableArticaAsGateway = $_GET["EnableArticaAsGateway"];
    $artica->Save();
    $dhcp = new dhcpd();
    $dhcp->Save();
}