<?php require_once '../autoloader.php'; $storage = new sqlite_storage(); $storage->start(); if (isset($_POST['device_id']) && isset($_POST['key'])) { switch ($_POST['action']) { case 'Add user': $storage->add_device($_POST['device_id'], $_POST['key']); break; case 'Remove': $storage->remove_device($_POST['device_id'], $_POST['key']); break; default: throw new unknown_action_exception('Unknown action "' . $_POST['action'] . '"'); break; } $storage->stop(); header('Location: ' . $_SERVER['REQUEST_URI'], true, 303); die; } $devices = $storage->get_devices(); $storage->stop(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8> <title>Users</title> </head> <body>