function SaveAddress() { $ip = new networking(); $server = $_GET["address_server"]; if (trim($server) == null) { echo "Host cannot be null!\n"; return; } $adip = "{$_GET["addr_1"]}.{$_GET["addr_2"]}.{$_GET["addr_3"]}.{$_GET["addr_4"]}"; if (!$ip->checkIP($adip)) { echo "IP {$adip}\nFailed"; return; } $conf = new dnsmasq(); $conf->array_address[$server] = $adip; writelogs("save {$server} {$adip}", __FUNCTION__, __FILE__); $conf->SaveConf(); }
function ipconfig_routes_add(){ $user=new usersMenus(); $tpl=new templates(); $ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}"); if(!$user->AsSystemAdministrator){echo $ERROR_NO_PRIVS;return;} $ip=new networking(); $ip1="{$_GET["ip_1"]}.{$_GET["ip_2"]}.{$_GET["ip_3"]}.0"; $mask="{$_GET["mask_1"]}.{$_GET["mask_2"]}.{$_GET["mask_3"]}.{$_GET["mask_4"]}"; $gw="{$_GET["gw_1"]}.{$_GET["gw_2"]}.{$_GET["gw_3"]}.{$_GET["gw_4"]}"; if(!$ip->checkIP($ip1)){echo "IP $ip1\nFailed";return;} if(!$ip->checkIP($mask)){echo "MASK $mask\nFailed";return;} if(!$ip->checkIP($gw)){echo "Gateway $gw\nFailed";return;} $nic=new system_nic($_GET["nic"]); $nic->ROUTES[$ip1]=array("NETMASK"=>$mask,"GATEWAY"=>$gw); $nic->SaveNic(); }
function ipconfig_routes_add(){ $user=new usersMenus(); $tpl=new templates(); $ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}"); if(!$user->AsSystemAdministrator){echo $ERROR_NO_PRIVS;return;} $ip=new networking(); $ip1=$_POST["route-network"]; $mask=$_POST["route-mask"]; $gw=$_POST["route-gateway"]; if(!$ip->checkIP($ip1)){echo "IP $ip1\nFailed";return;} if(!$ip->checkIP($mask)){echo "MASK $mask\nFailed";return;} if(!$ip->checkIP($gw)){echo "Gateway $gw\nFailed";return;} $nic=new system_nic($_POST["nic"]); writelogs("SaveNic:: {$_POST["nic"]} $ip1/$mask -> $gw",__FUNCTION__,__FILE__,__LINE__); $nic->ROUTES[$ip1]=array("NETMASK"=>$mask,"GATEWAY"=>$gw); $nic->SaveNic($_POST["nic"]); }
function import_dnsmasq_perform() { $ip = new networking(); $conf = new dnsmasq(); $tbl = explode("\n", $_POST["BulkImport"]); writelogs(count($tbl) . " line", __FUNCTION__, __FILE__); while (list($num, $ligne) = each($tbl)) { if (!preg_match("#(.+?)(,|;)(.+)#", $ligne, $re)) { writelogs("{$ligne} no match ", __FUNCTION__, __FILE__); continue; } $server = trim(strtolower($re[1])); $adip = trim($re[3]); if (!$ip->checkIP($adip)) { writelogs("IP {$adip} Failed", __FUNCTION__, __FILE__); echo "IP {$adip} Failed"; continue; } $conf->array_address[$server] = $adip; writelogs("save {$server} {$adip}", __FUNCTION__, __FILE__); } $conf->SaveConf(true); }
function routes_add() { $pattern = "{$_GET["net_1"]}.{$_GET["net_2"]}.{$_GET["net_3"]}.{$_GET["net_4"]}"; $gw = "{$_GET["gw_1"]}.{$_GET["gw_2"]}.{$_GET["gw_3"]}.{$_GET["gw_4"]}"; $cdir = "{$_GET["cdir"]}"; $ip = new networking(); if (!$ip->checkIP($pattern)) { echo "IP {$pattern}\nFailed"; return; } if (!$ip->checkIP($gw)) { echo "Gateway {$gw}\nFailed"; return; } $route_nic = $_GET["route-nic"]; $type = $_GET["route-type"]; $md5 = md5("{$route_nic}{$type}{$cdir}{$gw}{$pattern}"); $sql = "INSERT INTO nic_routes (`type`,`gateway`,`pattern`,`zmd5`,`nic`)\n\tVALUES('{$type}','{$gw}','{$pattern}/{$cdir}','{$md5}','{$route_nic}');"; $q = new mysql(); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error; return; } $sock = new sockets(); $sock->getFrameWork("cmd.php?ip-build-routes=yes"); }