$configurationsettings['dns2'] = "";
        }
        if (!empty($mtus)) {
            $configurationsettings['lanmtu'] = $mtus;
        } else {
            $configurationsettings['lanmtu'] = "";
        }
        if (empty($mac)) {
            $configurationsettings['lanmac'] = '';
        } else {
            $configurationsettings['lanmac'] = $mac;
        }
        logmessage("Writing changes to configuration file: /var/www/routersettings.ini");
        write_php_ini($configurationsettings, "/var/www/routersettings.ini");
        logmessage("Writing changes to interfaces file: /etc/network/interfaces");
        update_interfaces_file($configurationsettings['operationmode']);
    }
}
?>
<!-- ********************************************************************************************************************** -->
  <?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['buttonpppoe'])) {
    $ipaddress = $username = $password = $repeatpassword = $servicename = $idledisconnect = $primarydns = $secondarydns = $mtus = $mac = "";
    $ipaddresserr = $usernameerr = $passworderr = $repeatpassworderr = $servicenameerr = $idledisconnecterr = $primarydnserr = $secondarydnserr = $mtuerr = $macerr = "";
    if (!empty($_POST["ipaddress"])) {
        $ipaddress = test_input($_POST["ipaddress"]);
        if (!preg_match("/^[0-9.]*\$/", $ipaddress)) {
            $ipaddresserr = "dhcpuid field contains incorrect data, only a-zA-Z0-9_- allowed!<br />";
        }
    }
    if (!empty($_POST["username"])) {
     shell_exec("sudo update-rc.d dnsmasq defaults 2>&1 | sudo tee --append /var/log/raspberrywap.log");
     logmessage("Starting dnsmasq");
     shell_exec("sudo service dnsmasq start 2>&1 | sudo tee --append /var/log/raspberrywap.log");
     logmessage("Enabling NAT");
     shell_exec("sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 2>&1 | sudo tee --append /var/log/raspberrywap.log");
     logmessage("Writing iptables to /var/tmp/iptables");
     shell_exec("sudo iptables-save > /var/tmp/iptables");
     logmessage("Enabling iptables restore on boot in rc.local");
     shell_exec("sudo sed -i 's/# iptables-restore < \\/var\\/tmp\\/iptables/iptables-restore < \\/var\\/tmp\\/iptables/g' /etc/rc.local");
     echo "<script>\$('#functionstat').text('Router');</script>";
     echo "<script>\$('#selectopsmode').val('Access Point');</script>";
 }
 if (strcmp($opsmode, 'Access Point') == 0) {
     logmessage("Reconfiguring operation mode to Access Point");
     logmessage("Rewriting /etc/network/interfaces file with settings for Access Point mode");
     update_interfaces_file("Access Point");
     logmessage("Updating /var/www/routersettings.ini for Access Point operation mode");
     $configurationsettings['operationmode'] = "Access Point";
     write_php_ini($configurationsettings, "/var/www/routersettings.ini");
     logmessage("Disabling wlan0 ip address restore on boot in rc.local.");
     shell_exec("sudo sed -i 's/ip addr add 192.168.1.1\\/24 dev wlan0/# ip addr add 192.168.1.1\\/24 dev wlan0/g' /etc/rc.local");
     logmessage("Disabling IP forwarding");
     shell_exec("sudo sysctl -w net.ipv4.ip_forward=0  2>&1 | sudo tee --append /var/log/raspberrywap.log");
     logmessage("Disabling ip forwarding restore on boot in rc.local");
     shell_exec("sudo sed -i 's/sysctl -w net.ipv4.ip_forward=1/# sysctl -w net.ipv4.ip_forward=1/g' /etc/rc.local");
     if (strcmp($configurationsettings['captiveportal'], "disabled") == 0) {
         logmessage("Disabling dnsmasq to start at boot");
         shell_exec("sudo update-rc.d -f dnsmasq remove 2>&1 | sudo tee --append /var/log/raspberrywap.log");
         logmessage("Stopping dnsmasq service");
         shell_exec("sudo service dnsmasq stop  2>&1 | sudo tee --append /var/log/raspberrywap.log");
     } else {