public function setwifi() { $net = $this->input->post('net'); $password = $this->input->post('password'); $address = $this->input->post('address'); /** LOAD HELPERS */ $this->load->helper("os_helper"); $wlans = scan_wlan(); $type = ''; foreach ($wlans as $wl) { if ($wl['address'] == $address) { $type = $wl['type']; } } if (setWifi($net, $password, $type)) { $wlan = wlan(); $wlan_ip = isset($wlan['ip']) ? $wlan['ip'] : ''; $this->load->database(); $this->load->model('configuration'); /** SAVE NEW WIFI CONFIGURATION TO DB */ $this->configuration->save_confi_value('wifi', json_encode(array('ssid' => $net, 'password' => $password, 'ip' => $wlan_ip))); $response_items['wlan_ip'] = $wlan_ip; $response_items['response'] = 'OK'; } else { $response_items['response'] = 'KO'; } echo json_encode($response_items); }
<?php require 'utilities.php'; $wlan_list = scan_wlan(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $address = $_POST['address']; $password = $_POST['password']; $wifi_selected = ''; foreach ($wlan_list as $wl) { if ($wl['address'] == $address) { $wifi_selected = $wl; break; } } if (setWifi($wifi_selected['essid'], $password, $wifi_selected['type'])) { $alert['type'] = 'success'; $alert['messsage'] = 'New newtwork configuration saved'; } else { $alert['type'] = 'danger'; $alert['messsage'] = 'Oops an error occured, check the password and try again'; } } $wlan = wlan(); $wifi = true; if (!isset($wlan['ip'])) { $alert['type'] = 'warning'; $alert['messsage'] = 'No wifi properly configured'; $wifi = false; } $networkConfiguration = networkConfiguration(); $title = 'Wlan Configuration';