USERS_DIR added to config
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require 'config.php';
|
||||||
session_start();
|
session_start();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$usersFile = 'users.txt';
|
$usersFile = USERS_FILE;
|
||||||
|
|
||||||
// Determine if we are in setup mode:
|
// Determine if we are in setup mode:
|
||||||
// - Query parameter setup=1 is passed
|
// - Query parameter setup=1 is passed
|
||||||
|
|||||||
3
auth.php
3
auth.php
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require 'config.php';
|
||||||
session_start();
|
session_start();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$usersFile = 'users.txt';
|
$usersFile = USERS_FILE;
|
||||||
|
|
||||||
// Function to authenticate user
|
// Function to authenticate user
|
||||||
function authenticate($username, $password) {
|
function authenticate($username, $password) {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require 'config.php';
|
||||||
session_start();
|
session_start();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
// Check if users.txt is empty or doesn't exist
|
// Check if users.txt is empty or doesn't exist
|
||||||
$usersFile = __DIR__ . '/users.txt';
|
$usersFile = USERS_FILE;
|
||||||
if (!file_exists($usersFile) || trim(file_get_contents($usersFile)) === '') {
|
if (!file_exists($usersFile) || trim(file_get_contents($usersFile)) === '') {
|
||||||
// Return JSON indicating setup mode
|
// Return JSON indicating setup mode
|
||||||
echo json_encode(["setup" => true]);
|
echo json_encode(["setup" => true]);
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ define('BASE_URL', 'http://yourwebsite/uploads/');
|
|||||||
define('TIMEZONE', 'America/New_York');
|
define('TIMEZONE', 'America/New_York');
|
||||||
define('DATE_TIME_FORMAT', 'm/d/y h:iA');
|
define('DATE_TIME_FORMAT', 'm/d/y h:iA');
|
||||||
define('TOTAL_UPLOAD_SIZE', '5G');
|
define('TOTAL_UPLOAD_SIZE', '5G');
|
||||||
|
define('USERS_FILE', '/var/www/uploads/users.txt');
|
||||||
date_default_timezone_set(TIMEZONE);
|
date_default_timezone_set(TIMEZONE);
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require 'config.php';
|
||||||
session_start();
|
session_start();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true ||
|
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true ||
|
||||||
@@ -6,7 +7,7 @@ if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true ||
|
|||||||
echo json_encode(["error" => "Unauthorized"]);
|
echo json_encode(["error" => "Unauthorized"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$usersFile = 'users.txt';
|
$usersFile = USERS_FILE;
|
||||||
$users = [];
|
$users = [];
|
||||||
if (file_exists($usersFile)) {
|
if (file_exists($usersFile)) {
|
||||||
$lines = file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
$lines = file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require 'config.php';
|
||||||
session_start();
|
session_start();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$usersFile = 'users.txt';
|
$usersFile = USERS_FILE;
|
||||||
|
|
||||||
// Only allow admins to remove users
|
// Only allow admins to remove users
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user