Beispiel #1
0
 public function do_upgrade()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $updater = new Updater();
         if ($updater->updateAvailable()) {
             $image_data = $updater->downloadLatest();
             if (!$updater->validateSignature($image_data)) {
                 die('INVALID SIGNATURE');
             }
             if ($updater->performUpdate($image_data)) {
                 die('Upgrading, please wait for the device to reboot.');
             } else {
                 die('FAILED');
             }
         }
     }
 }
 public function do_upgrade()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $updater = new Updater();
         if ($updater->updateAvailable()) {
             if (!$updater->validateSignature()) {
                 $updater->deleteImage();
                 die('INVALID SIGNATURE');
             }
             //die('SUCCESS'); # ENABLE TO DEBUG!
             if ($updater->performUpdate()) {
                 die('SUCCESS');
             } else {
                 die('FAILURE');
             }
         }
     }
 }
Beispiel #3
0
<?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;
    }