function hostapd_addbridge($action)
{
    $hostapdconfig = parse_ini_file("/etc/hostapd/hostapd.conf");
    switch ($action) {
        case "enable":
            if (!walk($hostapdconfig, 'bridge')) {
                $hostapdconfig['bridge'] = "br0";
            }
            write_hostapd_conf($hostapdconfig, "/etc/hostapd/hostapd.conf");
            break;
        case "disable":
            if (walk($hostapdconfig, 'bridge')) {
                unset($hostapdconfig['bridge']);
            }
            write_hostapd_conf($hostapdconfig, "/etc/hostapd/hostapd.conf");
            break;
    }
}
         break;
     case "WEP":
         if (!walk($hostapdconfig, 'wep_default_key')) {
             $hostapdconfig["wep_default_key"] = "0";
             $hostapdconfig["wep_key0"] = $configurationsettings['wifiwepkey'];
         }
         break;
     case "WPA":
         if (!walk($hostapdconfig, 'wpa')) {
             $hostapdconfig["wpa"] = "3";
             $hostapdconfig["wpa_passphrase"] = $configurationsettings['wifiwpapassword'];
         }
         break;
 }
 //var_dump($hostapdconfig);
 write_hostapd_conf($hostapdconfig, "/etc/hostapd/hostapd.conf");
 switch ($configurationsettings['wifi']) {
     case "enabled":
         logmessage("Enabling Wireless Radio ...");
         logmessage("Scheduling hostapd to start at boot.");
         shell_exec("sudo update-rc.d hostapd defaults 2>&1 | sudo tee --append /var/log/raspberrywap.log");
         logmessage("Starting hostapd.");
         shell_exec("sudo service hostapd restart 2>&1 | sudo tee --append /var/log/raspberrywap.log");
         echo "<script>ReturnReadyOperation();</script>";
         break;
     case "disabled":
         logmessage("Disabling Wireless Radio ...");
         logmessage("Unscheduling hostapd to start at boot.");
         shell_exec("sudo update-rc.d -f hostapd remove 2>&1 | sudo tee --append /var/log/raspberrywap.log");
         logmessage("Stopping hostapd.");
         shell_exec("sudo service hostapd stop 2>&1 | sudo tee --append /var/log/raspberrywap.log");