Renames messages to feedback
parent
ef97dda39b
commit
3e9eb0d822
|
@ -168,7 +168,7 @@ class RateLimiter {
|
||||||
$message = "Cannot whitelist {$ip} - IP is currently blacklisted";
|
$message = "Cannot whitelist {$ip} - IP is currently blacklisted";
|
||||||
if ($userId) {
|
if ($userId) {
|
||||||
$this->log->insertLog($userId, "IP Whitelist: {$message}", 'system');
|
$this->log->insertLog($userId, "IP Whitelist: {$message}", 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', $message);
|
Feedback::flash('ERROR', 'DEFAULT', $message);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class RateLimiter {
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($userId) {
|
if ($userId) {
|
||||||
$this->log->insertLog($userId, "IP Whitelist: Failed to add {$ip}: " . $e->getMessage(), 'system');
|
$this->log->insertLog($userId, "IP Whitelist: Failed to add {$ip}: " . $e->getMessage(), 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', "IP Whitelist: Failed to add {$ip}: " . $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', "IP Whitelist: Failed to add {$ip}: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class RateLimiter {
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($userId) {
|
if ($userId) {
|
||||||
$this->log->insertLog($userId, "IP Whitelist: Failed to remove {$ip}: " . $e->getMessage(), 'system');
|
$this->log->insertLog($userId, "IP Whitelist: Failed to remove {$ip}: " . $e->getMessage(), 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', "IP Whitelist: Failed to remove {$ip}: " . $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', "IP Whitelist: Failed to remove {$ip}: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ class RateLimiter {
|
||||||
$message = "Cannot blacklist {$ip} - IP is currently whitelisted";
|
$message = "Cannot blacklist {$ip} - IP is currently whitelisted";
|
||||||
if ($userId) {
|
if ($userId) {
|
||||||
$this->log->insertLog($userId, "IP Blacklist: {$message}", 'system');
|
$this->log->insertLog($userId, "IP Blacklist: {$message}", 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', $message);
|
Feedback::flash('ERROR', 'DEFAULT', $message);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ class RateLimiter {
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($userId) {
|
if ($userId) {
|
||||||
$this->log->insertLog($userId, "IP Blacklist: Failed to add {$ip}: " . $e->getMessage(), 'system');
|
$this->log->insertLog($userId, "IP Blacklist: Failed to add {$ip}: " . $e->getMessage(), 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', "IP Blacklist: Failed to add {$ip}: " . $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', "IP Blacklist: Failed to add {$ip}: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ class RateLimiter {
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($userId) {
|
if ($userId) {
|
||||||
$this->log->insertLog($userId, "IP Blacklist: Failed to remove {$ip}: " . $e->getMessage(), 'system');
|
$this->log->insertLog($userId, "IP Blacklist: Failed to remove {$ip}: " . $e->getMessage(), 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', "IP Blacklist: Failed to remove {$ip}: " . $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', "IP Blacklist: Failed to remove {$ip}: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ class RateLimiter {
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log->insertLog(0, "Failed to cleanup expired entries: " . $e->getMessage(), 'system');
|
$this->log->insertLog(0, "Failed to cleanup expired entries: " . $e->getMessage(), 'system');
|
||||||
Messages::flash('ERROR', 'DEFAULT', "Failed to cleanup expired entries: " . $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', "Failed to cleanup expired entries: " . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
|
||||||
// unknown database
|
// unknown database
|
||||||
} else {
|
} else {
|
||||||
$error = "Error: unknow database type \"{$config['db']['db_type']}\"";
|
$error = "Error: unknow database type \"{$config['db']['db_type']}\"";
|
||||||
Messages::flash('ERROR', 'DEFAULT', $error);
|
Feedback::flash('ERROR', 'DEFAULT', $error);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
if (isset($messages) && is_array($messages)) {
|
if (isset($messages) && is_array($messages)) {
|
||||||
foreach ($messages as $msg) {
|
foreach ($messages as $msg) {
|
||||||
echo Messages::render($msg['category'], $msg['key'], $msg['custom_message'] ?? null, $msg['dismissible'] ?? false, $msg['small'] ?? false);
|
echo Feedback::render($msg['category'], $msg['key'], $msg['custom_message'] ?? null, $msg['dismissible'] ?? false, $msg['small'] ?? false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Get any flash messages from previous request
|
// Get any flash messages from previous request
|
||||||
$flash_messages = Messages::getFlash();
|
$flash_messages = Feedback::getFlash();
|
||||||
if (!empty($flash_messages)) {
|
if (!empty($flash_messages)) {
|
||||||
$messages = array_merge($messages, array_map(function($flash) {
|
$messages = array_merge($messages, array_map(function($flash) {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -49,7 +49,7 @@ function isCacheExpired($agentId) {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Validate agent ID for POST operations
|
// Validate agent ID for POST operations
|
||||||
if ($agentId === false || $agentId === null) {
|
if ($agentId === false || $agentId === null) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'Invalid agent ID format');
|
Feedback::flash('ERROR', 'DEFAULT', 'Invalid agent ID format');
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Invalid agent ID format']);
|
echo json_encode(['status' => 'error', 'message' => 'Invalid agent ID format']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Read and validate JSON data
|
// Read and validate JSON data
|
||||||
$jsonData = file_get_contents("php://input");
|
$jsonData = file_get_contents("php://input");
|
||||||
if ($jsonData === false) {
|
if ($jsonData === false) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'Failed to read input data');
|
Feedback::flash('ERROR', 'DEFAULT', 'Failed to read input data');
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Failed to read input data']);
|
echo json_encode(['status' => 'error', 'message' => 'Failed to read input data']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
unset($_SESSION[$cacheKey]);
|
unset($_SESSION[$cacheKey]);
|
||||||
unset($_SESSION[$timeKey]);
|
unset($_SESSION[$timeKey]);
|
||||||
|
|
||||||
Messages::flash('SUCCESS', 'DEFAULT', "Cache for agent {$agentId} is cleared.");
|
Feedback::flash('SUCCESS', 'DEFAULT', "Cache for agent {$agentId} is cleared.");
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "Cache for agent {$agentId} is cleared."
|
'message' => "Cache for agent {$agentId} is cleared."
|
||||||
|
@ -86,14 +86,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$_SESSION[$cacheKey] = $data;
|
$_SESSION[$cacheKey] = $data;
|
||||||
$_SESSION[$timeKey] = time();
|
$_SESSION[$timeKey] = time();
|
||||||
|
|
||||||
Messages::flash('SUCCESS', 'DEFAULT', "Cache for agent {$agentId} is stored.");
|
Feedback::flash('SUCCESS', 'DEFAULT', "Cache for agent {$agentId} is stored.");
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => "Cache for agent {$agentId} is stored."
|
'message' => "Cache for agent {$agentId} is stored."
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'Invalid data format');
|
Feedback::flash('ERROR', 'DEFAULT', 'Invalid data format');
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Invalid data format']);
|
echo json_encode(['status' => 'error', 'message' => 'Invalid data format']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
|
||||||
// Validate platform_id is set
|
// Validate platform_id is set
|
||||||
if (!isset($platform_id)) {
|
if (!isset($platform_id)) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'Platform ID is not set');
|
Feedback::flash('ERROR', 'DEFAULT', 'Platform ID is not set');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get host details for this platform
|
// Get host details for this platform
|
||||||
|
|
|
@ -13,7 +13,7 @@ $response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $pl
|
||||||
|
|
||||||
// if DB connection has error, display it and stop here
|
// if DB connection has error, display it and stop here
|
||||||
if ($response['db'] === null) {
|
if ($response['db'] === null) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $response['error']);
|
Feedback::flash('ERROR', 'DEFAULT', $response['error']);
|
||||||
|
|
||||||
// otherwise if DB connection is OK, go on
|
// otherwise if DB connection is OK, go on
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,7 +13,7 @@ $response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $pl
|
||||||
|
|
||||||
// if DB connection has error, display it and stop here
|
// if DB connection has error, display it and stop here
|
||||||
if ($response['db'] === null) {
|
if ($response['db'] === null) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $response['error']);
|
Feedback::flash('ERROR', 'DEFAULT', $response['error']);
|
||||||
|
|
||||||
// otherwise if DB connection is OK, go on
|
// otherwise if DB connection is OK, go on
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,7 +22,7 @@ $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
|
||||||
$isWritable = is_writable($config_file);
|
$isWritable = is_writable($config_file);
|
||||||
$configMessage = '';
|
$configMessage = '';
|
||||||
if (!$isWritable) {
|
if (!$isWritable) {
|
||||||
$configMessage = Messages::render('ERROR', 'DEFAULT', 'Config file is not writable', false);
|
$configMessage = Feedback::render('ERROR', 'DEFAULT', 'Config file is not writable', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
@ -41,7 +41,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
$error = json_last_error_msg();
|
$error = json_last_error_msg();
|
||||||
|
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'Invalid JSON data received: ' . $error, true);
|
Feedback::flash('ERROR', 'DEFAULT', 'Invalid JSON data received: ' . $error, true);
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Invalid JSON data received: ' . $error
|
'message' => 'Invalid JSON data received: ' . $error
|
||||||
|
@ -52,14 +52,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Try to update config file
|
// Try to update config file
|
||||||
$result = $configObject->editConfigFile($postData, $config_file);
|
$result = $configObject->editConfigFile($postData, $config_file);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$messageData = Messages::getMessageData('NOTICE', 'DEFAULT', 'Config file updated successfully', true);
|
$messageData = Feedback::getMessageData('NOTICE', 'DEFAULT', 'Config file updated successfully', true);
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Config file updated successfully',
|
'message' => 'Config file updated successfully',
|
||||||
'messageData' => $messageData
|
'messageData' => $messageData
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$messageData = Messages::getMessageData('ERROR', 'DEFAULT', "Error updating config file: $result", true);
|
$messageData = Feedback::getMessageData('ERROR', 'DEFAULT', "Error updating config file: $result", true);
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => "Error updating config file: $result",
|
'message' => "Error updating config file: $result",
|
||||||
|
@ -72,9 +72,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Handle non-AJAX POST
|
// Handle non-AJAX POST
|
||||||
$result = $configObject->editConfigFile($_POST, $config_file);
|
$result = $configObject->editConfigFile($_POST, $config_file);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
Messages::flash('NOTICE', 'DEFAULT', 'Config file updated successfully', true);
|
Feedback::flash('NOTICE', 'DEFAULT', 'Config file updated successfully', true);
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('ERROR', 'DEFAULT', "Error updating config file: $result", true);
|
Feedback::flash('ERROR', 'DEFAULT', "Error updating config file: $result", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: ' . htmlspecialchars($app_root) . '?page=config');
|
header('Location: ' . htmlspecialchars($app_root) . '?page=config');
|
||||||
|
|
|
@ -21,7 +21,7 @@ $response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $pl
|
||||||
|
|
||||||
// if DB connection has error, display it and stop here
|
// if DB connection has error, display it and stop here
|
||||||
if ($response['db'] === null) {
|
if ($response['db'] === null) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $response['error']);
|
Feedback::flash('ERROR', 'DEFAULT', $response['error']);
|
||||||
|
|
||||||
// otherwise if DB connection is OK, go on
|
// otherwise if DB connection is OK, go on
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,7 +13,7 @@ $hostObject = new Host($dbWeb);
|
||||||
// Connect to Jilo database for log data
|
// Connect to Jilo database for log data
|
||||||
$response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
|
$response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
|
||||||
if ($response['db'] === null) {
|
if ($response['db'] === null) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $response['error']);
|
Feedback::flash('ERROR', 'DEFAULT', $response['error']);
|
||||||
} else {
|
} else {
|
||||||
$db = $response['db'];
|
$db = $response['db'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,14 @@ try {
|
||||||
|
|
||||||
// Check if IP is blacklisted
|
// Check if IP is blacklisted
|
||||||
if ($rateLimiter->isIpBlacklisted($user_IP)) {
|
if ($rateLimiter->isIpBlacklisted($user_IP)) {
|
||||||
throw new Exception(Messages::get('LOGIN', 'IP_BLACKLISTED')['message']);
|
throw new Exception(Feedback::get('LOGIN', 'IP_BLACKLISTED')['message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check rate limiting (but skip if IP is whitelisted)
|
// Check rate limiting (but skip if IP is whitelisted)
|
||||||
if (!$rateLimiter->isIpWhitelisted($user_IP)) {
|
if (!$rateLimiter->isIpWhitelisted($user_IP)) {
|
||||||
$attempts = $rateLimiter->getRecentAttempts($user_IP);
|
$attempts = $rateLimiter->getRecentAttempts($user_IP);
|
||||||
if ($attempts >= $rateLimiter->maxAttempts) {
|
if ($attempts >= $rateLimiter->maxAttempts) {
|
||||||
throw new Exception(Messages::get('LOGIN', 'LOGIN_BLOCKED')['message']);
|
throw new Exception(Feedback::get('LOGIN', 'LOGIN_BLOCKED')['message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,15 +97,15 @@ try {
|
||||||
$logObject->insertLog($user_id, "Login: User \"$username\" logged in. IP: $user_IP", 'user');
|
$logObject->insertLog($user_id, "Login: User \"$username\" logged in. IP: $user_IP", 'user');
|
||||||
|
|
||||||
// Set success message and redirect
|
// Set success message and redirect
|
||||||
Messages::flash('LOGIN', 'LOGIN_SUCCESS', null, true);
|
Feedback::flash('LOGIN', 'LOGIN_SUCCESS', null, true);
|
||||||
header('Location: ' . htmlspecialchars($app_root));
|
header('Location: ' . htmlspecialchars($app_root));
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(Messages::get('LOGIN', 'LOGIN_FAILED')['message']);
|
throw new Exception(Feedback::get('LOGIN', 'LOGIN_FAILED')['message']);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Log the failed attempt
|
// Log the failed attempt
|
||||||
Messages::flash('ERROR', 'DEFAULT', $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', $e->getMessage());
|
||||||
if (isset($username)) {
|
if (isset($username)) {
|
||||||
$user_id = $userObject->getUserId($username)[0]['id'] ?? 0;
|
$user_id = $userObject->getUserId($username)[0]['id'] ?? 0;
|
||||||
$logObject->insertLog($user_id, "Login: Failed login attempt for user \"$username\". IP: $user_IP. Reason: {$e->getMessage()}", 'user');
|
$logObject->insertLog($user_id, "Login: Failed login attempt for user \"$username\". IP: $user_IP. Reason: {$e->getMessage()}", 'user');
|
||||||
|
@ -113,12 +113,12 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'There was an unexpected error. Please try again.');
|
Feedback::flash('ERROR', 'DEFAULT', 'There was an unexpected error. Please try again.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show configured login message if any
|
// Show configured login message if any
|
||||||
if (!empty($config['login_message'])) {
|
if (!empty($config['login_message'])) {
|
||||||
echo Messages::render('NOTICE', 'DEFAULT', $config['login_message'], false, false, false);
|
echo Feedback::render('NOTICE', 'DEFAULT', $config['login_message'], false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get any new messages
|
// Get any new messages
|
||||||
|
|
|
@ -13,7 +13,7 @@ $response = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $pl
|
||||||
|
|
||||||
// if DB connection has error, display it and stop here
|
// if DB connection has error, display it and stop here
|
||||||
if ($response['db'] === null) {
|
if ($response['db'] === null) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $response['error']);
|
Feedback::flash('ERROR', 'DEFAULT', $response['error']);
|
||||||
|
|
||||||
// otherwise if DB connection is OK, go on
|
// otherwise if DB connection is OK, go on
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -46,23 +46,23 @@ if ($config['registration_enabled'] == true) {
|
||||||
|
|
||||||
// redirect to login
|
// redirect to login
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
Messages::flash('NOTICE', 'DEFAULT', "Registration successful. You can log in now.");
|
Feedback::flash('NOTICE', 'DEFAULT', "Registration successful. You can log in now.");
|
||||||
header('Location: ' . htmlspecialchars($app_root));
|
header('Location: ' . htmlspecialchars($app_root));
|
||||||
exit();
|
exit();
|
||||||
// registration fail, redirect to login
|
// registration fail, redirect to login
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('ERROR', 'DEFAULT', "Registration failed. $result");
|
Feedback::flash('ERROR', 'DEFAULT', "Registration failed. $result");
|
||||||
header('Location: ' . htmlspecialchars($app_root));
|
header('Location: ' . htmlspecialchars($app_root));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $validator->getFirstError());
|
Feedback::flash('ERROR', 'DEFAULT', $validator->getFirstError());
|
||||||
header('Location: ' . htmlspecialchars($app_root . '?page=register'));
|
header('Location: ' . htmlspecialchars($app_root . '?page=register'));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', $e->getMessage());
|
Feedback::flash('ERROR', 'DEFAULT', $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get any new messages
|
// Get any new messages
|
||||||
|
@ -74,7 +74,7 @@ if ($config['registration_enabled'] == true) {
|
||||||
|
|
||||||
// registration disabled
|
// registration disabled
|
||||||
} else {
|
} else {
|
||||||
echo Messages::render('NOTICE', 'DEFAULT', 'Registration is disabled', false);
|
echo Feedback::render('NOTICE', 'DEFAULT', 'Registration is disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -49,9 +49,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||||
if (!$rateLimiter->addToWhitelist($_POST['ip_address'], $is_network, $_POST['description'] ?? '', $currentUser, $user_id)) {
|
if (!$rateLimiter->addToWhitelist($_POST['ip_address'], $is_network, $_POST['description'] ?? '', $currentUser, $user_id)) {
|
||||||
throw new Exception('Failed to add IP to whitelist');
|
throw new Exception('Failed to add IP to whitelist');
|
||||||
}
|
}
|
||||||
Messages::flash('SECURITY', 'WHITELIST_ADD_SUCCESS');
|
Feedback::flash('SECURITY', 'WHITELIST_ADD_SUCCESS');
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('SECURITY', 'WHITELIST_ADD_ERROR', $validator->getFirstError());
|
Feedback::flash('SECURITY', 'WHITELIST_ADD_ERROR', $validator->getFirstError());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||||
if (!$rateLimiter->removeFromWhitelist($_POST['ip_address'], $currentUser, $user_id)) {
|
if (!$rateLimiter->removeFromWhitelist($_POST['ip_address'], $currentUser, $user_id)) {
|
||||||
throw new Exception('Failed to remove IP from whitelist');
|
throw new Exception('Failed to remove IP from whitelist');
|
||||||
}
|
}
|
||||||
Messages::flash('SECURITY', 'WHITELIST_REMOVE_SUCCESS');
|
Feedback::flash('SECURITY', 'WHITELIST_REMOVE_SUCCESS');
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('SECURITY', 'WHITELIST_REMOVE_ERROR', $validator->getFirstError());
|
Feedback::flash('SECURITY', 'WHITELIST_REMOVE_ERROR', $validator->getFirstError());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||||
if (!$rateLimiter->addToBlacklist($_POST['ip_address'], $is_network, $_POST['reason'], $currentUser, $user_id, $expiry_hours)) {
|
if (!$rateLimiter->addToBlacklist($_POST['ip_address'], $is_network, $_POST['reason'], $currentUser, $user_id, $expiry_hours)) {
|
||||||
throw new Exception('Failed to add IP to blacklist');
|
throw new Exception('Failed to add IP to blacklist');
|
||||||
}
|
}
|
||||||
Messages::flash('SECURITY', 'BLACKLIST_ADD_SUCCESS');
|
Feedback::flash('SECURITY', 'BLACKLIST_ADD_SUCCESS');
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('SECURITY', 'BLACKLIST_ADD_ERROR', $validator->getFirstError());
|
Feedback::flash('SECURITY', 'BLACKLIST_ADD_ERROR', $validator->getFirstError());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -127,9 +127,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||||
if (!$rateLimiter->removeFromBlacklist($_POST['ip_address'], $currentUser, $user_id)) {
|
if (!$rateLimiter->removeFromBlacklist($_POST['ip_address'], $currentUser, $user_id)) {
|
||||||
throw new Exception('Failed to remove IP from blacklist');
|
throw new Exception('Failed to remove IP from blacklist');
|
||||||
}
|
}
|
||||||
Messages::flash('SECURITY', 'BLACKLIST_REMOVE_SUCCESS');
|
Feedback::flash('SECURITY', 'BLACKLIST_REMOVE_SUCCESS');
|
||||||
} else {
|
} else {
|
||||||
Messages::flash('SECURITY', 'BLACKLIST_REMOVE_ERROR', $validator->getFirstError());
|
Feedback::flash('SECURITY', 'BLACKLIST_REMOVE_ERROR', $validator->getFirstError());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||||
throw new Exception('Invalid action');
|
throw new Exception('Invalid action');
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Messages::flash('SECURITY', 'ERROR', $e->getMessage());
|
Feedback::flash('SECURITY', 'ERROR', $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect back to the appropriate section
|
// Redirect back to the appropriate section
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<?php if (isset($messages) && is_array($messages)): ?>
|
<?php if (isset($messages) && is_array($messages)): ?>
|
||||||
<?php foreach ($messages as $msg): ?>
|
<?php foreach ($messages as $msg): ?>
|
||||||
<?= Messages::render($msg['category'], $msg['key'], $msg['custom_message'] ?? null) ?>
|
<?= Feedback::render($msg['category'], $msg['key'], $msg['custom_message'] ?? null) ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -123,7 +123,7 @@ try {
|
||||||
}
|
}
|
||||||
$dbWeb = $response['db'];
|
$dbWeb = $response['db'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
|
||||||
include '../app/templates/page-header.php';
|
include '../app/templates/page-header.php';
|
||||||
include '../app/includes/messages.php';
|
include '../app/includes/messages.php';
|
||||||
include '../app/includes/messages-show.php';
|
include '../app/includes/messages-show.php';
|
||||||
|
@ -175,7 +175,7 @@ if ($page == 'logout') {
|
||||||
$logObject->insertLog($user_id, "Logout: User \"$currentUser\" logged out. IP: $user_IP", 'user');
|
$logObject->insertLog($user_id, "Logout: User \"$currentUser\" logged out. IP: $user_IP", 'user');
|
||||||
|
|
||||||
// Set success message
|
// Set success message
|
||||||
Messages::flash('LOGIN', 'LOGOUT_SUCCESS');
|
Feedback::flash('LOGIN', 'LOGOUT_SUCCESS');
|
||||||
|
|
||||||
include '../app/templates/page-header.php';
|
include '../app/templates/page-header.php';
|
||||||
include '../app/templates/page-menu.php';
|
include '../app/templates/page-menu.php';
|
||||||
|
@ -207,7 +207,7 @@ if ($page == 'logout') {
|
||||||
$server_endpoint = '/health';
|
$server_endpoint = '/health';
|
||||||
$server_status = $serverObject->getServerStatus($server_host, $server_port, $server_endpoint);
|
$server_status = $serverObject->getServerStatus($server_host, $server_port, $server_endpoint);
|
||||||
if (!$server_status) {
|
if (!$server_status) {
|
||||||
Messages::flash('ERROR', 'DEFAULT', 'The Jilo Server is not running. Some data may be old and incorrect.', false, true);
|
Feedback::flash('ERROR', 'DEFAULT', 'The Jilo Server is not running. Some data may be old and incorrect.', false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue