mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Move of API folder from /app/front/api to app/api
This commit is contained in:
38
front/php/server/query_json.php
Executable file
38
front/php/server/query_json.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// ---- IMPORTS ----
|
||||
//------------------------------------------------------------------------------
|
||||
// Check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
// Get init.php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
// ---- IMPORTS ----
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Handle incoming requests
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
// Get query string parameter ?file=settings_table.json
|
||||
$file = isset($_GET['file']) ? $_GET['file'] : null;
|
||||
|
||||
// Check if file parameter is provided
|
||||
if ($file) {
|
||||
// Define the folder where files are located
|
||||
$filePath = "/app/api/" . basename($file);
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($filePath)) {
|
||||
// Send the response back to the client
|
||||
header('Content-Type: application/json');
|
||||
echo file_get_contents($filePath);
|
||||
} else {
|
||||
// File not found response
|
||||
http_response_code(404);
|
||||
echo json_encode(["error" => "File not found"]);
|
||||
}
|
||||
} else {
|
||||
// Missing file parameter response
|
||||
http_response_code(400);
|
||||
echo json_encode(["error" => "Missing 'file' parameter"]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -430,7 +430,7 @@ function getString ($setKey, $default) {
|
||||
// -------------------------------------------------------------------------------------------
|
||||
function getSettingValue($setKey) {
|
||||
// Define the JSON endpoint URL
|
||||
$url = dirname(__FILE__).'/../../../front/api/table_settings.json';
|
||||
$url = dirname(__FILE__).'/../../../api/table_settings.json';
|
||||
|
||||
// Fetch the JSON data
|
||||
$json = file_get_contents($url);
|
||||
|
||||
@@ -64,7 +64,7 @@ function generate_guid() {
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Logs a notification in in-app notification system
|
||||
function write_notification($content, $level = "interrupt") {
|
||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||
$NOTIFICATION_API_FILE = '/app/api/user_notifications.json';
|
||||
|
||||
// Generate GUID
|
||||
$guid = generate_guid();
|
||||
@@ -97,7 +97,7 @@ function write_notification($content, $level = "interrupt") {
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Removes a notification based on GUID
|
||||
function remove_notification($guid) {
|
||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||
$NOTIFICATION_API_FILE = '/app/api/user_notifications.json';
|
||||
|
||||
// Read existing notifications
|
||||
$notifications = json_decode(file_get_contents($NOTIFICATION_API_FILE), true);
|
||||
@@ -114,7 +114,7 @@ function remove_notification($guid) {
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Deletes all notifications
|
||||
function notifications_clear() {
|
||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||
$NOTIFICATION_API_FILE = '/app/api/user_notifications.json';
|
||||
|
||||
// Clear notifications by writing an empty array to the file
|
||||
file_put_contents($NOTIFICATION_API_FILE, json_encode(array()));
|
||||
@@ -123,7 +123,7 @@ function notifications_clear() {
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Mark a notification read based on GUID
|
||||
function mark_notification_as_read($guid) {
|
||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||
$NOTIFICATION_API_FILE = '/app/api/user_notifications.json';
|
||||
$max_attempts = 3;
|
||||
$attempts = 0;
|
||||
|
||||
@@ -172,7 +172,7 @@ function notifications_mark_all_read() {
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
function get_unread_notifications() {
|
||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||
$NOTIFICATION_API_FILE = '/app/api/user_notifications.json';
|
||||
|
||||
// Read existing notifications
|
||||
if (file_exists($NOTIFICATION_API_FILE) && is_readable($NOTIFICATION_API_FILE)) {
|
||||
|
||||
Reference in New Issue
Block a user