From 338d163fd4253543875f6fa1c5bcb35d55959666 Mon Sep 17 00:00:00 2001 From: leiweibau <105860611+leiweibau@users.noreply.github.com> Date: Wed, 20 Jul 2022 18:51:39 +0200 Subject: [PATCH 1/2] wording changed idea from https://github.com/Final-Hawk/Pi.Alert/commit/9ca3ae0caa2f67fde2231976ce3283a1336d29c1 --- front/deviceDetails.php | 4 ++-- front/php/templates/language/de_de.php | 2 ++ front/php/templates/language/en_us.php | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 88243507..b5b11762 100644 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -321,9 +321,9 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D diff --git a/front/php/templates/language/de_de.php b/front/php/templates/language/de_de.php index a49e6f2c..e2e9f256 100644 --- a/front/php/templates/language/de_de.php +++ b/front/php/templates/language/de_de.php @@ -135,6 +135,8 @@ $pia_lang['DevDetail_EveandAl_Skip'] = 'pausiere wiederhol. Meldungen für'; $pia_lang['DevDetail_EveandAl_NewDevice'] = 'Neues Gerät'; $pia_lang['DevDetail_EveandAl_Archived'] = 'Archivierung'; $pia_lang['DevDetail_EveandAl_RandomMAC'] = 'Zufällige MAC'; +$pia_lang['DevDetail_EveandAl_ScanCycle_a'] = 'Gerät scannen (1 min)'; +$pia_lang['DevDetail_EveandAl_ScanCycle_z'] = 'Gerät nicht scannen (0 min)'; $pia_lang['DevDetail_button_Delete'] = 'Lösche Gerät'; $pia_lang['DevDetail_button_Reset'] = 'Verwerfen'; $pia_lang['DevDetail_button_Save'] = 'Speichern'; diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index cea6f1da..b560ba4b 100644 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -135,6 +135,8 @@ $pia_lang['DevDetail_EveandAl_Skip'] = 'Skip repeated notifications during'; $pia_lang['DevDetail_EveandAl_NewDevice'] = 'New Device'; $pia_lang['DevDetail_EveandAl_Archived'] = 'Archived'; $pia_lang['DevDetail_EveandAl_RandomMAC'] = 'Random MAC'; +$pia_lang['DevDetail_EveandAl_ScanCycle_a'] = 'Scan Device (1 min)'; +$pia_lang['DevDetail_EveandAl_ScanCycle_z'] = 'Don't Scan Device (0 min)'; $pia_lang['DevDetail_button_Delete'] = 'Delete Device'; $pia_lang['DevDetail_button_Reset'] = 'Reset Changes'; $pia_lang['DevDetail_button_Save'] = 'Save'; From 1928d1b581c989be2b21894130d500722807064a Mon Sep 17 00:00:00 2001 From: leiweibau <105860611+leiweibau@users.noreply.github.com> Date: Wed, 20 Jul 2022 21:21:21 +0200 Subject: [PATCH 2/2] basic support for pushsafer.com Currently, only a message with the link to the pi.alert page is sent. I am still struggling with the display of more detailed information. --- back/pialert.py | 28 ++++++++++++++++++++++++++++ config/pialert.conf | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/back/pialert.py b/back/pialert.py index 9e885b27..7fc7ecef 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -27,6 +27,8 @@ import socket import io import smtplib import csv +from urllib.parse import urlencode +from urllib.request import Request, urlopen #=============================================================================== @@ -1359,6 +1361,11 @@ def email_reporting (): print (' Skip mail...') else : print (' No changes to report...') + if REPORT_PUSHSAFER : + print (' Sending report by PUSHSAFER...') + send_pushsafer (mail_text) + else : + print (' Skip PUSHSAFER...') # Clean Pending Alert Events @@ -1376,6 +1383,27 @@ def email_reporting (): sql_connection.commit() closeDB() +#------------------------------------------------------------------------------- + +def send_pushsafer (_Text): + url = 'https://www.pushsafer.com/api' + post_fields = { + "t" : 'Pi.Alert Message', + "m" : 'Something has changed', + "s" : 11, + "v" : 3, + "i" : 148, + "c" : '#ef7f7f', + "d" : 'a', + "u" : REPORT_DASHBOARD_URL, + "ut" : 'Open Pi.Alert', + "k" : PUSHSAFER_TOKEN, + } + + request = Request(url, urlencode(post_fields).encode()) + json = urlopen(request).read().decode() + # print(json) + #------------------------------------------------------------------------------- def format_report_section (pActive, pSection, pTable, pText, pHTML): global mail_text diff --git a/config/pialert.conf b/config/pialert.conf index 65c0bf03..d58f0f3d 100644 --- a/config/pialert.conf +++ b/config/pialert.conf @@ -23,6 +23,10 @@ REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>' REPORT_TO = 'user@gmail.com' REPORT_DEVICE_URL = 'http://pi.alert/deviceDetails.php?mac=' +REPORT_PUSHSAFER = False +REPORT_DASHBOARD_URL = '' +PUSHSAFER_TOKEN = 'ApiKey' + # QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip' QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com' DDNS_ACTIVE = False