From 79b40c03caa5f0760df031012b060decac5a0e42 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 3 Mar 2025 12:53:52 -0500 Subject: [PATCH] added back USERS_DIR --- README.md | 2 +- addUser.php | 2 +- auth.php | 2 +- checkAuth.php | 2 +- config.php | 1 + getUsers.php | 2 +- removeUser.php | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index de8f590..ecf3b3e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ some refactoring - config added USERS_FILE + config added USERS_DIR & USERS_FILE # Multi File Upload & Edit diff --git a/addUser.php b/addUser.php index 1b2ee90..6dce62b 100644 --- a/addUser.php +++ b/addUser.php @@ -3,7 +3,7 @@ require 'config.php'; session_start(); header('Content-Type: application/json'); -$usersFile = UPLOAD_DIR . USERS_FILE; +$usersFile = USERS_DIR . USERS_FILE; // Determine if we are in setup mode: // - Query parameter setup=1 is passed diff --git a/auth.php b/auth.php index 6b819b7..613c3ff 100644 --- a/auth.php +++ b/auth.php @@ -3,7 +3,7 @@ require 'config.php'; session_start(); header('Content-Type: application/json'); -$usersFile = UPLOAD_DIR . USERS_FILE; +$usersFile = USERS_DIR . USERS_FILE; // Function to authenticate user function authenticate($username, $password) { diff --git a/checkAuth.php b/checkAuth.php index 586903a..eae563c 100644 --- a/checkAuth.php +++ b/checkAuth.php @@ -4,7 +4,7 @@ session_start(); header('Content-Type: application/json'); // Check if users.txt is empty or doesn't exist -$usersFile = UPLOAD_DIR . USERS_FILE; +$usersFile = USERS_DIR . USERS_FILE; if (!file_exists($usersFile) || trim(file_get_contents($usersFile)) === '') { // Return JSON indicating setup mode echo json_encode(["setup" => true]); diff --git a/config.php b/config.php index e5a1ea1..c7b5994 100644 --- a/config.php +++ b/config.php @@ -5,6 +5,7 @@ define('BASE_URL', 'http://yourwebsite/uploads/'); define('TIMEZONE', 'America/New_York'); define('DATE_TIME_FORMAT', 'm/d/y h:iA'); define('TOTAL_UPLOAD_SIZE', '5G'); +define('USERS_DIR', '/var/www/uploads/'); define('USERS_FILE', 'users.txt'); date_default_timezone_set(TIMEZONE); ?> diff --git a/getUsers.php b/getUsers.php index 7d78a81..6e1189a 100644 --- a/getUsers.php +++ b/getUsers.php @@ -7,7 +7,7 @@ if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true || echo json_encode(["error" => "Unauthorized"]); exit; } -$usersFile = UPLOAD_DIR . USERS_FILE; +$usersFile = USERS_DIR . USERS_FILE; $users = []; if (file_exists($usersFile)) { $lines = file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); diff --git a/removeUser.php b/removeUser.php index 4d13f12..08f8881 100644 --- a/removeUser.php +++ b/removeUser.php @@ -3,7 +3,7 @@ require 'config.php'; session_start(); header('Content-Type: application/json'); -$usersFile = UPLOAD_DIR . USERS_FILE; +$usersFile = USERS_DIR . USERS_FILE; // Only allow admins to remove users if (