mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Compare commits
8 Commits
v23.01.22
...
v23.01.22-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b35e68cf2 | ||
|
|
8b4115fe48 | ||
|
|
8bc1c3e0ed | ||
|
|
69061ed537 | ||
|
|
f151b1268d | ||
|
|
35d9c0e548 | ||
|
|
7baae289d1 | ||
|
|
a33c50361f |
@@ -20,7 +20,6 @@ from email.mime.text import MIMEText
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import tempfile
|
||||
import re
|
||||
import time
|
||||
import decimal
|
||||
@@ -384,7 +383,7 @@ def importConfig ():
|
||||
lastTimeImported = time.time()
|
||||
|
||||
# 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()
|
||||
|
||||
@@ -2841,6 +2840,20 @@ def upgradeDB ():
|
||||
AND name='Nmap_Scan';
|
||||
""").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:
|
||||
# # Re-creating Nmap_Scan table
|
||||
# sql.execute("DROP TABLE Nmap_Scan;")
|
||||
@@ -2860,8 +2873,14 @@ def upgradeDB ():
|
||||
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 ()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@@ -2869,7 +2888,6 @@ def updateState(newState):
|
||||
|
||||
sql.execute ("UPDATE Parameters SET par_Value='"+ newState +"' WHERE par_ID='Back_App_State'")
|
||||
|
||||
# don't hog DB access
|
||||
commitDB ()
|
||||
|
||||
|
||||
@@ -3102,7 +3120,7 @@ def isNewVersion():
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
file_print(" Couldn't check for new release.")
|
||||
data = ""
|
||||
|
||||
|
||||
# make sure we received a valid response and not an API rate limit exceeded message
|
||||
if len(data) > 0 and "published_at" in data[0]:
|
||||
|
||||
@@ -3113,7 +3131,7 @@ def isNewVersion():
|
||||
if realeaseTimestamp > buildTimestamp + 600:
|
||||
file_print(" New version of the container available!")
|
||||
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
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ services:
|
||||
volumes:
|
||||
- ${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:/home/pi/pialert/db
|
||||
# (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt
|
||||
- ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode
|
||||
- ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- ${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
|
||||
|
||||
@@ -45,7 +45,6 @@ docker run -d --rm --network=host \
|
||||
| :------------- | :------------- |:-------------|
|
||||
| **Required** | `:/home/pi/pialert/config` | Folder which will contain the `pialert.conf` file (see below for details) |
|
||||
| **Required** | `:/home/pi/pialert/db` | Folder which will contain the `pialert.db` file |
|
||||
|Optional| `:/home/pi/pialert/db/setting_darkmode` | Map an empty file with the name `setting_darkmode` if you want to force the dark mode on container rebuilt |
|
||||
|Optional| `:/home/pi/pialert/front/log` | Logs folder useful for debugging if you have issues setting up the container |
|
||||
|Optional| `:/etc/pihole/pihole-FTL.db` | PiHole's `pihole-FTL.db` database file. Required if you want to use PiHole |
|
||||
|Optional| `:/etc/pihole/dhcp.leases` | PiHole's `dhcp.leases` file. Required if you want to use PiHole |
|
||||
@@ -99,9 +98,7 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- local/path/pialert/config:/home/pi/pialert/config
|
||||
- local/path/pialert/db:/home/pi/pialert/db
|
||||
# (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt
|
||||
- local/path/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode
|
||||
- local/path/pialert/db:/home/pi/pialert/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- local/path/logs:/home/pi/pialert/front/log
|
||||
environment:
|
||||
@@ -127,9 +124,7 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
|
||||
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
||||
# (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt
|
||||
- ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode
|
||||
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
|
||||
environment:
|
||||
|
||||
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 tableRows = 10;
|
||||
var tableOrder = [[3,'desc'], [0,'asc']];
|
||||
var tableColumnVisible = [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,12,13,14]';
|
||||
var tableColumnOrder = [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,11,12,13,14]';
|
||||
var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14] ;
|
||||
|
||||
// Read parameters & Initialize components
|
||||
main();
|
||||
@@ -204,12 +204,12 @@
|
||||
function main () {
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -332,7 +332,7 @@ function initializeDatatable () {
|
||||
{className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10)] },
|
||||
{width: '80px', targets: [mapIndx(6), mapIndx(7)] },
|
||||
{width: '30px', targets: [mapIndx(10), mapIndx(13)] },
|
||||
{orderData: [mapIndx(11)], targets: mapIndx(8) },
|
||||
{orderData: [mapIndx(12)], targets: mapIndx(8) },
|
||||
|
||||
// Device Name
|
||||
{targets: [mapIndx(0)],
|
||||
@@ -461,7 +461,7 @@ function getDevicesFromTable(table)
|
||||
rowIDs.map(function(rowID, index){
|
||||
result.push({
|
||||
"rowid": rowID,
|
||||
"mac":rowMACs[index],
|
||||
"mac" : rowMACs[index],
|
||||
"name" : rowNames[index],
|
||||
"type" : rowTypes[index],
|
||||
"icon" : rowIcons[index],
|
||||
|
||||
@@ -292,12 +292,16 @@ function settingsChanged()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function translateHTMLcodes (text) {
|
||||
if (text == null) {
|
||||
if (text == null || emptyArr.includes(text)) {
|
||||
return null;
|
||||
} else if (typeof text === 'string' || text instanceof String)
|
||||
{
|
||||
var text2 = text.replace(new RegExp(' ', 'g'), " ");
|
||||
text2 = text2.replace(new RegExp('<', 'g'), "<");
|
||||
return text2;
|
||||
}
|
||||
var text2 = text.replace(new RegExp(' ', 'g'), " ");
|
||||
text2 = text2.replace(new RegExp('<', 'g'), "<");
|
||||
return text2;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -453,8 +453,36 @@
|
||||
<script src="lib/treeviz/require.js"></script>
|
||||
<script src="js/pialert_common.js"></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
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -462,7 +490,7 @@
|
||||
function getDevicesList()
|
||||
{
|
||||
// Read cache
|
||||
devicesList = getCache('devicesList');
|
||||
devicesList = getCache('devicesListNew');
|
||||
|
||||
if (devicesList != '') {
|
||||
devicesList = JSON.parse (devicesList);
|
||||
@@ -485,7 +513,7 @@
|
||||
// loop thru all items and find childern...
|
||||
for(var i in list)
|
||||
{
|
||||
//... of teh current node
|
||||
//... of the current node
|
||||
if(list[i].parentMac == node.mac && !hiddenMacs.includes(list[i].parentMac))
|
||||
{
|
||||
// and process them
|
||||
@@ -516,9 +544,11 @@
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
list = getDevicesList();
|
||||
|
||||
function getHierarchy()
|
||||
{
|
||||
list = getDevicesList();
|
||||
|
||||
for(i in list)
|
||||
{
|
||||
if(list[i].mac == 'Internet')
|
||||
@@ -580,7 +610,11 @@
|
||||
renderNode: nodeData => {
|
||||
|
||||
// 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>" : "";
|
||||
collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" :"square-minus";
|
||||
@@ -589,7 +623,7 @@
|
||||
|
||||
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+"' \
|
||||
style='height:"+nodeData.settings.nodeHeight+"px;\
|
||||
@@ -619,7 +653,7 @@
|
||||
marginTop: '5',
|
||||
hasZoom: false,
|
||||
hasPan: false,
|
||||
marginLeft: '15',
|
||||
// marginLeft: '15',
|
||||
idKey: "name",
|
||||
hasFlatData: false,
|
||||
linkWidth: (nodeData) => 3,
|
||||
@@ -637,25 +671,7 @@
|
||||
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
|
||||
// init parent node
|
||||
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')
|
||||
|
||||
initButtons()
|
||||
|
||||
});
|
||||
|
||||
@@ -690,14 +706,30 @@
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
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
|
||||
$('#unassignedDevices button[data-myleafmac]').each(function(){
|
||||
$(this).attr('onclick', 'updateLeaf("'+$(this).attr('data-myleafmac')+'","'+currentNodeMac+'")')
|
||||
@@ -712,6 +744,8 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
function updateLeaf(leafMac,nodeMac)
|
||||
{
|
||||
console.log(leafMac)
|
||||
console.log(nodeMac)
|
||||
saveData('updateNetworkLeaf', leafMac, nodeMac);
|
||||
setTimeout("location.reload();", 1000); // refresh page after 1s
|
||||
}
|
||||
@@ -720,11 +754,8 @@
|
||||
// init selected (first) tab
|
||||
initTab();
|
||||
|
||||
// create tree
|
||||
initTree(getHierarchy());
|
||||
|
||||
// attach on-click events
|
||||
attachTreeEvents();
|
||||
// init Assign/Unassign buttons
|
||||
initButtons()
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -569,38 +569,48 @@ function getDevicesTotals() {
|
||||
function getDevicesList() {
|
||||
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))
|
||||
$columnOrderMapping = array(
|
||||
array("dev_Name", 0, -1),
|
||||
array("dev_Owner", 1, -1),
|
||||
array("dev_DeviceType", 2, -1),
|
||||
array("dev_Icon", 3, -1),
|
||||
array("dev_Favorite", 4, -1),
|
||||
array("dev_Group", 5, -1),
|
||||
array("dev_FirstConnection", 6, -1),
|
||||
array("dev_LastConnection", 7, -1),
|
||||
array("dev_LastIP", 8, -1),
|
||||
array("dev_MAC", 9, -1),
|
||||
array("dev_Status", 10, -1),
|
||||
array("dev_MAC_full", 11, -1),
|
||||
array("dev_LastIP_orderable", 12, -1),
|
||||
array("rowid", 13, -1),
|
||||
array("dev_Network_Node_MAC_ADDR", 14, -1)
|
||||
array("dev_Name", 0, 0),
|
||||
array("dev_Owner", 1, 1),
|
||||
array("dev_DeviceType", 2, 2),
|
||||
array("dev_Icon", 3, 3),
|
||||
array("dev_Favorite", 4, 4),
|
||||
array("dev_Group", 5, 5),
|
||||
array("dev_FirstConnection", 6, 6),
|
||||
array("dev_LastConnection", 7, 7),
|
||||
array("dev_LastIP", 8, 8),
|
||||
array("dev_MAC", 9, 9),
|
||||
array("dev_Status", 10, 10),
|
||||
array("dev_MAC_full", 11, 11),
|
||||
array("dev_LastIP_orderable", 12, 12),
|
||||
array("rowid", 13, 13),
|
||||
array("dev_Network_Node_MAC_ADDR", 14, 14)
|
||||
);
|
||||
|
||||
// get device columns order
|
||||
$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)
|
||||
if($forceDefaultOrder == FALSE)
|
||||
{
|
||||
// ordered columns setting from the maintenance page
|
||||
$orderedColumns = createArray($row[0]);
|
||||
// get device columns order
|
||||
$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
|
||||
for($i = 0; $i < count($orderedColumns); $i++) {
|
||||
$columnOrderMapping[$i][2] = $orderedColumns[$i];
|
||||
if($row != NULL && count($row) == 1)
|
||||
{
|
||||
// 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'],
|
||||
$row['dev_Owner'],
|
||||
$row['dev_DeviceType'],
|
||||
$row['dev_Icon'],
|
||||
handleNull($row['dev_DeviceType']),
|
||||
handleNull($row['dev_Icon'], "laptop"),
|
||||
$row['dev_Favorite'],
|
||||
$row['dev_Group'],
|
||||
formatDate ($row['dev_FirstConnection']),
|
||||
@@ -634,12 +644,12 @@ function getDevicesList() {
|
||||
$row['dev_MAC'], // MAC (hidden)
|
||||
formatIPlong ($row['dev_LastIP']), // IP orderable
|
||||
$row['rowid'], // Rowid (hidden)
|
||||
$row['dev_Network_Node_MAC_ADDR'] //
|
||||
handleNull($row['dev_Network_Node_MAC_ADDR']) //
|
||||
);
|
||||
|
||||
$newOrder = array();
|
||||
|
||||
|
||||
// reorder columns based on user settings
|
||||
for($index = 0; $index < count($columnOrderMapping); $index++)
|
||||
{
|
||||
array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
|
||||
@@ -757,10 +767,11 @@ function getIcons() {
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$icon = handleNull($row['dev_Icon'], "laptop");
|
||||
// Push row data
|
||||
$tableData[] = array('id' => $row['dev_Icon'],
|
||||
'name' => '<i class="fa fa-'.$row['dev_Icon'].'"></i> - '.$row['dev_Icon'] );
|
||||
$tableData[] = array('id' => $icon,
|
||||
'name' => '<i class="fa fa-'.$icon.'"></i> - '.$icon );
|
||||
}
|
||||
|
||||
// Control no rows
|
||||
|
||||
@@ -80,6 +80,9 @@ function getParameter($skipCache, $defaultValue, $expireMinutes) {
|
||||
$value = $row[0];
|
||||
} else{
|
||||
$value = $defaultValue;
|
||||
|
||||
// Nothing found in the DB, Insert new value
|
||||
insertNew($parameter, $value);
|
||||
}
|
||||
|
||||
// update cache
|
||||
@@ -113,15 +116,7 @@ function setParameter($expireMinutes) {
|
||||
$changes = $db->changes();
|
||||
if ($changes == 0) {
|
||||
// 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;
|
||||
}
|
||||
insertNew($parameter, $value);
|
||||
}
|
||||
|
||||
// update cache
|
||||
@@ -130,4 +125,21 @@ function setParameter($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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -353,6 +353,18 @@ function logServerConsole ($text) {
|
||||
$x = array();
|
||||
$y = $x['__________'. $text .'__________'];
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
function handleNull ($text, $default = "") {
|
||||
if($text == NULL || $text == 'NULL')
|
||||
{
|
||||
return $default;
|
||||
} else
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ $lang['en_us'] = array(
|
||||
'Device_TableHead_Type' => 'Type',
|
||||
'Device_TableHead_Icon' => 'Icon',
|
||||
'Device_TableHead_RowID' => 'Row ID',
|
||||
'Device_TableHead_Rowid' => 'Row ID',
|
||||
'Device_TableHead_Parent_MAC' => 'Parent node MAC',
|
||||
'Device_TableHead_Favorite' => 'Favorite',
|
||||
'Device_TableHead_Group' => 'Group',
|
||||
@@ -515,7 +516,7 @@ the arp-scan will take hours to complete instead of seconds.
|
||||
'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.',
|
||||
'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_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',
|
||||
|
||||
@@ -469,8 +469,6 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
function handleEvent (value){
|
||||
setParameter ('Front_Event', value)
|
||||
|
||||
// console.log(value)
|
||||
|
||||
// show message
|
||||
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(){
|
||||
displayedEvent = $('#'+modalEventStatusId).html()
|
||||
|
||||
// console.log(displayedEvent)
|
||||
// console.log(displayedEvent.indexOf('finished') == -1)
|
||||
|
||||
// loop until finished
|
||||
if(displayedEvent.indexOf('finished') == -1) // if the message is different from finished, check again in 4s
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user