mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
fixing PHP warnings
This commit is contained in:
@@ -8,7 +8,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 TZ=Europe/London PORT=20211
|
|||||||
|
|
||||||
RUN apt-get update \
|
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 \
|
&& 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 \
|
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \
|
||||||
&& apt-get clean autoclean \
|
&& apt-get clean autoclean \
|
||||||
&& apt-get autoremove \
|
&& apt-get autoremove \
|
||||||
|
|||||||
@@ -74,9 +74,18 @@ Instructions for [pucherot's original code can be found here](https://github.com
|
|||||||
|
|
||||||
|
|
||||||
## 🔗 Other
|
## 🔗 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)
|
- [Device Management instructions](docs/DEVICE_MANAGEMENT.md)
|
||||||
- [Versions History](docs/VERSIONS_HISTORY.md)
|
- [Versions History](docs/VERSIONS_HISTORY.md)
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import requests
|
|||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from paho.mqtt import client as mqtt_client
|
from paho.mqtt import client as mqtt_client
|
||||||
import threading
|
import threading
|
||||||
|
from ssdpy import SSDPClient
|
||||||
|
import upnpclient
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# PATHS
|
# PATHS
|
||||||
@@ -631,6 +631,28 @@ def query_MAC_vendor (pMAC):
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def scan_network ():
|
def scan_network ():
|
||||||
reporting = False
|
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
|
# Header
|
||||||
file_print('Scan Devices')
|
file_print('Scan Devices')
|
||||||
@@ -2366,6 +2388,27 @@ def upgradeDB ():
|
|||||||
ALTER TABLE "Devices" ADD "dev_Network_Node_port" INTEGER
|
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
|
# don't hog DB access
|
||||||
closeDB ()
|
closeDB ()
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ services:
|
|||||||
# comment out / delete below lines, they are only for development purposes
|
# 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/pialert.py:/home/pi/pialert/back/pialert.py
|
||||||
- ${DEV_LOCATION}/back/update_vendors.sh:/home/pi/pialert/back/update_vendors.sh
|
- ${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/css:/home/pi/pialert/front/css
|
||||||
- ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js
|
- ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js
|
||||||
- ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php
|
- ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- local/path/pialert/config:/home/pi/pialert/config
|
- 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
|
# (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/setting_darkmode:/home/pi/pialert/db/setting_darkmode
|
||||||
# (optional) useful for debugging if you have issues setting up the container
|
# (optional) useful for debugging if you have issues setting up the container
|
||||||
|
|||||||
@@ -8,12 +8,15 @@
|
|||||||
#--------------------------------------------------------------------------- -->
|
#--------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if ($_SESSION["login"] != 1)
|
if(array_search('login', $_SESSION) != FALSE)
|
||||||
{
|
{
|
||||||
header('Location: index.php');
|
if ($_SESSION["login"] != 1)
|
||||||
exit;
|
{
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require 'php/templates/header.php';
|
require 'php/templates/header.php';
|
||||||
|
|||||||
@@ -1,36 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if ($_REQUEST['action'] == 'logout') {
|
if(array_search('action', $_REQUEST) != FALSE)
|
||||||
session_destroy();
|
{
|
||||||
setcookie("PiAler_SaveLogin", "", time() - 3600);
|
if ($_REQUEST['action'] == 'logout') {
|
||||||
header('Location: index.php');
|
session_destroy();
|
||||||
|
setcookie("PiAler_SaveLogin", "", time() - 3600);
|
||||||
|
header('Location: index.php');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ##################################################
|
// ##################################################
|
||||||
// ## Login Processing start
|
// ## Login Processing start
|
||||||
// ##################################################
|
// ##################################################
|
||||||
$config_file = "../config/pialert.conf";
|
$config_file = "../config/pialert.conf";
|
||||||
$config_file_lines = file($config_file);
|
$config_file_lines = file($config_file);
|
||||||
// ###################################
|
// ###################################
|
||||||
// ## Login language settings
|
// ## GUI settings processing start
|
||||||
// ###################################
|
// ###################################
|
||||||
if (file_exists('../db/setting_darkmode')) {
|
if (file_exists('../db/setting_darkmode')) {
|
||||||
$ENABLED_DARKMODE = True;
|
$ENABLED_DARKMODE = True;
|
||||||
}
|
}
|
||||||
foreach (glob("../db/setting_skin*") as $filename) {
|
foreach (glob("../db/setting_skin*") as $filename) {
|
||||||
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
||||||
}
|
}
|
||||||
if (strlen($pia_skin_selected) == 0) {$pia_skin_selected = 'skin-blue';}
|
if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';}
|
||||||
|
|
||||||
foreach (glob("../db/setting_language*") as $filename) {
|
|
||||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
|
||||||
}
|
|
||||||
if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';}
|
|
||||||
require 'php/templates/language/'.$pia_lang_selected.'.php';
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (glob("../db/setting_language*") as $filename) {
|
||||||
|
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||||
|
}
|
||||||
|
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = 'en_us';}
|
||||||
|
require '/home/pi/pialert/front/php/templates/language/'.$pia_lang_selected.'.php';
|
||||||
// ###################################
|
// ###################################
|
||||||
// ## Login language settings
|
// ## GUI settings processing end
|
||||||
// ###################################
|
// ###################################
|
||||||
foreach (glob("../db/setting_language*") as $filename) {
|
foreach (glob("../db/setting_language*") as $filename) {
|
||||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||||
|
|||||||
@@ -427,11 +427,8 @@ if ($_REQUEST['tab'] == '1') {
|
|||||||
</div>
|
</div>
|
||||||
<!-- ------------------------------------------------------------------------------ -->
|
<!-- ------------------------------------------------------------------------------ -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="box">
|
<div class="box-body" style="text-align: center;">
|
||||||
<div class="box-body" style="text-align: center;">
|
|
||||||
<h5 class="text-aqua" style="font-size: 16px;">
|
<h5 class="text-aqua" style="font-size: 16px;">
|
||||||
<span id="lastCommit">
|
<span id="lastCommit">
|
||||||
|
|
||||||
@@ -441,21 +438,28 @@ if ($_REQUEST['tab'] == '1') {
|
|||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div style="width: 100%; height: 20px;"></div>
|
<div style="width: 100%; height: 20px;"></div>
|
||||||
<!-- ----------------------------------------------------------------------- -->
|
<!-- ----------------------------------------------------------------------- -->
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- /.content -->
|
<!-- /.content -->
|
||||||
|
<?php
|
||||||
|
require 'php/templates/footer.php';
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.content-wrapper -->
|
<!-- /.content-wrapper -->
|
||||||
|
|
||||||
<!-- ----------------------------------------------------------------------- -->
|
<!-- ----------------------------------------------------------------------- -->
|
||||||
<?php
|
|
||||||
require 'php/templates/footer.php';
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,38 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ## TimeZone processing
|
// ## TimeZone processing
|
||||||
$config_file = "../../../config/pialert.conf";
|
$configFolderPath = "/home/pi/pialert/config/";
|
||||||
$config_file_lines = file($config_file);
|
$config_file = "pialert.conf";
|
||||||
|
$logFolderPath = "/home/pi/pialert/front/log/";
|
||||||
|
$log_file = "pialert_front.log";
|
||||||
|
|
||||||
|
|
||||||
|
$fullConfPath = $configFolderPath.$config_file;
|
||||||
|
|
||||||
|
$config_file_lines = file($fullConfPath);
|
||||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
|
||||||
$Pia_TimeZone = $timezone_line[1];
|
$timeZone = "";
|
||||||
date_default_timezone_set($Pia_TimeZone);
|
|
||||||
|
foreach ($config_file_lines as $line)
|
||||||
|
{
|
||||||
|
if( preg_match('/TIMEZONE(.*?)/', $line, $match) == 1 )
|
||||||
|
{
|
||||||
|
if (preg_match('/\'(.*?)\'/', $line, $match) == 1) {
|
||||||
|
$timeZone = $match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($timeZone == "")
|
||||||
|
{
|
||||||
|
$timeZone = "Europe/Berlin";
|
||||||
|
}
|
||||||
|
|
||||||
|
date_default_timezone_set($timeZone);
|
||||||
|
|
||||||
|
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||||
|
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// DB File Path
|
// DB File Path
|
||||||
|
|||||||
@@ -7,24 +7,54 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// ## TimeZone processing
|
// ###################################
|
||||||
$config_file = "../../../config/pialert.conf";
|
// ## TimeZone processing start
|
||||||
$config_file_lines = file($config_file);
|
// ###################################
|
||||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
|
||||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
|
||||||
$Pia_TimeZone = $timezone_line[1];
|
|
||||||
date_default_timezone_set($Pia_TimeZone);
|
|
||||||
|
|
||||||
foreach (glob("../../../db/setting_language*") as $filename) {
|
$configFolderPath = "/home/pi/pialert/config/";
|
||||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
$config_file = "pialert.conf";
|
||||||
|
$logFolderPath = "/home/pi/pialert/front/log/";
|
||||||
|
$log_file = "pialert_front.log";
|
||||||
|
|
||||||
|
|
||||||
|
$fullConfPath = $configFolderPath.$config_file;
|
||||||
|
|
||||||
|
$config_file_lines = file($fullConfPath);
|
||||||
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
|
|
||||||
|
$timeZone = "";
|
||||||
|
|
||||||
|
foreach ($config_file_lines as $line)
|
||||||
|
{
|
||||||
|
if( preg_match('/TIMEZONE(.*?)/', $line, $match) == 1 )
|
||||||
|
{
|
||||||
|
if (preg_match('/\'(.*?)\'/', $line, $match) == 1) {
|
||||||
|
$timeZone = $match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';}
|
|
||||||
|
if($timeZone == "")
|
||||||
|
{
|
||||||
|
$timeZone = "Europe/Berlin";
|
||||||
|
}
|
||||||
|
|
||||||
|
date_default_timezone_set($timeZone);
|
||||||
|
|
||||||
|
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||||
|
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||||
|
|
||||||
|
// ###################################
|
||||||
|
// ## TimeZone processing end
|
||||||
|
// ###################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// External files
|
// External files
|
||||||
require 'db.php';
|
require 'db.php';
|
||||||
require 'util.php';
|
require 'util.php';
|
||||||
require '../templates/language/'.$pia_lang_selected.'.php';
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Action selector
|
// Action selector
|
||||||
|
|||||||
@@ -7,14 +7,6 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// ## TimeZone processing
|
|
||||||
$config_file = "../../../config/pialert.conf";
|
|
||||||
$config_file_lines = file($config_file);
|
|
||||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
|
||||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
|
||||||
$Pia_TimeZone = $timezone_line[1];
|
|
||||||
date_default_timezone_set($Pia_TimeZone);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// External files
|
// External files
|
||||||
require 'db.php';
|
require 'db.php';
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ function getParameter() {
|
|||||||
$parameter = $_REQUEST['parameter'];
|
$parameter = $_REQUEST['parameter'];
|
||||||
$sql = 'SELECT par_Value FROM Parameters
|
$sql = 'SELECT par_Value FROM Parameters
|
||||||
WHERE par_ID="'. quotes($_REQUEST['parameter']) .'"';
|
WHERE par_ID="'. quotes($_REQUEST['parameter']) .'"';
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||||
$value = $row[0];
|
$value = $row[0];
|
||||||
|
|||||||
@@ -19,12 +19,8 @@ $log_file = "pialert_front.log";
|
|||||||
|
|
||||||
$fullConfPath = $configFolderPath.$config_file;
|
$fullConfPath = $configFolderPath.$config_file;
|
||||||
|
|
||||||
chmod($fullConfPath, 0777);
|
|
||||||
|
|
||||||
$config_file_lines = file($fullConfPath);
|
$config_file_lines = file($fullConfPath);
|
||||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
|
||||||
$Pia_TimeZone = $timezone_line[1];
|
|
||||||
|
|
||||||
$timeZone = "";
|
$timeZone = "";
|
||||||
|
|
||||||
@@ -52,11 +48,38 @@ $timestamp = $date->format('Y-m-d_H-i-s');
|
|||||||
// ###################################
|
// ###################################
|
||||||
// ## TimeZone processing end
|
// ## TimeZone processing end
|
||||||
// ###################################
|
// ###################################
|
||||||
|
// ###################################
|
||||||
|
// ## GUI settings processing start
|
||||||
|
// ###################################
|
||||||
|
if (file_exists('../db/setting_darkmode')) {
|
||||||
|
$ENABLED_DARKMODE = True;
|
||||||
|
}
|
||||||
|
foreach (glob("../db/setting_skin*") as $filename) {
|
||||||
|
$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';}
|
||||||
|
|
||||||
|
foreach (glob("../db/setting_language*") as $filename) {
|
||||||
|
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||||
|
}
|
||||||
|
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = 'en_us';}
|
||||||
|
require '/home/pi/pialert/front/php/templates/language/'.$pia_lang_selected.'.php';
|
||||||
|
// ###################################
|
||||||
|
// ## GUI settings processing end
|
||||||
|
// ###################################
|
||||||
|
$FUNCTION = [];
|
||||||
|
$SETTINGS = [];
|
||||||
|
|
||||||
|
|
||||||
$FUNCTION = $_REQUEST['function'];
|
if(array_search('function', $FUNCTION) != FALSE)
|
||||||
$SETTINGS = $_REQUEST['settings'];
|
{
|
||||||
|
$FUNCTION = $_REQUEST['function'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_search('function', $SETTINGS) != FALSE)
|
||||||
|
{
|
||||||
|
$SETTINGS = $_REQUEST['settings'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($FUNCTION == 'savesettings') {
|
if ($FUNCTION == 'savesettings') {
|
||||||
saveSettings();
|
saveSettings();
|
||||||
@@ -120,7 +143,7 @@ function formatIPlong ($IP) {
|
|||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Others functions
|
// Other functions
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
function checkPermissions($files)
|
function checkPermissions($files)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<!-- © 2020 Puche -->
|
<!-- © 2020 Puche -->
|
||||||
<?php
|
<?php
|
||||||
echo '<span style="display:inline-block; transform: rotate(180deg)">©</span> 2020 Puche (+2022 jokob-sk)';
|
echo '<span style="display:inline-block; transform: rotate(180deg)">©</span> 2020 Puche (2022+ jokob-sk)';
|
||||||
?>
|
?>
|
||||||
<!-- To the right -->
|
<!-- To the right -->
|
||||||
<div class="pull-right no-hidden-xs">
|
<div class="pull-right no-hidden-xs">
|
||||||
|
|||||||
@@ -20,12 +20,8 @@ $log_file = "pialert_front.log";
|
|||||||
|
|
||||||
$fullConfPath = $configFolderPath.$config_file;
|
$fullConfPath = $configFolderPath.$config_file;
|
||||||
|
|
||||||
chmod($fullConfPath, 0777);
|
|
||||||
|
|
||||||
$config_file_lines = file($fullConfPath);
|
$config_file_lines = file($fullConfPath);
|
||||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
|
||||||
$Pia_TimeZone = $timezone_line[1];
|
|
||||||
|
|
||||||
$timeZone = "";
|
$timeZone = "";
|
||||||
|
|
||||||
@@ -63,12 +59,12 @@ if (file_exists('../db/setting_darkmode')) {
|
|||||||
foreach (glob("../db/setting_skin*") as $filename) {
|
foreach (glob("../db/setting_skin*") as $filename) {
|
||||||
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
||||||
}
|
}
|
||||||
if (strlen($pia_skin_selected) == 0) {$pia_skin_selected = 'skin-blue';}
|
if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';}
|
||||||
|
|
||||||
foreach (glob("../db/setting_language*") as $filename) {
|
foreach (glob("../db/setting_language*") as $filename) {
|
||||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||||
}
|
}
|
||||||
if (strlen($pia_lang_selected) == 0) {$pia_lang_selected = 'en_us';}
|
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = 'en_us';}
|
||||||
require 'php/templates/language/'.$pia_lang_selected.'.php';
|
require 'php/templates/language/'.$pia_lang_selected.'.php';
|
||||||
// ###################################
|
// ###################################
|
||||||
// ## GUI settings processing end
|
// ## GUI settings processing end
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ $pia_lang['REPORT_WEBHOOK_description'] = 'Enable webhooks for notifications. If
|
|||||||
$pia_lang['WEBHOOK_URL_name'] = 'Target URL';
|
$pia_lang['WEBHOOK_URL_name'] = 'Target URL';
|
||||||
$pia_lang['WEBHOOK_URL_description'] = 'Target URL starting with <code>http://</code> or <code>https://</code>.';
|
$pia_lang['WEBHOOK_URL_description'] = 'Target URL starting with <code>http://</code> or <code>https://</code>.';
|
||||||
$pia_lang['WEBHOOK_PAYLOAD_name'] = 'Payload type';
|
$pia_lang['WEBHOOK_PAYLOAD_name'] = 'Payload type';
|
||||||
$pia_lang['WEBHOOK_PAYLOAD_description'] = 'The Webhook payload data format for the "body > attachements > text" attribute in the payload json. See an examnple of the payload <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/webhook_json_sample.json">here</a>. (e.g.: for discord use <code>\'html\'</code>)';
|
$pia_lang['WEBHOOK_PAYLOAD_description'] = 'The Webhook payload data format for the "body > attachements > text" attribute in the payload json. See an example of the payload <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/webhook_json_sample.json">here</a>. (e.g.: for discord use <code>\'html\'</code>)';
|
||||||
$pia_lang['WEBHOOK_REQUEST_METHOD_name'] = 'Request method';
|
$pia_lang['WEBHOOK_REQUEST_METHOD_name'] = 'Request method';
|
||||||
$pia_lang['WEBHOOK_REQUEST_METHOD_description'] = 'The HTTP request method to be used for the webhook call.';
|
$pia_lang['WEBHOOK_REQUEST_METHOD_description'] = 'The HTTP request method to be used for the webhook call.';
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ $db->close();
|
|||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<input class="form-control " id="ipMask" type="text" placeholder="192.168.1.0/24"/>
|
<input class="form-control " id="ipMask" type="text" placeholder="192.168.1.0/24"/>
|
||||||
</div>';
|
</div>';
|
||||||
|
// Add interface button
|
||||||
$input = $input.
|
$input = $input.
|
||||||
'<div class="col-xs-3">
|
'<div class="col-xs-3">
|
||||||
<input class="form-control " id="ipInterface" type="text" placeholder="eth0" />
|
<input class="form-control " id="ipInterface" type="text" placeholder="eth0" />
|
||||||
@@ -193,16 +194,18 @@ $db->close();
|
|||||||
<div class="col-xs-3"><button class="btn btn-primary" onclick="addInterface()" >Add</button></div>
|
<div class="col-xs-3"><button class="btn btn-primary" onclick="addInterface()" >Add</button></div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
|
// list all interfaces as options
|
||||||
$input = $input.'<div class="form-group">
|
$input = $input.'<div class="form-group">
|
||||||
<select class="form-control" name="'.$set['Code_Name'].'" id="'.$set['Code_Name'].'" multiple readonly>';
|
<select class="form-control" name="'.$set['Code_Name'].'" id="'.$set['Code_Name'].'" multiple readonly>';
|
||||||
$options = createArray($set['Value']);
|
|
||||||
|
$options = createArray($set['Value']);
|
||||||
|
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
|
|
||||||
$input = $input.'<option value="'.$option.'" disabled>'.$option.'</option>';
|
$input = $input.'<option value="'.$option.'" disabled>'.$option.'</option>';
|
||||||
}
|
}
|
||||||
$input = $input.'</select></div>';
|
$input = $input.'</select></div>';
|
||||||
|
// Remove all interfaces button
|
||||||
$input = $input.'<div><button class="btn btn-primary" onclick="removeInterfaces()">Remove all</button></div>';
|
$input = $input.'<div><button class="btn btn-primary" onclick="removeInterfaces()">Remove all</button></div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user