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
|
// Hide / Show Events
|
||||||
if (event.currentTarget.id == 'chkHideConnectionEvents') {
|
if (event.currentTarget.id == 'chkHideConnectionEvents') {
|
||||||
getDeviceEvents();
|
getDeviceEvents();
|
||||||
setParameter (parEventsHide, event.currentTarget.checked);
|
|
||||||
} else {
|
} else {
|
||||||
// Activate save & restore
|
// Activate save & restore
|
||||||
// activateSaveRestoreData();
|
// activateSaveRestoreData();
|
||||||
@@ -1014,25 +1013,6 @@ function initializeDatatables () {
|
|||||||
"info": "<?= lang('Events_Table_info');?>",
|
"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 () {
|
function periodChanged () {
|
||||||
// Save Parameter Period
|
|
||||||
period = $('#period').val();
|
|
||||||
setParameter (parPeriod, period);
|
|
||||||
|
|
||||||
// Requery Device data
|
// Requery Device data
|
||||||
getDeviceData(true);
|
getDeviceData(true);
|
||||||
getSessionsPresenceEvents();
|
getSessionsPresenceEvents();
|
||||||
@@ -1831,12 +1807,6 @@ function initTable(tableId, mac){
|
|||||||
|
|
||||||
$("#"+tableId).attr("data-mac", mac)
|
$("#"+tableId).attr("data-mac", mac)
|
||||||
|
|
||||||
// Save Parameters rows & order when changed
|
|
||||||
$('#'+tableId).on( 'length.dt', function ( e, settings, len ) {
|
|
||||||
setParameter (parSessionsRows, len);
|
|
||||||
|
|
||||||
} );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -183,43 +183,31 @@
|
|||||||
|
|
||||||
<!-- page script ----------------------------------------------------------- -->
|
<!-- page script ----------------------------------------------------------- -->
|
||||||
<script>
|
<script>
|
||||||
var parPeriod = 'Front_Events_Period';
|
var parPeriod = 'nax_parPeriod';
|
||||||
var parTableRows = 'Front_Events_Rows';
|
var parTableRows = 'nax_parTableRows';
|
||||||
|
|
||||||
var eventsType = 'all';
|
var eventsType = 'all';
|
||||||
var period = '';
|
var period = '1 day';
|
||||||
var tableRows = 10;
|
var tableRows = 25;
|
||||||
|
|
||||||
// Read parameters & Initialize components
|
// Read parameters & Initialize components
|
||||||
main();
|
main();
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
function main () {
|
function main() {
|
||||||
// get parameter value
|
// Get parameter value from cookies instead of server
|
||||||
$.get('php/server/parameters.php?action=get&defaultValue=1 day¶meter='+ parPeriod, function(data) {
|
period = getCookie(parPeriod) === "" ? "1 day" : getCookie(parPeriod);
|
||||||
var result = JSON.parse(data);
|
$('#period').val(period);
|
||||||
if (result) {
|
|
||||||
period = result;
|
|
||||||
$('#period').val(period);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get parameter value
|
tableRows = getCookie(parTableRows) === "" ? 50 : parseInt(getCookie(parTableRows), 10);
|
||||||
$.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize components
|
// Initialize components
|
||||||
initializeDatatable();
|
initializeDatatable();
|
||||||
|
|
||||||
// query data
|
// Query data
|
||||||
getEventsTotals();
|
getEventsTotals();
|
||||||
getEvents (eventsType);
|
getEvents(eventsType);
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -281,7 +269,7 @@ function initializeDatatable () {
|
|||||||
|
|
||||||
// Save Parameter rows when changed
|
// Save Parameter rows when changed
|
||||||
$('#tableEvents').on( 'length.dt', function ( e, settings, len ) {
|
$('#tableEvents').on( 'length.dt', function ( e, settings, len ) {
|
||||||
setParameter (parTableRows, len);
|
setCookie(parTableRows, len)
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -290,7 +278,8 @@ function initializeDatatable () {
|
|||||||
function periodChanged () {
|
function periodChanged () {
|
||||||
// Save Parameter Period
|
// Save Parameter Period
|
||||||
period = $('#period').val();
|
period = $('#period').val();
|
||||||
setParameter (parPeriod, period);
|
|
||||||
|
setCookie(parTableRows, period)
|
||||||
|
|
||||||
// Requery totals and events
|
// Requery totals and events
|
||||||
getEventsTotals();
|
getEventsTotals();
|
||||||
|
|||||||
@@ -423,29 +423,6 @@ function numberArrayFromString(data)
|
|||||||
return data.replace(/\[|\]/g, '').split(',').map(Number);
|
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) {
|
function saveData(functionName, id, value) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
@@ -502,33 +502,6 @@ setTimeout(() => {
|
|||||||
});
|
});
|
||||||
}, 1000);
|
}, 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
|
// Show/hide the metadata settings
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
require '../server/init.php';
|
require '../server/init.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
// Function to render the log area component
|
// Function to render the log area component
|
||||||
function renderLogArea($params) {
|
function renderLogArea($params) {
|
||||||
$fileName = isset($params['fileName']) ? $params['fileName'] : '';
|
$fileName = isset($params['fileName']) ? $params['fileName'] : '';
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
function renderInfobox($params) {
|
function renderInfobox($params) {
|
||||||
$onclickEvent = isset($params['onclickEvent']) ? $params['onclickEvent'] : '';
|
$onclickEvent = isset($params['onclickEvent']) ? $params['onclickEvent'] : '';
|
||||||
$color = isset($params['color']) ? $params['color'] : '';
|
$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 = dirname(__FILE__).'/../../../db/app.db';
|
||||||
$DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../front/log/db_is_locked.log';
|
$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;
|
$db_locked = false;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -3,16 +3,18 @@
|
|||||||
// NetAlertX
|
// NetAlertX
|
||||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||||
//
|
//
|
||||||
// parameters.php - Front module. Server side. Manage Parameters
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
# Puche 2022+ jokob jokob@duck.com GNU GPLv3
|
# Puche 2022+ jokob jokob@duck.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// External files
|
// External files
|
||||||
require dirname(__FILE__).'/init.php';
|
require dirname(__FILE__).'/init.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Action selector
|
// Action selector
|
||||||
|
|||||||
@@ -11,6 +11,10 @@
|
|||||||
// External files
|
// External files
|
||||||
require dirname(__FILE__).'/init.php';
|
require dirname(__FILE__).'/init.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Action selector
|
// Action selector
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -8,9 +8,12 @@
|
|||||||
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
|
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// External files
|
// External files
|
||||||
require dirname(__FILE__).'/init.php';
|
require dirname(__FILE__).'/init.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Action selector
|
// Action selector
|
||||||
@@ -72,7 +75,7 @@ function getEventsTotals() {
|
|||||||
$resultJSON = getCache("getEventsTotals".$days);
|
$resultJSON = getCache("getEventsTotals".$days);
|
||||||
} else
|
} 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
|
$sql = "select
|
||||||
(SELECT Count(*) FROM Events WHERE eve_DateTime >= date('now', '".$periodDateSQL."')) as all_events,
|
(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,
|
(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'] .'"';
|
$endDate = '"'. $_REQUEST ['end'] .'"';
|
||||||
|
|
||||||
// SQL
|
// SQL
|
||||||
$SQL = 'SELECT ses_MAC, ses_EventTypeConnection, ses_DateTimeConnection,
|
$SQL = 'SELECT SES1.ses_MAC, SES1.ses_EventTypeConnection, SES1.ses_DateTimeConnection,
|
||||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo, ses_StillConnected,
|
SES1.ses_EventTypeDisconnection, SES1.ses_DateTimeDisconnection, SES1.ses_IP,
|
||||||
|
SES1.ses_AdditionalInfo, SES1.ses_StillConnected,
|
||||||
CASE
|
|
||||||
WHEN ses_EventTypeConnection = "<missing event>" THEN
|
CASE
|
||||||
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"))
|
WHEN SES1.ses_EventTypeConnection = "<missing event>" THEN
|
||||||
ELSE ses_DateTimeConnection
|
IFNULL (
|
||||||
END AS ses_DateTimeConnectionCorrected,
|
(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
|
CASE
|
||||||
WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
WHEN SES1.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)
|
(SELECT MIN(SES2.ses_DateTimeConnection)
|
||||||
ELSE ses_DateTimeDisconnection
|
FROM Sessions AS SES2
|
||||||
END AS ses_DateTimeDisconnectionCorrected
|
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 (SES1.ses_DateTimeConnection BETWEEN Date('. $startDate .') AND Date('. $endDate .'))
|
||||||
|
OR (SES1.ses_DateTimeDisconnection BETWEEN Date('. $startDate .') AND Date('. $endDate .'))
|
||||||
|
OR SES1.ses_StillConnected = 1';
|
||||||
|
|
||||||
FROM Sessions AS SES1
|
|
||||||
WHERE ( ses_DateTimeConnectionCorrected <= Date('. $endDate .')
|
|
||||||
AND (ses_DateTimeDisconnectionCorrected >= Date('. $startDate .') OR ses_StillConnected = 1 )) ';
|
|
||||||
$result = $db->query($SQL);
|
$result = $db->query($SQL);
|
||||||
|
|
||||||
// arrays of rows
|
// arrays of rows
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
// Get init.php
|
// Get init.php
|
||||||
require dirname(__FILE__).'/../server/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
|
// Perform a test with the PING command
|
||||||
$output = shell_exec("curl ipinfo.io");
|
$output = shell_exec("curl ipinfo.io");
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
require 'util.php';
|
require 'util.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
$PIA_HOST_IP = $_REQUEST['scan'];
|
$PIA_HOST_IP = $_REQUEST['scan'];
|
||||||
$PIA_SCAN_MODE = $_REQUEST['mode'];
|
$PIA_SCAN_MODE = $_REQUEST['mode'];
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,11 @@
|
|||||||
// Get init.php
|
// Get init.php
|
||||||
require dirname(__FILE__).'/../server/init.php';
|
require dirname(__FILE__).'/../server/init.php';
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
// Get IP
|
// Get IP
|
||||||
$ip = $_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
|
<?php
|
||||||
require dirname(__FILE__).'/../server/init.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);
|
exec('../../../back/speedtest-cli --secure --simple', $output);
|
||||||
|
|
||||||
echo '<h4>'. lang('Speedtest_Results') .'</h4>';
|
echo '<h4>'. lang('Speedtest_Results') .'</h4>';
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
// Get init.php
|
// Get init.php
|
||||||
require dirname(__FILE__).'/../server/init.php';
|
require dirname(__FILE__).'/../server/init.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
// Get IP
|
// Get IP
|
||||||
$ip = $_GET['ip'];
|
$ip = $_GET['ip'];
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@
|
|||||||
require dirname(__FILE__).'/../templates/timezone.php';
|
require dirname(__FILE__).'/../templates/timezone.php';
|
||||||
require dirname(__FILE__).'/../templates/skinUI.php';
|
require dirname(__FILE__).'/../templates/skinUI.php';
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
$FUNCTION = [];
|
$FUNCTION = [];
|
||||||
$SETTINGS = [];
|
$SETTINGS = [];
|
||||||
$ACTION = "";
|
$ACTION = "";
|
||||||
@@ -484,7 +488,7 @@ function getDateFromPeriod () {
|
|||||||
$days = "3650"; //10 years
|
$days = "3650"; //10 years
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$days = "1";
|
$days = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
$periodDateSQL = "-".$days." day";
|
$periodDateSQL = "-".$days." day";
|
||||||
|
|||||||
@@ -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
|
<?php
|
||||||
|
|
||||||
|
|
||||||
require dirname(__FILE__).'/../templates/timezone.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
|
// Check if the action parameter is set in the GET request
|
||||||
if (isset($_GET['action'])) {
|
if (isset($_GET['action'])) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
if (session_status() == PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
$isAuthenticated = false;
|
$isAuthenticated = false;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
#---------------------------------------------------------------------------------#
|
#---------------------------------------------------------------------------------#
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
?>
|
||||||
|
|
||||||
<!-- Main Footer -->
|
<!-- Main Footer -->
|
||||||
<footer class="main-footer">
|
<footer class="main-footer">
|
||||||
<!-- Default to the left -->
|
<!-- Default to the left -->
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// check if authenticated
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$Pia_Graph_Device_Time = array();
|
$Pia_Graph_Device_Time = array();
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
#--------------------------------------------------------------------------- -->
|
#--------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require dirname(__FILE__).'/../server/init.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;}
|
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");
|
$result = $db->query("SELECT * FROM Plugins_Language_Strings");
|
||||||
$strings = array();
|
$strings = array();
|
||||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
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>
|
<script>
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ if (strpos($url,'index.php') !== false) {
|
|||||||
$isLogonPage = TRUE;
|
$isLogonPage = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
session_start();
|
// start session if not started yet
|
||||||
|
if (session_status() == PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
if(array_search('action', $_REQUEST) != FALSE)
|
if(array_search('action', $_REQUEST) != FALSE)
|
||||||
{
|
{
|
||||||
@@ -24,7 +27,7 @@ if(array_search('action', $_REQUEST) != FALSE)
|
|||||||
// ##################################################
|
// ##################################################
|
||||||
// ## Login Processing start
|
// ## Login Processing start
|
||||||
// ##################################################
|
// ##################################################
|
||||||
$config_file = "../config/app.conf";
|
$config_file = $_SERVER['DOCUMENT_ROOT'] . "/../config/app.conf";
|
||||||
$config_file_lines = file($config_file);
|
$config_file_lines = file($config_file);
|
||||||
$CookieSaveLoginName = "NetAlertX_SaveLogin";
|
$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;
|
$ENABLED_DARKMODE = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (glob("/app/db/setting_skin*") as $filename) {
|
$pia_skin_selected = 'skin-blue';
|
||||||
$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';}
|
|
||||||
|
|
||||||
// ###################################
|
// ###################################
|
||||||
// ## GUI settings processing end
|
// ## GUI settings processing end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#---------------------------------------------------------------------------------#
|
#---------------------------------------------------------------------------------#
|
||||||
|
|
||||||
$filename = "/app/.VERSION";
|
$filename = "/app/.VERSION";
|
||||||
|
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
$fileContents = file_get_contents($filename);
|
$fileContents = file_get_contents($filename);
|
||||||
if(trim($fileContents) === 'Dev') {
|
if(trim($fileContents) === 'Dev') {
|
||||||
@@ -22,5 +23,6 @@ if(file_exists($filename)) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo date('H:i:s') . " - N/A";
|
echo date('H:i:s') . " - N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ function initializeCalendar () {
|
|||||||
center : 'title',
|
center : 'title',
|
||||||
right : 'timelineYear,timelineMonth,timelineWeek,timelineDay'
|
right : 'timelineYear,timelineMonth,timelineWeek,timelineDay'
|
||||||
},
|
},
|
||||||
defaultView : 'timelineMonth',
|
defaultView : 'timelineWeek',
|
||||||
height : 'auto',
|
height : 'auto',
|
||||||
firstDay : 1,
|
firstDay : 1,
|
||||||
allDaySlot : false,
|
allDaySlot : false,
|
||||||
@@ -389,6 +389,33 @@ function getDevicesPresence (status) {
|
|||||||
default: tableTitle = '<?= lang('Presence_Shortcut_Devices');?>'; color = 'gray'; break;
|
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
|
// Set title and color
|
||||||
$('#tableDevicesTitle')[0].className = 'box-title text-'+ color;
|
$('#tableDevicesTitle')[0].className = 'box-title text-'+ color;
|
||||||
$('#tableDevicesBox')[0].className = 'box box-'+ color;
|
$('#tableDevicesBox')[0].className = 'box box-'+ color;
|
||||||
@@ -399,7 +426,7 @@ function getDevicesPresence (status) {
|
|||||||
$('#calendar').fullCalendar ('refetchResources');
|
$('#calendar').fullCalendar ('refetchResources');
|
||||||
|
|
||||||
$('#calendar').fullCalendar('removeEventSources');
|
$('#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>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user