function write_ifcfg($filename, $interface, $uuid) { //Write to file with a standard template $ipaddr = get_ipaddr(); if ($ipaddr != '') { $ipsettings = 'BOOTPROTO=static IPADDR=' . $ipaddr . ' NETMASK=' . get_subnet() . ' GATEWAY=' . get_ipgateway(); } else { $ipsettings = 'BOOTPROTO=dhcp'; } file_put_contents($filename, "TYPE=Ethernet\n{$ipsettings}\nDEFROUTE=yes\nPEERDNS=yes\nPEERROUTES=yes\nIPV4_FAILURE_FATAL=no\nIPV6INIT=yes\nIPV6_AUTOCONF=yes\nIPV6_DEFROUTE=yes\nIPV6_PEERDNS=yes\nIPV6_PEERROUTES=yes\nIPV6_FAILURE_FATAL=no\nNAME={$interface}\nUUID={$uuid}\nDEVICE={$interface}\nONBOOT=yes\n"); }
<div class="row"> <div class="large-6 medium-6 columns"> <label>Network IPv4 Address (Leave blank for DHCP)</label> <input type="text" name="staticIP" placeholder="Leave blank for dynamic IP Address" value="<?php echo get_ipaddr(); ?> "/> <label>Network IPv4 Subnet </label> <input type="text" name="staticSN" placeholder="Leave blank for DHCP assigned value" value="<?php echo get_subnet(); ?> "/> <label>Network IPv4 Gateway</label> <input type="text" name="staticGW" placeholder="Leave blank for DHCP assigned value" value="<?php echo get_ipgateway(); ?> "/> <label>Network IPv4 DNS</label> <input type="text" name="staticDNS" placeholder="Leave blank for DHCP assigned value" value="<?php echo get_ipdns(); ?> "/> </div> <div class="large-6 medium-6 columns"> <?php if (file_exists('reboot.now')) { echo '<label>Rebooting... Please wait a minute.</label>'; } ?>