From d1fc7642f0b954b69058b0cc041374f30608e6a5 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 9 Aug 2018 18:12:42 +0200 Subject: [PATCH] login/emulate: request page as different user Admin feature to download user-customised texts (in particular the welcoming letter to be sent to everyone). --- auth.inc.php | 3 +++ login/emulate/index.php | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 login/emulate/index.php diff --git a/auth.inc.php b/auth.inc.php index 631bf8b..a2db9f3 100644 --- a/auth.inc.php +++ b/auth.inc.php @@ -5,6 +5,9 @@ class User { function __construct($dir) { + if (!file_exists($dir)) { + throw new Exception("Gebruiker niet gevonden in $dir"); + } $this->dir = $dir; $this->login = basename($dir); } diff --git a/login/emulate/index.php b/login/emulate/index.php new file mode 100644 index 0000000..b5c3e69 --- /dev/null +++ b/login/emulate/index.php @@ -0,0 +1,21 @@ +%s

', $e->getMessage()); + return; +} + +$Place['login/name'] = $user->name ?: 'bewoner'; +$Place['user'] = $user->login; +if ( $password = trim(@file_get_contents("{$user->dir}/.passwd")) ) { + if (substr($password, 0, 1) == '$') { + $password = NULL; // hashed + } + $Place['pass'] = htmlspecialchars($password) ?: 'zelf ingesteld'; +} +include ($request ?: 'index').'.html'; -- 2.30.0