From bdafa8dfbd54627ff33481cce7869069bf43fd9d Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 2 Feb 2021 10:03:09 +0000 Subject: [PATCH] Wrap auth with getConfig(), thx @mp035 --- index.php | 1 + raspap.php | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index 88715c4f..b9544faa 100755 --- a/index.php +++ b/index.php @@ -47,6 +47,7 @@ require_once 'includes/about.php'; require_once 'includes/openvpn.php'; require_once 'includes/torproxy.php'; +$config = getConfig(); $output = $return = 0; $page = $_SERVER['REQUEST_URI']; diff --git a/raspap.php b/raspap.php index 9487720c..e45e3eb4 100755 --- a/raspap.php +++ b/raspap.php @@ -1,14 +1,19 @@ 'admin', - 'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i' -); +function getConfig() +{ + $config = array( + 'admin_user' => 'admin', + 'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i' + ); -if (file_exists(RASPI_CONFIG.'/raspap.auth')) { - if ($auth_details = fopen(RASPI_CONFIG.'/raspap.auth', 'r')) { - $config['admin_user'] = trim(fgets($auth_details)); - $config['admin_pass'] = trim(fgets($auth_details)); - fclose($auth_details); + if (file_exists(RASPI_CONFIG . '/raspap.auth')) { + if ($auth_details = fopen(RASPI_CONFIG . '/raspap.auth', 'r')) { + $config['admin_user'] = trim(fgets($auth_details)); + $config['admin_pass'] = trim(fgets($auth_details)); + fclose($auth_details); + } } + return $config; } +