<?php
$wificonf = "/etc/wpa_supplicant/wpa_supplicant.conf";

$confprefix = "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nap_scan=1\nupdate_config=1\n\n";

$confout = $confprefix."network={\n    ssid=\"".str_replace("+"," ",$_GET['SSID'])."\"\n    psk=\"".$_GET['passphrase']."\"\n}\n";

shell_exec('sudo chmod -R 777 /etc/wpa_supplicant/wpa_supplicant.conf');

file_put_contents($wificonf, $confout);

shell_exec('sudo chmod -R 600 /etc/wpa_supplicant/wpa_supplicant.conf');


$isNetworked = false;
$hasInternet = false;
$ipAddress = "0.0.0.0";
$ipoctets = explode(".",$ipAddress);
$isConnecting=true;
