public function index() { $updater = new Updater(); if (!$updater->updateAvailable()) { $this->_redirect('/admin/index'); } $network = NetAidManager::ap_name(); $params = array('network' => $network); $view = new View('update', $params); return $view->display(); }
public function index() { $cur_stage = NetAidManager::get_stage(); if ($cur_stage == STAGE_DEFAULT) { $this->_redirect('/setup/ap'); } if ($cur_stage == STAGE_OFFLINE) { $this->_redirect('/setup/wan'); } $torLog = $this->_getTorLog(); $vpnLog = $this->_getVpnLog(); $params = array('torLog' => $torLog, 'vpnLog' => $vpnLog); $view = new View('logs', $params); return $view->display(); }
public function save() { $request = $this->getRequest(); if ($request->isPost()) { $broadcast_ssid = $request->postvar('broadcast_ssid'); $mode = $broadcast_ssid ? 'on' : 'off'; $success = NetAidManager::toggle_broadcast($mode); if ($success) { $this->_addMessage('info', _('Successfully saved network settings.'), 'network'); } if ($request->isAjax()) { echo $success ? "SUCCESS" : "FAILURE"; exit; } } }
public function do_login() { $request = $this->getRequest(); if ($request->isPost()) { $username = $request->postvar('username'); $password = $request->postvar('password'); if (empty($username) || empty($password)) { $this->_addMessage('error', _('All fields are required'), 'login'); $this->_redirect('/user/login'); } if ($username == 'admin' && NetAidManager::check_adminpass($password)) { $_SESSION['token'] = md5(uniqid(rand(), true)); $_SESSION['logged_in'] = 1; $this->_redirect('/admin/index'); } else { $this->_addMessage('error', _('Username/password is incorrect.'), 'login'); $this->_redirect('/user/login'); } } }
public function wan() { $request = $this->getRequest(); if ($request->isPost()) { $ssid = $request->postvar('ssid'); $key = $request->postvar('key'); $wan_success = NetAidManager::setup_wan($ssid, $key); if ($request->isAjax()) { echo $wan_success ? "SUCCESS" : "FAILURE"; exit; } } }
public function wan() { $cur_stage = NetAidManager::get_stage(); if ($cur_stage == STAGE_DEFAULT) { $this->_redirect('/setup/ap'); } if ($cur_stage == STAGE_ONLINE) { $this->_redirect('/admin/index'); } if (NetAidManager::get_inetstat()) { NetAidManager::go_online(); NetAidManager::set_stage(STAGE_ONLINE); $this->_addMessage('info', 'Setup complete.', 'setup'); $this->_redirect('/admin/index'); } $request = $this->getRequest(); if ($request->isPost()) { $ssid = $request->postvar('ssid'); $key = $request->postvar('key'); $wan_success = NetAidManager::setup_wan($ssid, $key); if ($wan_success) { NetAidManager::set_stage(STAGE_ONLINE); $this->_addMessage('info', 'Setup complete.', 'setup'); } if ($request->isAjax()) { echo $wan_success ? "SUCCESS" : "FAILURE"; exit; } } $wifi_list = NetAidManager::scan_wifi(); $params = array('wifi_list' => $wifi_list); $view = new View('setup_wan', $params); return $view->display(); }
public function performUpdate() { NetAidManager::do_update($this->_localImagePath); return true; }
protected function password_validate($adminpass_check, $adminpass, $adminpass_confirm) { $valid = true; if (!($adminpass_check && $adminpass && $adminpass_confirm)) { $valid = false; $this->_addMessage('error', _('All fields are required.'), 'pwd'); if (empty($adminpass_check)) { $this->_addFormError('adminpass_check', 'pwd'); } if (empty($adminpass)) { $this->_addFormError('adminpass', 'pwd'); } if (empty($adminpass_confirm)) { $this->_addFormError('adminpass_confirm', 'pwd'); } } if (!NetAidManager::check_adminpass($adminpass_check)) { $valid = false; $this->_addMessage('error', _('Current admin password is incorrect.'), 'pwd'); $this->_addFormError('adminpass_check', 'pwd'); } if (!($adminpass == $adminpass_confirm)) { $valid = false; $this->_addMessage('error', _('Passwords do not match.'), 'pwd'); $this->_addFormError('adminpass', 'pwd'); $this->_addFormError('adminpass_confirm', 'pwd'); } $passlen = strlen($adminpass); if ($passlen < 8) { $valid = false; $this->_addMessage('error', _('Password must be at least 8 characters.'), 'pwd'); $this->_addFormError('adminpass', 'pwd'); $this->_addFormError('adminpass_confirm', 'pwd'); } return $valid; }
<?php require_once '/nak/webapp/bootstrap.php'; if (!session_id()) { session_start(); } $cur_stage = NetAidManager::get_stage(); $request = new Request($_GET['query']); $dispatcher = new Dispatcher(); $controller = $request->getController(); $action = $request->getAction(); $updater = new Updater(); if ($cur_stage >= STAGE_ONLINE && $_SESSION['logged_in'] == 1 && $updater->updateAvailable()) { if ($controller != 'update') { $request->setController('update'); $request->setAction('index'); } } else { if ($cur_stage != STAGE_ONLINE && $_SERVER['SERVER_NAME'] != '192.168.101.1') { header('Location: http://192.168.101.1/' . $controller . '/' . $action); die; } } $page_html = ''; try { $page_html = $dispatcher->run($request); } catch (NotFoundException $e) { if ($cur_stage != STAGE_ONLINE) { header('Location: http://192.168.101.1/index/index'); die; }