diff --git a/mince.php b/mince.php index c2bea0b..90138f0 100644 --- a/mince.php +++ b/mince.php @@ -3,6 +3,7 @@ namespace Mince; use Index\Autoloader; use Index\Environment; +use Index\XString; use Index\Data\ConnectionFailedException; use Index\Data\DbTools; @@ -31,16 +32,17 @@ try { die($ex->getMessage()); } -Remote::setUrl($config['remote_url']); -Remote::setSecret($config['remote_secret']); +$remote = new RemoteV2($config['remotev2_url'], $config['remotev2_secret']); -if(empty($_COOKIE['mc_random'])) { - $sVerification = Utils::generatePassKey(32); - setcookie('mc_random', $sVerification, strtotime('1 day'), '/', $_SERVER['HTTP_HOST']); -} else - $sVerification = (string)filter_input(INPUT_COOKIE, 'mc_random'); +if(PHP_SAPI !== 'cli') { + if(empty($_COOKIE['mc_random'])) { + $sVerification = XString::random(32); + setcookie('mc_random', $sVerification, strtotime('1 day'), '/', $_SERVER['HTTP_HOST']); + } else + $sVerification = (string)filter_input(INPUT_COOKIE, 'mc_random'); -$sVerification = hash('sha256', $sVerification); + $sVerification = hash('sha256', $sVerification); -// replace this with id.flashii.net shit -$userInfo = ChatAuth::attempt($db, $config['chat_endpoint'], $config['chat_secret'], (string)filter_input(INPUT_COOKIE, 'msz_auth')); + // replace this with id.flashii.net shit + $userInfo = ChatAuth::attempt($db, $config['chat_endpoint'], $config['chat_secret'], (string)filter_input(INPUT_COOKIE, 'msz_auth')); +} diff --git a/public/index.php b/public/index.php index 3ad7c11..8f65ae6 100644 --- a/public/index.php +++ b/public/index.php @@ -8,12 +8,8 @@ use Mince\HTML; require_once __DIR__ . '/../mince.php'; -$timing = new Timings; - $router = new HttpFx; -$timing->lap('httpfx', 'HttpFx Created'); - $loginUrl = $config['login_url']; $router->setDefaultErrorHandler(function($response, $request, $code, $text) use ($loginUrl, $userInfo) { @@ -26,19 +22,15 @@ $router->setDefaultErrorHandler(function($response, $request, $code, $text) use $response->setContent($body); }); -$router->use('/', function($response) use ($timing) { - $response->setPoweredBy('Mince+Index'); - $response->setServerTiming($timing); +$router->use('/', function($response) { + $response->setPoweredBy('Mince'); }); $router->get('/index.php', function($response) { $response->redirect('/', true); }); -$router->get('/map.php', function($response) { - $response->redirect('/maps/survival', true); -}); -$router->get('/', function($response, $request) use ($db, $loginUrl, $userInfo, $sVerification) { +$router->get('/', function($response, $request) use ($db, $remote, $loginUrl, $userInfo, $sVerification) { $name = (string)$request->getParam('name'); $error = (string)$request->getParam('error'); @@ -79,12 +71,12 @@ $router->get('/', function($response, $request) use ($db, $loginUrl, $userInfo, $body .= '
This will give you access to the server.
'; $body .= ' '; $body .= ''; } @@ -113,8 +105,8 @@ $router->get('/', function($response, $request) use ($db, $loginUrl, $userInfo, $body .= 'This will revoke your access to the server.
'; $body .= sprintf('You are currently whitelisted as %s on %s.
', $userInfo->mc_username, date('Y-m-d H:i:s T', $userInfo->mc_whitelisted)); $body .= ' '; $body .= ''; } @@ -146,21 +138,6 @@ $router->get('/', function($response, $request) use ($db, $loginUrl, $userInfo, return $body; }); -$router->get('/maps', function($response) { - $response->redirect('/maps/survival'); -}); -$router->get('/maps/survival', function($response) use ($loginUrl, $userInfo) { - $body = HTML::getHeader($userInfo, $loginUrl); - - $body .= '