From 155cf6aeea9ba7ecbc39face6442d3ce1b03ad8e Mon Sep 17 00:00:00 2001 From: Nils Schwabe Date: Wed, 4 Jun 2014 14:27:03 +0200 Subject: Add webinterface with functionallity --- management-interface/index.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'management-interface/index.php') diff --git a/management-interface/index.php b/management-interface/index.php index afee942..c206e66 100644 --- a/management-interface/index.php +++ b/management-interface/index.php @@ -5,6 +5,9 @@ $f3 = require('lib/base.php'); $f3->set('DEBUG', 3); +ini_set('display_errors', 1); +error_reporting(E_ALL); + $f3->set('AUTOLOAD', 'api/models/'); // set defaults @@ -13,11 +16,12 @@ $f3->set('username', (isset($f3->get('SESSION')['username']))?$f3->get('SESSION' $f3->set('message', ''); $f3->config('config/global.cfg'); +require('config/mysql.php'); $f3->set('DB', new DB\SQL( - 'mysql:host=localhost;port=3306;dbname=masterserver', - 'root', - 'password' + 'mysql:host=localhost;port=3306;dbname='.$mysql_database, + $mysql_username, + $mysql_password )); $f3->route('POST /do/@action', @@ -27,11 +31,26 @@ $f3->route('POST /do/@action', if (isset($_POST['user']) && isset($_POST['pass'])) { $master->dologin($f3, $f3->get('POST')['user'], $f3->get('POST')['pass']); } + } else if ($params['action'] === 'savesatellite') { + if(isset($_POST['organization']) && isset($_POST['address']) + && isset($_POST['name']) && isset($_POST['prefix']) && isset($_POST['publickey'])) { + $master->saveSatellite($f3, $_POST['organization'], $_POST['address'], $_POST['name'], $_POST['prefix'], $_POST['publickey']); + } + } else if ($params['action'] === 'newsatellite') { + if(isset($_POST['organization']) && isset($_POST['address']) + && isset($_POST['name']) && isset($_POST['prefix']) && isset($_POST['publickey'])) { + $master->newSatellite($f3, $_POST['organization'], $_POST['address'], $_POST['name'], $_POST['prefix'], $_POST['publickey']); + } + } else { + $f3->reroute('@module(@m=home)'); } - } + }, + 0, + 512 ); + // ^ sending files with a maximum rate of 64 KB/s --> slow responses to prevent attacks -$f3->route('GET @module: /@m', +$f3->route('GET @module: /site/@m', function($f3, $params) { $master = new Master; if ($params['m'] === 'logout') { -- cgit v1.2.3-55-g7522