From 0714aea30d10bae40b6961500d05571a5d3b0b1e Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 24 Dec 2022 21:57:43 +1100 Subject: [PATCH] fixing PHP warnings --- Dockerfile | 2 +- README.md | 9 +++++ back/pialert.py | 47 +++++++++++++++++++++- docker-compose.yml | 1 + dockerfiles/README.md | 2 +- front/devices.php | 11 ++++-- front/index.php | 43 ++++++++++---------- front/maintenance.php | 18 +++++---- front/php/server/db.php | 36 ++++++++++++++--- front/php/server/devices.php | 54 ++++++++++++++++++++------ front/php/server/events.php | 8 ---- front/php/server/parameters.php | 1 + front/php/server/util.php | 37 ++++++++++++++---- front/php/templates/footer.php | 2 +- front/php/templates/header.php | 8 +--- front/php/templates/language/en_us.php | 2 +- front/settings.php | 11 ++++-- 17 files changed, 213 insertions(+), 79 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd297e62..323748db 100755 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 TZ=Europe/London PORT=20211 RUN apt-get update \ && apt-get install --no-install-recommends tini ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip -y \ - && pip3 install requests paho-mqtt \ + && pip3 install requests paho-mqtt ssdpy upnpclient \ && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \ && apt-get clean autoclean \ && apt-get autoremove \ diff --git a/README.md b/README.md index 3c5a8ad2..9fd7176b 100755 --- a/README.md +++ b/README.md @@ -74,9 +74,18 @@ Instructions for [pucherot's original code can be found here](https://github.com ## 🔗 Other + + +### Alternatives + + - [WatchYourLAN](https://github.com/aceberg/WatchYourLAN) - Lightweight network IP scanner with web GUI (Open source) + - [Fing](https://www.fing.com/) - Network scanner app for your Internet security (Commercial, Phone App, Proprietary hardware) + +### Old docs + - [Device Management instructions](docs/DEVICE_MANAGEMENT.md) - [Versions History](docs/VERSIONS_HISTORY.md) diff --git a/back/pialert.py b/back/pialert.py index 68dcd2a4..0a66d465 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -34,8 +34,8 @@ import requests from base64 import b64encode from paho.mqtt import client as mqtt_client import threading - - +from ssdpy import SSDPClient +import upnpclient #=============================================================================== # PATHS @@ -631,6 +631,28 @@ def query_MAC_vendor (pMAC): #=============================================================================== def scan_network (): reporting = False + + # # devtest start + + # file_print("---------------------------------------------") + + # client = SSDPClient() + # devices = client.m_search("ssdp:all") + # for device in devices: + # file_print(device.get("usn")) + + # file_print("---------------------------------------------") + + # devices = upnpclient.discover() + + # file_print("---------------------------------------------") + + # for device in devices: + # file_print(device) + + # file_print("---------------------------------------------") + + # # devtest end # Header file_print('Scan Devices') @@ -2366,6 +2388,27 @@ def upgradeDB (): ALTER TABLE "Devices" ADD "dev_Network_Node_port" INTEGER """) + # Missing parameters in the Parameters table + missingSettings = len(sql.execute (""" + SELECT * FROM Parameters WHERE par_ID='Front_Events_Period' + """).fetchall()) == 0 + + if missingSettings: + file_print("[upgradeDB] Adding missing values into the Parameters table") + + params = [ + # General + ('Front_Events_Period', 'Subnets to scan'), + ('Front_Details_Sessions_Rows', '50'), + ('Front_Details_Events_Rows', '50'), + ('Front_Details_Events_Hide', 'True'), + ('Front_Events_Rows', '50'), + ('Front_Details_Period', '1 day') + ] + + sql.executemany ("""INSERT INTO Parameters ("Par_ID", "Par_Value") VALUES (?, ?)""", params) + + # don't hog DB access closeDB () diff --git a/docker-compose.yml b/docker-compose.yml index e3fcb4ea..437dee27 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: # comment out / delete below lines, they are only for development purposes - ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py - ${DEV_LOCATION}/back/update_vendors.sh:/home/pi/pialert/back/update_vendors.sh + # - ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 30a38272..c8318bb2 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -92,7 +92,7 @@ services: restart: unless-stopped volumes: - local/path/pialert/config:/home/pi/pialert/config - - local/path/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db + - 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 # (optional) useful for debugging if you have issues setting up the container diff --git a/front/devices.php b/front/devices.php index e42c9b3d..a4b18f82 100755 --- a/front/devices.php +++ b/front/devices.php @@ -8,12 +8,15 @@ #--------------------------------------------------------------------------- --> - - -
-
+
@@ -441,21 +438,28 @@ if ($_REQUEST['tab'] == '1') {
+ +
+ + + +
+
- +