From ff0e72da839e761693c5fea8c4346bd6a6e8d04b Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sat, 27 Jun 2020 14:51:31 +0200 Subject: [PATCH] Allow verify, encrypt and proofs with prefilled UID --- index.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index 3f2d9fe..3fe74f9 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,9 @@ $router->map('GET', '/', function() {}, 'index'); $router->map('GET', '/verify', function() {}, 'verify'); $router->map('GET', '/encrypt', function() {}, 'encrypt'); $router->map('GET', '/proofs', function() {}, 'proofs'); +$router->map('GET', '/verify/[:uid]', function() {}, 'verifyUid'); +$router->map('GET', '/encrypt/[:uid]', function() {}, 'encryptUid'); +$router->map('GET', '/proofs/[:uid]', function() {}, 'proofsUid'); $router->map('GET', '/faq', function() {}, 'faq'); $router->map('GET', '/[:uid]', function() {}, 'profile'); @@ -25,19 +28,27 @@ if(is_array($match) && is_callable($match['target'])) { break; case 'verify': - readfile('pages/verify.html'); + case 'verifyUid': + $content = file_get_contents('pages/verify.html'); + $content = str_replace('%UID%', (array_key_exists('uid', $match['params']) ? $match['params']['uid'] : ""), $content); + header('Content-Type: text/html; charset=utf-8'); + echo($content); break; case 'encrypt': - readfile('pages/encrypt.html'); + case 'encryptUid': + $content = file_get_contents('pages/encrypt.html'); + $content = str_replace('%UID%', (array_key_exists('uid', $match['params']) ? $match['params']['uid'] : ""), $content); + header('Content-Type: text/html; charset=utf-8'); + echo($content); break; case 'proofs': - readfile('pages/proofs.html'); - break; - - case 'faq': - readfile('pages/faq.html'); + case 'proofsUid': + $content = file_get_contents('pages/proofs.html'); + $content = str_replace('%UID%', (array_key_exists('uid', $match['params']) ? $match['params']['uid'] : ""), $content); + header('Content-Type: text/html; charset=utf-8'); + echo($content); break; case 'profile': @@ -46,6 +57,10 @@ if(is_array($match) && is_callable($match['target'])) { header('Content-Type: text/html; charset=utf-8'); echo($content); break; + + case 'faq': + readfile('pages/faq.html'); + break; } } else { // No route was matched