mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Compare commits
6 Commits
23.01.22-H
...
v23.01.22-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b35e68cf2 | ||
|
|
8b4115fe48 | ||
|
|
8bc1c3e0ed | ||
|
|
69061ed537 | ||
|
|
f151b1268d | ||
|
|
35d9c0e548 |
@@ -383,7 +383,7 @@ def importConfig ():
|
|||||||
lastTimeImported = time.time()
|
lastTimeImported = time.time()
|
||||||
|
|
||||||
# Used to display a message in the UI when old (outdated) settings are loaded
|
# Used to display a message in the UI when old (outdated) settings are loaded
|
||||||
sql.execute ("""UPDATE Parameters set "par_Value" = ? where "par_ID" = "Back_Settings_Imported" """, (round(time.time() * 1000),))
|
initOrSetParam("Back_Settings_Imported",(round(time.time() * 1000),) )
|
||||||
|
|
||||||
commitDB()
|
commitDB()
|
||||||
|
|
||||||
@@ -2840,6 +2840,20 @@ def upgradeDB ():
|
|||||||
AND name='Nmap_Scan';
|
AND name='Nmap_Scan';
|
||||||
""").fetchone() == None
|
""").fetchone() == None
|
||||||
|
|
||||||
|
# Re-creating Parameters table
|
||||||
|
file_print("[upgradeDB] Re-creating Parameters table")
|
||||||
|
sql.execute("DROP TABLE Parameters;")
|
||||||
|
|
||||||
|
sql.execute("""
|
||||||
|
CREATE TABLE "Parameters" (
|
||||||
|
"par_ID" TEXT PRIMARY KEY,
|
||||||
|
"par_Value" TEXT
|
||||||
|
);
|
||||||
|
""")
|
||||||
|
|
||||||
|
# Initialize Parameters if unavailable
|
||||||
|
initOrSetParam('Back_App_State','Initializing')
|
||||||
|
|
||||||
# if nmapScanMissing == False:
|
# if nmapScanMissing == False:
|
||||||
# # Re-creating Nmap_Scan table
|
# # Re-creating Nmap_Scan table
|
||||||
# sql.execute("DROP TABLE Nmap_Scan;")
|
# sql.execute("DROP TABLE Nmap_Scan;")
|
||||||
@@ -2859,8 +2873,14 @@ def upgradeDB ():
|
|||||||
PRIMARY KEY("Index" AUTOINCREMENT)
|
PRIMARY KEY("Index" AUTOINCREMENT)
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# don't hog DB access
|
commitDB ()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
def initOrSetParam(parID, parValue):
|
||||||
|
|
||||||
|
sql.execute ("INSERT INTO Parameters(par_ID, par_Value) VALUES('"+str(parID)+"', '"+str(parValue)+"') ON CONFLICT(par_ID) DO UPDATE SET par_Value='"+str(parValue)+"' where par_ID='"+str(parID)+"'")
|
||||||
|
|
||||||
commitDB ()
|
commitDB ()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -2868,7 +2888,6 @@ def updateState(newState):
|
|||||||
|
|
||||||
sql.execute ("UPDATE Parameters SET par_Value='"+ newState +"' WHERE par_ID='Back_App_State'")
|
sql.execute ("UPDATE Parameters SET par_Value='"+ newState +"' WHERE par_ID='Back_App_State'")
|
||||||
|
|
||||||
# don't hog DB access
|
|
||||||
commitDB ()
|
commitDB ()
|
||||||
|
|
||||||
|
|
||||||
@@ -3112,7 +3131,7 @@ def isNewVersion():
|
|||||||
if realeaseTimestamp > buildTimestamp + 600:
|
if realeaseTimestamp > buildTimestamp + 600:
|
||||||
file_print(" New version of the container available!")
|
file_print(" New version of the container available!")
|
||||||
newVersionAvailable = True
|
newVersionAvailable = True
|
||||||
sql.execute ("UPDATE Parameters SET par_Value='"+ str(newVersionAvailable) +"' WHERE par_ID='Back_New_Version_Available'")
|
initOrSetParam('Back_New_Version_Available', str(newVersionAvailable))
|
||||||
|
|
||||||
return newVersionAvailable
|
return newVersionAvailable
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ services:
|
|||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ${APP_DATA_LOCATION}/pialert/config2:/home/pi/pialert/config
|
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||||
# - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
# - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
||||||
- ${APP_DATA_LOCATION}/pialert/db2:/home/pi/pialert/db
|
- ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||||
# (optional) useful for debugging if you have issues setting up the container
|
# (optional) useful for debugging if you have issues setting up the container
|
||||||
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
||||||
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes
|
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes
|
||||||
|
|||||||
15
docs/SMTP_GMAIL.md
Normal file
15
docs/SMTP_GMAIL.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
## Use the Gmail SMTP server
|
||||||
|
|
||||||
|
1) Create an app password by following the instructions from Google, you need to Enable 2FA for this to work.
|
||||||
|
[https://support.google.com/accounts/answer/185833](https://support.google.com/accounts/answer/185833)
|
||||||
|
|
||||||
|
2) Specify the following settings:
|
||||||
|
|
||||||
|
```python
|
||||||
|
SMTP_SKIP_TLS=True
|
||||||
|
SMTP_FORCE_SSL=True
|
||||||
|
SMTP_PORT=465
|
||||||
|
SMTP_SERVER='smtp.gmail.com'
|
||||||
|
SMTP_PASS='16-digit passcode from google'
|
||||||
|
```
|
||||||
|
|
||||||
@@ -192,9 +192,9 @@
|
|||||||
var parTableOrder = 'Front_Devices_Order';
|
var parTableOrder = 'Front_Devices_Order';
|
||||||
var tableRows = 10;
|
var tableRows = 10;
|
||||||
var tableOrder = [[3,'desc'], [0,'asc']];
|
var tableOrder = [[3,'desc'], [0,'asc']];
|
||||||
var tableColumnVisible = [0,1,2,3,4,5,6,7,8,9,10,12,13,14];
|
var tableColumnVisible = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14];
|
||||||
var columnsStr = '[0,1,2,3,4,5,6,7,8,9,10,12,13,14]';
|
var columnsStr = '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]';
|
||||||
var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,12,13,14] ;
|
var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14] ;
|
||||||
|
|
||||||
// Read parameters & Initialize components
|
// Read parameters & Initialize components
|
||||||
main();
|
main();
|
||||||
@@ -204,12 +204,12 @@
|
|||||||
function main () {
|
function main () {
|
||||||
|
|
||||||
// get visible columns
|
// get visible columns
|
||||||
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'¶meter=Front_Devices_Columns_Visible', function(data) {
|
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'¶meter=Front_Devices_Columns_Visible&skipcache', function(data) {
|
||||||
|
|
||||||
tableColumnVisible = numberArrayFromString(data);
|
tableColumnVisible = numberArrayFromString(data);
|
||||||
|
|
||||||
// get the custom order specified by the user
|
// get the custom order specified by the user
|
||||||
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'¶meter=Front_Devices_Columns_Order', function(data) {
|
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'¶meter=Front_Devices_Columns_Order&skipcache', function(data) {
|
||||||
|
|
||||||
tableColumnOrder = numberArrayFromString(data);
|
tableColumnOrder = numberArrayFromString(data);
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ function initializeDatatable () {
|
|||||||
{className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10)] },
|
{className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10)] },
|
||||||
{width: '80px', targets: [mapIndx(6), mapIndx(7)] },
|
{width: '80px', targets: [mapIndx(6), mapIndx(7)] },
|
||||||
{width: '30px', targets: [mapIndx(10), mapIndx(13)] },
|
{width: '30px', targets: [mapIndx(10), mapIndx(13)] },
|
||||||
{orderData: [mapIndx(11)], targets: mapIndx(8) },
|
{orderData: [mapIndx(12)], targets: mapIndx(8) },
|
||||||
|
|
||||||
// Device Name
|
// Device Name
|
||||||
{targets: [mapIndx(0)],
|
{targets: [mapIndx(0)],
|
||||||
@@ -461,7 +461,7 @@ function getDevicesFromTable(table)
|
|||||||
rowIDs.map(function(rowID, index){
|
rowIDs.map(function(rowID, index){
|
||||||
result.push({
|
result.push({
|
||||||
"rowid": rowID,
|
"rowid": rowID,
|
||||||
"mac":rowMACs[index],
|
"mac" : rowMACs[index],
|
||||||
"name" : rowNames[index],
|
"name" : rowNames[index],
|
||||||
"type" : rowTypes[index],
|
"type" : rowTypes[index],
|
||||||
"icon" : rowIcons[index],
|
"icon" : rowIcons[index],
|
||||||
|
|||||||
@@ -453,8 +453,36 @@
|
|||||||
<script src="lib/treeviz/require.js"></script>
|
<script src="lib/treeviz/require.js"></script>
|
||||||
<script src="js/pialert_common.js"></script>
|
<script src="js/pialert_common.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
$.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) {
|
||||||
|
|
||||||
|
rawData = JSON.parse (data)
|
||||||
|
console.log(rawData)
|
||||||
|
|
||||||
|
devicesListnew = rawData["data"].map(item => { return {
|
||||||
|
"name":item[0],
|
||||||
|
"type":item[2],
|
||||||
|
"icon":item[3],
|
||||||
|
"mac":item[11],
|
||||||
|
"parentMac":item[14],
|
||||||
|
"rowid":item[13],
|
||||||
|
"status":item[10]
|
||||||
|
}})
|
||||||
|
|
||||||
|
setCache('devicesListNew', JSON.stringify(devicesListnew))
|
||||||
|
|
||||||
|
console.log(devicesListnew)
|
||||||
|
|
||||||
|
// create tree
|
||||||
|
initTree(getHierarchy());
|
||||||
|
|
||||||
|
// attach on-click events
|
||||||
|
attachTreeEvents();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script defer>
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Tree functionality
|
// Tree functionality
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -462,7 +490,7 @@
|
|||||||
function getDevicesList()
|
function getDevicesList()
|
||||||
{
|
{
|
||||||
// Read cache
|
// Read cache
|
||||||
devicesList = getCache('devicesList');
|
devicesList = getCache('devicesListNew');
|
||||||
|
|
||||||
if (devicesList != '') {
|
if (devicesList != '') {
|
||||||
devicesList = JSON.parse (devicesList);
|
devicesList = JSON.parse (devicesList);
|
||||||
@@ -485,7 +513,7 @@
|
|||||||
// loop thru all items and find childern...
|
// loop thru all items and find childern...
|
||||||
for(var i in list)
|
for(var i in list)
|
||||||
{
|
{
|
||||||
//... of teh current node
|
//... of the current node
|
||||||
if(list[i].parentMac == node.mac && !hiddenMacs.includes(list[i].parentMac))
|
if(list[i].parentMac == node.mac && !hiddenMacs.includes(list[i].parentMac))
|
||||||
{
|
{
|
||||||
// and process them
|
// and process them
|
||||||
@@ -516,9 +544,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
list = getDevicesList();
|
|
||||||
function getHierarchy()
|
function getHierarchy()
|
||||||
{
|
{
|
||||||
|
list = getDevicesList();
|
||||||
|
|
||||||
for(i in list)
|
for(i in list)
|
||||||
{
|
{
|
||||||
if(list[i].mac == 'Internet')
|
if(list[i].mac == 'Internet')
|
||||||
@@ -580,7 +610,11 @@
|
|||||||
renderNode: nodeData => {
|
renderNode: nodeData => {
|
||||||
|
|
||||||
// calculate the font size of the leaf nodes to fit everything into the tree area
|
// calculate the font size of the leaf nodes to fit everything into the tree area
|
||||||
var fontSize = (nodeData.data.hasChildren) ? "" : "font-size:"+((600/(20*leafNodesCount)).toFixed(2))+"em;";
|
leafNodesCount == 0 ? 1 : leafNodesCount;
|
||||||
|
emSize = ((600/(20*leafNodesCount)).toFixed(2));
|
||||||
|
emSize = emSize > 1 ? 1 : emSize;
|
||||||
|
|
||||||
|
var fontSize = (nodeData.data.hasChildren) ? "" : "font-size:"+emSize+"em;";
|
||||||
|
|
||||||
deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? "<div class='netIcon '><i class='fa fa-"+nodeData.data.icon +"'></i></div>" : "";
|
deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? "<div class='netIcon '><i class='fa fa-"+nodeData.data.icon +"'></i></div>" : "";
|
||||||
collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" :"square-minus";
|
collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" :"square-minus";
|
||||||
@@ -589,7 +623,7 @@
|
|||||||
|
|
||||||
selectedNodeMac = $(".nav-tabs-custom .active a").attr('data-mytabmac')
|
selectedNodeMac = $(".nav-tabs-custom .active a").attr('data-mytabmac')
|
||||||
|
|
||||||
highlightedCss = nodeData.data.mac == selectedNodeMac ? " highlightedNode" : "";
|
highlightedCss = nodeData.data.mac == selectedNodeMac ? " highlightedNode" : "";
|
||||||
|
|
||||||
return result = "<div class='box "+statusCss+" "+highlightedCss+"' data-mytreemacmain='"+nodeData.data.mac+"' \
|
return result = "<div class='box "+statusCss+" "+highlightedCss+"' data-mytreemacmain='"+nodeData.data.mac+"' \
|
||||||
style='height:"+nodeData.settings.nodeHeight+"px;\
|
style='height:"+nodeData.settings.nodeHeight+"px;\
|
||||||
@@ -619,7 +653,7 @@
|
|||||||
marginTop: '5',
|
marginTop: '5',
|
||||||
hasZoom: false,
|
hasZoom: false,
|
||||||
hasPan: false,
|
hasPan: false,
|
||||||
marginLeft: '15',
|
// marginLeft: '15',
|
||||||
idKey: "name",
|
idKey: "name",
|
||||||
hasFlatData: false,
|
hasFlatData: false,
|
||||||
linkWidth: (nodeData) => 3,
|
linkWidth: (nodeData) => 3,
|
||||||
@@ -637,25 +671,7 @@
|
|||||||
|
|
||||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
|
||||||
// init parent node
|
initButtons()
|
||||||
var currentNodeMac = $(".tab-content .active td[data-mynodemac]").attr('data-mynodemac');
|
|
||||||
|
|
||||||
initButtons(currentNodeMac);
|
|
||||||
|
|
||||||
// change highlighted node in the tree
|
|
||||||
selNode = $("#networkTree .highlightedNode")[0]
|
|
||||||
|
|
||||||
// console.log(selNode)
|
|
||||||
|
|
||||||
if(selNode)
|
|
||||||
{
|
|
||||||
$(selNode).attr('class', $(selNode).attr('class').replace('highlightedNode'))
|
|
||||||
}
|
|
||||||
|
|
||||||
newSelNode = $("#networkTree div[data-mytreemacmain='"+currentNodeMac+"']")[0]
|
|
||||||
|
|
||||||
$(newSelNode).attr('class', $(newSelNode).attr('class') + ' highlightedNode')
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -690,14 +706,30 @@
|
|||||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
setCache(key, $(e.target).attr('id'))
|
setCache(key, $(e.target).attr('id'))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
function initButtons(currentNodeMac)
|
function initButtons()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var currentNodeMac = $(".tab-content .active td[data-mynodemac]").attr('data-mynodemac');
|
||||||
|
|
||||||
|
// change highlighted node in the tree
|
||||||
|
selNode = $("#networkTree .highlightedNode")[0]
|
||||||
|
|
||||||
|
// console.log(selNode)
|
||||||
|
|
||||||
|
if(selNode)
|
||||||
|
{
|
||||||
|
$(selNode).attr('class', $(selNode).attr('class').replace('highlightedNode'))
|
||||||
|
}
|
||||||
|
|
||||||
|
newSelNode = $("#networkTree div[data-mytreemacmain='"+currentNodeMac+"']")[0]
|
||||||
|
|
||||||
|
$(newSelNode).attr('class', $(newSelNode).attr('class') + ' highlightedNode')
|
||||||
|
|
||||||
|
|
||||||
// init the Assign buttons
|
// init the Assign buttons
|
||||||
$('#unassignedDevices button[data-myleafmac]').each(function(){
|
$('#unassignedDevices button[data-myleafmac]').each(function(){
|
||||||
$(this).attr('onclick', 'updateLeaf("'+$(this).attr('data-myleafmac')+'","'+currentNodeMac+'")')
|
$(this).attr('onclick', 'updateLeaf("'+$(this).attr('data-myleafmac')+'","'+currentNodeMac+'")')
|
||||||
@@ -712,6 +744,8 @@
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
function updateLeaf(leafMac,nodeMac)
|
function updateLeaf(leafMac,nodeMac)
|
||||||
{
|
{
|
||||||
|
console.log(leafMac)
|
||||||
|
console.log(nodeMac)
|
||||||
saveData('updateNetworkLeaf', leafMac, nodeMac);
|
saveData('updateNetworkLeaf', leafMac, nodeMac);
|
||||||
setTimeout("location.reload();", 1000); // refresh page after 1s
|
setTimeout("location.reload();", 1000); // refresh page after 1s
|
||||||
}
|
}
|
||||||
@@ -720,11 +754,8 @@
|
|||||||
// init selected (first) tab
|
// init selected (first) tab
|
||||||
initTab();
|
initTab();
|
||||||
|
|
||||||
// create tree
|
// init Assign/Unassign buttons
|
||||||
initTree(getHierarchy());
|
initButtons()
|
||||||
|
|
||||||
// attach on-click events
|
|
||||||
attachTreeEvents();
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -569,6 +569,13 @@ function getDevicesTotals() {
|
|||||||
function getDevicesList() {
|
function getDevicesList() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
$forceDefaultOrder = FALSE;
|
||||||
|
|
||||||
|
if (isset ($_REQUEST['forceDefaultOrder']) )
|
||||||
|
{
|
||||||
|
$forceDefaultOrder = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// This object is used to map from the old order ( second parameter, first number) to the 3rd parameter (Second number (here initialized to -1))
|
// This object is used to map from the old order ( second parameter, first number) to the 3rd parameter (Second number (here initialized to -1))
|
||||||
$columnOrderMapping = array(
|
$columnOrderMapping = array(
|
||||||
array("dev_Name", 0, 0),
|
array("dev_Name", 0, 0),
|
||||||
@@ -588,19 +595,22 @@ function getDevicesList() {
|
|||||||
array("dev_Network_Node_MAC_ADDR", 14, 14)
|
array("dev_Network_Node_MAC_ADDR", 14, 14)
|
||||||
);
|
);
|
||||||
|
|
||||||
// get device columns order
|
if($forceDefaultOrder == FALSE)
|
||||||
$sql = 'SELECT par_Value FROM Parameters where par_ID = "Front_Devices_Columns_Order"';
|
|
||||||
$result = $db->query($sql);
|
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
|
||||||
|
|
||||||
if($row != NULL && count($row) == 1)
|
|
||||||
{
|
{
|
||||||
// ordered columns setting from the maintenance page
|
// get device columns order
|
||||||
$orderedColumns = createArray($row[0]);
|
$sql = 'SELECT par_Value FROM Parameters where par_ID = "Front_Devices_Columns_Order"';
|
||||||
|
$result = $db->query($sql);
|
||||||
|
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||||
|
|
||||||
// init ordered columns
|
if($row != NULL && count($row) == 1)
|
||||||
for($i = 0; $i < count($orderedColumns); $i++) {
|
{
|
||||||
$columnOrderMapping[$i][2] = $orderedColumns[$i];
|
// ordered columns setting from the maintenance page
|
||||||
|
$orderedColumns = createArray($row[0]);
|
||||||
|
|
||||||
|
// init ordered columns
|
||||||
|
for($i = 0; $i < count($orderedColumns); $i++) {
|
||||||
|
$columnOrderMapping[$i][2] = $orderedColumns[$i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,8 +632,8 @@ function getDevicesList() {
|
|||||||
|
|
||||||
$defaultOrder = array ($row['dev_Name'],
|
$defaultOrder = array ($row['dev_Name'],
|
||||||
$row['dev_Owner'],
|
$row['dev_Owner'],
|
||||||
$row['dev_DeviceType'],
|
handleNull($row['dev_DeviceType']),
|
||||||
$row['dev_Icon'],
|
handleNull($row['dev_Icon'], "laptop"),
|
||||||
$row['dev_Favorite'],
|
$row['dev_Favorite'],
|
||||||
$row['dev_Group'],
|
$row['dev_Group'],
|
||||||
formatDate ($row['dev_FirstConnection']),
|
formatDate ($row['dev_FirstConnection']),
|
||||||
@@ -634,12 +644,12 @@ function getDevicesList() {
|
|||||||
$row['dev_MAC'], // MAC (hidden)
|
$row['dev_MAC'], // MAC (hidden)
|
||||||
formatIPlong ($row['dev_LastIP']), // IP orderable
|
formatIPlong ($row['dev_LastIP']), // IP orderable
|
||||||
$row['rowid'], // Rowid (hidden)
|
$row['rowid'], // Rowid (hidden)
|
||||||
$row['dev_Network_Node_MAC_ADDR'] //
|
handleNull($row['dev_Network_Node_MAC_ADDR']) //
|
||||||
);
|
);
|
||||||
|
|
||||||
$newOrder = array();
|
$newOrder = array();
|
||||||
|
|
||||||
|
// reorder columns based on user settings
|
||||||
for($index = 0; $index < count($columnOrderMapping); $index++)
|
for($index = 0; $index < count($columnOrderMapping); $index++)
|
||||||
{
|
{
|
||||||
array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
|
array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
|
||||||
@@ -757,10 +767,11 @@ function getIcons() {
|
|||||||
|
|
||||||
// arrays of rows
|
// arrays of rows
|
||||||
$tableData = array();
|
$tableData = array();
|
||||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||||
|
$icon = handleNull($row['dev_Icon'], "laptop");
|
||||||
// Push row data
|
// Push row data
|
||||||
$tableData[] = array('id' => $row['dev_Icon'],
|
$tableData[] = array('id' => $icon,
|
||||||
'name' => '<i class="fa fa-'.$row['dev_Icon'].'"></i> - '.$row['dev_Icon'] );
|
'name' => '<i class="fa fa-'.$icon.'"></i> - '.$icon );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control no rows
|
// Control no rows
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ function getParameter($skipCache, $defaultValue, $expireMinutes) {
|
|||||||
$value = $row[0];
|
$value = $row[0];
|
||||||
} else{
|
} else{
|
||||||
$value = $defaultValue;
|
$value = $defaultValue;
|
||||||
|
|
||||||
|
// Nothing found in the DB, Insert new value
|
||||||
|
insertNew($parameter, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update cache
|
// update cache
|
||||||
@@ -113,15 +116,7 @@ function setParameter($expireMinutes) {
|
|||||||
$changes = $db->changes();
|
$changes = $db->changes();
|
||||||
if ($changes == 0) {
|
if ($changes == 0) {
|
||||||
// Insert new value
|
// Insert new value
|
||||||
$sql = 'INSERT INTO Parameters (par_ID, par_Value)
|
insertNew($parameter, $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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update cache
|
// update cache
|
||||||
@@ -130,4 +125,21 @@ function setParameter($expireMinutes) {
|
|||||||
echo 'OK';
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -353,6 +353,18 @@ function logServerConsole ($text) {
|
|||||||
$x = array();
|
$x = array();
|
||||||
$y = $x['__________'. $text .'__________'];
|
$y = $x['__________'. $text .'__________'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------
|
||||||
|
function handleNull ($text, $default = "") {
|
||||||
|
if($text == NULL || $text == 'NULL')
|
||||||
|
{
|
||||||
|
return $default;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ the arp-scan will take hours to complete instead of seconds.
|
|||||||
'REPORT_MAIL_name' => 'Enable email',
|
'REPORT_MAIL_name' => 'Enable email',
|
||||||
'REPORT_MAIL_description' => 'If enabled an email is sent out with a list of changes you\'ve subscribed to. Please also fill out all remaining settings related to the SMTP setup below.',
|
'REPORT_MAIL_description' => 'If enabled an email is sent out with a list of changes you\'ve subscribed to. Please also fill out all remaining settings related to the SMTP setup below.',
|
||||||
'SMTP_SERVER_name' => 'SMTP server URL',
|
'SMTP_SERVER_name' => 'SMTP server URL',
|
||||||
'SMTP_SERVER_description' => 'The SMTP server host URL. For example <code>smtp-relay.sendinblue.com</code>. I don\'t recommend using Gmail as an SMTP server as the setup is <a target="_blank" href="https://support.google.com/a/answer/176600">quite complex</a> (I couldn\'t get it to work - Please reach out with a guide if you did)',
|
'SMTP_SERVER_description' => 'The SMTP server host URL. For example <code>smtp-relay.sendinblue.com</code>. To use Gmail as an SMTP server <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/SMTP_GMAIL.md">follow this guide</a>',
|
||||||
'SMTP_PORT_name' => 'SMTP server PORT',
|
'SMTP_PORT_name' => 'SMTP server PORT',
|
||||||
'SMTP_PORT_description' => 'Port number used for the SMTP connection. Set to <code>0</code> if you don\'t want to use a port when connecting to the SMTP server.',
|
'SMTP_PORT_description' => 'Port number used for the SMTP connection. Set to <code>0</code> if you don\'t want to use a port when connecting to the SMTP server.',
|
||||||
'SMTP_SKIP_LOGIN_name' => 'Skip authentication',
|
'SMTP_SKIP_LOGIN_name' => 'Skip authentication',
|
||||||
|
|||||||
@@ -469,8 +469,6 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
|||||||
function handleEvent (value){
|
function handleEvent (value){
|
||||||
setParameter ('Front_Event', value)
|
setParameter ('Front_Event', value)
|
||||||
|
|
||||||
// console.log(value)
|
|
||||||
|
|
||||||
// show message
|
// show message
|
||||||
showModalOk("<?php echo lang("general_event_title")?>", "<?php echo lang("general_event_description")?> <code id='"+modalEventStatusId+"'></code>");
|
showModalOk("<?php echo lang("general_event_title")?>", "<?php echo lang("general_event_description")?> <code id='"+modalEventStatusId+"'></code>");
|
||||||
|
|
||||||
@@ -486,9 +484,6 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
displayedEvent = $('#'+modalEventStatusId).html()
|
displayedEvent = $('#'+modalEventStatusId).html()
|
||||||
|
|
||||||
// console.log(displayedEvent)
|
|
||||||
// console.log(displayedEvent.indexOf('finished') == -1)
|
|
||||||
|
|
||||||
// loop until finished
|
// loop until finished
|
||||||
if(displayedEvent.indexOf('finished') == -1) // if the message is different from finished, check again in 4s
|
if(displayedEvent.indexOf('finished') == -1) // if the message is different from finished, check again in 4s
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user