mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
chore: 🧹 Code Cleanup
This commit is contained in:
@@ -790,7 +790,6 @@ function initializeiCheck () {
|
||||
// Hide / Show Events
|
||||
if (event.currentTarget.id == 'chkHideConnectionEvents') {
|
||||
getDeviceEvents();
|
||||
setParameter (parEventsHide, event.currentTarget.checked);
|
||||
} else {
|
||||
// Activate save & restore
|
||||
// activateSaveRestoreData();
|
||||
@@ -1014,25 +1013,6 @@ function initializeDatatables () {
|
||||
"info": "<?= lang('Events_Table_info');?>",
|
||||
}
|
||||
});
|
||||
|
||||
// Save Parameters rows & order when changed
|
||||
$('#tableSessions').on( 'length.dt', function ( e, settings, len ) {
|
||||
setParameter (parSessionsRows, len);
|
||||
|
||||
// Sync Rows in both datatables
|
||||
// if ( $('#tableEvents').DataTable().page.len() != len) {
|
||||
// $('#tableEvents').DataTable().page.len( len ).draw();
|
||||
// }
|
||||
} );
|
||||
|
||||
$('#tableEvents').on( 'length.dt', function ( e, settings, len ) {
|
||||
setParameter (parEventsRows, len);
|
||||
|
||||
// Sync Rows in both datatables
|
||||
// if ( $('#tableSessions').DataTable().page.len() != len) {
|
||||
// $('#tableSessions').DataTable().page.len( len ).draw();
|
||||
// }
|
||||
} );
|
||||
};
|
||||
|
||||
|
||||
@@ -1149,10 +1129,6 @@ function initializeCalendar () {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function periodChanged () {
|
||||
// Save Parameter Period
|
||||
period = $('#period').val();
|
||||
setParameter (parPeriod, period);
|
||||
|
||||
// Requery Device data
|
||||
getDeviceData(true);
|
||||
getSessionsPresenceEvents();
|
||||
@@ -1831,12 +1807,6 @@ function initTable(tableId, mac){
|
||||
|
||||
$("#"+tableId).attr("data-mac", mac)
|
||||
|
||||
// Save Parameters rows & order when changed
|
||||
$('#'+tableId).on( 'length.dt', function ( e, settings, len ) {
|
||||
setParameter (parSessionsRows, len);
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
@@ -183,12 +183,12 @@
|
||||
|
||||
<!-- page script ----------------------------------------------------------- -->
|
||||
<script>
|
||||
var parPeriod = 'Front_Events_Period';
|
||||
var parTableRows = 'Front_Events_Rows';
|
||||
var parPeriod = 'nax_parPeriod';
|
||||
var parTableRows = 'nax_parTableRows';
|
||||
|
||||
var eventsType = 'all';
|
||||
var period = '';
|
||||
var tableRows = 10;
|
||||
var period = '1 day';
|
||||
var tableRows = 25;
|
||||
|
||||
// Read parameters & Initialize components
|
||||
main();
|
||||
@@ -196,30 +196,18 @@
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function main() {
|
||||
// get parameter value
|
||||
$.get('php/server/parameters.php?action=get&defaultValue=1 day¶meter='+ parPeriod, function(data) {
|
||||
var result = JSON.parse(data);
|
||||
if (result) {
|
||||
period = result;
|
||||
// Get parameter value from cookies instead of server
|
||||
period = getCookie(parPeriod) === "" ? "1 day" : getCookie(parPeriod);
|
||||
$('#period').val(period);
|
||||
}
|
||||
|
||||
// get parameter value
|
||||
$.get('php/server/parameters.php?action=get&defaultValue=50¶meter='+ parTableRows, function(data) {
|
||||
var result = JSON.parse(data);
|
||||
result = parseInt(result, 10)
|
||||
if (Number.isInteger (result) ) {
|
||||
tableRows = result;
|
||||
}
|
||||
tableRows = getCookie(parTableRows) === "" ? 50 : parseInt(getCookie(parTableRows), 10);
|
||||
|
||||
// Initialize components
|
||||
initializeDatatable();
|
||||
|
||||
// query data
|
||||
// Query data
|
||||
getEventsTotals();
|
||||
getEvents(eventsType);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +269,7 @@ function initializeDatatable () {
|
||||
|
||||
// Save Parameter rows when changed
|
||||
$('#tableEvents').on( 'length.dt', function ( e, settings, len ) {
|
||||
setParameter (parTableRows, len);
|
||||
setCookie(parTableRows, len)
|
||||
} );
|
||||
};
|
||||
|
||||
@@ -290,7 +278,8 @@ function initializeDatatable () {
|
||||
function periodChanged () {
|
||||
// Save Parameter Period
|
||||
period = $('#period').val();
|
||||
setParameter (parPeriod, period);
|
||||
|
||||
setCookie(parTableRows, period)
|
||||
|
||||
// Requery totals and events
|
||||
getEventsTotals();
|
||||
|
||||
@@ -423,29 +423,6 @@ function numberArrayFromString(data)
|
||||
return data.replace(/\[|\]/g, '').split(',').map(Number);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function setParameter (parameter, value) {
|
||||
// Retry
|
||||
$.get('php/server/parameters.php?action=set¶meter=' + parameter +
|
||||
'&value='+ value,
|
||||
function(data) {
|
||||
if (data != "OK") {
|
||||
// Retry
|
||||
sleep (200);
|
||||
$.get('php/server/parameters.php?action=set¶meter=' + parameter +
|
||||
'&value='+ value,
|
||||
function(data) {
|
||||
if (data != "OK") {
|
||||
// alert (data);
|
||||
} else {
|
||||
// alert ("OK. Second attempt");
|
||||
};
|
||||
} );
|
||||
};
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function saveData(functionName, id, value) {
|
||||
$.ajax({
|
||||
|
||||
@@ -502,33 +502,6 @@ setTimeout(() => {
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// handling events on the backend initiated by the front end END
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// UNUSED?
|
||||
function getParam(targetId, key, skipCache = false) {
|
||||
skipCacheQuery = "";
|
||||
|
||||
if (skipCache) {
|
||||
skipCacheQuery = "&skipcache";
|
||||
}
|
||||
|
||||
// get parameter value
|
||||
$.get(
|
||||
"php/server/parameters.php?action=get&defaultValue=0¶meter=" +
|
||||
key +
|
||||
skipCacheQuery,
|
||||
function (data) {
|
||||
var result = data;
|
||||
|
||||
result = result.replaceAll('"', "");
|
||||
|
||||
document.getElementById(targetId).innerHTML = result.replaceAll('"', "");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Show/hide the metadata settings
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
require '../server/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
// Function to render the log area component
|
||||
function renderLogArea($params) {
|
||||
$fileName = isset($params['fileName']) ? $params['fileName'] : '';
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
function renderInfobox($params) {
|
||||
$onclickEvent = isset($params['onclickEvent']) ? $params['onclickEvent'] : '';
|
||||
$color = isset($params['color']) ? $params['color'] : '';
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
// Cache the contents to a cache file
|
||||
$cached = fopen($cachefile, 'w');
|
||||
fwrite($cached, ob_get_contents());
|
||||
fclose($cached);
|
||||
ob_end_flush(); // Send the output to the browser
|
||||
?>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
$url = $_SERVER["SCRIPT_NAME"];
|
||||
$break = Explode('/', $url);
|
||||
$file = $break[count($break) - 1];
|
||||
$cachefile = 'cached-'.substr_replace($file ,"",-4).'.html';
|
||||
$cachetime = 18000;
|
||||
|
||||
// Serve from the cache if it is younger than $cachetime
|
||||
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
|
||||
echo "<!-- Cached copy, generated ".date('H:i', filemtime($cachefile))." -->\n";
|
||||
readfile($cachefile);
|
||||
exit;
|
||||
}
|
||||
ob_start(); // Start the output buffer
|
||||
?>
|
||||
@@ -13,6 +13,10 @@
|
||||
$DBFILE = dirname(__FILE__).'/../../../db/app.db';
|
||||
$DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../front/log/db_is_locked.log';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
$db_locked = false;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// NetAlertX
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// parameters.php - Front module. Server side. Manage Parameters
|
||||
//------------------------------------------------------------------------------
|
||||
# Puche 2022+ jokob jokob@duck.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -13,6 +12,9 @@
|
||||
// External files
|
||||
require dirname(__FILE__).'/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
// External files
|
||||
require dirname(__FILE__).'/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
// External files
|
||||
require dirname(__FILE__).'/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
@@ -72,7 +75,7 @@ function getEventsTotals() {
|
||||
$resultJSON = getCache("getEventsTotals".$days);
|
||||
} else
|
||||
{
|
||||
// one query to get all numbers, whcih is quicker than multiple queries
|
||||
// one query to get all numbers, which is quicker than multiple queries
|
||||
$sql = "select
|
||||
(SELECT Count(*) FROM Events WHERE eve_DateTime >= date('now', '".$periodDateSQL."')) as all_events,
|
||||
(SELECT Count(*) FROM Sessions as sessions WHERE ( ses_DateTimeConnection >= date('now', '".$periodDateSQL."') OR ses_DateTimeDisconnection >= date('now', '".$periodDateSQL."') OR ses_StillConnected = 1 )) as sessions,
|
||||
@@ -334,24 +337,40 @@ function getEventsCalendar() {
|
||||
$endDate = '"'. $_REQUEST ['end'] .'"';
|
||||
|
||||
// SQL
|
||||
$SQL = 'SELECT ses_MAC, ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo, ses_StillConnected,
|
||||
$SQL = 'SELECT SES1.ses_MAC, SES1.ses_EventTypeConnection, SES1.ses_DateTimeConnection,
|
||||
SES1.ses_EventTypeDisconnection, SES1.ses_DateTimeDisconnection, SES1.ses_IP,
|
||||
SES1.ses_AdditionalInfo, SES1.ses_StillConnected,
|
||||
|
||||
CASE
|
||||
WHEN ses_EventTypeConnection = "<missing event>" THEN
|
||||
IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour"))
|
||||
ELSE ses_DateTimeConnection
|
||||
WHEN SES1.ses_EventTypeConnection = "<missing event>" THEN
|
||||
IFNULL (
|
||||
(SELECT MAX(SES2.ses_DateTimeDisconnection)
|
||||
FROM Sessions AS SES2
|
||||
WHERE SES2.ses_MAC = SES1.ses_MAC
|
||||
AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection
|
||||
AND SES2.ses_DateTimeDisconnection BETWEEN Date('. $startDate .') AND Date('. $endDate .')
|
||||
),
|
||||
DATETIME(SES1.ses_DateTimeDisconnection, "-1 hour")
|
||||
)
|
||||
ELSE SES1.ses_DateTimeConnection
|
||||
END AS ses_DateTimeConnectionCorrected,
|
||||
|
||||
CASE
|
||||
WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||
ELSE ses_DateTimeDisconnection
|
||||
WHEN SES1.ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
(SELECT MIN(SES2.ses_DateTimeConnection)
|
||||
FROM Sessions AS SES2
|
||||
WHERE SES2.ses_MAC = SES1.ses_MAC
|
||||
AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection
|
||||
AND SES2.ses_DateTimeConnection BETWEEN Date('. $startDate .') AND Date('. $endDate .')
|
||||
)
|
||||
ELSE SES1.ses_DateTimeDisconnection
|
||||
END AS ses_DateTimeDisconnectionCorrected
|
||||
|
||||
FROM Sessions AS SES1
|
||||
WHERE ( ses_DateTimeConnectionCorrected <= Date('. $endDate .')
|
||||
AND (ses_DateTimeDisconnectionCorrected >= Date('. $startDate .') OR ses_StillConnected = 1 )) ';
|
||||
WHERE (SES1.ses_DateTimeConnection BETWEEN Date('. $startDate .') AND Date('. $endDate .'))
|
||||
OR (SES1.ses_DateTimeDisconnection BETWEEN Date('. $startDate .') AND Date('. $endDate .'))
|
||||
OR SES1.ses_StillConnected = 1';
|
||||
|
||||
$result = $db->query($SQL);
|
||||
|
||||
// arrays of rows
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
// Get init.php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
// Perform a test with the PING command
|
||||
$output = shell_exec("curl ipinfo.io");
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
require 'util.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
$PIA_HOST_IP = $_REQUEST['scan'];
|
||||
$PIA_SCAN_MODE = $_REQUEST['mode'];
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
// Get init.php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
// Get IP
|
||||
$ip = $_GET['ip'];
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// NetAlertX
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// parameters.php - Front module. Server side. Manage Parameters
|
||||
//------------------------------------------------------------------------------
|
||||
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// External files
|
||||
require dirname(__FILE__).'/init.php';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
//------------------------------------------------------------------------------
|
||||
// Set maximum execution time to 15 seconds
|
||||
ini_set ('max_execution_time','15');
|
||||
|
||||
$skipCache = FALSE;
|
||||
$expireMinutes = 5;
|
||||
$defaultValue = '';
|
||||
|
||||
|
||||
if (isset ($_REQUEST['skipcache'])) {
|
||||
$skipCache = TRUE;
|
||||
}
|
||||
|
||||
if (isset ($_REQUEST['defaultValue'])) {
|
||||
$defaultValue = $_REQUEST['defaultValue'];
|
||||
}
|
||||
|
||||
if (isset ($_REQUEST['expireMinutes'])) {
|
||||
$expireMinutes = $_REQUEST['expireMinutes'];
|
||||
}
|
||||
|
||||
// Action functions
|
||||
if (isset ($_REQUEST['action']) && !empty ($_REQUEST['action'])) {
|
||||
$action = $_REQUEST['action'];
|
||||
switch ($action) {
|
||||
case 'get': getParameter($skipCache, $defaultValue, $expireMinutes); break;
|
||||
case 'set': setParameter($expireMinutes); break;
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Get Parameter Value
|
||||
//------------------------------------------------------------------------------
|
||||
function getParameter($skipCache, $defaultValue, $expireMinutes) {
|
||||
|
||||
$parameter = $_REQUEST['parameter'];
|
||||
$value = "";
|
||||
|
||||
// get the value from the cache if available
|
||||
$cachedValue = getCache($parameter);
|
||||
if($cachedValue != "")
|
||||
{
|
||||
$value = $cachedValue;
|
||||
}
|
||||
|
||||
// query the database if no cache entry found or requesting live data (skipping cache)
|
||||
if($skipCache || $value == "" )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT par_Value FROM Parameters
|
||||
WHERE par_ID="'. quotes($parameter) .'"';
|
||||
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
|
||||
if($row != NULL && count($row) == 1)
|
||||
{
|
||||
$value = $row[0];
|
||||
} else{
|
||||
$value = $defaultValue;
|
||||
|
||||
// Nothing found in the DB, Insert new value
|
||||
insertNew($parameter, $value);
|
||||
}
|
||||
|
||||
// update cache
|
||||
setCache($parameter, $value, $expireMinutes);
|
||||
}
|
||||
// return value
|
||||
echo (json_encode ($value));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Set Parameter Value
|
||||
//------------------------------------------------------------------------------
|
||||
function setParameter($expireMinutes) {
|
||||
|
||||
$parameter = $_REQUEST['parameter'];
|
||||
$value = $_REQUEST['value'];
|
||||
|
||||
global $db;
|
||||
|
||||
// Update value
|
||||
$sql = 'UPDATE Parameters SET par_Value="'. quotes ($value) .'"
|
||||
WHERE par_ID="'. quotes($parameter) .'"';
|
||||
$result = $db->query($sql);
|
||||
|
||||
if (! $result == TRUE) {
|
||||
echo "Error updating parameter\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
return;
|
||||
}
|
||||
|
||||
$changes = $db->changes();
|
||||
if ($changes == 0) {
|
||||
// Insert new value
|
||||
insertNew($parameter, $value);
|
||||
}
|
||||
|
||||
// update cache
|
||||
setCache($parameter, $value, $expireMinutes);
|
||||
|
||||
echo 'OK';
|
||||
}
|
||||
|
||||
function insertNew($parameter, $value)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Insert new value
|
||||
$sql = 'INSERT INTO Parameters (par_ID, par_Value)
|
||||
VALUES ("'. quotes($parameter) .'",
|
||||
"'. quotes($value) .'")';
|
||||
$result = $db->query($sql);
|
||||
|
||||
if (! $result == TRUE) {
|
||||
echo "Error creating parameter\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
exec('../../../back/speedtest-cli --secure --simple', $output);
|
||||
|
||||
echo '<h4>'. lang('Speedtest_Results') .'</h4>';
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
// Get init.php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
// Get IP
|
||||
$ip = $_GET['ip'];
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
require dirname(__FILE__).'/../templates/timezone.php';
|
||||
require dirname(__FILE__).'/../templates/skinUI.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
$FUNCTION = [];
|
||||
$SETTINGS = [];
|
||||
$ACTION = "";
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<!-- utils needing a DB connection -->
|
||||
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__).'/init.php';
|
||||
|
||||
// Action functions
|
||||
if (isset ($_REQUEST['key']))
|
||||
{
|
||||
echo lang($_REQUEST['key']);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
require dirname(__FILE__).'/../templates/timezone.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Check if the action parameter is set in the GET request
|
||||
if (isset($_GET['action'])) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$isAuthenticated = false;
|
||||
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
#---------------------------------------------------------------------------------#
|
||||
-->
|
||||
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
?>
|
||||
|
||||
<!-- Main Footer -->
|
||||
<footer class="main-footer">
|
||||
<!-- Default to the left -->
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
global $db;
|
||||
|
||||
$Pia_Graph_Device_Time = array();
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
<?php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
require dirname(__FILE__).'/security.php';
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ switch($result){
|
||||
|
||||
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = $defaultLang;}
|
||||
|
||||
require dirname(__FILE__).'/../skinUI.php';
|
||||
|
||||
$result = $db->query("SELECT * FROM Plugins_Language_Strings");
|
||||
$strings = array();
|
||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php require 'php/templates/notification.php'; ?>
|
||||
<?php
|
||||
|
||||
require 'php/templates/notification.php';
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ if (strpos($url,'index.php') !== false) {
|
||||
$isLogonPage = TRUE;
|
||||
}
|
||||
|
||||
// start session if not started yet
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
if(array_search('action', $_REQUEST) != FALSE)
|
||||
{
|
||||
@@ -24,7 +27,7 @@ if(array_search('action', $_REQUEST) != FALSE)
|
||||
// ##################################################
|
||||
// ## Login Processing start
|
||||
// ##################################################
|
||||
$config_file = "../config/app.conf";
|
||||
$config_file = $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf";
|
||||
$config_file_lines = file($config_file);
|
||||
$CookieSaveLoginName = "NetAlertX_SaveLogin";
|
||||
|
||||
|
||||
5
front/php/templates/skinUI.php
Executable file → Normal file
5
front/php/templates/skinUI.php
Executable file → Normal file
@@ -12,10 +12,7 @@ if( isset($_COOKIE['UI_dark_mode']))
|
||||
$ENABLED_DARKMODE = False;
|
||||
}
|
||||
|
||||
foreach (glob("/app/db/setting_skin*") as $filename) {
|
||||
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
||||
}
|
||||
if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';}
|
||||
$pia_skin_selected = 'skin-blue';
|
||||
|
||||
// ###################################
|
||||
// ## GUI settings processing end
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#---------------------------------------------------------------------------------#
|
||||
|
||||
$filename = "/app/.VERSION";
|
||||
|
||||
if(file_exists($filename)) {
|
||||
$fileContents = file_get_contents($filename);
|
||||
if(trim($fileContents) === 'Dev') {
|
||||
@@ -23,4 +24,5 @@ if(file_exists($filename)) {
|
||||
else {
|
||||
echo date('H:i:s') . " - N/A";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -239,7 +239,7 @@ function initializeCalendar () {
|
||||
center : 'title',
|
||||
right : 'timelineYear,timelineMonth,timelineWeek,timelineDay'
|
||||
},
|
||||
defaultView : 'timelineMonth',
|
||||
defaultView : 'timelineWeek',
|
||||
height : 'auto',
|
||||
firstDay : 1,
|
||||
allDaySlot : false,
|
||||
@@ -389,6 +389,33 @@ function getDevicesPresence (status) {
|
||||
default: tableTitle = '<?= lang('Presence_Shortcut_Devices');?>'; color = 'gray'; break;
|
||||
}
|
||||
|
||||
period = "7 days"
|
||||
|
||||
// Calculate startDate and endDate based on the period
|
||||
let startDate = "";
|
||||
let endDate = new Date().toISOString().slice(0, 10); // Today's date in ISO format (YYYY-MM-DD)
|
||||
|
||||
// Calculate startDate based on period
|
||||
switch (period) {
|
||||
case "7 days":
|
||||
startDate = new Date();
|
||||
startDate.setDate(startDate.getDate() - 7); // Subtract 7 days
|
||||
startDate = startDate.toISOString().slice(0, 10); // Convert to ISO format
|
||||
break;
|
||||
case "1 month":
|
||||
startDate = new Date();
|
||||
startDate.setMonth(startDate.getMonth() - 1); // Subtract 1 month
|
||||
startDate = startDate.toISOString().slice(0, 10); // Convert to ISO format
|
||||
break;
|
||||
case "1 year":
|
||||
startDate = new Date();
|
||||
startDate.setFullYear(startDate.getFullYear() - 1); // Subtract 1 year
|
||||
startDate = startDate.toISOString().slice(0, 10); // Convert to ISO format
|
||||
break;
|
||||
default:
|
||||
console.error("Invalid period selected");
|
||||
}
|
||||
|
||||
// Set title and color
|
||||
$('#tableDevicesTitle')[0].className = 'box-title text-'+ color;
|
||||
$('#tableDevicesBox')[0].className = 'box box-'+ color;
|
||||
@@ -399,7 +426,7 @@ function getDevicesPresence (status) {
|
||||
$('#calendar').fullCalendar ('refetchResources');
|
||||
|
||||
$('#calendar').fullCalendar('removeEventSources');
|
||||
$('#calendar').fullCalendar('addEventSource', { url: 'php/server/events.php?action=getEventsCalendar' });
|
||||
$('#calendar').fullCalendar('addEventSource', { url: `php/server/events.php?period=${period}&start=${startDate}&end=${endDate}&action=getEventsCalendar` });
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user