Compare commits

...

43 Commits

Author SHA1 Message Date
jokob-sk
f8cf7f0717 Increase once off Pholus run timeout 2023-02-02 18:46:48 +11:00
Jokob-sk
29a6b78f27 Cleanup 2023-02-02 18:45:30 +11:00
Jokob-sk
388370b49d Txt message cleanup 0.1 2023-02-01 21:53:23 +11:00
Jokob-sk
4d67c25e5a Txt message cleanup 2023-02-01 21:46:59 +11:00
Jokob-sk
eec0dcca82 n8n updated example + formating 2023-02-01 20:40:14 +11:00
Jokob-sk
7ea74d0fe3 Mior Language in config fixes 0.1 2023-02-01 00:05:47 +11:00
Jokob-sk
0c635534a1 Merge branch 'main' of https://github.com/jokob-sk/Pi.Alert 2023-01-31 23:55:50 +11:00
Jokob-sk
f70a3a4207 Rework of notification templates 0.5 2023-01-31 23:55:15 +11:00
jokob-sk
0fc174b5b3 Merge pull request #158 from mariorodriguezlopez/main
Language in database
2023-01-31 12:54:40 +00:00
Jokob-sk
d4eddf042d Rework of notification templates 0.4 2023-01-31 23:25:21 +11:00
Mario Rodriguez
a4210c7e6b Merge pull request #2 from mariorodriguezlopez/Lang
lang in db
2023-01-31 12:11:47 +01:00
Mario Rodriguez
106438d61d lang in db 2023-01-31 12:10:07 +01:00
Jokob-sk
94365d2cc9 Apprise payload type setting 2023-01-31 22:08:35 +11:00
Mario Rodriguez
b633c43078 Exclude vscode folder 2023-01-31 09:27:42 +01:00
Mario Rodriguez
84c3f1d786 Merge pull request #1 from jokob-sk/main
Sinc
2023-01-31 09:10:57 +01:00
Jokob-sk
1c963e9aff Rework of notification templates 0.3 2023-01-30 23:14:54 +11:00
Jokob-sk
a2fe7f79cc Rework of notification templates 0.2 2023-01-30 23:12:19 +11:00
Jokob-sk
8dabdb3f11 Rework of notification templates 0.1 2023-01-30 23:02:05 +11:00
Jokob-sk
b9f2957104 Rework of notification templates 2023-01-30 23:00:02 +11:00
Jokob-sk
bdeda87600 Better font and node scaling in Network 2023-01-29 15:27:20 +11:00
Jokob-sk
e98a538f53 API 0.3 2023-01-29 14:42:43 +11:00
Jokob-sk
2e0cb923db Column settings preserved after restart 2023-01-29 14:13:31 +11:00
Jokob-sk
2e532abf6b API v0.2 2023-01-29 12:32:48 +11:00
Jokob-sk
51e865c98d API v0.1 2023-01-29 00:07:46 +11:00
Jokob-sk
2c27248aa1 Addd subprocess timeout into Pholus 0.2 2023-01-27 00:07:34 +11:00
Jokob-sk
43c2084e15 Addd subprocess timeout into Pholus + cleanup 2023-01-26 23:44:54 +11:00
Jokob-sk
14cb0f46f3 New columns: Connected devices, Location, Vendor 2023-01-26 12:01:12 +11:00
Jokob-sk
162d507468 Prep work for flat tree backup 2023-01-26 11:07:16 +11:00
Jokob-sk
8624851cf5 Prep work for flat tree 2023-01-25 23:50:02 +11:00
Jokob-sk
2d92e93b7b Guides updates 2023-01-24 23:00:58 +11:00
Jokob-sk
78f9018083 Empty fields on New Devices selection 2023-01-24 21:58:01 +11:00
Jokob-sk
ecb8a01aaa Guides updates 0.2 2023-01-24 21:36:16 +11:00
Jokob-sk
cca2c99f6b Guides updates 0.1 2023-01-24 21:18:34 +11:00
Jokob-sk
028d0dd7d8 Guides updates 2023-01-24 21:17:06 +11:00
Jokob-sk
7753e0481c Network tree guide 2023-01-24 21:03:35 +11:00
Jokob-sk
5b35e68cf2 GMAIL as SMTP guide 2023-01-23 23:00:21 +11:00
Jokob-sk
8b4115fe48 Order fix on restart 2023-01-23 22:51:29 +11:00
Jokob-sk
8bc1c3e0ed Column order bogfix in network 2023-01-23 22:39:18 +11:00
Jokob-sk
69061ed537 Last IP ordering fix 2023-01-23 22:15:57 +11:00
Jokob-sk
f151b1268d Network tre refresh on device (un-)assign 2023-01-23 22:12:48 +11:00
Jokob-sk
35d9c0e548 Fix Network scaling, DeviceDetials link, missing lang string, incorrectly mapped columns, default device values 2023-01-23 21:18:27 +11:00
Jokob-sk
7baae289d1 Fix Device table not loading 2023-01-23 00:03:34 +11:00
Jokob-sk
a33c50361f Remove references to setting_darkmode 2023-01-22 17:03:49 +11:00
51 changed files with 1853 additions and 1439 deletions

4
.gitignore vendored
View File

@@ -1,4 +1,8 @@
.vscode
.DS_Store
config/pialert.conf
db/*
front/log/*
front/api/*
**/%40eaDir/
**/@eaDir/

View File

@@ -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 scapy cron-converter pytz \
&& pip3 install requests paho-mqtt scapy cron-converter pytz json2table \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \
&& apt-get clean autoclean \
&& apt-get autoremove \

View File

@@ -31,11 +31,12 @@ The system continuously scans the network for, **New devices**, **New connection
that were not discovered by the other methods.
## 🧩 Notification Integrations
## 🧩 Integrations
- [Apprise](https://hub.docker.com/r/caronc/apprise), [Pushsafer](https://www.pushsafer.com/), [NTFY](https://ntfy.sh/)
- [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md) ([sample JSON](docs/webhook_json_sample.json))
- Home Assistant via [MQTT](https://www.home-assistant.io/integrations/mqtt/)
- discovery ~10s per device, deleting not supported, use [MQTT Explorer](https://mqtt-explorer.com/) for now
- A simple [API endpoint](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md)
## 🔐 Security

File diff suppressed because it is too large Load Diff

173
back/report_sample.html Executable file
View File

@@ -0,0 +1,173 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_template.html - Back module. Template to email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html>
<head></head>
<body>
<font face=sans-serif>
<table align=center width=100% cellpadding=0 cellspacing=0 style="border-radius: 5px;">
<tr>
<td bgcolor=#EFB956 align=center style="padding: 20px 10px 10px 10px; font-size: 30px; font-weight: bold; color:#000000; border-top-right-radius: 5px; border-top-left-radius: 5px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
Pi.Alert Report
</td>
</tr>
<tr>
<td bgcolor=#2656f1 width=100% align=center style="padding: 20px 10px 10px 10px; font-size: 20px; font-weight: bold; color:#ffffff; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<a style="color:#ffffff;cursor:pointer;" href="https://github.com/jokob-sk/Pi.Alert/releases">🆕 New version available 🆕</a>
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#FFD966 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#404040">
<tr>
<td width=100%> Report Date: <b>2023-01-30 22:17</b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor=#F5F5F5 height=200 valign=top style="padding: 10px">
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' >New devices</th>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Datetime</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >IP</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Event Type</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Device name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Comments</th>
</tr>
<tr>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>2023-01-30 22:15:09</td>
<td>192.168.1.1</td>
<td>New Device</td>
<td>(name not found)</td>
<td></td>
</tr>
<tr>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>2023-01-30 22:17:59</td>
<td>192.168.1.82</td>
<td>New Device</td>
<td>(name not found)</td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' >Events</th>
</tr>
<tr>
<td>
<ul>
<li>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Datetime</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >IP</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Event Type</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Device name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Comments</th>
</tr>
<tr>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>2023-01-30 22:15:09</td>
<td>192.168.1.92</td>
<td>Disconnected</td>
<td>(name not found)</td>
<td></td>
</tr>
</table>
</li>
</ul>
</td>
</tr>
</table>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' >Changed or new ports</th>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th>new</th>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Port</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >State</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Service</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Extra</th>
</tr>
<tr>
<td>New device</td>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>3263/tcp</td>
<td>open</td>
<td>ecolor-imager</td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Port</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >State</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Service</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Extra</th>
</tr>
<tr>
<td>New device</td>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>3264/tcp</td>
<td>open</td>
<td>ccmail</td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<tr>
<td>
<table width=100% bgcolor=#46802e cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<td width=50% style="text-align:center"> Pi.Alert - Synology-NAS</td>
</tr>
</table>
</td>
</tr>
</table>
</font>
</body>
</html>

View File

@@ -1,143 +0,0 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_sample.html - Back module. Sample email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html>
<head>
</head>
<body>
<font face=sans-serif>
<table align=center width=80% border=1 bordercolor=#909090 cellpadding=0 cellspacing=0 style="border-collapse: collapse; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.5)">
<tr>
<td bgcolor=#EFB956 align=center style="padding: 20px 10px 10px 10px; font-size: 36px; font-weight: bold; color:#7F6000; text-shadow: 4px 4px 6px #909090">
Pi.Alert Report
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#FFD966 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 16px; text-align:center; color:#5F5000">
<tr>
<td width=33%> Report Date: <b>2021-01-01 08:00</b> </td>
<td width=34%> Scan Cycle: <b>1</b> </td>
<td width=33%> Server: <b>pi4</b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor=#F5F5F5 height=400 valign=top style="padding: 20px">
<p style="font-size: 14px; font-weight: bold; color:#C04040; text-shadow: 2px 2px 4px #A0A0A0"> New Devices: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Vendor </th>
</tr>
<tr>
<td> f8:d0:27:00:00:00 </td>
<td> 2021-01-01 08:00:00 </td>
<td> 192.168.1.20 </td>
<td> Seiko Epson Corporation </td>
</tr>
<tr>
<td> c8:6c:3d:00:00:00 </td>
<td> 2021-01-01 08:00:00 </td>
<td> 192.168.1.181 </td>
<td> Amazon Technologies Inc. </td>
</tr>
</table>
<br>
<p style="font-size: 14px; font-weight: bold; color:#C04040; text-shadow: 2px 2px 4px #A0A0A0"> Devices Down: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Device Name </th>
</tr>
<tr>
<td> 0c:ee:99:00:00:00 </td>
<td> 2021-01-01 08:00:00 </td>
<td> 192.168.1.171 </td>
<td> Alexa - Echo </td>
</tr>
</table>
<br>
<p style="font-size: 14px; font-weight: bold; color:#409040; text-shadow: 2px 2px 4px #A0A0A0"> Events: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th width=100> Event Type </th>
<th width=140> Device Name </th>
<th> Additional Info </th>
</tr>
<tr>
<td> 94:0c:98:00:00:00 </td>
<td> 2021-01-01 08:00:00 </td>
<td> 192.168.1.132 </td>
<td> Connected </td>
<td> Person 1 - iPhone 11 </td>
<td> </td>
</tr>
<tr>
<td> 5c:41:5a:00:00:00 </td>
<td> 2021-01-01 08:00:00 </td>
<td> 192.168.1.170 </td>
<td> IP Changed </td>
<td> Alexa Dot </td>
<td> Previous IP: 192.168.1.243 </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#70AD47 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 12px; font-weight: bold; color:#385723">
<tr>
<td width=25% style="text-align:Left"> Puche 2021</td>
<td width=50% style="text-align:center"> Pi.Alert 2.50 &nbsp; / &nbsp; 2021-01-01 </td>
<td width=25% style="text-align:right"> GNU GPLv3</td>
</tr>
</table>
</td>
</tr>
</table>
</font>
</body>
</html>

View File

@@ -32,74 +32,16 @@
<tr>
<td bgcolor=#F5F5F5 height=200 valign=top style="padding: 10px">
<SECTION_INTERNET>
<p style="font-size: 24px; font-weight: bold; color:#C04040"> Internet: </p>
<INTERNET_TABLE>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#f0f0f0">
<th width=140> Event Type </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Additional Info </th>
</tr>
<TABLE_INTERNET>
</table>
<br>
</SECTION_INTERNET>
<SECTION_NEW_DEVICES>
<p style="font-size: 14px; font-weight: bold; color:#C04040"> New Devices: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=150> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th width=140> Device Name </th>
<th> Vendor </th>
</tr>
<TABLE_NEW_DEVICES>
</table>
<br>
</SECTION_NEW_DEVICES>
<SECTION_DEVICES_DOWN>
<p style="font-size: 14px; font-weight: bold; color:#C04040"> Devices Down: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Device Name </th>
</tr>
<TABLE_DEVICES_DOWN>
</table>
<br>
</SECTION_DEVICES_DOWN>
<SECTION_EVENTS>
<p style="font-size: 14px; font-weight: bold; color:#409040"> Events: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th width=100> Event Type </th>
<th width=140> Device Name </th>
<th> Additional Info </th>
</tr>
<TABLE_EVENTS>
</table>
</SECTION_EVENTS>
<NEW_DEVICES_TABLE>
<DOWN_DEVICES_TABLE>
<EVENTS_TABLE>
<PORTS_TABLE>
</td>
</tr>

View File

@@ -1,19 +1,8 @@
Report Date: <REPORT_DATE>
Server: <SERVER_NAME>
<SECTION_NEW_DEVICES>
New Devices
----------------------
<TABLE_NEW_DEVICES>
</SECTION_NEW_DEVICES><SECTION_DEVICES_DOWN>
Devices Down
----------------------
<TABLE_DEVICES_DOWN>
</SECTION_DEVICES_DOWN><SECTION_EVENTS>
Events
----------------------
<TABLE_EVENTS>
</SECTION_EVENTS><SECTION_INTERNET>
Internet
----------------------
<TABLE_INTERNET>
</SECTION_INTERNET>
<SECTION_DEVICES_DOWN>
<SECTION_EVENTS>
<SECTION_INTERNET>
<PORTS_TABLE>

View File

@@ -21,7 +21,7 @@
</td>
</tr>
<tr>
<td bgcolor=#2656f1 width=100% align=center style="padding: 20px 10px 10px 10px; font-size: 20px; font-weight: bold; color:#ffffff; border-top-right-radius: 5px; border-top-left-radius: 5px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<td bgcolor=#2656f1 width=100% align=center style="padding: 20px 10px 10px 10px; font-size: 20px; font-weight: bold; color:#ffffff; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<a style="color:#ffffff;cursor:pointer;" href="https://github.com/jokob-sk/Pi.Alert/releases">🆕 New version available 🆕</a>
</td>
</tr>
@@ -36,76 +36,16 @@
<tr>
<td bgcolor=#F5F5F5 height=200 valign=top style="padding: 10px">
<SECTION_INTERNET>
<p style="font-size: 24px; font-weight: bold; color:#C04040"> Internet: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#f0f0f0">
<th width=140> Event Type </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Additional Info </th>
</tr>
<INTERNET_TABLE>
<TABLE_INTERNET>
</table>
<br>
</SECTION_INTERNET>
<SECTION_NEW_DEVICES>
<p style="font-size: 14px; font-weight: bold; color:#C04040"> New Devices: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=150> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th width=140> Device Name </th>
<th> Vendor </th>
</tr>
<TABLE_NEW_DEVICES>
</table>
<br>
</SECTION_NEW_DEVICES>
<SECTION_DEVICES_DOWN>
<p style="font-size: 14px; font-weight: bold; color:#C04040"> Devices Down: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Device Name </th>
</tr>
<TABLE_DEVICES_DOWN>
</table>
<br>
</SECTION_DEVICES_DOWN>
<SECTION_EVENTS>
<p style="font-size: 14px; font-weight: bold; color:#409040"> Events: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> MAC </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th width=100> Event Type </th>
<th width=140> Device Name </th>
<th> Additional Info </th>
</tr>
<TABLE_EVENTS>
</table>
</SECTION_EVENTS>
</td>
</tr>
<NEW_DEVICES_TABLE>
<DOWN_DEVICES_TABLE>
<EVENTS_TABLE>
<PORTS_TABLE>
<tr>
<td>
@@ -118,5 +58,7 @@
</tr>
</table>
</font>
</body>
</html>

View File

@@ -17,197 +17,68 @@
"title": "Pi.Alert Notifications",
"title_link": "",
"text": {
"internet": [
[
"Internet",
"243.243.243.243",
"2022-01-06 18:32:03",
"Internet IP Changed",
"Previous Internet IP: 0.0.0.0",
1,
null
],
[
"Internet",
"243.243.243.243",
"2022-01-06 18:32:03",
"New Device",
null,
1,
null
]
],
"new_devices": [
[
"b8:b8:b8:b8:b8:b8",
"192.168.1.19",
"2023-01-06 18:32:03",
"New Device",
"Raspberry Pi Foundation",
1,
null,
"b8:b8:b8:b8:b8:b8",
"raspberrypi",
"(unknown)",
null,
"Raspberry Pi Foundation",
0,
null,
null,
"2021-01-06 18:32:03",
"2021-01-06 18:32:03",
"192.168.1.19",
0,
1,
1,
1,
0,
0,
null,
1,
1,
null,
0,
null,
null
],
[
"b1:b8:b8:b8:b8:b8",
"192.168.1.45",
"2021-01-06 18:32:03",
"New Device",
"EliteGroup Computer Systems Co., LTD",
1,
null,
"b1:b8:b8:b8:b8:b8",
"my-NUC",
"(unknown)",
null,
"EliteGroup Computer Systems Co., LTD",
0,
null,
null,
"2023-01-06 18:32:03",
"2023-01-06 18:32:03",
"192.168.1.45",
0,
1,
1,
1,
0,
0,
null,
1,
1,
null,
0,
null,
null
]
],
"down_devices": [
[
"aa:77:aa:77:aa:77",
"192.168.1.151",
"2021-01-07 14:20:53",
"Device Down",
"",
1,
25,
"aa:77:aa:77:aa:77",
"ttgo_tdisplay_weather",
"(unknown)",
"",
"Espressif Inc.",
0,
"",
"",
"2021-01-06 23:13:06",
"2021-01-06 23:13:06",
"192.168.1.151",
0,
1,
1,
0,
1,
0,
"2021-01-06 23:34:37.067330",
0,
0,
"",
0,
"",
""
]
],
"events": [
[
"aa:77:aa:77:aa:77",
"192.168.1.151",
"2022-08-12 21:48:00",
"Connected",
"",
1,
null,
"aa:77:aa:77:aa:77",
"ESP32 - display",
"House",
"",
"Espressif Inc.",
0,
"",
"",
"2022-07-21 20:35:00",
"2022-08-12 21:48:00",
"192.168.1.151",
0,
1,
1,
1,
0,
0,
"2022-08-12 21:42:47.937413",
1,
0,
"",
0,
"aa:77:aa:77:aa:77",
""
],
[
"aa:77:aa:77:aa:77",
"192.168.1.149",
"2022-08-12 21:48:00",
"Connected",
"",
1,
null,
"aa:77:aa:77:aa:77",
"ESP32 - 1",
"House",
"Singleboard Computer (SBC)",
"Espressif Inc.",
0,
"",
"",
"2022-07-15 05:30:00",
"2022-08-12 21:48:00",
"192.168.1.149",
0,
1,
1,
1,
0,
0,
"2022-08-12 21:42:47.937413",
1,
1,
"",
0,
"aa:77:aa:77:aa:77",
""
]
]
"internet": [],
"new_devices": [{
"MAC": "74:ac:74:ac:74:ac",
"Datetime": "2023-01-30 22:15:09",
"IP": "192.168.1.1",
"Event Type": "New Device",
"Device name": "(name not found)",
"Comments": null
}],
"down_devices": [],
"events": [{
"MAC": "74:ac:74:ac:74:ac",
"Datetime": "2023-01-30 22:15:09",
"IP": "192.168.1.92",
"Event Type": "Disconnected",
"Device name": "(name not found)",
"Comments": null
}, {
"MAC": "74:ac:74:ac:74:ac",
"Datetime": "2023-01-30 22:15:09",
"IP": "192.168.1.150",
"Event Type": "Disconnected",
"Device name": "(name not found)",
"Comments": null
}],
"ports": [{
"new": {
"Name": "New device",
"MAC": "74:ac:74:ac:74:ac",
"Port": "22/tcp",
"State": "open",
"Service": "ssh",
"Extra": ""
}
}, {
"new": {
"Name": "New device",
"MAC": "74:ac:74:ac:74:ac",
"Port": "53/tcp",
"State": "open",
"Service": "domain",
"Extra": ""
}
}, {
"new": {
"Name": "New device",
"MAC": "74:ac:74:ac:74:ac",
"Port": "80/tcp",
"State": "open",
"Service": "http",
"Extra": ""
}
}, {
"new": {
"Name": "New device",
"MAC": "74:ac:74:ac:74:ac",
"Port": "443/tcp",
"State": "open",
"Service": "https",
"Extra": ""
}
}]
}
}
]

View File

@@ -103,7 +103,7 @@ DHCP_ACTIVE=False
# Pholus
#---------------------------
PHOLUS_ACTIVE=False
PHOLUS_TIMEOUT=20
PHOLUS_TIMEOUT=120
PHOLUS_FORCE=False
PHOLUS_DAYS_DATA=7
PHOLUS_RUN='once'

View File

@@ -7,20 +7,17 @@ services:
network_mode: "host"
restart: unless-stopped
volumes:
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
- ${APP_DATA_LOCATION}/pialert/config2:/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/db2:/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
- ${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/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html
- ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py
- ${DEV_LOCATION}/pholus:/home/pi/pialert/pholus
- ${DEV_LOCATION}/dockerfiles:/home/pi/pialert/dockerfiles
- ${APP_DATA_LOCATION}/pialert/php.ini:/etc/php/7.4/fpm/php.ini
- ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api
- ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css
- ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE
- ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js

View File

@@ -45,10 +45,10 @@ 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 |
|Optional| `:/home/pi/pialert/front/api` | A simple [API endpoint](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) containing static (but regularly updated) json and other files. |
### Config (`pialert.conf`)
@@ -57,7 +57,7 @@ docker run -d --rm --network=host \
- ❗ Set the `SCAN_SUBNETS` variable.
* The adapter will probably be `eth0` or `eth1`. (Run `iwconfig` to find your interface name(s))
* Specify the network filter (which **significantly** speeds up the scan process). For example, the filter `192.168.1.0/24` covers IP ranges 192.168.1.0 to 192.168.1.255.
* Examples for one and two subnets (❗ Note the `['...', '...']` format for two or more subnets):
* Examples for one and two subnets (❗ Note the `['...', '...']` format):
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0', '192.168.1.0/24 --interface=eth1']`
@@ -99,9 +99,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 +125,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:

99
docs/API.md Executable file
View File

@@ -0,0 +1,99 @@
## API endpoints
PiAlert comes with a simple API. These API endpoints are static files, that are periodically updated based on your settings.
### When are the endpoints updated
Once you enable the API (`ENABLE_API` setting), the endpoints are updated during these events:
1) Always during a notification event.
2) (optional) If `API_RUN` is set to `schedule` on a specified cron-like schedule specified by the `API_RUN_SCHD` setting.
3) (optional) If `API_RUN` is set to `interval` every N seconds specified by the `API_RUN_INTERVAL` setting (minimum 5).
### Location of the endpoints
In the container, these files are located under the `/home/pi/pialert/front/api/` folder and thus on the `<pialert_url>/api/<File name>` url.
### Available endpoints
You can access the following files:
| File name | Description |
|----------------------|----------------------|
| `notification_text.txt` | The plain text version of the last notification. |
| `notification_text.html` | The full HTML of the last email notification. |
| `notification_json_final.json` | The json version of the last notification (e.g. used for webhooks - [sample JSON](https://github.com/jokob-sk/Pi.Alert/blob/main/back/webhook_json_sample.json)). |
| `table_devices.json` | The current (at the time of the last update as mentioned above on this page) state of all of the available Devices detected by the app. |
| `table_nmap_scan.json` | The current state of the discovered ports by the regular NMAP scans. |
| `table_pholus_scan.json` | The latest state of the [pholus](https://github.com/jokob-sk/Pi.Alert/tree/main/pholus) (A multicast DNS and DNS Service Discovery Security Assessment Tool) scan results. |
| `table_events_pending_alert.json` | The list of the unprocessed (pending) notification events. |
| `table_custom_endpoint.json` | A custom endpoint generated by the SQL query specified by the `API_CUSTOM_SQL` setting. |
Current/latest state of the aforementioned files depends on your settings.
### JSON Data format
The endpoints starting with the `table_` prefix contain most, if not all, data contained in the corresponding database table. The common format for those is:
```JSON
{
"data": [
{
"db_column_name": "data",
"db_column_name2": "data2"
},
{
"db_column_name": "data3",
"db_column_name2": "data4"
}
]
}
```
Example JSON of the `table_devices.json` endpoint with two Devices (database rows):
```JSON
{
"data": [
{
"dev_MAC": "Internet",
"dev_Name": "Net - Huawei",
"dev_DeviceType": "Router",
"dev_Vendor": null,
"dev_Group": "Always on",
"dev_FirstConnection": "2021-01-01 00:00:00",
"dev_LastConnection": "2021-01-28 22:22:11",
"dev_LastIP": "192.168.1.24",
"dev_StaticIP": 0,
"dev_PresentLastScan": 1,
"dev_LastNotification": "2023-01-28 22:22:28.998715",
"dev_NewDevice": 0,
"dev_Network_Node_MAC_ADDR": "",
"dev_Network_Node_port": "",
"dev_Icon": "globe"
},
{
"dev_MAC": "a4:8f:ff:aa:ba:1f",
"dev_Name": "Net - USG",
"dev_DeviceType": "Firewall",
"dev_Vendor": "Ubiquiti Inc",
"dev_Group": "",
"dev_FirstConnection": "2021-02-12 22:05:00",
"dev_LastConnection": "2021-07-17 15:40:00",
"dev_LastIP": "192.168.1.1",
"dev_StaticIP": 1,
"dev_PresentLastScan": 1,
"dev_LastNotification": "2021-07-17 15:40:10.667717",
"dev_NewDevice": 0,
"dev_Network_Node_MAC_ADDR": "Internet",
"dev_Network_Node_port": 1,
"dev_Icon": "shield-halved"
}
]
}
```

43
docs/NETWORK_TREE.md Executable file
View File

@@ -0,0 +1,43 @@
## How to setup your Network page
Make sure you have a root device with the MAC `Internet` (No other MAC addresses are currently support as root)
To setup a device named `rapberrypi` as a `Switch` in our network.
### 1) Device details page
- Go to the `Devices` (1) page:
![Device details](/docs/img/NETWORK_TREE/Device_Details_Network_Type.png)
- In the (2) `Details` tab navigate to the the `Type` (3) dropdown and select the type `Switch` (4).
> Note: Only the following device types will show up as selectable Network nodes ( = devices you can connect other devices to):
> AP, Firewall, Gateway, PLC, Powerline, Router, Switch, USB LAN Adapter, USB WIFI Adapter and WLAN.
- Assign a device to your root device from the `Node` (5) dropdown whitch has the MAC `Internet` (6) (Your name may differ, but the MAC needs to be set to `Internet` - this is done by default).
- Save your changes (7)
### 1) Network page
- Navigate to your `Network` (1) page:
![Network page](/docs/img/NETWORK_TREE/Network_Page.png)
- Notice the newly added `raspberrypi` (2) tab which now represents a network node, also showing up in the tree (3).
- As we asssigned the `raspberrypi` in the previous 1) Device details page section to the `Internet` parent network node in step (6), the link is also showing up in the tree diagram (4)
- We can now assign the device `(AppleTV)` (5) to this `raspberrypi` node, representing a network Switch in this example
### 1) Network page with 2 levels
- After clicking the `Assign` button in the previous section, the `(AppleTV)` (1) device is now connected to our `raspberrypi` (2).
![Network page with 2 levels](/docs/img/NETWORK_TREE/Network_Page_2_Levels.png)
- You can see the `raspberrypi` represents the Network node type `Switch` (3)
- The `(AppleTV)` to `raspberrypi` connection is also displayed in the table of `Connected devices` (4).
- You can also see that our `raspberrypi` node is connected to it's Parent network device node with the MAC `Internet` (5). This connection again shows up in the tree (6) as well.

15
docs/SMTP_GMAIL.md Executable file
View 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'
```

View File

@@ -1,12 +1,18 @@
### Create a simple n8n workflow
![n8n workflow](https://i.imgur.com/2EGrQjt.png)
![n8n workflow](/docs/img/WEBHOOK_N8N/n8n_workflow.png)
### Specify your email template
See [sample JSON](https://github.com/jokob-sk/Pi.Alert/blob/main/back/webhook_json_sample.json) if you want to see the JSON paths used in the email template below
![Email template](https://i.imgur.com/kcVjGm1.png)
![Email template](/docs/img/WEBHOOK_N8N/n8n_send_email_settings.png)
```
Events count: {{ $json["body"]["attachments"][0]["text"]["events"].length }}
New devices count: {{ $json["body"]["attachments"][0]["text"]["new_devices"].length }}
```
### Get your webhook in n8n
![n8n webhook URL](https://i.imgur.com/clN8eE5.png)
![n8n webhook URL](/docs/img/WEBHOOK_N8N/n8n_webhook_settings.png)
### Configure PiAlert to point to the above URL
![PiAlert config](https://i.imgur.com/rowJCC7.png)
![PiAlert config](/docs/img/WEBHOOK_N8N/Webhook_settings.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@@ -1,80 +0,0 @@
<!-- ---------------------------------------------------------------------------
# Pi.Alert
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_sample.html - Back module. Sample email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
#--------------------------------------------------------------------------- -->
<html>
<head>
</head>
<body>
<font face=sans-serif>
<table align=center width=80% border=1 bordercolor=#909090 cellpadding=0 cellspacing=0 style="border-collapse: collapse; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.5)">
<tr>
<td bgcolor=#EFB956 align=center style="padding: 20px 10px 10px 10px; font-size: 36px; font-weight: bold; color:#7F6000; text-shadow: 4px 4px 6px #909090">
Pi.Alert Report
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#FFD966 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 16px; text-align:center; color:#5F5000">
<tr>
<td width=33%> Report Date: <b>2021-01-01 08:00</b> </td>
<td width=34%> Scan Cycle: <b>Internet</b> </td>
<td width=33%> Server: <b>pi4</b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor=#F5F5F5 valign=top height=400 style="padding: 20px">
<p style="font-size: 24px; font-weight: bold; color:#C04040; text-shadow: 2px 2px 4px #A0A0A0"> Internet: </p>
<table width=100% border=1 bordercolor=#C0C0C0 cellpadding=3px cellspacing=0 style="border-collapse: collapse; font-size: 12px; color:#707070; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<tr bgcolor=#909090 style="color:#F0F0F0">
<th width=140> Event Type </th>
<th width=130> Datetime </th>
<th width=100> IP </th>
<th> Additional Info </th>
</tr>
<tr>
<td> Internet IP Changed </td>
<td> 2021-01-01 08:00:00 </td>
<td style="font-size: 24px; color:#D02020"> 1.1.1.0 </td>
<td> Previous Internet IP: 1.1.0.0 </td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#70AD47 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 12px; font-weight: bold; color:#385723">
<tr>
<td width=25% style="text-align:Left"> Puche 2021</td>
<td width=50% style="text-align:center"> Pi.Alert 2.50 &nbsp; / &nbsp; 2021-01-01 </td>
<td width=25% style="text-align:right"> GNU GPLv3</td>
</tr>
</table>
</td>
</tr>
</table>
</font>
</body>
</html>

View File

@@ -741,6 +741,12 @@ height: 50px;
background-color:#606060;
}
.networkPageHelp{
position: absolute;
font-size: x-small;
margin-bottom: 6px;
}
#networkTree .box
{
padding:2px;

View File

@@ -9,7 +9,6 @@
<?php
require 'php/templates/header.php';
require 'php/server/db.php';
?>
<!-- Page ------------------------------------------------------------------ -->
@@ -26,11 +25,11 @@
<!-- period selector -->
<span class="breadcrumb" style="top: 0px;">
<select class="form-control" id="period" onchange="javascript: periodChanged();">
<option value="1 day"><?php echo lang('DevDetail_Periodselect_today');?></option>
<option value="7 days"><?php echo lang('DevDetail_Periodselect_LastWeek');?></option>
<option value="1 month" selected><?php echo lang('DevDetail_Periodselect_LastMonth');?></option>
<option value="1 year"><?php echo lang('DevDetail_Periodselect_LastYear');?></option>
<option value="100 years"><?php echo lang('DevDetail_Periodselect_All');?></option>
<option value="1 day"><?= lang('DevDetail_Periodselect_today');?></option>
<option value="7 days"><?= lang('DevDetail_Periodselect_LastWeek');?></option>
<option value="1 month" selected><?= lang('DevDetail_Periodselect_LastMonth');?></option>
<option value="1 year"><?= lang('DevDetail_Periodselect_LastYear');?></option>
<option value="100 years"><?= lang('DevDetail_Periodselect_All');?></option>
</select>
</span>
</section>
@@ -45,7 +44,7 @@
<a href="#" onclick="javascript: $('#tabDetails').trigger('click')">
<div class="small-box bg-aqua">
<div class="inner"> <h3 id="deviceStatus" style="margin-left: 0em"> -- </h3>
<p class="infobox_label"><?php echo lang('DevDetail_Shortcut_CurrentStatus');?></p>
<p class="infobox_label"><?= lang('DevDetail_Shortcut_CurrentStatus');?></p>
</div>
<div class="icon"> <i id="deviceStatusIcon" class=""></i></div>
</div>
@@ -57,7 +56,7 @@
<a href="#" onclick="javascript: $('#tabSessions').trigger('click');">
<div class="small-box bg-green">
<div class="inner"> <h3 id="deviceSessions"> -- </h3>
<p class="infobox_label"><?php echo lang('DevDetail_Shortcut_Sessions');?></p>
<p class="infobox_label"><?= lang('DevDetail_Shortcut_Sessions');?></p>
</div>
<div class="icon"> <i class="fa fa-plug"></i> </div>
</div>
@@ -69,7 +68,7 @@
<a href="#" onclick="javascript: $('#tabPresence').trigger('click')">
<div class="small-box bg-yellow">
<div class="inner"> <h3 id="deviceEvents" style="margin-left: 0em"> -- </h3>
<p class="infobox_label"><?php echo lang('DevDetail_Shortcut_Presence');?></p>
<p class="infobox_label"><?= lang('DevDetail_Shortcut_Presence');?></p>
</div>
<div id="deviceEventsIcon" class="icon"> <i class="fa fa-calendar"></i> </div>
</div>
@@ -81,7 +80,7 @@
<a href="#" onclick="javascript: $('#tabEvents').trigger('click');">
<div class="small-box bg-red">
<div class="inner"> <h3 id="deviceDownAlerts"> -- </h3>
<p class="infobox_label"><?php echo lang('DevDetail_Shortcut_DownAlerts');?></p>
<p class="infobox_label"><?= lang('DevDetail_Shortcut_DownAlerts');?></p>
</div>
<div class="icon"> <i class="fa fa-warning"></i> </div>
</div>
@@ -99,15 +98,15 @@
<div id="navDevice" class="nav-tabs-custom">
<ul class="nav nav-tabs" style="fon t-size:16px;">
<li> <a id="tabDetails" href="#panDetails" data-toggle="tab"> <?php echo lang('DevDetail_Tab_Details');?> </a></li>
<li> <a id="tabDetails" href="#panDetails" data-toggle="tab"> <?= lang('DevDetail_Tab_Details');?> </a></li>
<?php
if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $DevDetail_Tap_temp = lang('DevDetail_Tab_Nmap');}
?>
<li> <a id="tabNmap" href="#panNmap" data-toggle="tab"> <?php echo $DevDetail_Tap_temp;?> </a></li>
<li> <a id="tabSessions" href="#panSessions" data-toggle="tab"> <?php echo lang('DevDetail_Tab_Sessions');?> </a></li>
<li> <a id="tabPresence" href="#panPresence" data-toggle="tab"> <?php echo lang('DevDetail_Tab_Presence');?> </a></li>
<li> <a id="tabEvents" href="#panEvents" data-toggle="tab"> <?php echo lang('DevDetail_Tab_Events');?> </a></li>
<li> <a id="tabPholus" href="#panPholus" data-toggle="tab"> <?php echo lang('DevDetail_Tab_Pholus');?> </a></li>
<li> <a id="tabSessions" href="#panSessions" data-toggle="tab"> <?= lang('DevDetail_Tab_Sessions');?> </a></li>
<li> <a id="tabPresence" href="#panPresence" data-toggle="tab"> <?= lang('DevDetail_Tab_Presence');?> </a></li>
<li> <a id="tabEvents" href="#panEvents" data-toggle="tab"> <?= lang('DevDetail_Tab_Events');?> </a></li>
<li> <a id="tabPholus" href="#panPholus" data-toggle="tab"> <?= lang('DevDetail_Tab_Pholus');?> </a></li>
<div class="btn-group pull-right">
<button type="button" class="btn btn-default" style="padding: 10px; min-width: 30px;"
@@ -134,12 +133,12 @@
<div class="row">
<!-- column 1 -->
<div class="col-lg-4 col-sm-6 col-xs-12">
<h4 class="bottom-border-aqua"><?php echo lang('DevDetail_MainInfo_Title');?></h4>
<h4 class="bottom-border-aqua"><?= lang('DevDetail_MainInfo_Title');?></h4>
<div class="box-body form-horizontal">
<!-- MAC -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_mac');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_mac');?></label>
<div class="col-sm-9">
<input class="form-control" id="txtMAC" type="text" readonly value="--">
</div>
@@ -147,7 +146,7 @@
<!-- Name -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Name');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Name');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtName" type="text" value="--">
@@ -158,7 +157,7 @@
<!-- Owner -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Owner');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Owner');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtOwner" type="text" value="--">
@@ -175,7 +174,7 @@
<!-- Type -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Type');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Type');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtDeviceType" type="text" value="--">
@@ -194,13 +193,13 @@
<!-- Icon -->
<div class="form-group">
<label class="col-sm-3 control-label">
<?php echo lang('DevDetail_Icon');?>
<?= lang('DevDetail_Icon');?>
<a href="https://fontawesome.com/search?q=laptop&o=r&m=free" target="_blank"> <span><i class="fa fa-fw fa-arrow-up-right-from-square"></i></a><span>
</label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" title="<?php echo lang('DevDetail_Icon_Descr');?>" id="txtIcon" type="text" value="--">
<span class="input-group-addon" title='<?php echo lang('DevDetail_button_OverwriteIcons_Tooltip');?>'><i class="fa fa-copy pointer" onclick="askOverwriteIconType();"></i></span>
<input class="form-control" title="<?= lang('DevDetail_Icon_Descr');?>" id="txtIcon" type="text" value="--">
<span class="input-group-addon" title='<?= lang('DevDetail_button_OverwriteIcons_Tooltip');?>'><i class="fa fa-copy pointer" onclick="askOverwriteIconType();"></i></span>
<span class="input-group-addon"><i class="fa fa-pencil pointer" onclick="editDrp('txtIcon');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
@@ -215,7 +214,7 @@
<!-- Vendor -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Vendor');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Vendor');?></label>
<div class="col-sm-9">
<input class="form-control" id="txtVendor" type="text" value="--">
</div>
@@ -223,7 +222,7 @@
<!-- Favorite -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Favorite');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Favorite');?></label>
<div class="col-sm-9" style="padding-top:6px;">
<input class="checkbox blue hidden" id="chkFavorite" type="checkbox">
</div>
@@ -231,7 +230,7 @@
<!-- Group -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Group');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Group');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtGroup" type="text" value="--">
@@ -249,7 +248,7 @@
<!-- Location -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Location');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Location');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtLocation" type="text" value="--">
@@ -267,7 +266,7 @@
<!-- Comments -->
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Comments');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Comments');?></label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" id="txtComments"></textarea>
</div>
@@ -280,12 +279,12 @@
<!-- column 2 -->
<div class="col-lg-4 col-sm-6 col-xs-12">
<h4 class="bottom-border-aqua"><?php echo lang('DevDetail_SessionInfo_Title');?></h4>
<h4 class="bottom-border-aqua"><?= lang('DevDetail_SessionInfo_Title');?></h4>
<div class="box-body form-horizontal">
<!-- Status -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_SessionInfo_Status');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_SessionInfo_Status');?></label>
<div class="col-sm-7">
<input class="form-control" id="txtStatus" type="text" readonly value="--">
</div>
@@ -293,7 +292,7 @@
<!-- First Session -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_SessionInfo_FirstSession');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_SessionInfo_FirstSession');?></label>
<div class="col-sm-7">
<input class="form-control" id="txtFirstConnection" type="text" readonly value="--">
</div>
@@ -301,7 +300,7 @@
<!-- Last Session -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_SessionInfo_LastSession');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_SessionInfo_LastSession');?></label>
<div class="col-sm-7">
<input class="form-control" id="txtLastConnection" type="text" readonly value="--">
</div>
@@ -309,7 +308,7 @@
<!-- Last IP -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_SessionInfo_LastIP');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_SessionInfo_LastIP');?></label>
<div class="col-sm-7">
<input class="form-control" id="txtLastIP" type="text" readonly value="--">
</div>
@@ -317,21 +316,21 @@
<!-- Static IP -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_SessionInfo_StaticIP');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_SessionInfo_StaticIP');?></label>
<div class="col-sm-7" style="padding-top:6px;">
<input class="checkbox blue hidden" id="chkStaticIP" type="checkbox">
</div>
</div>
<!-- Network -->
<h4 class="bottom-border-aqua"><?php echo lang('DevDetail_MainInfo_Network_Title');?></h4>
<h4 class="bottom-border-aqua"><?= lang('DevDetail_MainInfo_Network_Title');?><span class="networkPageHelp"> <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/NETWORK_TREE.md"><i class="fa fa-circle-question"></i></a><span></h4>
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Network');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Network');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtNetworkNodeMac" type="text" value="--">
<span class="input-group-addon"><i title="<?php echo lang('DevDetail_GoToNetworkNode');?>" class="fa fa-square-up-right pointer" onclick="goToNetworkNode('txtNetworkNodeMac');"></i></span>
<span class="input-group-addon"><i title="<?= lang('DevDetail_GoToNetworkNode');?>" class="fa fa-square-up-right pointer" onclick="goToNetworkNode('txtNetworkNodeMac');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-mynodemac="" data-toggle="dropdown" aria-expanded="false" id="buttonNetworkNodeMac">
<span class="fa fa-caret-down"></span></button>
@@ -343,7 +342,7 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo lang('DevDetail_MainInfo_Network_Port');?></label>
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Network_Port');?></label>
<div class="col-sm-9">
<input class="form-control" id="txtNetworkPort" type="text" value="--">
</div>
@@ -354,12 +353,12 @@
<!-- column 3 -->
<div class="col-lg-4 col-sm-6 col-xs-12">
<h4 class="bottom-border-aqua"><?php echo lang('DevDetail_EveandAl_Title');?></h4>
<h4 class="bottom-border-aqua"><?= lang('DevDetail_EveandAl_Title');?></h4>
<div class="box-body form-horizontal">
<!-- Scan Cycle -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_EveandAl_ScanCycle');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_EveandAl_ScanCycle');?></label>
<div class="col-sm-7">
<div class="input-group">
<input class="form-control" id="txtScanCycle" type="text" value="--" readonly >
@@ -367,8 +366,8 @@
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false" id="dropdownButtonScanCycle">
<span class="fa fa-caret-down"></span></button>
<ul id="dropdownScanCycle" class="dropdown-menu dropdown-menu-right">
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','yes')"><?php echo lang('DevDetail_EveandAl_ScanCycle_a');?></a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','no');"><?php echo lang('DevDetail_EveandAl_ScanCycle_z');?></a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','yes')"><?= lang('DevDetail_EveandAl_ScanCycle_a');?></a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','no');"><?= lang('DevDetail_EveandAl_ScanCycle_z');?></a></li>
</ul>
</div>
</div>
@@ -377,7 +376,7 @@
<!-- Alert events -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_EveandAl_AlertAllEvents');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_EveandAl_AlertAllEvents');?></label>
<div class="col-sm-7" style="padding-top:6px;">
<input class="checkbox blue hidden" id="chkAlertEvents" type="checkbox">
</div>
@@ -385,7 +384,7 @@
<!-- Alert Down -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_EveandAl_AlertDown');?></label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_EveandAl_AlertDown');?></label>
<div class="col-sm-7" style="padding-top:6px;">
<input class="checkbox red hidden" id="chkAlertDown" type="checkbox">
</div>
@@ -393,7 +392,7 @@
<!-- Skip Notifications -->
<div class="form-group">
<label class="col-sm-5 control-label" style="padding-top: 0px; padding-left: 0px;"><?php echo lang('DevDetail_EveandAl_Skip');?></label>
<label class="col-sm-5 control-label" style="padding-top: 0px; padding-left: 0px;"><?= lang('DevDetail_EveandAl_Skip');?></label>
<div class="col-sm-7">
<div class="input-group">
<input class="form-control" id="txtSkipRepeated" type="text" value="--" readonly >
@@ -414,7 +413,7 @@
<!-- New Device -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_EveandAl_NewDevice');?>:</label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_EveandAl_NewDevice');?>:</label>
<div class="col-sm-7" style="padding-top:6px;">
<input class="checkbox orange hidden" id="chkNewDevice" type="checkbox">
</div>
@@ -422,7 +421,7 @@
<!-- Archived -->
<div class="form-group">
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_EveandAl_Archived');?>:</label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_EveandAl_Archived');?>:</label>
<div class="col-sm-7" style="padding-top:6px;">
<input class="checkbox blue hidden" id="chkArchived" type="checkbox">
</div>
@@ -430,7 +429,7 @@
<!-- Randomized MAC -->
<div class="form-group" >
<label class="col-sm-5 control-label"><?php echo lang('DevDetail_EveandAl_RandomMAC');?>:</label>
<label class="col-sm-5 control-label"><?= lang('DevDetail_EveandAl_RandomMAC');?>:</label>
<div class="col-sm-7" style="padding-top:6px;">
<span id="iconRandomMACinactive" data-toggle="tooltip" data-placement="right" title="Random MAC is Inactive">
<i style="font-size: 24px;" class="text-gray glyphicon glyphicon-random"></i> &nbsp &nbsp </span>
@@ -450,13 +449,13 @@
<div class="col-xs-12">
<div class="pull-right">
<button type="button" class="btn btn-default pa-btn pa-btn-delete" style="margin-left:0px;"
id="btnDeleteEvents" onclick="askDeleteDeviceEvents()"> <?php echo lang('DevDetail_button_DeleteEvents');?> </button>
id="btnDeleteEvents" onclick="askDeleteDeviceEvents()"> <?= lang('DevDetail_button_DeleteEvents');?> </button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete" style="margin-left:0px;"
id="btnDelete" onclick="askDeleteDevice()"> <?php echo lang('DevDetail_button_Delete');?> </button>
id="btnDelete" onclick="askDeleteDevice()"> <?= lang('DevDetail_button_Delete');?> </button>
<button type="button" class="btn btn-default pa-btn" style="margin-left:6px;"
id="btnRestore" onclick="getDeviceData(true)"> <?php echo lang('DevDetail_button_Reset');?> </button>
id="btnRestore" onclick="getDeviceData(true)"> <?= lang('DevDetail_button_Reset');?> </button>
<button type="button" disabled class="btn btn-primary pa-btn" style="margin-left:6px; "
id="btnSave" onclick="setDeviceData()" > <?php echo lang('DevDetail_button_Save');?> </button>
id="btnSave" onclick="setDeviceData()" > <?= lang('DevDetail_button_Save');?> </button>
</div>
</div>
@@ -470,12 +469,12 @@
<table id="tableSessions" class="table table-bordered table-hover table-striped ">
<thead>
<tr>
<th><?php echo lang('DevDetail_SessionTable_Order');?></th>
<th><?php echo lang('DevDetail_SessionTable_Connection');?></th>
<th><?php echo lang('DevDetail_SessionTable_Disconnection');?></th>
<th><?php echo lang('DevDetail_SessionTable_Duration');?></th>
<th><?php echo lang('DevDetail_SessionTable_IP');?></th>
<th><?php echo lang('DevDetail_SessionTable_Additionalinfo');?></th>
<th><?= lang('DevDetail_SessionTable_Order');?></th>
<th><?= lang('DevDetail_SessionTable_Connection');?></th>
<th><?= lang('DevDetail_SessionTable_Disconnection');?></th>
<th><?= lang('DevDetail_SessionTable_Duration');?></th>
<th><?= lang('DevDetail_SessionTable_IP');?></th>
<th><?= lang('DevDetail_SessionTable_Additionalinfo');?></th>
</tr>
</thead>
</table>
@@ -516,10 +515,10 @@
<div style="width:100%; text-align: center;">
<script>
setTimeout(function(){
document.getElementById('piamanualnmap_fast').innerHTML='<?php echo lang('DevDetail_Nmap_buttonFast');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_normal').innerHTML='<?php echo lang('DevDetail_Nmap_buttonDefault');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_detail').innerHTML='<?php echo lang('DevDetail_Nmap_buttonDetail');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_skipdiscovery').innerHTML='<?php echo lang('DevDetail_Nmap_buttonSkipDiscovery');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_fast').innerHTML='<?= lang('DevDetail_Nmap_buttonFast');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_normal').innerHTML='<?= lang('DevDetail_Nmap_buttonDefault');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_detail').innerHTML='<?= lang('DevDetail_Nmap_buttonDetail');?> (' + document.getElementById('txtLastIP').value +')';
document.getElementById('piamanualnmap_skipdiscovery').innerHTML='<?= lang('DevDetail_Nmap_buttonSkipDiscovery');?> (' + document.getElementById('txtLastIP').value +')';
}, 2000);
</script>
@@ -530,11 +529,11 @@
<div style="text-align: left;">
<ul style="padding:20px;">
<li><?php echo lang('DevDetail_Nmap_buttonFast_text');?></li>
<li><?php echo lang('DevDetail_Nmap_buttonDefault_text');?></li>
<li><?php echo lang('DevDetail_Nmap_buttonDetail_text');?></li>
<li><?php echo lang('DevDetail_Nmap_buttonSkipDiscovery_text');?></li>
<li><a onclick="setCache('activeMaintenanceTab', 'tab_Logging_id')" href="/maintenance.php#tab_Logging"><?php echo lang('DevDetail_Nmap_resultsLink');?></a></li>
<li><?= lang('DevDetail_Nmap_buttonFast_text');?></li>
<li><?= lang('DevDetail_Nmap_buttonDefault_text');?></li>
<li><?= lang('DevDetail_Nmap_buttonDetail_text');?></li>
<li><?= lang('DevDetail_Nmap_buttonSkipDiscovery_text');?></li>
<li><a onclick="setCache('activeMaintenanceTab', 'tab_Logging_id')" href="/maintenance.php#tab_Logging"><?= lang('DevDetail_Nmap_resultsLink');?></a></li>
</ul>
</div>
@@ -559,9 +558,9 @@
}
</script>
<h3><?php echo lang("DevDetail_Tab_NmapTableHeader");?></h3>
<h3><?= lang("DevDetail_Tab_NmapTableHeader");?></h3>
<div><?php echo lang("DevDetail_Tab_NmapTableText");?></div>
<div><?= lang("DevDetail_Tab_NmapTableText");?></div>
<table id="tableNmap" class="table table-bordered table-hover table-striped ">
<thead>
@@ -577,7 +576,7 @@
<!-- Comment out tbody when trying to implement better table with datatables here -->
<!-- IDEA: Show unmatched pholus entries? -->
<tbody id="tableNmapBody">
<tr id="tableNmapPlc" class="text-center"><td colspan='7'><span><?php echo lang("DevDetail_Tab_NmapEmpty"); ?></span></td></tr>
<tr id="tableNmapPlc" class="text-center"><td colspan='7'><span><?= lang("DevDetail_Tab_NmapEmpty"); ?></span></td></tr>
</tbody>
</table>
@@ -614,7 +613,7 @@
<div class="text-center">
<label>
<input class="checkbox blue hidden" id="chkHideConnectionEvents" type="checkbox" checked>
<?php echo lang('DevDetail_Events_CheckBox');?>
<?= lang('DevDetail_Events_CheckBox');?>
</label>
</div>
@@ -648,7 +647,7 @@
<!-- Comment out tbody when trying to implement better table with datatables here -->
<!-- IDEA: Show unmatched pholus entries? -->
<tbody id="tablePholusBody">
<tr id="tablePholusPlc" class="text-center"><td colspan='7'><span><?php echo lang("DevDetail_Tab_PholusEmpty"); ?></span></td></tr>
<tr id="tablePholusPlc" class="text-center"><td colspan='7'><span><?= lang("DevDetail_Tab_PholusEmpty"); ?></span></td></tr>
</tbody>
</table>
</div>
@@ -715,12 +714,15 @@ if ($ENABLED_DARKMODE === True) {
// ------------------------------------------------------------
function getDevicesListValue(idColumn, idValue, returnColumn)
{
if(emptyArr.includes(devicesList) || emptyArr.includes(idValue))
// Read cache
devicesListAll = JSON.parse(getCache('devicesListAll'));
if(emptyArr.includes(devicesListAll) || emptyArr.includes(idValue))
{
return '';
}
return devicesList.find((item) => {return item[idColumn] == idValue})[returnColumn]
return devicesListAll.find((item) => {return item[idColumn] == idValue})[returnColumn]
}
// ------------------------------------------------------------
@@ -741,8 +743,29 @@ if ($ENABLED_DARKMODE === True) {
mac = getMac() // can also be rowID!! not only mac
var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI
var devicesListAll = []; // this will contain a list off all devices
$.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) {
rawData = JSON.parse (data)
devicesListAll = 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('devicesListAll', JSON.stringify(devicesListAll))
// Read parameters & Initialize components
main();
});
devicesList = getDevicesList();
var pos = -1;
var parPeriod = 'Front_Details_Period';
@@ -759,8 +782,7 @@ if ($ENABLED_DARKMODE === True) {
var selectedTab = 'tabDetails';
var emptyArr = ['undefined', "", undefined, null];
// Read parameters & Initialize components
main();
// -----------------------------------------------------------------------------
@@ -1042,13 +1064,13 @@ function initializeDatatables () {
'<td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw">'+
'</td></table>',
emptyTable: 'No data',
"lengthMenu": "<?php echo lang('Events_Tablelenght');?>",
"search": "<?php echo lang('Events_Searchbox');?>: ",
"lengthMenu": "<?= lang('Events_Tablelenght');?>",
"search": "<?= lang('Events_Searchbox');?>: ",
"paginate": {
"next": "<?php echo lang('Events_Table_nav_next');?>",
"previous": "<?php echo lang('Events_Table_nav_prev');?>"
"next": "<?= lang('Events_Table_nav_next');?>",
"previous": "<?= lang('Events_Table_nav_prev');?>"
},
"info": "<?php echo lang('Events_Table_info');?>",
"info": "<?= lang('Events_Table_info');?>",
}
});
@@ -1081,13 +1103,13 @@ function initializeDatatables () {
'<td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw">'+
'</td></table>',
emptyTable: 'No data',
"lengthMenu": "<?php echo lang('Events_Tablelenght');?>",
"search": "<?php echo lang('Events_Searchbox');?>: ",
"lengthMenu": "<?= lang('Events_Tablelenght');?>",
"search": "<?= lang('Events_Searchbox');?>: ",
"paginate": {
"next": "<?php echo lang('Events_Table_nav_next');?>",
"previous": "<?php echo lang('Events_Table_nav_prev');?>"
"next": "<?= lang('Events_Table_nav_next');?>",
"previous": "<?= lang('Events_Table_nav_prev');?>"
},
"info": "<?php echo lang('Events_Table_info');?>",
"info": "<?= lang('Events_Table_info');?>",
}
});
@@ -1126,7 +1148,7 @@ function initializeCalendar () {
slotLabelInterval : '04:00:00',
slotLabelFormat : 'H:mm',
timeFormat : 'H:mm',
locale : '<?php echo lang('Presence_CalHead_lang');?>',
locale : '<?= lang('Presence_CalHead_lang');?>',
header: {
left : 'prev,next today',
center : 'title',
@@ -1137,14 +1159,14 @@ function initializeCalendar () {
agendaYear: {
type : 'agenda',
duration : { year: 1 },
buttonText : '<?php echo lang('Presence_CalHead_year');?>',
buttonText : '<?= lang('Presence_CalHead_year');?>',
columnHeaderFormat : ''
},
agendaMonth: {
type : 'agenda',
duration : { month: 1 },
buttonText : '<?php echo lang('Presence_CalHead_month');?>',
buttonText : '<?= lang('Presence_CalHead_month');?>',
columnHeaderFormat : 'D'
}
},
@@ -1430,7 +1452,7 @@ function recordSwitch(direction) {
if(somethingChanged)
{
showModalDefaultStrParam ('Unsaved changes', 'Do you want to discard your changes?',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', performSwitch, direction);
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', performSwitch, direction);
} else
{
performSwitch(direction)
@@ -1538,7 +1560,7 @@ function askSkipNotifications () {
if ($('#chkArchived')[0].checked && $('#txtScanCycle').val() != "no") {
// Ask skip notifications
showModalDefault ('Device Archived', 'Do you want to skip all notifications for this device?',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', 'skipNotifications');
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', 'skipNotifications');
}
}
@@ -1552,6 +1574,32 @@ function skipNotifications () {
// Set cycle 0
$('#txtScanCycle').val ('no');
}
// -----------------------------------------------------------------------------
function askDeleteDeviceEvents () {
// Check MAC
if (mac == '') {
return;
}
// Ask delete device Events
showModalWarning ('<?= lang('DevDetail_button_DeleteEvents');?>', '<?= lang('DevDetail_button_DeleteEvents_Warning');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteDeviceEvents');
}
function deleteDeviceEvents () {
// Check MAC
if (mac == '') {
return;
}
// Delete device events
$.get('php/server/devices.php?action=deleteDeviceEvents&mac='+ mac, function(msg) {
showMessage (msg);
});
// Deactivate controls
$('#panDetails :input').attr('disabled', true);
}
// -----------------------------------------------------------------------------
// Overwrite all devices of the same type with the currently selected icon
@@ -1562,8 +1610,8 @@ function askOverwriteIconType () {
}
// Ask overwrite icon types
showModalWarning ('<?php echo lang('DevDetail_button_OverwriteIcons');?>', '<?php echo lang('DevDetail_button_OverwriteIcons_Warning');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', 'overwriteIconType');
showModalWarning ('<?= lang('DevDetail_button_OverwriteIcons');?>', '<?= lang('DevDetail_button_OverwriteIcons_Warning');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', 'overwriteIconType');
}
// -----------------------------------------------------------------------------
@@ -1593,7 +1641,7 @@ function askDeleteDevice () {
// Ask delete device
showModalWarning ('Delete Device', 'Are you sure you want to delete this device?<br>(maybe you prefer to archive it)',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteDevice');
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteDevice');
}
@@ -1621,7 +1669,7 @@ function askDeleteDevice () {
// Ask delete device
showModalWarning ('Delete Device', 'Are you sure you want to delete this device?<br>(maybe you prefer to archive it)',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteDevice');
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteDevice');
}
@@ -1843,13 +1891,13 @@ function initTable(tableId, mac){
'<td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw">'+
'</td></table>',
emptyTable: 'No data',
"lengthMenu": "<?php echo lang('Events_Tablelenght');?>",
"search": "<?php echo lang('Events_Searchbox');?>: ",
"lengthMenu": "<?= lang('Events_Tablelenght');?>",
"search": "<?= lang('Events_Searchbox');?>: ",
"paginate": {
"next": "<?php echo lang('Events_Table_nav_next');?>",
"previous": "<?php echo lang('Events_Table_nav_prev');?>"
"next": "<?= lang('Events_Table_nav_next');?>",
"previous": "<?= lang('Events_Table_nav_prev');?>"
},
"info": "<?php echo lang('Events_Table_info');?>",
"info": "<?= lang('Events_Table_info');?>",
}
});

View File

@@ -11,7 +11,6 @@
require 'php/templates/header.php';
require 'php/templates/graph.php';
require 'php/server/util.php';
// check permissions
@@ -27,7 +26,7 @@
<!-- Content header--------------------------------------------------------- -->
<section class="content-header">
<h1 id="pageTitle">
<?php echo lang('Device_Title');?>
<?= lang('Device_Title');?>
</h1>
</section>
@@ -40,7 +39,7 @@
<a href="#" onclick="javascript: getDevicesList('all');">
<div class="small-box bg-aqua">
<div class="inner"><h3 id="devicesAll"> -- </h3>
<p class="infobox_label"><?php echo lang('Device_Shortcut_AllDevices');?></p>
<p class="infobox_label"><?= lang('Device_Shortcut_AllDevices');?></p>
</div>
<div class="icon"><i class="fa fa-laptop text-aqua-40"></i></div>
</div>
@@ -52,7 +51,7 @@
<a href="#" onclick="javascript: getDevicesList('connected');">
<div class="small-box bg-green">
<div class="inner"><h3 id="devicesConnected"> -- </h3>
<p class="infobox_label"><?php echo lang('Device_Shortcut_Connected');?></p>
<p class="infobox_label"><?= lang('Device_Shortcut_Connected');?></p>
</div>
<div class="icon"><i class="fa fa-plug text-green-40"></i></div>
</div>
@@ -64,7 +63,7 @@
<a href="#" onclick="javascript: getDevicesList('favorites');">
<div class="small-box bg-yellow">
<div class="inner"><h3 id="devicesFavorites"> -- </h3>
<p class="infobox_label"><?php echo lang('Device_Shortcut_Favorites');?></p>
<p class="infobox_label"><?= lang('Device_Shortcut_Favorites');?></p>
</div>
<div class="icon"><i class="fa fa-star text-yellow-40"></i></div>
</div>
@@ -76,7 +75,7 @@
<a href="#" onclick="javascript: getDevicesList('new');">
<div class="small-box bg-yellow">
<div class="inner"><h3 id="devicesNew"> -- </h3>
<p class="infobox_label"><?php echo lang('Device_Shortcut_NewDevices');?></p>
<p class="infobox_label"><?= lang('Device_Shortcut_NewDevices');?></p>
</div>
<div class="icon"><i class="ion ion-plus-round text-yellow-40"></i></div>
</div>
@@ -88,7 +87,7 @@
<a href="#" onclick="javascript: getDevicesList('down');">
<div class="small-box bg-red">
<div class="inner"><h3 id="devicesDown"> -- </h3>
<p class="infobox_label"><?php echo lang('Device_Shortcut_DownAlerts');?></p>
<p class="infobox_label"><?= lang('Device_Shortcut_DownAlerts');?></p>
</div>
<div class="icon"><i class="fa fa-warning text-red-40"></i></div>
</div>
@@ -100,7 +99,7 @@
<a href="#" onclick="javascript: getDevicesList('archived');">
<div class="small-box bg-gray top_small_box_gray_text">
<div class="inner"><h3 id="devicesArchived"> -- </h3>
<p class="infobox_label"><?php echo lang('Device_Shortcut_Archived');?></p>
<p class="infobox_label"><?= lang('Device_Shortcut_Archived');?></p>
</div>
<div class="icon"><i class="fa fa-eye-slash text-gray-40"></i></div>
</div>
@@ -115,7 +114,7 @@
<div class="col-md-12">
<div class="box" id="clients">
<div class="box-header with-border">
<h3 class="box-title"><?php echo lang('Device_Shortcut_OnlineChart');?> </h3>
<h3 class="box-title"><?= lang('Device_Shortcut_OnlineChart');?> </h3>
</div>
<div class="box-body">
<div class="chart">
@@ -192,9 +191,10 @@
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 columnsStr = '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]';
var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] ;
var tableColumnVisible = tableColumnOrder;
// Read parameters & Initialize components
main();
@@ -203,32 +203,47 @@
// -----------------------------------------------------------------------------
function main () {
// get from cookie if available (need to use decodeURI as saved as part of URI in PHP)
cookieColumnsVisibleStr = decodeURI(getCookie("Front_Devices_Columns_Visible")).replaceAll('%2C',',')
defaultValue = cookieColumnsVisibleStr == "" ? columnsStr : cookieColumnsVisibleStr;
// get visible columns
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'&parameter=Front_Devices_Columns_Visible', function(data) {
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+defaultValue+'&parameter=Front_Devices_Columns_Visible&skipcache', function(data) {
// save which columns are in the Devices page visible
tableColumnVisible = numberArrayFromString(data);
// get from cookie if available (need to use decodeURI as saved as part of URI in PHP)
cookieColumnsOrderStr = decodeURI(getCookie("Front_Devices_Columns_Order")).replaceAll('%2C',',')
defaultValue = cookieColumnsOrderStr == "" ? columnsStr : cookieColumnsOrderStr;
// get the custom order specified by the user
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'&parameter=Front_Devices_Columns_Order', function(data) {
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+defaultValue+'&parameter=Front_Devices_Columns_Order&skipcache', function(data) {
// save the columns order in the Devices page
tableColumnOrder = numberArrayFromString(data);
//initialize the table headers in the correct order
var headersDefaultOrder = [ '<?php echo lang('Device_TableHead_Name');?>',
'<?php echo lang('Device_TableHead_Owner');?>',
'<?php echo lang('Device_TableHead_Type');?>',
'<?php echo lang('Device_TableHead_Icon');?>',
'<?php echo lang('Device_TableHead_Favorite');?>',
'<?php echo lang('Device_TableHead_Group');?>',
'<?php echo lang('Device_TableHead_FirstSession');?>',
'<?php echo lang('Device_TableHead_LastSession');?>',
'<?php echo lang('Device_TableHead_LastIP');?>',
'<?php echo lang('Device_TableHead_MAC');?>',
'<?php echo lang('Device_TableHead_Status');?>',
'<?php echo lang('Device_TableHead_MAC_full');?>',
'<?php echo lang('Device_TableHead_LastIPOrder');?>',
'<?php echo lang('Device_TableHead_Rowid');?>',
'<?php echo lang('Device_TableHead_Parent_MAC');?>'
var headersDefaultOrder = [ '<?= lang('Device_TableHead_Name');?>',
'<?= lang('Device_TableHead_Owner');?>',
'<?= lang('Device_TableHead_Type');?>',
'<?= lang('Device_TableHead_Icon');?>',
'<?= lang('Device_TableHead_Favorite');?>',
'<?= lang('Device_TableHead_Group');?>',
'<?= lang('Device_TableHead_FirstSession');?>',
'<?= lang('Device_TableHead_LastSession');?>',
'<?= lang('Device_TableHead_LastIP');?>',
'<?= lang('Device_TableHead_MAC');?>',
'<?= lang('Device_TableHead_Status');?>',
'<?= lang('Device_TableHead_MAC_full');?>',
'<?= lang('Device_TableHead_LastIPOrder');?>',
'<?= lang('Device_TableHead_Rowid');?>',
'<?= lang('Device_TableHead_Parent_MAC');?>',
'<?= lang('Device_TableHead_Connected_Devices');?>',
'<?= lang('Device_TableHead_Location');?>',
'<?= lang('Device_TableHead_Vendor');?>'
];
html = '';
@@ -239,8 +254,6 @@ function main () {
}
$('#tableDevices tr').html(html);
// get parameter value
$.get('php/server/parameters.php?action=get&defaultValue=50&parameter='+ parTableRows, function(data) {
@@ -278,14 +291,13 @@ function main () {
// -----------------------------------------------------------------------------
var tableColumnHide = [];
// mapping the default order to the user specified one
function mapIndx(oldIndex)
{
for(i=0;i<tableColumnOrder.length;i++)
{
if(tableColumnOrder[i] == oldIndex)
{
// console.log('newIndex')
// console.log(i)
return i;
}
}
@@ -315,7 +327,7 @@ function initializeDatatable () {
$('#tableDevices').DataTable({
'paging' : true,
'lengthChange' : true,
'lengthMenu' : [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, '<?php echo lang('Device_Tablelenght_all');?>']],
'lengthMenu' : [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, '<?= lang('Device_Tablelenght_all');?>']],
'searching' : true,
'ordering' : true,
@@ -329,10 +341,10 @@ function initializeDatatable () {
'columnDefs' : [
{visible: false, targets: tableColumnHide },
{className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10)] },
{width: '80px', targets: [mapIndx(6), mapIndx(7)] },
{className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10), mapIndx(15)] },
{width: '80px', targets: [mapIndx(6), mapIndx(7), mapIndx(15)] },
{width: '30px', targets: [mapIndx(10), mapIndx(13)] },
{orderData: [mapIndx(11)], targets: mapIndx(8) },
{orderData: [mapIndx(12)], targets: mapIndx(8) },
// Device Name
{targets: [mapIndx(0)],
@@ -340,6 +352,12 @@ function initializeDatatable () {
$(td).html ('<b class="anonymizeDev"><a href="deviceDetails.php?mac='+ rowData[mapIndx(11)] +'" class="">'+ cellData +'</a></b>');
} },
// Connected Devices
{targets: [mapIndx(15)],
'createdCell': function (td, cellData, rowData, row, col) {
$(td).html ('<b><a href="./network.php?mac='+ rowData[mapIndx(11)] +'" class="">'+ cellData +'</a></b>');
} },
// Icon
{targets: [mapIndx(3)],
'createdCell': function (td, cellData, rowData, row, col) {
@@ -417,13 +435,13 @@ function initializeDatatable () {
'language' : {
processing: '<table> <td width="130px" align="middle">Loading...</td><td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw"></td> </table>',
emptyTable: 'No data',
"lengthMenu": "<?php echo lang('Device_Tablelenght');?>",
"search": "<?php echo lang('Device_Searchbox');?>: ",
"lengthMenu": "<?= lang('Device_Tablelenght');?>",
"search": "<?= lang('Device_Searchbox');?>: ",
"paginate": {
"next": "<?php echo lang('Device_Table_nav_next');?>",
"previous": "<?php echo lang('Device_Table_nav_prev');?>"
"next": "<?= lang('Device_Table_nav_next');?>",
"previous": "<?= lang('Device_Table_nav_prev');?>"
},
"info": "<?php echo lang('Device_Table_info');?>",
"info": "<?= lang('Device_Table_info');?>",
}
});
@@ -461,7 +479,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],
@@ -505,13 +523,13 @@ function getDevicesList (status) {
// Define color & title for the status selected
switch (deviceStatus) {
case 'all': tableTitle = '<?php echo lang('Device_Shortcut_AllDevices');?>'; color = 'aqua'; break;
case 'connected': tableTitle = '<?php echo lang('Device_Shortcut_Connected');?>'; color = 'green'; break;
case 'favorites': tableTitle = '<?php echo lang('Device_Shortcut_Favorites');?>'; color = 'yellow'; break;
case 'new': tableTitle = '<?php echo lang('Device_Shortcut_NewDevices');?>'; color = 'yellow'; break;
case 'down': tableTitle = '<?php echo lang('Device_Shortcut_DownAlerts');?>'; color = 'red'; break;
case 'archived': tableTitle = '<?php echo lang('Device_Shortcut_Archived');?>'; color = 'gray'; break;
default: tableTitle = '<?php echo lang('Device_Shortcut_Devices');?>'; color = 'gray'; break;
case 'all': tableTitle = '<?= lang('Device_Shortcut_AllDevices');?>'; color = 'aqua'; break;
case 'connected': tableTitle = '<?= lang('Device_Shortcut_Connected');?>'; color = 'green'; break;
case 'favorites': tableTitle = '<?= lang('Device_Shortcut_Favorites');?>'; color = 'yellow'; break;
case 'new': tableTitle = '<?= lang('Device_Shortcut_NewDevices');?>'; color = 'yellow'; break;
case 'down': tableTitle = '<?= lang('Device_Shortcut_DownAlerts');?>'; color = 'red'; break;
case 'archived': tableTitle = '<?= lang('Device_Shortcut_Archived');?>'; color = 'gray'; break;
default: tableTitle = '<?= lang('Device_Shortcut_Devices');?>'; color = 'gray'; break;
}
// Set title and color

View File

@@ -17,17 +17,17 @@
<!-- Content header--------------------------------------------------------- -->
<section class="content-header">
<h1 id="pageTitle">
<?php echo lang('Events_Title');?>
<?= lang('Events_Title');?>
</h1>
<!-- period selector -->
<span class="breadcrumb" style="top: 0px;">
<select class="form-control" id="period" onchange="javascript: periodChanged();">
<option value="1 day"><?php echo lang('Events_Periodselect_today');?></option>
<option value="7 days"><?php echo lang('Events_Periodselect_LastWeek');?></option>
<option value="1 month" selected><?php echo lang('Events_Periodselect_LastMonth');?></option>
<option value="1 year"><?php echo lang('Events_Periodselect_LastYear');?></option>
<option value="100 years"><?php echo lang('Events_Periodselect_All');?></option>
<option value="1 day"><?= lang('Events_Periodselect_today');?></option>
<option value="7 days"><?= lang('Events_Periodselect_LastWeek');?></option>
<option value="1 month" selected><?= lang('Events_Periodselect_LastMonth');?></option>
<option value="1 year"><?= lang('Events_Periodselect_LastYear');?></option>
<option value="100 years"><?= lang('Events_Periodselect_All');?></option>
</select>
</span>
</section>
@@ -42,7 +42,7 @@
<a href="#" onclick="javascript: getEvents('all');">
<div class="small-box bg-aqua">
<div class="inner"> <h3 id="eventsAll"> -- </h3>
<p class="infobox_label"><?php echo lang('Events_Shortcut_AllEvents');?></p>
<p class="infobox_label"><?= lang('Events_Shortcut_AllEvents');?></p>
</div>
<div class="icon"> <i class="fa fa-bolt text-aqua-40"></i> </div>
</div>
@@ -54,7 +54,7 @@
<a href="#" onclick="javascript: getEvents('sessions');">
<div class="small-box bg-green">
<div class="inner"> <h3 id="eventsSessions"> -- </h3>
<p class="infobox_label"><?php echo lang('Events_Shortcut_Sessions');?></p>
<p class="infobox_label"><?= lang('Events_Shortcut_Sessions');?></p>
</div>
<div class="icon"> <i class="fa fa-plug text-green-40"></i> </div>
</div>
@@ -66,7 +66,7 @@
<a href="#" onclick="javascript: getEvents('missing');">
<div class="small-box bg-yellow">
<div class="inner"> <h3 id="eventsMissing"> -- </h3>
<p class="infobox_label"><?php echo lang('Events_Shortcut_MissSessions');?></p>
<p class="infobox_label"><?= lang('Events_Shortcut_MissSessions');?></p>
</div>
<div class="icon"> <i class="fa fa-exchange text-yellow-40"></i> </div>
</div>
@@ -78,7 +78,7 @@
<a href="#" onclick="javascript: getEvents('voided');">
<div class="small-box bg-yellow">
<div class="inner"> <h3 id="eventsVoided"> -- </h3>
<p class="infobox_label"><?php echo lang('Events_Shortcut_VoidSessions');?></p>
<p class="infobox_label"><?= lang('Events_Shortcut_VoidSessions');?></p>
</div>
<div class="icon"> <i class="fa fa-exclamation-circle text-yellow-40"></i> </div>
</div>
@@ -90,7 +90,7 @@
<a href="#" onclick="javascript: getEvents('new');">
<div class="small-box bg-yellow">
<div class="inner"> <h3 id="eventsNewDevices"> -- </h3>
<p class="infobox_label"><?php echo lang('Events_Shortcut_NewDevices');?></p>
<p class="infobox_label"><?= lang('Events_Shortcut_NewDevices');?></p>
</div>
<div class="icon"> <i class="ion ion-plus-round text-yellow-40"></i> </div>
</div>
@@ -102,7 +102,7 @@
<a href="#" onclick="javascript: getEvents('down');">
<div class="small-box bg-red">
<div class="inner"> <h3 id="eventsDown"> -- </h3>
<p class="infobox_label"><?php echo lang('Events_Shortcut_DownAlerts');?></p>
<p class="infobox_label"><?= lang('Events_Shortcut_DownAlerts');?></p>
</div>
<div class="icon"> <i class="fa fa-warning text-red-40"></i> </div>
</div>
@@ -127,18 +127,18 @@
<table id="tableEvents" class="table table-bordered table-hover table-striped ">
<thead>
<tr>
<th><?php echo lang('Events_TableHead_Order');?></th>
<th><?php echo lang('Events_TableHead_Device');?></th>
<th><?php echo lang('Events_TableHead_Owner');?></th>
<th><?php echo lang('Events_TableHead_Date');?></th>
<th><?php echo lang('Events_TableHead_EventType');?></th>
<th><?php echo lang('Events_TableHead_Connection');?></th>
<th><?php echo lang('Events_TableHead_Disconnection');?></th>
<th><?php echo lang('Events_TableHead_Duration');?></th>
<th><?php echo lang('Events_TableHead_DurationOrder');?></th>
<th><?php echo lang('Events_TableHead_IP');?></th>
<th><?php echo lang('Events_TableHead_IPOrder');?></th>
<th><?php echo lang('Events_TableHead_AdditionalInfo');?></th>
<th><?= lang('Events_TableHead_Order');?></th>
<th><?= lang('Events_TableHead_Device');?></th>
<th><?= lang('Events_TableHead_Owner');?></th>
<th><?= lang('Events_TableHead_Date');?></th>
<th><?= lang('Events_TableHead_EventType');?></th>
<th><?= lang('Events_TableHead_Connection');?></th>
<th><?= lang('Events_TableHead_Disconnection');?></th>
<th><?= lang('Events_TableHead_Duration');?></th>
<th><?= lang('Events_TableHead_DurationOrder');?></th>
<th><?= lang('Events_TableHead_IP');?></th>
<th><?= lang('Events_TableHead_IPOrder');?></th>
<th><?= lang('Events_TableHead_AdditionalInfo');?></th>
</tr>
</thead>
</table>
@@ -253,13 +253,13 @@ function initializeDatatable () {
'language' : {
processing: '<table><td width="130px" align="middle">Loading...</td><td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw"></td></table>',
emptyTable: 'No data',
"lengthMenu": "<?php echo lang('Events_Tablelenght');?>",
"search": "<?php echo lang('Events_Searchbox');?>: ",
"lengthMenu": "<?= lang('Events_Tablelenght');?>",
"search": "<?= lang('Events_Searchbox');?>: ",
"paginate": {
"next": "<?php echo lang('Events_Table_nav_next');?>",
"previous": "<?php echo lang('Events_Table_nav_prev');?>"
"next": "<?= lang('Events_Table_nav_next');?>",
"previous": "<?= lang('Events_Table_nav_prev');?>"
},
"info": "<?php echo lang('Events_Table_info');?>",
"info": "<?= lang('Events_Table_info');?>",
}
});
@@ -311,13 +311,13 @@ function getEvents (p_eventsType) {
// Define color & title for the status selected
switch (eventsType) {
case 'all': tableTitle = '<?php echo lang('Events_Shortcut_AllEvents');?>'; color = 'aqua'; sesionCols = false; break;
case 'sessions': tableTitle = '<?php echo lang('Events_Shortcut_Sessions');?>'; color = 'green'; sesionCols = true; break;
case 'missing': tableTitle = '<?php echo lang('Events_Shortcut_MissSessions');?>'; color = 'yellow'; sesionCols = true; break;
case 'voided': tableTitle = '<?php echo lang('Events_Shortcut_VoidSessions');?>'; color = 'yellow'; sesionCols = false; break;
case 'new': tableTitle = '<?php echo lang('Events_Shortcut_NewDevices');?>'; color = 'yellow'; sesionCols = false; break;
case 'down': tableTitle = '<?php echo lang('Events_Shortcut_DownAlerts');?>'; color = 'red'; sesionCols = false; break;
default: tableTitle = '<?php echo lang('Events_Shortcut_Events');?>'; boxClass = ''; sesionCols = false; break;
case 'all': tableTitle = '<?= lang('Events_Shortcut_AllEvents');?>'; color = 'aqua'; sesionCols = false; break;
case 'sessions': tableTitle = '<?= lang('Events_Shortcut_Sessions');?>'; color = 'green'; sesionCols = true; break;
case 'missing': tableTitle = '<?= lang('Events_Shortcut_MissSessions');?>'; color = 'yellow'; sesionCols = true; break;
case 'voided': tableTitle = '<?= lang('Events_Shortcut_VoidSessions');?>'; color = 'yellow'; sesionCols = false; break;
case 'new': tableTitle = '<?= lang('Events_Shortcut_NewDevices');?>'; color = 'yellow'; sesionCols = false; break;
case 'down': tableTitle = '<?= lang('Events_Shortcut_DownAlerts');?>'; color = 'red'; sesionCols = false; break;
default: tableTitle = '<?= lang('Events_Shortcut_Events');?>'; boxClass = ''; sesionCols = false; break;
}
// Set title and color

View File

@@ -8,13 +8,13 @@
<section class="content-header">
<?php require 'php/templates/notification.php'; ?>
<h1 id="pageTitle">
<?php echo lang('HelpFAQ_Title');?>
<?= lang('HelpFAQ_Title');?>
</h1>
</section>
<!-- Main content ---------------------------------------------------------- -->
<section class="content">
<h4><?php echo lang('HelpFAQ_Cat_General');?></h4>
<h4><?= lang('HelpFAQ_Cat_General');?></h4>
<div class="panel-group" id="accordion_gen">
<div class="panel panel-default">
@@ -22,16 +22,16 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_gen" href="#collapse100">
<?php echo lang('HelpFAQ_Cat_General_100_head');?></a>
<?= lang('HelpFAQ_Cat_General_100_head');?></a>
</h4>
</div>
<div id="collapse100" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body"><?php echo lang('HelpFAQ_Cat_General_100_text_a');?>
<div class="panel-body"><?= lang('HelpFAQ_Cat_General_100_text_a');?>
<span class="text-danger help_faq_code"><?php echo date_default_timezone_get(); ?></span><br>
<?php echo lang('HelpFAQ_Cat_General_100_text_b');?>
<?= lang('HelpFAQ_Cat_General_100_text_b');?>
<span class="text-danger help_faq_code"><?php echo php_ini_loaded_file(); ?></span><br>
<?php echo lang('HelpFAQ_Cat_General_100_text_c');?>
<?= lang('HelpFAQ_Cat_General_100_text_c');?>
</div>
</div>
@@ -42,12 +42,12 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_gen" href="#collapse101">
<?php echo lang('HelpFAQ_Cat_General_101_head');?></a>
<?= lang('HelpFAQ_Cat_General_101_head');?></a>
</h4>
</div>
<div id="collapse101" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_General_101_text');?>
<?= lang('HelpFAQ_Cat_General_101_text');?>
</div>
</div>
</div>
@@ -55,12 +55,12 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_gen" href="#collapse102">
<?php echo lang('HelpFAQ_Cat_General_102_head');?></a>
<?= lang('HelpFAQ_Cat_General_102_head');?></a>
</h4>
</div>
<div id="collapse102" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_General_102_text');?>
<?= lang('HelpFAQ_Cat_General_102_text');?>
</div>
</div>
</div>
@@ -68,12 +68,12 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_gen" href="#collapse102docker">
<?php echo lang('HelpFAQ_Cat_General_102docker_head');?></a>
<?= lang('HelpFAQ_Cat_General_102docker_head');?></a>
</h4>
</div>
<div id="collapse102docker" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_General_102docker_text');?>
<?= lang('HelpFAQ_Cat_General_102docker_text');?>
</div>
</div>
</div>
@@ -81,48 +81,48 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_gen" href="#collapse103">
<?php echo lang('HelpFAQ_Cat_General_103_head');?></a>
<?= lang('HelpFAQ_Cat_General_103_head');?></a>
</h4>
</div>
<div id="collapse103" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_General_103_text');?>
<?= lang('HelpFAQ_Cat_General_103_text');?>
</div>
</div>
</div>
</div>
<h4><?php echo lang('Navigation_Devices');?></h4>
<h4><?= lang('Navigation_Devices');?></h4>
<div class="panel-group" id="accordion_dev">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_dev" href="#collapse200">
<?php echo lang('HelpFAQ_Cat_Device_200_head');?></a>
<?= lang('HelpFAQ_Cat_Device_200_head');?></a>
</h4>
</div>
<div id="collapse200" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Device_200_text');?>
<?= lang('HelpFAQ_Cat_Device_200_text');?>
</div>
</div>
</div>
</div>
<h4><?php echo lang('HelpFAQ_Cat_Detail');?></h4>
<h4><?= lang('HelpFAQ_Cat_Detail');?></h4>
<div class="panel-group" id="accordion_det">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_det" href="#collapse300">
<?php echo lang('HelpFAQ_Cat_Detail_300_head');?> "<?php echo lang('DevDetail_MainInfo_Network');?>" / "<?php echo lang('DevDetail_MainInfo_Network_Port');?>"?</a>
<?= lang('HelpFAQ_Cat_Detail_300_head');?> "<?= lang('DevDetail_MainInfo_Network');?>" / "<?= lang('DevDetail_MainInfo_Network_Port');?>"?</a>
</h4>
</div>
<div id="collapse300" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
"<?php echo lang('DevDetail_MainInfo_Network');?>" <?php echo lang('HelpFAQ_Cat_Detail_300_text_a');?><br>
"<?php echo lang('DevDetail_MainInfo_Network_Port');?>" <?php echo lang('HelpFAQ_Cat_Detail_300_text_b');?>
"<?= lang('DevDetail_MainInfo_Network');?>" <?= lang('HelpFAQ_Cat_Detail_300_text_a');?><br>
"<?= lang('DevDetail_MainInfo_Network_Port');?>" <?= lang('HelpFAQ_Cat_Detail_300_text_b');?>
</div>
</div>
</div>
@@ -130,12 +130,12 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_det" href="#collapse301">
<?php echo lang('HelpFAQ_Cat_Detail_301_head_a');?> "<?php echo lang('DevDetail_EveandAl_ScanCycle');?>" <?php echo lang('HelpFAQ_Cat_Detail_301_head_b');?></a>
<?= lang('HelpFAQ_Cat_Detail_301_head_a');?> "<?= lang('DevDetail_EveandAl_ScanCycle');?>" <?= lang('HelpFAQ_Cat_Detail_301_head_b');?></a>
</h4>
</div>
<div id="collapse301" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Detail_301_text');?>
<?= lang('HelpFAQ_Cat_Detail_301_text');?>
</div>
</div>
</div>
@@ -143,12 +143,12 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_det" href="#collapse302">
<?php echo lang('HelpFAQ_Cat_Detail_302_head_a');?> "<?php echo lang('DevDetail_EveandAl_RandomMAC');?>" <?php echo lang('HelpFAQ_Cat_Detail_302_head_b');?></a>
<?= lang('HelpFAQ_Cat_Detail_302_head_a');?> "<?= lang('DevDetail_EveandAl_RandomMAC');?>" <?= lang('HelpFAQ_Cat_Detail_302_head_b');?></a>
</h4>
</div>
<div id="collapse302" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Detail_302_text');?>
<?= lang('HelpFAQ_Cat_Detail_302_text');?>
</div>
</div>
</div>
@@ -156,29 +156,29 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_det" href="#collapse303">
<?php echo lang('HelpFAQ_Cat_Detail_303_head');?></a>
<?= lang('HelpFAQ_Cat_Detail_303_head');?></a>
</h4>
</div>
<div id="collapse303" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Detail_303_text');?>
<?= lang('HelpFAQ_Cat_Detail_303_text');?>
</div>
</div>
</div>
</div>
<h4><?php echo lang('Navigation_Presence');?></h4>
<h4><?= lang('Navigation_Presence');?></h4>
<div class="panel-group" id="accordion_pre">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_pre" href="#collapse400">
<?php echo lang('HelpFAQ_Cat_Presence_400_head');?></a>
<?= lang('HelpFAQ_Cat_Presence_400_head');?></a>
</h4>
</div>
<div id="collapse400" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Presence_400_text');?>
<?= lang('HelpFAQ_Cat_Presence_400_text');?>
</div>
</div>
</div>
@@ -186,29 +186,29 @@
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_pre" href="#collapse401">
<?php echo lang('HelpFAQ_Cat_Presence_401_head');?></a>
<?= lang('HelpFAQ_Cat_Presence_401_head');?></a>
</h4>
</div>
<div id="collapse401" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Presence_401_text');?>
<?= lang('HelpFAQ_Cat_Presence_401_text');?>
</div>
</div>
</div>
</div>
<h4><?php echo lang('Navigation_Network');?></h4>
<h4><?= lang('Navigation_Network');?></h4>
<div class="panel-group" id="accordion_net">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion_net" href="#collapse600">
<?php echo lang('HelpFAQ_Cat_Network_600_head');?></a>
<?= lang('HelpFAQ_Cat_Network_600_head');?></a>
</h4>
</div>
<div id="collapse600" class="panel-collapse collapse" style="font-size: 16px;">
<div class="panel-body">
<?php echo lang('HelpFAQ_Cat_Network_600_text');?>
<?= lang('HelpFAQ_Cat_Network_600_text');?>
</div>
</div>
</div>

View File

@@ -1,7 +1,5 @@
<?php
require 'php/templates/language/lang.php';
require dirname(__FILE__).'/php/server/init.php';
require 'php/templates/security.php';
if ($Pia_WebProtection != 'true')
@@ -97,10 +95,10 @@ if ($ENABLED_DARKMODE === True) {
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg"><?php echo lang('Login_Box');?></p>
<p class="login-box-msg"><?= lang('Login_Box');?></p>
<form action="index.php" method="post">
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="<?php echo lang('Login_Psw-box');?>" name="loginpassword">
<input type="password" class="form-control" placeholder="<?= lang('Login_Psw-box');?>" name="loginpassword">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
@@ -109,21 +107,21 @@ if ($ENABLED_DARKMODE === True) {
<label>
<input type="checkbox" name="PWRemember">
<div style="margin-left: 10px; display: inline-block; vertical-align: top;">
<?php echo lang('Login_Remember');?><br><span style="font-size: smaller"><?php echo lang('Login_Remember_small');?></span>
<?= lang('Login_Remember');?><br><span style="font-size: smaller"><?= lang('Login_Remember_small');?></span>
</div>
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-4" style="padding-top: 10px;">
<button type="submit" class="btn btn-primary btn-block btn-flat"><?php echo lang('Login_Submit');?></button>
<button type="submit" class="btn btn-primary btn-block btn-flat"><?= lang('Login_Submit');?></button>
</div>
<!-- /.col -->
</div>
</form>
<div style="padding-top: 10px;">
<button class="btn btn-xs btn-primary btn-block btn-flat" onclick="Passwordhinfo()"><?php echo lang('Login_Toggle_Info');?></button>
<button class="btn btn-xs btn-primary btn-block btn-flat" onclick="Passwordhinfo()"><?= lang('Login_Toggle_Info');?></button>
</div>
</div>
@@ -136,7 +134,7 @@ if ($ENABLED_DARKMODE === True) {
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button>
<h4><i class="icon fa <?php echo $login_icon;?>"></i><?php echo $login_headline;?></h4>
<p><?php echo $login_info;?></p>
<p><?php echo lang('Login_Psw_run');?><br><span style="border: solid 1px yellow; padding: 2px;">./reset_password.sh <?php echo lang('Login_Psw_new');?></span><br><?php echo lang('Login_Psw_folder');?></p>
<p><?= lang('Login_Psw_run');?><br><span style="border: solid 1px yellow; padding: 2px;">./reset_password.sh <?= lang('Login_Psw_new');?></span><br><?= lang('Login_Psw_folder');?></p>
</div>
</div>

View File

@@ -10,7 +10,7 @@
// -----------------------------------------------------------------------------
var timerRefreshData = ''
var modalCallbackFunction = '';
var emptyArr = ['undefined', "", undefined, null];
var emptyArr = ['undefined', "", undefined, null, 'null'];
// urlParams = new Proxy(new URLSearchParams(window.location.search), {
// get: (searchParams, prop) => searchParams.get(prop.toString()),
@@ -290,14 +290,30 @@ function settingsChanged()
};
}
// -----------------------------------------------------------------------------
function getQueryString(key){
params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
tmp = params[key]
result = emptyArr.includes(tmp) ? "" : tmp;
return result
}
// -----------------------------------------------------------------------------
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'), "&nbsp");
text2 = text2.replace(new RegExp('<', 'g'), "&lt");
return text2;
}
var text2 = text.replace(new RegExp(' ', 'g'), "&nbsp");
text2 = text2.replace(new RegExp('<', 'g'), "&lt");
return text2;
return "";
}

View File

@@ -11,19 +11,6 @@
// leiweibau 2022 https://github.com/leiweibau GNU GPLv3
//------------------------------------------------------------------------------
// Language selector config ----------------------------------------------------
//
// For security reasons, new language files must be entered into this array.
// The files in the language directory are compared with this array and only
// then accepted.
//
$pia_installed_langs = array('en_us',
'de_de',
'es_es');
//
// In addition to this, the language must also be added to the select tag in
// line 235. Later, the whole thing may become dynamic.
// Skin selector config ----------------------------------------------------
//
// For security reasons, new language files must be entered into this array.
@@ -57,7 +44,7 @@ $pia_installed_skins = array('skin-black-light',
<section class="content-header">
<?php require 'php/templates/notification.php'; ?>
<h1 id="pageTitle">
<?php echo lang('Maintenance_Title');?>
<?= lang('Maintenance_Title');?>
</h1>
</section>
@@ -145,31 +132,31 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<div class="box-body" style="padding-bottom: 5px;">
<div class="db_info_table">
<div class="db_info_table_row">
<div class="db_info_table_cell" style="min-width: 140px"><?php echo lang('Maintenance_version');?></div>
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_version');?></div>
<div class="db_info_table_cell">
<div class="version" id="version" data-build-time="<?php echo file_get_contents( "buildtimestamp.txt");?>"><?php echo '<span id="new-version-text" class="myhidden">' .lang('Maintenance_new_version').'</span>'.'<span id="current-version-text" class="myhidden">' .lang('Maintenance_current_version').'</span>';?></div>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell" style="min-width: 140px"><?php echo lang('Maintenance_database_path');?></div>
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_database_path');?></div>
<div class="db_info_table_cell">
<?php echo $pia_db;?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell"><?php echo lang('Maintenance_database_size');?></div>
<div class="db_info_table_cell"><?= lang('Maintenance_database_size');?></div>
<div class="db_info_table_cell">
<?php echo $pia_db_size;?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell"><?php echo lang('Maintenance_database_lastmod');?></div>
<div class="db_info_table_cell"><?= lang('Maintenance_database_lastmod');?></div>
<div class="db_info_table_cell">
<?php echo $pia_db_mod;?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell"><?php echo lang('Maintenance_database_backup');?></div>
<div class="db_info_table_cell"><?= lang('Maintenance_database_backup');?></div>
<div class="db_info_table_cell">
<?php echo $Pia_Archive_count.' '.lang('Maintenance_database_backup_found').' / '.lang('Maintenance_database_backup_total').': '.$Pia_Archive_diskusage;?>
</div>
@@ -184,44 +171,27 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active">
<a id="tab_Settings_id" href="#tab_Settings" data-toggle="tab"><?php echo lang('Maintenance_Tools_Tab_UISettings');?></a>
<a id="tab_Settings_id" href="#tab_Settings" data-toggle="tab"><?= lang('Maintenance_Tools_Tab_UISettings');?></a>
</li>
<li>
<a id="tab_DBTools_id" href="#tab_DBTools" data-toggle="tab"><?php echo lang('Maintenance_Tools_Tab_Tools');?></a>
<a id="tab_DBTools_id" href="#tab_DBTools" data-toggle="tab"><?= lang('Maintenance_Tools_Tab_Tools');?></a>
</li>
<li>
<a id="tab_BackupRestore_id" href="#tab_BackupRestore" data-toggle="tab"><?php echo lang('Maintenance_Tools_Tab_BackupRestore');?></a>
<a id="tab_BackupRestore_id" href="#tab_BackupRestore" data-toggle="tab"><?= lang('Maintenance_Tools_Tab_BackupRestore');?></a>
</li>
<li>
<a id="tab_Logging_id" href="#tab_Logging" data-toggle="tab"><?php echo lang('Maintenance_Tools_Tab_Logging');?></a>
<a id="tab_Logging_id" href="#tab_Logging" data-toggle="tab"><?= lang('Maintenance_Tools_Tab_Logging');?></a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_Settings">
<div class="db_info_table">
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="text-align:center;">
<form method="post" action="maintenance.php">
<div style="display: inline-block;">
<select name="langselector" id="langselector" class="form-control bg-green" style="width:160px; margin-bottom:5px;">
<option value=""><?php echo lang('Maintenance_lang_selector_empty');?></option>
<option value="en_us"><?php echo lang('Maintenance_lang_en_us');?></option>
<option value="de_de"><?php echo lang('Maintenance_lang_de_de');?></option>
<option value="es_es"><?php echo lang('Maintenance_lang_es_es');?></option>
</select>
</div>
</form>
</div>
<div class="db_info_table_cell" style="padding: 10px; height:40px; text-align:left; vertical-align: middle;">
<?php echo lang('Maintenance_lang_selector_text');?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="text-align: center;">
<form method="post" action="maintenance.php">
<div style="display: inline-block; text-align: center;">
<select name="skinselector" class="form-control bg-green" style="width:160px; margin-bottom:5px;">
<option value=""><?php echo lang('Maintenance_themeselector_empty');?></option>
<option value=""><?= lang('Maintenance_themeselector_empty');?></option>
<option value="skin-black-light">black light</option>
<option value="skin-black">black</option>
<option value="skin-blue-light">blue light</option>
@@ -235,49 +205,52 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<option value="skin-yellow-light">yellow light</option>
<option value="skin-yellow">yellow</option>
</select></div>
<div style="display: block;"><input type="submit" name="skinselector_set" value="<?php echo lang('Maintenance_themeselector_apply');?>" class="btn bg-green" style="width:160px;">
<div style="display: block;"><input type="submit" name="skinselector_set" value="<?= lang('Maintenance_themeselector_apply');?>" class="btn bg-green" style="width:160px;">
<?php // echo $pia_skin_test; ?>
</div>
</form>
</div>
<div class="db_info_table_cell" style="padding: 10px; height:40px; text-align:left; vertical-align: middle;">
<?php echo lang('Maintenance_themeselector_text'); ?>
<?= lang('Maintenance_themeselector_text'); ?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a">
<button type="button" class="btn bg-green dbtools-button" id="btnToggleDarkmode" onclick="askToggleDarkmode()"><?php echo lang('Maintenance_Tool_darkmode');?></button>
<button type="button" class="btn bg-green dbtools-button" id="btnToggleDarkmode" onclick="askToggleDarkmode()"><?= lang('Maintenance_Tool_darkmode');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_darkmode_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_darkmode_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a">
<div class="form-group" >
<div class="input-group" >
<select id="columnsSelect" class="form-control select2 select2-hidden-accessible" multiple="" style="width: 100%;" tabindex="-1" aria-hidden="true">
<option value="0"><?php echo lang('Device_TableHead_Name');?></option>
<option value="1"><?php echo lang('Device_TableHead_Owner');?></option>
<option value="2"><?php echo lang('Device_TableHead_Type');?></option>
<option value="3"><?php echo lang('Device_TableHead_Icon');?></option>
<option value="4"><?php echo lang('Device_TableHead_Favorite');?></option>
<option value="5"><?php echo lang('Device_TableHead_Group');?></option>
<option value="6"><?php echo lang('Device_TableHead_FirstSession');?></option>
<option value="7"><?php echo lang('Device_TableHead_LastSession');?></option>
<option value="8"><?php echo lang('Device_TableHead_LastIP');?></option>
<option value="9"><?php echo lang('Device_TableHead_MAC');?></option>
<option value="10"><?php echo lang('Device_TableHead_Status');?></option>
<option value="11"><?php echo lang('Device_TableHead_MAC_full');?></option>
<option value="12"><?php echo lang('Device_TableHead_LastIPOrder');?></option>
<option value="13"><?php echo lang('Device_TableHead_Rowid');?></option>
<option value="14"><?php echo lang('Device_TableHead_Parent_MAC');?></option>
<option value="0"><?= lang('Device_TableHead_Name');?></option>
<option value="1"><?= lang('Device_TableHead_Owner');?></option>
<option value="2"><?= lang('Device_TableHead_Type');?></option>
<option value="3"><?= lang('Device_TableHead_Icon');?></option>
<option value="4"><?= lang('Device_TableHead_Favorite');?></option>
<option value="5"><?= lang('Device_TableHead_Group');?></option>
<option value="6"><?= lang('Device_TableHead_FirstSession');?></option>
<option value="7"><?= lang('Device_TableHead_LastSession');?></option>
<option value="8"><?= lang('Device_TableHead_LastIP');?></option>
<option value="9"><?= lang('Device_TableHead_MAC');?></option>
<option value="10"><?= lang('Device_TableHead_Status');?></option>
<option value="11"><?= lang('Device_TableHead_MAC_full');?></option>
<option value="12"><?= lang('Device_TableHead_LastIPOrder');?></option>
<option value="13"><?= lang('Device_TableHead_Rowid');?></option>
<option value="14"><?= lang('Device_TableHead_Parent_MAC');?></option>
<option value="15"><?= lang('Device_TableHead_Connected_Devices');?></option>
<option value="16"><?= lang('Device_TableHead_Location');?></option>
<option value="17"><?= lang('Device_TableHead_Vendor');?></option>
</select>
<span class="input-group-addon"><i title="<?php echo lang('DevDetail_GoToNetworkNode');?>" class="fa fa-save pointer" onclick="saveSelectedColumns();"></i></span>
<span class="input-group-addon"><i title="<?= lang('DevDetail_GoToNetworkNode');?>" class="fa fa-save pointer" onclick="saveSelectedColumns();"></i></span>
</div>
</div>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_displayed_columns_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_displayed_columns_text');?></div>
</div>
@@ -287,39 +260,39 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<div class="db_info_table">
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" onclick="askDeleteDevicesWithEmptyMACs()"><?php echo lang('Maintenance_Tool_del_empty_macs');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" onclick="askDeleteDevicesWithEmptyMACs()"><?= lang('Maintenance_Tool_del_empty_macs');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_del_empty_macs_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_empty_macs_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" onclick="askDeleteAllDevices()"><?php echo lang('Maintenance_Tool_del_alldev');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteMAC" onclick="askDeleteAllDevices()"><?= lang('Maintenance_Tool_del_alldev');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_del_alldev_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_alldev_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteUnknown" onclick="askDeleteUnknown()"><?php echo lang('Maintenance_Tool_del_unknowndev');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteUnknown" onclick="askDeleteUnknown()"><?= lang('Maintenance_Tool_del_unknowndev');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_del_unknowndev_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_unknowndev_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteEvents" onclick="askDeleteEvents()"><?php echo lang('Maintenance_Tool_del_allevents');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteEvents" onclick="askDeleteEvents()"><?= lang('Maintenance_Tool_del_allevents');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_del_allevents_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_allevents_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteEvents30" onclick="askDeleteEvents30()"><?php echo lang('Maintenance_Tool_del_allevents30');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteEvents30" onclick="askDeleteEvents30()"><?= lang('Maintenance_Tool_del_allevents30');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_del_allevents30_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_allevents30_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteActHistory" onclick="askDeleteActHistory()"><?php echo lang('Maintenance_Tool_del_ActHistory');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnDeleteActHistory" onclick="askDeleteActHistory()"><?= lang('Maintenance_Tool_del_ActHistory');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_del_ActHistory_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_del_ActHistory_text');?></div>
</div>
</div>
</div>
@@ -327,33 +300,33 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<div class="db_info_table">
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaBackupDBtoArchive" onclick="askPiaBackupDBtoArchive()"><?php echo lang('Maintenance_Tool_backup');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaBackupDBtoArchive" onclick="askPiaBackupDBtoArchive()"><?= lang('Maintenance_Tool_backup');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_backup_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_backup_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaRestoreDBfromArchive" onclick="askPiaRestoreDBfromArchive()"><?php echo lang('Maintenance_Tool_restore');?><br><?php echo $latestbackup_date;?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaRestoreDBfromArchive" onclick="askPiaRestoreDBfromArchive()"><?= lang('Maintenance_Tool_restore');?><br><?php echo $latestbackup_date;?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_restore_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_restore_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaPurgeDBBackups" onclick="askPiaPurgeDBBackups()"><?php echo lang('Maintenance_Tool_purgebackup');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnPiaPurgeDBBackups" onclick="askPiaPurgeDBBackups()"><?= lang('Maintenance_Tool_purgebackup');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_purgebackup_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_purgebackup_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn bg-green dbtools-button" id="btnExportCSV" onclick="askExportCSV()"><?php echo lang('Maintenance_Tool_ExportCSV');?></button>
<button type="button" class="btn btn-default pa-btn bg-green dbtools-button" id="btnExportCSV" onclick="askExportCSV()"><?= lang('Maintenance_Tool_ExportCSV');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_ExportCSV_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_ExportCSV_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a" style="">
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnImportCSV" onclick="askImportCSV()"><?php echo lang('Maintenance_Tool_ImportCSV');?></button>
<button type="button" class="btn btn-default pa-btn pa-btn-delete bg-red dbtools-button" id="btnImportCSV" onclick="askImportCSV()"><?= lang('Maintenance_Tool_ImportCSV');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_ImportCSV_text');?></div>
<div class="db_tools_table_cell_b"><?= lang('Maintenance_Tool_ImportCSV_text');?></div>
</div>
</div>
</div>
@@ -371,7 +344,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/pialert.log" target="_blank"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('pialert.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('pialert.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -387,7 +360,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/pialert_front.log"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('pialert_front.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('pialert_front.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -404,7 +377,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/pialert_pholus.log"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('pialert_pholus.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('pialert_pholus.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -422,7 +395,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/pialert_pholus_lastrun.log"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('pialert_pholus_lastrun.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('pialert_pholus_lastrun.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -440,7 +413,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/IP_changes.log"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('IP_changes.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('IP_changes.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -457,7 +430,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/stdout.log"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('stdout.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('stdout.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -474,7 +447,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<span class="span-padding"><a href="./log/stderr.log"><i class="fa fa-download"></i> </a></span>
</div></div>
<div class="log-purge">
<button class="btn btn-primary" onclick="logManage('stderr.log','cleanLog')"><?php echo lang('Gen_Purge');?></button>
<button class="btn btn-primary" onclick="logManage('stderr.log','cleanLog')"><?= lang('Gen_Purge');?></button>
</div>
</div>
</div>
@@ -525,7 +498,7 @@ initializeTabs();
// delete devices with emty macs
function askDeleteDevicesWithEmptyMACs () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_del_empty_macs_noti');?>', '<?php echo lang('Maintenance_Tool_del_empty_macs_noti_text');?>',
showModalWarning('<?= lang('Maintenance_Tool_del_empty_macs_noti');?>', '<?= lang('Maintenance_Tool_del_empty_macs_noti_text');?>',
'Cancel', 'Delete', 'deleteDevicesWithEmptyMACs');
}
function deleteDevicesWithEmptyMACs()
@@ -539,8 +512,8 @@ function deleteDevicesWithEmptyMACs()
// delete all devices
function askDeleteAllDevices () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_del_alldev_noti');?>', '<?php echo lang('Maintenance_Tool_del_alldev_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteAllDevices');
showModalWarning('<?= lang('Maintenance_Tool_del_alldev_noti');?>', '<?= lang('Maintenance_Tool_del_alldev_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteAllDevices');
}
function deleteAllDevices()
{
@@ -553,8 +526,8 @@ function deleteAllDevices()
// delete all (unknown) devices
function askDeleteUnknown () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_del_unknowndev_noti');?>', '<?php echo lang('Maintenance_Tool_del_unknowndev_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteUnknownDevices');
showModalWarning('<?= lang('Maintenance_Tool_del_unknowndev_noti');?>', '<?= lang('Maintenance_Tool_del_unknowndev_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteUnknownDevices');
}
function deleteUnknownDevices()
{
@@ -567,8 +540,8 @@ function deleteUnknownDevices()
// delete all Events
function askDeleteEvents () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_del_allevents_noti');?>', '<?php echo lang('Maintenance_Tool_del_allevents_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteEvents');
showModalWarning('<?= lang('Maintenance_Tool_del_allevents_noti');?>', '<?= lang('Maintenance_Tool_del_allevents_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteEvents');
}
function deleteEvents()
{
@@ -581,8 +554,8 @@ function deleteEvents()
// delete all Events older than 30 days
function askDeleteEvents30 () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_del_allevents30_noti');?>', '<?php echo lang('Maintenance_Tool_del_allevents30_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteEvents30');
showModalWarning('<?= lang('Maintenance_Tool_del_allevents30_noti');?>', '<?= lang('Maintenance_Tool_del_allevents30_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteEvents30');
}
function deleteEvents30()
{
@@ -595,8 +568,8 @@ function deleteEvents30()
// delete History
function askDeleteActHistory () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_del_ActHistory_noti');?>', '<?php echo lang('Maintenance_Tool_del_ActHistory_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Delete');?>', 'deleteActHistory');
showModalWarning('<?= lang('Maintenance_Tool_del_ActHistory_noti');?>', '<?= lang('Maintenance_Tool_del_ActHistory_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteActHistory');
}
function deleteActHistory()
{
@@ -609,8 +582,8 @@ function deleteActHistory()
// Backup DB to Archive
function askPiaBackupDBtoArchive () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_backup_noti');?>', '<?php echo lang('Maintenance_Tool_backup_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Backup');?>', 'PiaBackupDBtoArchive');
showModalWarning('<?= lang('Maintenance_Tool_backup_noti');?>', '<?= lang('Maintenance_Tool_backup_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Backup');?>', 'PiaBackupDBtoArchive');
}
function PiaBackupDBtoArchive()
{
@@ -623,8 +596,8 @@ function PiaBackupDBtoArchive()
// Restore DB from Archive
function askPiaRestoreDBfromArchive () {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_restore_noti');?>', '<?php echo lang('Maintenance_Tool_restore_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Restore');?>', 'PiaRestoreDBfromArchive');
showModalWarning('<?= lang('Maintenance_Tool_restore_noti');?>', '<?= lang('Maintenance_Tool_restore_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Restore');?>', 'PiaRestoreDBfromArchive');
}
function PiaRestoreDBfromArchive()
{
@@ -637,8 +610,8 @@ function PiaRestoreDBfromArchive()
// Purge Backups
function askPiaPurgeDBBackups() {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_purgebackup_noti');?>', '<?php echo lang('Maintenance_Tool_purgebackup_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Purge');?>', 'PiaPurgeDBBackups');
showModalWarning('<?= lang('Maintenance_Tool_purgebackup_noti');?>', '<?= lang('Maintenance_Tool_purgebackup_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Purge');?>', 'PiaPurgeDBBackups');
}
function PiaPurgeDBBackups()
{
@@ -651,8 +624,8 @@ function PiaPurgeDBBackups()
// Export CSV
function askExportCSV() {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_ExportCSV_noti');?>', '<?php echo lang('Maintenance_Tool_ExportCSV_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', 'ExportCSV');
showModalWarning('<?= lang('Maintenance_Tool_ExportCSV_noti');?>', '<?= lang('Maintenance_Tool_ExportCSV_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', 'ExportCSV');
}
function ExportCSV()
{
@@ -663,8 +636,8 @@ function ExportCSV()
// Import CSV
function askImportCSV() {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_ImportCSV_noti');?>', '<?php echo lang('Maintenance_Tool_ImportCSV_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', 'ImportCSV');
showModalWarning('<?= lang('Maintenance_Tool_ImportCSV_noti');?>', '<?= lang('Maintenance_Tool_ImportCSV_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', 'ImportCSV');
}
function ImportCSV()
{
@@ -679,8 +652,8 @@ function ImportCSV()
// Switch Darkmode
function askToggleDarkmode() {
// Ask
showModalWarning('<?php echo lang('Maintenance_Tool_darkmode_noti');?>', '<?php echo lang('Maintenance_Tool_darkmode_noti_text');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Switch');?>', 'ToggleDarkmode');
showModalWarning('<?= lang('Maintenance_Tool_darkmode_noti');?>', '<?= lang('Maintenance_Tool_darkmode_noti_text');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Switch');?>', 'ToggleDarkmode');
}
// --------------------------------------------------------
@@ -724,8 +697,8 @@ function logManage(callback) {
targetLogFile = arguments[0]; // target
logFileAction = arguments[1]; // action
// Ask
showModalWarning('<?php echo lang('Gen_Purge');?>' + ' ' + arguments[1], '<?php echo lang('Gen_AreYouSure');?>',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', "performLogManage");
showModalWarning('<?= lang('Gen_Purge');?>' + ' ' + arguments[1], '<?= lang('Gen_AreYouSure');?>',
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Okay');?>', "performLogManage");
}
// --------------------------------------------------------
@@ -760,6 +733,9 @@ function scrollDown()
// --------------------------------------------------------
// Manage displayed columns
// --------------------------------------------------------
colDefaultOrder = ['0','1','2','3','4','5','6','7','8','9','10','12','13','14','15','16','17'];
colDefaultOrderTxt = '[0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17]';
function saveSelectedColumns () {
$.get('php/server/parameters.php?action=set&expireMinutes=525600&value=['+ $('#columnsSelect').val().toString() +']&parameter=Front_Devices_Columns_Visible', function(data) {
@@ -767,7 +743,7 @@ function saveSelectedColumns () {
colDisplayed = $('#columnsSelect').val();
colDefaultOrder = ['0','1','2','3','4','5','6','7','8','9','10','12','13','14'];
colNewOrder = colDisplayed;
@@ -791,7 +767,7 @@ function saveSelectedColumns () {
// --------------------------------------------------------
function initializeSelectedColumns () {
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue=[0,1,2,3,4,5,6,7,8,9,10,12,13,14]&parameter=Front_Devices_Columns_Visible', function(data) {
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+colDefaultOrderTxt+'&parameter=Front_Devices_Columns_Visible', function(data) {
tableColumnShow = numberArrayFromString(data);

View File

@@ -1,8 +1,6 @@
<?php
require 'php/templates/header.php';
require 'php/server/db.php';
require 'php/server/util.php';
// online / offline badges HTML snippets
define('badge_online', '<div class="badge bg-green text-white" style="width: 60px;">Online</div>');
@@ -20,8 +18,9 @@
<section class="content-header">
<?php require 'php/templates/notification.php'; ?>
<h1 id="pageTitle">
<i class="fa fa-network-wired"></i> <?php echo lang('Network_Title');?>
</h1>
<i class="fa fa-network-wired"></i> <?= lang('Network_Title');?>
<span class="networkPageHelp"> <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/NETWORK_TREE.md"><i class="fa fa-circle-question"></i></a><span>
</h1>
</section>
@@ -126,7 +125,7 @@
<b>'.lang('Network_Parent').'</b>
</td>
<td>
<a onclick="setCache(\'activeNetworkTab\',\''.$idParentMac.'_id\')" href="./network.php">
<a href="./network.php?mac='.$idParentMac.'">
<b class="anonymize">'.$idParentMac.' <i class="fa fa-square-up-right"></i></b>
</a>
</td>
@@ -359,7 +358,7 @@
dev_Name as name,
dev_LastIP as last_ip,
dev_Network_Node_MAC_ADDR
FROM Devices WHERE (dev_Network_Node_MAC_ADDR is null or dev_Network_Node_MAC_ADDR = "" or dev_Network_Node_MAC_ADDR = " " ) and dev_MAC not like "%internet%" order by name asc';
FROM Devices WHERE (dev_Network_Node_MAC_ADDR is null or dev_Network_Node_MAC_ADDR = "" or dev_Network_Node_MAC_ADDR = " " or dev_Network_Node_MAC_ADDR = "undefined") and dev_MAC not like "%internet%" order by name asc';
global $db;
$func_result = $db->query($func_sql);
@@ -453,8 +452,34 @@
<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)
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],
"childrenQty":item[15]
}})
setCache('devicesListNew', JSON.stringify(devicesListnew))
// create tree
initTree(getHierarchy());
// attach on-click events
attachTreeEvents();
});
</script>
<script defer>
// ---------------------------------------------------------------------------
// Tree functionality
// ---------------------------------------------------------------------------
@@ -462,7 +487,7 @@
function getDevicesList()
{
// Read cache
devicesList = getCache('devicesList');
devicesList = getCache('devicesListNew');
if (devicesList != '') {
devicesList = JSON.parse (devicesList);
@@ -475,9 +500,15 @@
// ---------------------------------------------------------------------------
var leafNodesCount = 0;
var treeLoadedAlready = false;
var hiddenMacs = [];
var visibleNodesCount = 0;
var parentNodesCount = 0;
var hiddenMacs = []; // hidden children
var hiddenChildren = [];
// ---------------------------------------------------------------------------
function getChildren(node, list, path)
{
var children = [];
@@ -485,24 +516,32 @@
// 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))
{
{
visibleNodesCount++
// and process them
children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + list[i].parentMac, hiddenMacs))
}
}
// note the total number of leaf nodes to calculate the font scaling
if(!treeLoadedAlready && children.length == 0)
if(children.length == 0)
{
leafNodesCount++
}
} else
{
parentNodesCount++
}
return {
name: node.name,
path: path,
mac: node.mac,
id: node.mac,
parentMac: node.parentMac,
icon: node.icon,
type: node.type,
@@ -516,9 +555,11 @@
}
// ---------------------------------------------------------------------------
list = getDevicesList();
function getHierarchy()
{
list = getDevicesList();
for(i in list)
{
if(list[i].mac == 'Internet')
@@ -554,23 +595,30 @@
// re-attach any onclick events
attachTreeEvents();
}
// ---------------------------------------------------------------------------
function attachTreeEvents()
{
// toggle subtree functionality
$("div[data-mytreemac]").each(function(){
$(this).attr('onclick', 'toggleSubTree("'+$(this).attr('data-mytreemac')+'","'+ $(this).attr('data-mytreepath')+'")')
$(this).attr('onclick', 'toggleSubTree("'+$(this).attr('data-mytreemac')+'","'+ $(this).attr('data-mytreepath')+'")')
});
}
// ---------------------------------------------------------------------------
var myTree;
var treeAreaHeight = 600;
var emSize;
var nodeHeight;
function initTree(myHierarchy)
{
// to prevent font scaling everytime we collapse/expand a subtree
treeLoadedAlready = true;
// calculate the font size of the leaf nodes to fit everything into the tree area
leafNodesCount == 0 ? 1 : leafNodesCount;
emSize = ((600/(20*leafNodesCount)).toFixed(2));
emSize = emSize > 1 ? 1 : emSize;
nodeHeight = ((emSize*100*0.30).toFixed(0))
$("#networkTree").attr('style', "height:"+treeAreaHeight+"px; width:1070px")
@@ -578,18 +626,16 @@
htmlId: "networkTree",
renderNode: nodeData => {
var fontSize = "font-size:"+emSize+"em;";
// 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;";
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";
collapseExpandHtml = (nodeData.data.hasChildren) ? "<div class='netCollapse' data-mytreepath='"+nodeData.data.path+"' data-mytreemac='"+nodeData.data.mac+"'><i class='fa fa-"+ collapseExpandIcon +" pointer'></i></div>" : "";
collapseExpandHtml = (nodeData.data.hasChildren) ? "<div class='netCollapse' style='font-size:"+emSize*2.5+"em;' data-mytreepath='"+nodeData.data.path+"' data-mytreemac='"+nodeData.data.mac+"'><i class='fa fa-"+ collapseExpandIcon +" pointer'></i></div>" : "";
statusCss = " netStatus-" + nodeData.data.status;
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;\
@@ -599,7 +645,6 @@
justify-content:center;\
" + fontSize + "\
align-items:center;\
background-color:" +nodeData.data.color+";\
border-radius:5px;'\
>\
<div class='netNodeText '>\
@@ -614,20 +659,20 @@
// console.log(this)
},
mainAxisNodeSpacing: 'auto',
// mainAxisNodeSpacing: 3,
secondaryAxisNodeSpacing: 0.3,
nodeHeight: '25',
nodeHeight: nodeHeight.toString(),
marginTop: '5',
hasZoom: false,
hasPan: false,
marginLeft: '15',
idKey: "name",
hasFlatData: false,
// marginLeft: '15',
idKey: "id",
hasFlatData: false,
linkWidth: (nodeData) => 3,
relationnalField: "children",
relationnalField: "children",
});
myTree.refresh(myHierarchy);
myTree.refresh(myHierarchy);
}
// ---------------------------------------------------------------------------
@@ -637,25 +682,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()
});
@@ -669,12 +696,12 @@
selectedTab = "Internet_id"
// the #target from the url
target = window.location.hash.substr(1)
target = getQueryString('mac')
// update cookie if target specified
if(target != "")
{
setCache(key, target+'_id') // _id is added so it doesn't conflict with AdminLTE tab behavior
setCache(key, target.replaceAll(":","_")+'_id') // _id is added so it doesn't conflict with AdminLTE tab behavior
}
// get the tab id from the cookie (already overriden by the target)
@@ -690,14 +717,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 +755,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 +765,8 @@
// init selected (first) tab
initTab();
// create tree
initTree(getHierarchy());
// attach on-click events
attachTreeEvents();
// init Assign/Unassign buttons
initButtons()
</script>

View File

@@ -8,11 +8,9 @@
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
//------------------------------------------------------------------------------
require '/home/pi/pialert/front/php/templates/timezone.php';
//------------------------------------------------------------------------------
// DB File Path
$DBFILE = '/home/pi/pialert/db/pialert.db';
$DBFILE = dirname(__FILE__).'/../../../db/pialert.db';
//------------------------------------------------------------------------------
// Connect DB
@@ -74,6 +72,3 @@ function OpenDB (...$DBPath) {
// # Open DB once and keep open
// # Opening / closing DB frequently actually casues more issues
OpenDB (); // main
?>

View File

@@ -9,10 +9,7 @@
//------------------------------------------------------------------------------
// External files
require '/home/pi/pialert/front/php/templates/timezone.php';
require '/home/pi/pialert/front/php/templates/language/lang.php';
require '/home/pi/pialert/front/php/server/db.php';
require '/home/pi/pialert/front/php/server/util.php';
require dirname(__FILE__).'/init.php';
//------------------------------------------------------------------------------
// Action selector
@@ -563,57 +560,145 @@ function getDevicesTotals() {
}
//------------------------------------------------------------------------------
// Query the List of devices in a determined Status
//------------------------------------------------------------------------------
// function getDevicesListForNetworkTree() {
// global $db;
// $sql = 'SELECT *, CASE
// WHEN t1.dev_AlertDeviceDown=1 AND t1.dev_PresentLastScan=0 THEN "Down"
// WHEN t1.dev_NewDevice=1 THEN "New"
// WHEN t1.dev_PresentLastScan=1 THEN "On-line"
// ELSE "Off-line" END AS dev_Status
// FROM (Devices ) t1
// LEFT JOIN
// (
// SELECT *,
// count() as connected_devices
// FROM Devices b
// WHERE b.dev_Network_Node_MAC_ADDR NOT NULL group by b.dev_Network_Node_MAC_ADDR
// ) t2
// ON (t1.dev_MAC = t2.dev_MAC); ';
// $result = $db->query($sql);
// // arrays of rows
// $tableData = array();
// while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// $defaultOrder = array ($row['dev_Name'],
// $row['dev_Owner'],
// handleNull($row['dev_DeviceType']),
// handleNull($row['dev_Icon'], "laptop"),
// $row['dev_Favorite'],
// $row['dev_Group'],
// formatDate ($row['dev_FirstConnection']),
// formatDate ($row['dev_LastConnection']),
// $row['dev_LastIP'],
// ( in_array($row['dev_MAC'][1], array("2","6","A","E","a","e")) ? 1 : 0),
// $row['dev_Status'],
// $row['dev_MAC'], // MAC (hidden)
// formatIPlong ($row['dev_LastIP']), // IP orderable
// $row['rowid'], // Rowid (hidden)
// handleNull($row['dev_Network_Node_MAC_ADDR']), //
// handleNull($row['connected_devices']) //
// );
// $newOrder = array();
// // reorder columns based on user settings
// for($index = 0; $index < count($columnOrderMapping); $index++)
// {
// array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
// }
// $tableData['data'][] = $newOrder;
// }
// // Control no rows
// if (empty($tableData['data'])) {
// $tableData['data'] = '';
// }
// // Return json
// echo (json_encode ($tableData));
// }
//------------------------------------------------------------------------------
// Query the List of devices in a determined Status
//------------------------------------------------------------------------------
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),
array("connected_devices", 15, 15),
array("dev_Location", 16, 16),
array("dev_Vendor", 17, 17)
);
// 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];
}
}
}
// SQL
$condition = getDeviceCondition ($_REQUEST['status']);
$sql = 'SELECT rowid, *, CASE
WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down"
WHEN dev_NewDevice=1 THEN "New"
WHEN dev_PresentLastScan=1 THEN "On-line"
ELSE "Off-line"
END AS dev_Status
FROM Devices '. $condition;
$sql = 'SELECT * FROM (
SELECT rowid, *, CASE
WHEN t1.dev_AlertDeviceDown=1 AND t1.dev_PresentLastScan=0 THEN "Down"
WHEN t1.dev_NewDevice=1 THEN "New"
WHEN t1.dev_PresentLastScan=1 THEN "On-line"
ELSE "Off-line" END AS dev_Status
FROM Devices t1 '.$condition.') t3
LEFT JOIN
(
SELECT dev_Network_Node_MAC_ADDR as dev_Network_Node_MAC_ADDR_t2, dev_MAC as dev_MAC_t2,
count() as connected_devices
FROM Devices b
WHERE b.dev_Network_Node_MAC_ADDR NOT NULL group by b.dev_Network_Node_MAC_ADDR
) t2
ON (t3.dev_MAC = t2.dev_Network_Node_MAC_ADDR_t2);';
$result = $db->query($sql);
// arrays of rows
@@ -622,8 +707,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 +719,15 @@ 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']),
handleNull($row['connected_devices']),
handleNull($row['dev_Location']),
handleNull($row['dev_Vendor'])
);
$newOrder = array();
// reorder columns based on user settings
for($index = 0; $index < count($columnOrderMapping); $index++)
{
array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]);
@@ -757,10 +845,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

View File

@@ -9,8 +9,7 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// External files
require 'db.php';
require 'util.php';
require dirname(__FILE__).'/init.php';
//------------------------------------------------------------------------------

5
front/php/server/init.php Executable file
View File

@@ -0,0 +1,5 @@
<?php
require dirname(__FILE__).'/../templates/timezone.php';
require dirname(__FILE__).'/db.php';
require dirname(__FILE__).'/util.php';
require dirname(__FILE__).'/../templates/language/lang.php';

View File

@@ -33,4 +33,3 @@ if(filter_var($PIA_HOST_IP, FILTER_VALIDATE_IP)) // Vulnerability fix v22.12.20
{
echo '<h4>Internal error.</h4>';
}
?>

View File

@@ -11,8 +11,7 @@
//------------------------------------------------------------------------------
// External files
require 'db.php';
require 'util.php';
require dirname(__FILE__).'/init.php';
//------------------------------------------------------------------------------
@@ -80,6 +79,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 +115,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 +124,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;
}
}
?>

View File

@@ -8,8 +8,8 @@
# Puche 2021 / 2022+ jokob jokob@duck.com GNU GPLv3
//------------------------------------------------------------------------------
require '/home/pi/pialert/front/php/templates/timezone.php';
require '/home/pi/pialert/front/php/templates/skinUI.php';
require dirname(__FILE__).'/../templates/timezone.php';
require dirname(__FILE__).'/../templates/skinUI.php';
$FUNCTION = [];
$SETTINGS = [];
@@ -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;
}
}
// -------------------------------------------------------------------------------------------

View File

@@ -1,7 +1,5 @@
<?php
require 'php/server/db.php';
global $db;
$Pia_Graph_Device_Time = array();
@@ -27,6 +25,3 @@ function pia_graph_devices_data($Pia_Graph_Array) {
echo ",";
}
}
?>

View File

@@ -8,10 +8,8 @@
#--------------------------------------------------------------------------- -->
<?php
require '/home/pi/pialert/front/php/templates/timezone.php';
require '/home/pi/pialert/front/php/templates/language/lang.php';
require '/home/pi/pialert/front/php/templates/security.php';
require dirname(__FILE__).'/../server/init.php';
require dirname(__FILE__).'/security.php';
?>
@@ -169,8 +167,8 @@ if ($ENABLED_DARKMODE === True) {
<li class="user-header" style=" height: 100px;">
<img src="img/pialertLogoWhite.png" class="img-circle" alt="Pi.Alert Logo" style="border-color:transparent; height: 50px; width: 50px; margin-top:15px;">
<p style="float: right; width: 200px">
<?php echo lang('About_Title');?>
<small><?php echo lang('About_Design');?> Raspberry Pi</small>
<?= lang('About_Title');?>
<small><?= lang('About_Design');?> Raspberry Pi</small>
</p>
</li>
@@ -178,7 +176,7 @@ if ($ENABLED_DARKMODE === True) {
<li class="user-footer">
<div class="pull-right">
<a href="index.php?action=logout" class="btn btn-danger"><?php echo lang('About_Exit');?></a>
<a href="index.php?action=logout" class="btn btn-danger"><?= lang('About_Exit');?></a>
</div>
</li>
</ul>
@@ -209,31 +207,31 @@ if ($ENABLED_DARKMODE === True) {
<ul class="sidebar-menu" data-widget="tree">
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('devices.php', 'deviceDetails.php') ) ){ echo 'active'; } ?>">
<a href="devices.php"><span><?php echo lang('Navigation_Devices');?></span></a>
<a href="devices.php"><span><i class="fa fa-laptop"></i> <?= lang('Navigation_Devices');?></span></a>
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('presence.php') ) ){ echo 'active'; } ?>">
<a href="presence.php"><?php echo lang('Navigation_Presence');?></span></a>
<a href="presence.php"><i class="fa fa-calendar"></i> <?= lang('Navigation_Presence');?></span></a>
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('events.php') ) ){ echo 'active'; } ?>">
<a href="events.php"><i class="fa fa-bolt"></i> <span><?php echo lang('Navigation_Events');?></span></a>
<a href="events.php"><i class="fa fa-bolt"></i> <span><?= lang('Navigation_Events');?></span></a>
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('network.php') ) ){ echo 'active'; } ?>">
<a href="network.php"><span><?php echo lang('Navigation_Network');?></span></a>
<a href="network.php"><span><i class="fa fa-fw fa-network-wired"></i> <?= lang('Navigation_Network');?></span></a>
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('maintenance.php') ) ){ echo 'active'; } ?>">
<div class="new-version myhidden" id="version" data-build-time="<?php echo file_get_contents( "buildtimestamp.txt");?>">🆕</div>
<a href="maintenance.php"><i class="fa fa-wrench "></i> <span><?php echo lang('Navigation_Maintenance');?></span></a>
<a href="maintenance.php"><i class="fa fa-wrench "></i> <span><?= lang('Navigation_Maintenance');?></span></a>
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('settings.php') ) ){ echo 'active'; } ?>">
<a href="settings.php"><i class="fa fa-cog"></i> <span><?php echo lang('Navigation_Settings');?></span></a>
<a href="settings.php"><i class="fa fa-cog"></i> <span><?= lang('Navigation_Settings');?></span></a>
</li>
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('help_faq.php') ) ){ echo 'active'; } ?>">
<a href="help_faq.php"><i class="fa fa-question"></i> <span><?php echo lang('Navigation_HelpFAQ');?></span></a>
<a href="help_faq.php"><i class="fa fa-question"></i> <span><?= lang('Navigation_HelpFAQ');?></span></a>
</li>
</ul>

View File

@@ -47,12 +47,12 @@ $lang['en_us'] = array(
// Device Page
//////////////////////////////////////////////////////////////////
'Navigation_Devices' => '<i class="fa fa-laptop"></i> Devices',
'Navigation_Presence' => '<i class="fa fa-calendar"></i> Presence',
'Navigation_Devices' => 'Devices',
'Navigation_Presence' => 'Presence',
'Navigation_Events' => 'Events',
'Navigation_Maintenance' => 'Maintenance',
'Navigation_Settings' => 'Settings',
'Navigation_Network' => '<i class="fa fa-fw fa-network-wired"></i> Network',
'Navigation_Network' => 'Network',
'Navigation_HelpFAQ' => 'Help / FAQ',
'Device_Title' => 'Devices',
'Device_Shortcut_AllDevices' => 'All Devices',
@@ -68,7 +68,11 @@ $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_Connected_Devices' => 'Connected Devices',
'Device_TableHead_Location' => 'Location',
'Device_TableHead_Vendor' => 'Vendor',
'Device_TableHead_Favorite' => 'Favorite',
'Device_TableHead_Group' => 'Group',
'Device_TableHead_FirstSession' => 'First Session',
@@ -171,7 +175,7 @@ $lang['en_us'] = array(
'DevDetail_MainInfo_Owner' => 'Owner',
'DevDetail_MainInfo_Type' => 'Type',
'DevDetail_Icon' => 'Icon',
'DevDetail_Icon_Descr' => 'Enter a font awesome icon name without the fa- prefix.',
'DevDetail_Icon_Descr' => 'Enter a font awesome icon name without the fa- prefix or with complete class, e.g.: fa fa-brands fa-apple.',
'DevDetail_MainInfo_Vendor' => 'Vendor',
'DevDetail_MainInfo_Favorite' => 'Favorite',
'DevDetail_MainInfo_Group' => 'Group',
@@ -191,7 +195,7 @@ $lang['en_us'] = array(
'DevDetail_EveandAl_ScanCycle' => 'Scan device',
'DevDetail_EveandAl_AlertAllEvents' => 'Alert All Events',
'DevDetail_EveandAl_AlertDown' => 'Alert Down',
'DevDetail_EveandAl_Skip' => 'Skip repeated notifications during',
'DevDetail_EveandAl_Skip' => 'Skip repeated notifications for',
'DevDetail_EveandAl_NewDevice' => 'New Device',
'DevDetail_EveandAl_Archived' => 'Archived',
'DevDetail_EveandAl_RandomMAC' => 'Random MAC',
@@ -428,7 +432,7 @@ $lang['en_us'] = array(
If yes, delete them there as well. Now you can start Pi.Alert again. Now the device(s) should not show up anymore.',
'HelpFAQ_Cat_Detail_300_head' => 'What means ',
'HelpFAQ_Cat_Detail_300_text_a' => 'means a network device (a device of the type AP, Gateway, Firewall, Powerline, Switch, WLAN, PLC, Router,USB LAN Adapter, USB WIFI Adapter, or Internet).',
'HelpFAQ_Cat_Detail_300_text_b' => 'designates the port number where the currently edited device is connected to this network device.',
'HelpFAQ_Cat_Detail_300_text_b' => 'designates the port number where the currently edited device is connected to this network device. Read <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/NETWORK_TREE.md">this guide</a> for more info.',
'HelpFAQ_Cat_Detail_301_head_a' => 'When is scanning now? At ',
'HelpFAQ_Cat_Detail_301_head_b' => ' says 1min but the graph shows 5min intervals.',
'HelpFAQ_Cat_Detail_301_text' => 'The time interval between the scans is defined by the "Cronjob", which is set to 5min by default. The designation "1min" refers to the expected duration of the scan.
@@ -450,7 +454,7 @@ $lang['en_us'] = array(
and then simply switch the device off again. Now Pi.Alert should properly note the state of the device in the database with the next scan.',
'HelpFAQ_Cat_Network_600_head' => 'What is this page for?',
'HelpFAQ_Cat_Network_600_text' => 'This page should offer you the possibility to map the assignment of your network devices. For this purpose, you can create one or more switches, WLANs, routers, etc., provide them with a port number if necessary and assign already detected
devices to them. This assignment is done in the detailed view of the device to be assigned. So it is possible for you to quickly determine to which port a host is connected and if it is online.',
devices to them. This assignment is done in the detailed view of the device to be assigned. So it is possible for you to quickly determine to which port a host is connected and if it is online. Read <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/NETWORK_TREE.md">this guide</a> for more info.',
//////////////////////////////////////////////////////////////////
// Front end events
@@ -458,6 +462,8 @@ $lang['en_us'] = array(
'test_event_tooltip' => 'Save your changes at first before you test your settings.',
'test_event_icon' => 'fa-vial-circle-check',
'run_event_tooltip' => 'Enable the setting and save your changes at first before you run it.',
'run_event_icon' => 'fa-play',
'general_event_title' => 'Executing an ad-hoc event',
'general_event_description' => 'The event you\'ve triggered might take a while until background processes finish. The execution ended once you see <code>finished</code> below. Check the <a onclick=\'setCache(\"activeMaintenanceTab\", \"tab_Logging_id\")\' href=\"/maintenance.php#tab_Logging\">error log</a> if you didn\'t get the expected result. <br/> <br/> Status: ',
@@ -509,13 +515,15 @@ the arp-scan will take hours to complete instead of seconds.
'REPORT_DASHBOARD_URL_description' => 'This URL is used as the base for generating links in the emails. Enter full URL starting with <code>http://</code> including the port number (no trailig slash <code>/</code>).',
'DIG_GET_IP_ARG_name' => 'Internet IP discovery',
'DIG_GET_IP_ARG_description' => 'Change the <a href="https://linux.die.net/man/1/dig" target="_blank">dig utility</a> arguments if you have issues resolving your Internet IP. Arguments are added at the end of the following command: <code>dig +short </code>.',
'UI_LANG_name' => 'UI Language',
'UI_LANG_description' => 'Select the preferred UI language.',
//Email
'Email_settings_group' => '<i class="fa fa-at"></i> 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.',
'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',
@@ -551,7 +559,7 @@ the arp-scan will take hours to complete instead of seconds.
'APPRISE_HOST_name' => 'Apprise host URL',
'APPRISE_HOST_description' => 'Apprise host URL starting with <code>http://</code> or <code>https://</code>. (don\'t forget to include <code>/notify</code> at the end)',
'APPRISE_URL_name' => 'Apprise notification URL',
'APPRISE_URL_description' => 'Apprise notification target URL.',
'APPRISE_URL_description' => 'Apprise notification target URL. For example for Telegram it would be <code>tgram://{bot_token}/{chat_id}</code>.',
// NTFY
'NTFY_settings_group' => '<i class="fa fa-terminal"></i> NTFY',
@@ -572,6 +580,8 @@ the arp-scan will take hours to complete instead of seconds.
'REPORT_PUSHSAFER_description' => 'Enable sending notifications via <a target="_blank" href="https://www.pushsafer.com/">Pushsafer</a>.',
'PUSHSAFER_TOKEN_name' => 'Pushsafer token',
'PUSHSAFER_TOKEN_description' => 'Your secret Pushsafer API key (token).',
'APPRISE_PAYLOAD_name' => 'Payload type',
'APPRISE_PAYLOAD_description' => 'Select the payoad type sent to Apprise. For example <code>html</code> works well with emails, <code>text</code> with chat apps, such as Telegram.',
// MQTT
@@ -634,7 +644,7 @@ the arp-scan will take hours to complete instead of seconds.
'NMAP_ACTIVE_name' => 'Cycle run',
'NMAP_ACTIVE_description' => 'If enabled this will execute a scan on a newly found device. For a scheduled or one-off scan, check the <a href="#NMAP_RUN"><code>NMAP_RUN</code> setting</a>.',
'NMAP_TIMEOUT_name' => 'Run timeout',
'NMAP_TIMEOUT_description' => 'Maximum time to wait for an Nmap scan to finish on any device.',
'NMAP_TIMEOUT_description' => 'Maximum time in seconds to wait for an Nmap scan to finish on any device.',
'NMAP_RUN_name' => 'Scheduled run',
'NMAP_RUN_description' => 'Enable a regular Nmap scan on your network on all devices. The scheduling settings can be found below. If you select <code>once</code> Nmap is run only once on start for the time specified in <a href="#NMAP_TIMEOUT"><code>NMAP_TIMEOUT</code> setting</a>.',
'NMAP_RUN_SCHD_name' => 'Schedule',
@@ -642,6 +652,21 @@ the arp-scan will take hours to complete instead of seconds.
'NMAP_ARGS_name' => 'Arguments',
'NMAP_ARGS_description' => 'Arguments used to run the Nmap scan. Be careful to specify <a href="https://linux.die.net/man/1/nmap" target="_blank">the arguments</a> correctly. For example <code>-p -10000</code> scans ports from 1 to 10000.',
// API
'API_settings_group' => '<i class="fa fa-arrow-down-up-across-line"></i> API',
'ENABLE_API_name' => 'Enable API',
'ENABLE_API_description' => 'If enabled the app will start publishing and updating <a href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md" target="_blank">simple API endpoints</a> under the <code>/home/pi/pialert/front/api/</code> folder and thus on the <code>pialert_url/api/File_name</code> url.',
'API_RUN_name' => 'Scheduling updates',
'API_RUN_description' => 'Scheduling settings to specify when the API endpoints should be updated. If set to <code>schedule</code> then endpoints will be updated on a specified cron-like schedule specified by the <code>API_RUN_SCHD</code> setting. Otherwise if set to <code>interval</code> endpoints will be updated every N seconds specified by the <code>API_RUN_INTERVAL</code> setting.',
'API_RUN_SCHD_name' => 'Schedule',
'API_RUN_SCHD_description' => 'Depends on the <code>API_RUN</code> settings to be set to <code>schedule</code>. Make sure you enter the schedule in the correct cron-like format (e.g. validate at <a href="https://crontab.guru/" target="_blank">crontab.guru</a>).',
'API_RUN_INTERVAL_name' => 'Update interval',
'API_RUN_INTERVAL_description' => 'Depends on the <code>API_RUN</code> settings to be set to <code>interval</code>. The minimum cycle is <code>5</code> seconds.',
'API_CUSTOM_SQL_name' => 'Custom endpoint',
'API_CUSTOM_SQL_description' => 'You can specify a custom SQL query which will generate a JSON file and then expose it via the <a href="/api/table_custom_endpoint.json" target="_blank"><code>table_custom_endpoint.json</code> file endpoint</a>.',
);
?>

View File

@@ -46,7 +46,7 @@ $lang['es_es'] = array(
'Navigation_Devices' => 'Dispositivos',
'Navigation_Presence' => 'Historial',
'Navigation_Events' => 'Eventos',
'Navigation_Maintenance' => 'Cantenimiento',
'Navigation_Maintenance' => 'Mantenimiento',
'Navigation_Settings' => 'Configuración',
'Navigation_Network' => 'Red',
'Navigation_HelpFAQ' => 'Ayuda / FAQ',

View File

@@ -6,18 +6,21 @@
$defaultLang = "en_us";
if(!isset($_COOKIE["language"])) {
$pia_lang_selected = $defaultLang;
} else {
$pia_lang_selected = $_COOKIE["language"];
global $db;
$result = $db->querySingle("SELECT Value FROM Settings WHERE Code_Name = 'UI_LANG'");
switch($result){
case 'Spanish': $pia_lang_selected = 'es_es'; break;
case 'German': $pia_lang_selected = 'de_de'; break;
default: $pia_lang_selected = 'en_us'; break;
}
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = defaultLang;}
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = $defaultLang;}
require '/home/pi/pialert/front/php/templates/skinUI.php';
require 'en_us.php';
require 'de_de.php';
require 'es_es.php';
require dirname(__FILE__).'/../skinUI.php';
require dirname(__FILE__).'/en_us.php';
require dirname(__FILE__).'/de_de.php';
require dirname(__FILE__).'/es_es.php';
function lang($key)
{
@@ -45,4 +48,3 @@ function lang($key)
return $temp;
}
?>

View File

@@ -4,9 +4,9 @@
// ## TimeZone processing start
// ###################################
$configFolderPath = "/home/pi/pialert/config/";
$configFolderPath = dirname(__FILE__)."/../../../config/";
$config_file = "pialert.conf";
$logFolderPath = "/home/pi/pialert/front/log/";
$logFolderPath = dirname(__FILE__)."/../../log/";
$log_file = "pialert_front.log";
@@ -40,5 +40,3 @@ $timestamp = $date->format('Y-m-d_H-i-s');
// ###################################
// ## TimeZone processing end
// ###################################
?>

View File

@@ -18,7 +18,7 @@
<!-- Content header--------------------------------------------------------- -->
<section class="content-header">
<h1 id="pageTitle">
<?php echo lang('Presence_Title');?>
<?= lang('Presence_Title');?>
</h1>
</section>
@@ -32,7 +32,7 @@
<a href="#" onclick="javascript: getDevicesPresence('all');">
<div class="small-box bg-aqua">
<div class="inner"><h3 id="devicesAll"> -- </h3>
<p class="infobox_label"><?php echo lang('Presence_Shortcut_AllDevices');?></p>
<p class="infobox_label"><?= lang('Presence_Shortcut_AllDevices');?></p>
</div>
<div class="icon"><i class="fa fa-laptop text-aqua-40"></i></div>
</div>
@@ -44,7 +44,7 @@
<a href="#" onclick="javascript: getDevicesPresence('connected');">
<div class="small-box bg-green">
<div class="inner"> <h3 id="devicesConnected"> -- </h3>
<p class="infobox_label"><?php echo lang('Presence_Shortcut_Connected');?></p>
<p class="infobox_label"><?= lang('Presence_Shortcut_Connected');?></p>
</div>
<div class="icon"> <i class="fa fa-plug text-green-40"></i> </div>
</div>
@@ -56,7 +56,7 @@
<a href="#" onclick="javascript: getDevicesPresence('favorites');">
<div class="small-box bg-yellow">
<div class="inner"> <h3 id="devicesFavorites"> -- </h3>
<p class="infobox_label"><?php echo lang('Presence_Shortcut_Favorites');?></p>
<p class="infobox_label"><?= lang('Presence_Shortcut_Favorites');?></p>
</div>
<div class="icon"> <i class="fa fa-star text-yellow-40"></i> </div>
</div>
@@ -68,7 +68,7 @@
<a href="#" onclick="javascript: getDevicesPresence('new');">
<div class="small-box bg-yellow">
<div class="inner"> <h3 id="devicesNew"> -- </h3>
<p class="infobox_label"><?php echo lang('Presence_Shortcut_NewDevices');?></p>
<p class="infobox_label"><?= lang('Presence_Shortcut_NewDevices');?></p>
</div>
<div class="icon"> <i class="ion ion-plus-round text-yellow-40"></i> </div>
</div>
@@ -80,7 +80,7 @@
<a href="#" onclick="javascript: getDevicesPresence('down');">
<div class="small-box bg-red">
<div class="inner"> <h3 id="devicesDown"> -- </h3>
<p class="infobox_label"><?php echo lang('Presence_Shortcut_DownAlerts');?></p>
<p class="infobox_label"><?= lang('Presence_Shortcut_DownAlerts');?></p>
</div>
<div class="icon"> <i class="fa fa-warning text-red-40"></i> </div>
</div>
@@ -92,7 +92,7 @@
<a href="#" onclick="javascript: getDevicesPresence('archived');">
<div class="small-box bg-gray top_small_box_gray_text">
<div class="inner"> <h3 id="devicesHidden"> -- </h3>
<p class="infobox_label"><?php echo lang('Presence_Shortcut_Archived');?></p>
<p class="infobox_label"><?= lang('Presence_Shortcut_Archived');?></p>
</div>
<div class="icon"> <i class="fa fa-eye-slash text-gray-40"></i> </div>
</div>
@@ -106,7 +106,7 @@
<div class="col-md-12">
<div class="box" id="clients">
<div class="box-header with-border">
<h3 class="box-title"><?php echo lang('Device_Shortcut_OnlineChart');?></h3>
<h3 class="box-title"><?= lang('Device_Shortcut_OnlineChart');?></h3>
</div>
<div class="box-body">
<div class="chart">
@@ -242,12 +242,12 @@ function initializeCalendar () {
allDaySlot : false,
timeFormat : 'H:mm',
resourceLabelText : '<?php echo lang('Presence_CallHead_Devices');?>',
resourceLabelText : '<?= lang('Presence_CallHead_Devices');?>',
resourceAreaWidth : '160px',
slotWidth : '1px',
resourceOrder : '-favorite,title',
locale : '<?php echo lang('Presence_CalHead_lang');?>',
locale : '<?= lang('Presence_CalHead_lang');?>',
//schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
@@ -256,7 +256,7 @@ function initializeCalendar () {
timelineYear: {
type : 'timeline',
duration : { year: 1 },
buttonText : '<?php echo lang('Presence_CalHead_year');?>',
buttonText : '<?= lang('Presence_CalHead_year');?>',
slotLabelFormat : 'MMM',
// Hack to show partial day events not as fullday events
slotDuration : {minutes: 44641}
@@ -265,7 +265,7 @@ function initializeCalendar () {
timelineQuarter: {
type : 'timeline',
duration : { month: 3 },
buttonText : '<?php echo lang('Presence_CalHead_quarter');?>',
buttonText : '<?= lang('Presence_CalHead_quarter');?>',
slotLabelFormat : 'MMM',
// Hack to show partial day events not as fullday events
slotDuration : {minutes: 44641}
@@ -274,7 +274,7 @@ function initializeCalendar () {
timelineMonth: {
type : 'timeline',
duration : { month: 1 },
buttonText : '<?php echo lang('Presence_CalHead_month');?>',
buttonText : '<?= lang('Presence_CalHead_month');?>',
slotLabelFormat : 'D',
// Hack to show partial day events not as fullday events
slotDuration : '24:00:01'
@@ -283,7 +283,7 @@ function initializeCalendar () {
timelineWeek: {
type : 'timeline',
duration : { week: 1 },
buttonText : '<?php echo lang('Presence_CalHead_week');?>',
buttonText : '<?= lang('Presence_CalHead_week');?>',
slotLabelFormat : 'D',
slotDuration : '24:00:01'
}
@@ -361,13 +361,13 @@ function getDevicesPresence (status) {
// Defini color & title for the status selected
switch (deviceStatus) {
case 'all': tableTitle = '<?php echo lang('Presence_Shortcut_AllDevices');?>'; color = 'aqua'; break;
case 'connected': tableTitle = '<?php echo lang('Presence_Shortcut_Connected');?>'; color = 'green'; break;
case 'favorites': tableTitle = '<?php echo lang('Presence_Shortcut_Favorites');?>'; color = 'yellow'; break;
case 'new': tableTitle = '<?php echo lang('Presence_Shortcut_NewDevices');?>'; color = 'yellow'; break;
case 'down': tableTitle = '<?php echo lang('Presence_Shortcut_DownAlerts');?>'; color = 'red'; break;
case 'archived': tableTitle = '<?php echo lang('Presence_Shortcut_Archived');?>'; color = 'gray'; break;
default: tableTitle = '<?php echo lang('Presence_Shortcut_Devices');?>'; color = 'gray'; break;
case 'all': tableTitle = '<?= lang('Presence_Shortcut_AllDevices');?>'; color = 'aqua'; break;
case 'connected': tableTitle = '<?= lang('Presence_Shortcut_Connected');?>'; color = 'green'; break;
case 'favorites': tableTitle = '<?= lang('Presence_Shortcut_Favorites');?>'; color = 'yellow'; break;
case 'new': tableTitle = '<?= lang('Presence_Shortcut_NewDevices');?>'; color = 'yellow'; break;
case 'down': tableTitle = '<?= lang('Presence_Shortcut_DownAlerts');?>'; color = 'red'; break;
case 'archived': tableTitle = '<?= lang('Presence_Shortcut_Archived');?>'; color = 'gray'; break;
default: tableTitle = '<?= lang('Presence_Shortcut_Devices');?>'; color = 'gray'; break;
}
// Set title and color

View File

@@ -2,12 +2,6 @@
require 'php/templates/header.php';
//------------------------------------------------------------------------------
// External files
require 'php/server/db.php';
require 'php/server/util.php';
//------------------------------------------------------------------------------
// Action selector
//------------------------------------------------------------------------------
@@ -49,14 +43,14 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
<section class="content-header">
<?php require 'php/templates/notification.php'; ?>
<h1 id="pageTitle">
<?php echo lang('Navigation_Settings');?>
<?= lang('Navigation_Settings');?>
<a style="cursor:pointer">
<span>
<i id='toggleSettings' onclick="toggleAllSettings()" class="settings-expand-icon fa fa-angle-double-down"></i>
</span>
</a>
</h1>
<div class="settingsImported"><?php echo lang("settings_imported");?> <span id="lastImportedTime"></span></div>
<div class="settingsImported"><?= lang("settings_imported");?> <span id="lastImportedTime"></span></div>
</section>
<div class="content " id='accordion_gen'>
<?php
@@ -244,10 +238,11 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
if(count($eventsList) > 0)
{
foreach ($eventsList as $event) {
$eventsHtml = $eventsHtml.'<span class="input-group-addon">
<i title="'.lang($event."_event_tooltip").'" class="fa '.lang($event."_event_icon").' pointer"
$eventsHtml = $eventsHtml.'<span class="input-group-addon pointer"
data-myparam="'.$set['Code_Name'].'"
data-myevent="'.$event.'">
data-myevent="'.$event.'"
>
<i title="'.lang($event."_event_tooltip").'" class="fa '.lang($event."_event_icon").' " >
</i>
</span>';
}
@@ -268,7 +263,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
<!-- /.content -->
<div class="row" >
<div class="row">
<button type="button" class="center top-margin btn btn-primary btn-default pa-btn bg-green dbtools-button" id="save" onclick="saveSettings()"><?php echo lang('DevDetail_button_Save');?></button>
<button type="button" class="center top-margin btn btn-primary btn-default pa-btn bg-green dbtools-button" id="save" onclick="saveSettings()"><?= lang('DevDetail_button_Save');?></button>
</div>
<div id="result"></div>
</div>
@@ -285,12 +280,12 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
<script>
// number of settings has to be equal to
var settingsNumber = 61;
var settingsNumber = 68;
// Wrong number of settings processing
if(<?php echo count($settings)?> != settingsNumber)
{
showModalOk('WARNING', "<?php echo lang("settings_missing")?>");
showModalOk('WARNING', "<?= lang("settings_missing")?>");
}
@@ -367,7 +362,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
function saveSettings() {
if(<?php echo count($settings)?> != settingsNumber)
{
showModalOk('WARNING', "<?php echo lang("settings_missing_block")?>");
showModalOk('WARNING', "<?= lang("settings_missing_block")?>");
} else
{
$.ajax({
@@ -408,7 +403,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// check if displayed settings are outdated
if(fileModificationTime > importedMiliseconds)
{
showModalOk('WARNING: Outdated settings displayed', "<?php echo lang("settings_old")?>");
showModalOk('WARNING: Outdated settings displayed', "<?= lang("settings_old")?>");
}
} else{
result = result.replaceAll('"', '');
@@ -457,7 +452,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// handling events on the backend initiated by the front end START
// -----------------------------------------------------------------------------
$(window).on('load', function() {
$('i[data-myevent]').each(function(index, element){
$('span[data-myevent]').each(function(index, element){
$(element).attr('onclick',
'handleEvent(\"' + $(element).attr('data-myevent') + '|'+ $(element).attr('data-myparam') + '\")'
);
@@ -469,10 +464,8 @@ 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>");
showModalOk("<?= lang("general_event_title")?>", "<?= lang("general_event_description")?> <code id='"+modalEventStatusId+"'></code>");
// Periodically update state of the requested action
getParam(modalEventStatusId,"Front_Event", true, updateModalState)
@@ -486,9 +479,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
{

View File

@@ -21,6 +21,8 @@ logging.getLogger("scapy.runtime").setLevel(logging.ERROR)#supress Scapy warning
runPath = os.path.dirname(os.path.abspath(__file__))
runPathTmp = runPath + "/.."
logPath = runPathTmp + '/front/log'
# DEBUG
isDebug = False
#===============================================================================
@@ -61,6 +63,8 @@ write_file(logPath + "/pialert_pholus_subp_pr.log", "")
# For separate logging of the multiprocess subprocess
def file_print_pr(*args):
if isDebug == False:
return
result = ''
@@ -139,10 +143,10 @@ def get_my_ipv4_addr(interface):
##########################
class Sniffer():
def __init__ (self,filter,interface,sniffer_timeout,queue,dns,show_ttl,dos_ttl, conflict, ttl,d4, d6, target_mac, auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2,source_mac,hlimit,workstation,printer,googlecast,airtv,flood,flooding_timeout,flooding_interval, v4, v6):
file_print(">>>>>>> sniffer_args: ", filter," ",interface," ",sniffer_timeout," ",queue," ",dns," ",show_ttl," ",dos_ttl," ", conflict," ", ttl," ",d4," ", d6," ", target_mac," ", auto_fake_responses," ",source_IPv6," ", source_IPv4," ", target_mac1," ", target_mac2," ",source_mac," ",hlimit," ",workstation," ",printer," ",googlecast," ",airtv," ",flood," ",flooding_timeout," ",flooding_interval," ", v4," ", v6)
file_print_pr("[DEBUG] sniffer_args: ", filter," ",interface," ",sniffer_timeout," ",queue," ",dns," ",show_ttl," ",dos_ttl," ", conflict," ", ttl," ",d4," ", d6," ", target_mac," ", auto_fake_responses," ",source_IPv6," ", source_IPv4," ", target_mac1," ", target_mac2," ",source_mac," ",hlimit," ",workstation," ",printer," ",googlecast," ",airtv," ",flood," ",flooding_timeout," ",flooding_interval," ", v4," ", v6)
self.filter = filter
self.interface = interface
file_print(">>>>>>> sniffer_timeout: ", sniffer_timeout)
file_print_pr("[DEBUG] sniffer_timeout: ", sniffer_timeout)
self.sniffer_timeout=sniffer_timeout
self.queue=queue
self.dns=dns
@@ -178,7 +182,7 @@ class Sniffer():
##################################
class Sniffer_Offline():
def __init__ (self,interface,queue,show_ttl,d4, d6, target_mac,auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2,source_mac,hlimit):
file_print(">>>>>>> Timestamp 0.0210aa: ", timeNow())
file_print_pr("[DEBUG] Timestamp 1: ", timeNow())
self.interface = interface
self.queue=queue
self.show_ttl=show_ttl
@@ -201,9 +205,8 @@ class Sniffer_Offline():
########################################################################
def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,interface,d4,d6,target_mac,auto_fake_responses,source_IPv6,source_IPv4,target_mac1,target_mac2,source_mac,hlimit,workstation,printer,googlecast,airtv,flood,flooding_timeout,flodding_interval,v4,v6):
# file_print(">>>>>>> Timestamp 0.0210: ", timeNow())
file_print_pr(">>>>>>> Timestamp 0.0210: ", timeNow())
file_print_pr(">>>>>>> Test ")
file_print_pr("[DEBUG] Timestamp 2: ", timeNow())
file_print_pr("[DEBUG] 3 ")
dns_type = {12: "PTR", 28: "AAAA", 13: "HINFO",33: "SRV", 1: "A", 255: "* (ANY)", 16: "TXT", 15: "MX", 6: "SOA", 256: "URI", 5: "CNAME",39: "DNAME"}
Ether_src=packets.getlayer(Ether).src
@@ -213,12 +216,11 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
elif packets.haslayer(IP):
IP_src=packets.getlayer(IP).src
else:
file_print(">>>>>>> Timestamp 0.021: ", timeNow())
file_print_pr(">>>>>>> Test 2")
file_print_pr("[DEBUG] Timestamp 4: ", timeNow())
res0= Ether_src + " | " + IP_src.ljust(27)
if packets.haslayer(DNS):
file_print_pr(">>>>>>> Test 4")
file_print_pr("[DEBUG] Timestamp 5: ", timeNow())
dns=packets.getlayer(DNS)
if (conflict or dos_ttl) and dns.ancount>0:
DNSBlocks = [ ]
@@ -274,13 +276,13 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
else:
new_packet=new_packet/UDP(dport=5353,sport=5353)/new_DNS_packet
for x in range(0,2):#Send each packet twice
file_print_pr(">>>>>>> Test 6")
file_print_pr("[DEBUG] Timestamp 6: ", timeNow())
sendp(new_packet,iface=interface)
file_print_pr(">>>>>>> Test 6.1")
file_print_pr("[DEBUG] Timestamp 7: ", timeNow())
elif auto_fake_responses or (not (dos_ttl or conflict)):
## IF THIS IS A QUERY ##
file_print_pr(">>>>>>> Test 6.2")
file_print_pr("[DEBUG] Timestamp 8: ", timeNow())
if dns.opcode==0:
res0 = res0 + ""
if dns.qdcount>0:
@@ -488,9 +490,9 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
dns_packet=UDP(sport=5353,dport=5353)/DNS(qr=1,aa=1,rd=0,ancount=1)/DNSRR(rrname=qname,ttl=myttl,rdata=source_IPv4,type="A")
else:
dns_packet=UDP(sport=5353,dport=5353)/DNS(qr=1,aa=1,rd=0,ancount=1)/DNSRR(rrname=qname,ttl=myttl,rdata=source_IPv4,type="A")
file_print_pr(">>>>>>> Test 6.23")
file_print_pr("[DEBUG] Timestamp 9: ", timeNow())
send_packets(v4,v6,source_mac,target_mac1,target_mac2,source_IPv4,d4,source_IPv6,d6,interface,hlimit,dns_packet,False,10.0,0.1)#CHANGE DEFAULT VALUES
file_print_pr(">>>>>>> Test 6.24")
file_print_pr("[DEBUG] Timestamp 10: ", timeNow())
### END "IF WE NEED TO AUTO RESPOND WITH A FAKE RESPONSE
### NEXT LINES ARE ONLY USED TO PRINT RESULTS ###
if dnsqr.qclass==32769:
@@ -526,7 +528,7 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
else:
ARtype=str(dnsrropt.type)
res = res0 + " | Additional_Record | " + rrname.decode("utf-8") + " " + ARtype
file_print_pr(">>>>>>> Test 6.24")
file_print_pr("[DEBUG] Timestamp 11: ", timeNow())
if dnsrropt.haslayer(EDNS0TLV):
edns0tlv=dnsrropt.getlayer(EDNS0TLV)
if edns0tlv.optcode==4:
@@ -595,26 +597,27 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
str_type = str(b_to_str(dns_type[dnsrr.type])) + ""
str_rdata = str(b_to_str(dnsrr.rdata)) + ""
str_rclass = str(b_to_str(dnsrr.rclass)) + ""
file_print_pr("[DEBUG] Timestamp 12: ", timeNow())
res = str_res0 + " | Additional_Record | "+str_rrname + " " + str_type+" " + str_rclass + ' "' +str_rdata+'"'
if show_ttl:
res = res + " TTL:"+str(dnsrr.ttl)
if print_res==1:
file_print(res)
file_print_pr(">>>>>>> Test 6.27")
file_print_pr("[DEBUG] Timestamp 13: ", timeNow())
queue.put(res)
block = block.payload
file_print_pr(">>>>>>> Test 6.270")
file_print_pr("[DEBUG] Timestamp 14: ", timeNow())
if dns.ancount>0:
DNSBlocks = [ ]
DNSBlocks.append(dns.an)
for block in DNSBlocks:
file_print_pr(">>>>>>> Test 6.271")
file_print_pr("[DEBUG] Timestamp 15: ", timeNow())
while isinstance(block,DNSRR):
dnsrr=block.getlayer(DNSRR)
if dnsrr.rclass==1:
rclass="Class:IN"
file_print_pr("[DEBUG] Timestamp 16: ", timeNow())
else:
rclass="Class:"+str(dnsrr.rclass)
rdata=dnsrr.rdata
@@ -632,24 +635,28 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
if isinstance(rdata,list):
rdata = b" ".join(rdata).decode("utf-8")
res = res0 + " | Answer | "+dnsrr.rrname.decode("utf-8") + " " + dns_type[dnsrr.type]+" " + rclass + ' "' +rdata+'"'
file_print_pr(">>>>>>> Test 6.272004")
file_print_pr("[DEBUG] Timestamp 17: ", timeNow())
file_print_pr("[DEBUG] Timestamp 18: ", timeNow())
if show_ttl:
res = res + " TTL:"+str(dnsrr.ttl)
if print_res==1:
file_print(res)
file_print_pr("[DEBUG] Timestamp 19: ", timeNow())
queue.put(res)
block = block.payload
file_print_pr(">>>>>>> Test 6.272")
if dns.nscount>0:
file_print_pr(">>>>>>> Test 6.273")
file_print_pr("[DEBUG] Timestamp 20: ", timeNow())
if dns.nscount>0: #MAYBE HERE
file_print_pr("[DEBUG] Timestamp 21: ", timeNow())
DNSBlocks = [ ]
DNSBlocks.append(dns.ns)
file_print_pr("[DEBUG] Timestamp 22: ", timeNow())
for block in DNSBlocks:
file_print_pr(">>>>>>> Test 6.28")
file_print_pr("[DEBUG] Timestamp 23: ", timeNow())
while isinstance(block,DNSRR):
dnsrr=block.getlayer(DNSRR)
if dnsrr.rclass==1:
rclass="Class:IN"
file_print_pr("[DEBUG] Timestamp 24: ", timeNow())
else:
rclass="Class:"+str(dnsrr.rclass)
@@ -664,20 +671,22 @@ def ext_handler(packets,queue,unidns,show_ttl,print_res,dos_ttl,conflict,ttl,int
res = res + " TTL:"+str(dnsrr.ttl)
if print_res==1:
file_print(res)
file_print_pr(">>>>>>> Test 6.274")
file_print_pr("[DEBUG] Timestamp 25: ", timeNow())
queue.put(res)
block = block.payload
block = block.payload
file_print_pr("[DEBUG] Timestamp 26: ", timeNow())
else:
file_print_pr(">>>>>>> Test 6.27200")
file_print_pr("[DEBUG] Timestamp 27: ", timeNow())
else:
file_print("not a DNS Query", dns.summary())
file_print_pr(">>>>>>> Test 6.272001")
file_print_pr("[DEBUG] Timestamp 28: ", timeNow())
else:
file_print_pr(">>>>>>> Test 6.2720055")
file_print_pr("[DEBUG] Timestamp 29: ", timeNow())
else:
file_print_pr(">>>>>>> Test 3")
file_print_pr("[DEBUG] Timestamp 30: ", timeNow())
file_print_pr(">>>>>>> Test 6.272005599")
file_print_pr("[DEBUG] Timestamp 31: ", timeNow())
file_print_pr("[DEBUG] Timestamp 32: ", timeNow(), " ", res0)
file_print_pr("[DEBUG] Timestamp 33: ", timeNow(), " ", res)
########################################
@@ -852,11 +861,13 @@ def main():
exit(0)
file_print("Press Ctrl-C to exit and print the results")
q = multiprocessing.Queue()
file_print(">>>>>>> Timestamp 0.1: ", timeNow())
file_print_pr("[DEBUG] Timestamp 34: ", timeNow())
pr = multiprocessing.Process(target=Sniffer_Offline, args=(values.interface,q,values.show_ttl,values.d4, values.d6, values.target_mac, values.auto_fake_responses,values.source6,values.source4,values.target_mac,values.target_mac,values.source_mac,values.hlimit))
pr.start()
pr.join()
file_print(">>>>>>> Timestamp 0.2: ", timeNow())
pr.join(15)
if pr.is_alive():
file_print("SUB-PROCESS KILLED TIMESTAMP: ", timeNow())
file_print_pr("[DEBUG] Timestamp 35: ", timeNow())
results=[]
while not q.empty():
results.append(q.get())
@@ -928,9 +939,9 @@ def main():
file_print("I will sniff for ",values.sniffer_timeout," seconds, unless interrupted by Ctrl-C")
file_print("Press Ctrl-C to exit")
try:
file_print(">>>>>>> Timestamp 0.0210ab: ", timeNow())
file_print_pr("[DEBUG] Timestamp 36: ", timeNow())
Sniffer(myfilter, values.interface, float(values.sniffer_timeout),q,values.dns,values.show_ttl, values.dos_ttl, values.conflict, values.ttl,values.d4, values.d6, values.target_mac, values.auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2,source_mac,values.hlimit,values.workstation,values.printer,values.googlecast,values.airtv,values.flood,values.flooding_timeout,values.flooding_interval,values.v4,values.v6)
file_print(">>>>>>> Timestamp 0.0210abc: ", timeNow())
file_print_pr("[DEBUG] Timestamp 37: ", timeNow())
except KeyboardInterrupt:
file_print("Exiting on user's request 1")
exit(0)
@@ -940,25 +951,25 @@ def main():
file_print("I will sniff for ",values.sniffer_timeout," seconds, unless interrupted by Ctrl-C")
pr = multiprocessing.Process(target=Sniffer, args=(myfilter, values.interface, float(values.sniffer_timeout),q,values.dns,values.show_ttl, values.dos_ttl, values.conflict, values.ttl,values.d4,values.d6, values.target_mac, values.auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2, source_mac,values.hlimit,values.workstation,values.printer,values.googlecast,values.airtv,values.flood,values.flooding_timeout,values.flooding_interval,values.v4,values.v6))
pr.daemon = True
file_print(">>>>>>> Timestamp 0.01: ", timeNow())
file_print_pr("[DEBUG] Timestamp 38: ", timeNow())
pr.start()
file_print(">>>>>>> Timestamp 0.02: ", timeNow())
file_print_pr("[DEBUG] Timestamp 39: ", timeNow())
file_print("------------------------------------------------------------------------")
time.sleep(1)#to make sure than sniffer has started before we proceed, otherwise you may miss some traffic
file_print(">>>>>>> Timestamp 0.03: ", timeNow())
file_print_pr("[DEBUG] Timestamp 40: ", timeNow())
##########################################################################################################
if values.request:
file_print(">>>>>>> Timestamp 1: ", timeNow())
file_print_pr("[DEBUG] Timestamp 41: ", timeNow())
requests(values.interface,values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,source_IPv6,values.d4,values.d6,values.hlimit,values.dns,values.domain,values.query,values.qtype,True,q_class,values.flood,values.flooding_interval,values.flooding_timeout)
file_print(">>>>>>> Timestamp 2: ", timeNow())
file_print_pr("[DEBUG] Timestamp 42: ", timeNow())
elif values.response:
#qr=1=>Response, aa=1=>Server is an authority for the domain, rd=0=> Do not query recursively
file_print(">>>>>>> Timestamp 3: ", timeNow())
file_print_pr("[DEBUG] Timestamp 43: ", timeNow())
if values.dns:
dns_packet=UDP(dport=53)/DNS(qr=1,aa=1,rd=0)
else:
dns_packet=UDP(sport=5353,dport=5353)/DNS(qr=1,aa=1,rd=0)
file_print(">>>>>>> Timestamp 4: ", timeNow())
file_print_pr("[DEBUG] Timestamp 44: ", timeNow())
responses = values.dns_response.split(",")
no_of_answers=0
no_of_additional_records=0
@@ -1046,7 +1057,7 @@ def main():
dns_packet[DNS].arcount=no_of_additional_records
send_packets(values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,values.d4,source_IPv6,values.d6,values.interface,values.hlimit,dns_packet,values.flood,values.flooding_timeout,values.flooding_interval)
elif values.rdns_scanning:
file_print(">>>>>>> Timestamp 5: ", timeNow())
file_print_pr("[DEBUG] Timestamp 45: ", timeNow())
dns_query=None
ipn = ipaddress.ip_network(values.rdns_scanning)
for ip in ipn.hosts():
@@ -1060,22 +1071,28 @@ def main():
else:
dns_packet=UDP(sport=5353,dport=5353)/DNS(qr=0,qd=dns_query)
send_packets(values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,values.d4,source_IPv6,values.d6,values.interface,values.hlimit,dns_packet,values.flood,values.flooding_timeout,values.flooding_interval)
file_print(">>>>>>> Timestamp 6: ", timeNow())
file_print_pr("[DEBUG] Timestamp 46: ", timeNow())
elif values.service_scan:
file_print(">>>>>>> Timestamp 7: ", timeNow())
file_print_pr("[DEBUG] Timestamp 47: ", timeNow())
requests(values.interface,values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,source_IPv6,values.d4,values.d6,values.hlimit,values.dns,values.domain,values.query,values.qtype,True,q_class,values.flood,values.flooding_interval,values.flooding_timeout)
file_print(">>>>>>> Timestamp 8: ", timeNow())
file_print_pr("[DEBUG] Timestamp 48: ", timeNow())
############################################################################################
############################################################################################
if pr:
file_print_pr("[DEBUG] Timestamp 49: ", timeNow())
try:
file_print(">>>>>>> Timestamp 6.1000: ", timeNow())
pr.join()
file_print(">>>>>>> Timestamp 6.2: ", timeNow())
file_print_pr("[DEBUG] Timestamp 50: ", timeNow()) #HERE STUCK
pr.join(20)
if pr.is_alive():
file_print("SUB-PROCESS KILLED TIMESTAMP: ", timeNow())
file_print_pr("[DEBUG] Timestamp 51: ", timeNow())
file_print_pr("[DEBUG] Timestamp 52: ", timeNow())
except KeyboardInterrupt:
file_print("Exiting on user's request 2")
exit(0)
file_print_pr("[DEBUG] Timestamp 53: ", timeNow())
#### AFTER EXITING, PRINT THE RESULTS ####
results=[]
while not q.empty():
@@ -1083,12 +1100,12 @@ def main():
if values.rdns_scanning:
targets=[]
q2 = multiprocessing.Queue()
file_print(">>>>>>> Timestamp 9: ", timeNow())
file_print_pr("[DEBUG] Timestamp 54: ", timeNow())
pr2 = multiprocessing.Process(target=Sniffer, args=(myfilter, values.interface, float(values.sniffer_timeout),q2,values.dns,values.show_ttl, values.dos_ttl,values.conflict, values.ttl,values.d4, values.d6, values.target_mac, values.auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2,source_mac,values.hlimit,values.workstation,values.printer,values.googlecast,values.airtv,values.flood,values.flooding_timeout,values.flooding_interval,values.v4,values.v6))
pr2.daemon = True
pr2.start()
time.sleep(1) #to make sure than sniffer has started before we proceed, otherwise you may miss some traffic
file_print(">>>>>>> Timestamp 10: ", timeNow())
file_print_pr("[DEBUG] Timestamp 55: ", timeNow())
for r in results:
r2=r.split(" ")
service=r2[7].strip('"')
@@ -1100,8 +1117,13 @@ def main():
targets.append((r2[1],service))
requests(values.interface,values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,source_IPv6,values.d4,values.d6,values.hlimit,values.dns,values.domain,service,values.qtype,True,q_class,values.flood,values.flooding_interval,values.flooding_timeout)
if pr2:
file_print_pr("[DEBUG] Timestamp 56: ", timeNow())
try:
pr2.join()
file_print_pr("[DEBUG] Timestamp 57: ", timeNow())
pr2.join(15)
if pr.is_alive():
file_print("SUB-PROCESS KILLED TIMESTAMP: ", timeNow())
file_print_pr("[DEBUG] Timestamp 58: ", timeNow())
except KeyboardInterrupt:
file_print("Exiting on user's request 3")
while not q2.empty():
@@ -1109,12 +1131,12 @@ def main():
elif values.service_scan:
targets=[]
q2 = multiprocessing.Queue()
file_print(">>>>>>> Timestamp 11: ", timeNow())
file_print_pr("[DEBUG] Timestamp 59: ", timeNow())
pr2 = multiprocessing.Process(target=Sniffer, args=(myfilter, values.interface, float(values.sniffer_timeout),q2,values.dns,values.show_ttl, values.dos_ttl,values.conflict, values.ttl,values.d4, values.d6, values.target_mac, values.auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2,source_mac,values.hlimit,values.workstation,values.printer,values.googlecast,values.airtv,values.flood,values.flooding_timeout,values.flooding_interval,values.v4,values.v6))
pr2.daemon = True
pr2.start()
time.sleep(1) #to make sure than sniffer has started before we proceed, otherwise you may miss some traffic
file_print(">>>>>>> Timestamp 12: ", timeNow())
file_print_pr("[DEBUG] Timestamp 60: ", timeNow())
for r in results:
r2=r.split(" ")
service=r2[7].strip('"')[:-1]
@@ -1124,19 +1146,23 @@ def main():
requests(values.interface,values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,source_IPv6,values.d4,values.d6,values.hlimit,values.dns,values.domain,service,values.qtype,True,q_class,values.flood,values.flooding_interval,values.flooding_timeout)
if pr2:
try:
pr2.join()
file_print_pr("[DEBUG] Timestamp 61: ", timeNow())
pr2.join(15)
if pr.is_alive():
file_print("SUB-PROCESS KILLED TIMESTAMP: ", timeNow())
file_print_pr("[DEBUG] Timestamp 62: ", timeNow())
except KeyboardInterrupt:
file_print("Exiting on user's request 4")
while not q2.empty():
results.append(q2.get())
targets2=[]
q3 = multiprocessing.Queue()
file_print(">>>>>>> Timestamp 13: ", timeNow())
file_print_pr("[DEBUG] Timestamp 63: ", timeNow())
pr3 = multiprocessing.Process(target=Sniffer, args=(myfilter, values.interface, float(values.sniffer_timeout),q3,values.dns,values.show_ttl, values.dos_ttl, values.conflict,values.ttl,values.d4, values.d6, values.target_mac, values.auto_fake_responses,source_IPv6, source_IPv4, target_mac1, target_mac2,source_mac,values.hlimit,values.workstation,values.printer,values.googlecast,values.airtv,values.flood,values.flooding_timeout,values.flooding_interval,values.v4,values.v6))
pr3.daemon = True
pr3.start()
time.sleep(1) #to make sure than sniffer has started before we proceed, otherwise you may miss some traffic
file_print(">>>>>>> Timestamp 14: ", timeNow())
file_print_pr("[DEBUG] Timestamp 64: ", timeNow())
for r in results:
r2=r.split(" ")
service=r2[4]
@@ -1149,7 +1175,11 @@ def main():
requests(values.interface,values.v4,values.v6,source_mac,target_mac1,target_mac2,source_IPv4,source_IPv6,values.d4,values.d6,values.hlimit,values.dns,values.domain,service,values.qtype,True,q_class,values.flood,values.flooding_interval,values.flooding_timeout)
if pr3:
try:
pr3.join()
file_print_pr("[DEBUG] Timestamp 65: ", timeNow())
pr3.join(15)
if pr.is_alive():
file_print("SUB-PROCESS KILLED TIMESTAMP: ", timeNow())
file_print_pr("[DEBUG] Timestamp 66: ", timeNow())
except KeyboardInterrupt:
file_print("Exiting on user's request 5")
while not q3.empty():