mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
v2.70
This commit is contained in:
@@ -1,32 +1,40 @@
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// PHP Open DB
|
||||
// Pi.Alert
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// db.php - Front module. Server side. DB common file
|
||||
//------------------------------------------------------------------------------
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// DB File Path
|
||||
$DBFILE = '../../../db/pialert.db';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Connect DB
|
||||
//------------------------------------------------------------------------------
|
||||
function SQLite3_connect ($trytoreconnect) {
|
||||
global $DBFILE;
|
||||
try
|
||||
global $DBFILE;
|
||||
try
|
||||
{
|
||||
// connect to database
|
||||
// return new SQLite3($DBFILE, SQLITE3_OPEN_READONLY);
|
||||
return new SQLite3($DBFILE, SQLITE3_OPEN_READWRITE);
|
||||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
// sqlite3 throws an exception when it is unable to connect
|
||||
// try to reconnect one time after 3 seconds
|
||||
if($trytoreconnect)
|
||||
{
|
||||
// connect to database
|
||||
// return new SQLite3($DBFILE, SQLITE3_OPEN_READONLY);
|
||||
return new SQLite3($DBFILE, SQLITE3_OPEN_READWRITE);
|
||||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
// sqlite3 throws an exception when it is unable to connect
|
||||
// try to reconnect one time after 3 seconds
|
||||
if($trytoreconnect)
|
||||
{
|
||||
sleep(3);
|
||||
return SQLite3_connect(false);
|
||||
}
|
||||
sleep(3);
|
||||
return SQLite3_connect(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +42,19 @@ function SQLite3_connect ($trytoreconnect) {
|
||||
// Open DB
|
||||
//------------------------------------------------------------------------------
|
||||
function OpenDB () {
|
||||
global $DBFILE;
|
||||
global $db;
|
||||
global $DBFILE;
|
||||
global $db;
|
||||
|
||||
if(strlen($DBFILE) == 0)
|
||||
{
|
||||
die ('No database available');
|
||||
}
|
||||
if(strlen($DBFILE) == 0)
|
||||
{
|
||||
die ('Database no available');
|
||||
}
|
||||
|
||||
$db = SQLite3_connect(true);
|
||||
if(!$db)
|
||||
{
|
||||
die ('Error connecting to database');
|
||||
}
|
||||
$db = SQLite3_connect(true);
|
||||
if(!$db)
|
||||
{
|
||||
die ('Error connecting to database');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// Pi.Alert
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// devices.php - Front module. Server side. Manage Devices
|
||||
//------------------------------------------------------------------------------
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// External files
|
||||
require 'db.php';
|
||||
require 'util.php';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
//------------------------------------------------------------------------------
|
||||
// Set maximum execution time to 1 minute
|
||||
ini_set ('max_execution_time','60');
|
||||
// Set maximum execution time to 15 seconds
|
||||
ini_set ('max_execution_time','15');
|
||||
|
||||
// Open DB
|
||||
OpenDB();
|
||||
@@ -17,23 +28,152 @@
|
||||
if (isset ($_REQUEST['action']) && !empty ($_REQUEST['action'])) {
|
||||
$action = $_REQUEST['action'];
|
||||
switch ($action) {
|
||||
case 'totals': queryTotals(); break;
|
||||
case 'list': queryList(); break;
|
||||
case 'queryDeviceData': queryDeviceData(); break;
|
||||
case 'updateData': updateDeviceData(); break;
|
||||
case 'calendar': queryCalendarList(); break;
|
||||
case 'queryOwners': queryOwners(); break;
|
||||
case 'queryDeviceTypes': queryDeviceTypes(); break;
|
||||
case 'queryGroups': queryGroups(); break;
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
case 'getDeviceData': getDeviceData(); break;
|
||||
case 'setDeviceData': setDeviceData(); break;
|
||||
case 'deleteDevice': deleteDevice(); break;
|
||||
|
||||
case 'getDevicesTotals': getDevicesTotals(); break;
|
||||
case 'getDevicesList': getDevicesList(); break;
|
||||
case 'getDevicesListCalendar': getDevicesListCalendar(); break;
|
||||
|
||||
case 'getOwners': getOwners(); break;
|
||||
case 'getDeviceTypes': getDeviceTypes(); break;
|
||||
case 'getGroups': getGroups(); break;
|
||||
case 'getLocations': getLocations(); break;
|
||||
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Device Data
|
||||
//------------------------------------------------------------------------------
|
||||
function getDeviceData() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
$periodDate = getDateFromPeriod();
|
||||
$mac = $_REQUEST['mac'];
|
||||
|
||||
// Device Data
|
||||
$sql = 'SELECT *,
|
||||
CASE WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down"
|
||||
WHEN dev_PresentLastScan=1 THEN "On-line"
|
||||
ELSE "Off-line" END as dev_Status
|
||||
FROM Devices
|
||||
WHERE dev_MAC="'. $mac .'"';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_ASSOC);
|
||||
$deviceData = $row;
|
||||
|
||||
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
|
||||
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
|
||||
|
||||
// Count Totals
|
||||
$condition = ' WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate;
|
||||
|
||||
// Connections
|
||||
$sql = 'SELECT COUNT(*) FROM Sessions
|
||||
WHERE ses_MAC="'. $mac .'"
|
||||
AND ( ses_DateTimeConnection >= '. $periodDate .'
|
||||
OR ses_DateTimeDisconnection >= '. $periodDate .'
|
||||
OR ses_StillConnected = 1 )';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_Sessions'] = $row[0];
|
||||
|
||||
// Events
|
||||
$sql = 'SELECT COUNT(*) FROM Events '. $condition .' AND eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" ';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_Events'] = $row[0];
|
||||
|
||||
// Donw Alerts
|
||||
$sql = 'SELECT COUNT(*) FROM Events '. $condition .' AND eve_EventType = "Device Down"';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_DownAlerts'] = $row[0];
|
||||
|
||||
// Presence hours
|
||||
$sql = 'SELECT SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now")))
|
||||
- julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .'
|
||||
ELSE ses_DateTimeConnection END)) *24
|
||||
FROM Sessions
|
||||
WHERE ses_MAC="'. $mac .'"
|
||||
AND ses_DateTimeConnection IS NOT NULL
|
||||
AND (ses_DateTimeDisconnection IS NOT NULL OR ses_StillConnected = 1 )
|
||||
AND ( ses_DateTimeConnection >= '. $periodDate .'
|
||||
OR ses_DateTimeDisconnection >= '. $periodDate .'
|
||||
OR ses_StillConnected = 1 )';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_PresenceHours'] = round ($row[0]);
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($deviceData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Update Device Data
|
||||
//------------------------------------------------------------------------------
|
||||
function setDeviceData() {
|
||||
global $db;
|
||||
|
||||
// sql
|
||||
$sql = 'UPDATE Devices SET
|
||||
dev_Name = "'. quotes($_REQUEST['name']) .'",
|
||||
dev_Owner = "'. quotes($_REQUEST['owner']) .'",
|
||||
dev_DeviceType = "'. quotes($_REQUEST['type']) .'",
|
||||
dev_Vendor = "'. quotes($_REQUEST['vendor']) .'",
|
||||
dev_Favorite = "'. quotes($_REQUEST['favorite']) .'",
|
||||
dev_Group = "'. quotes($_REQUEST['group']) .'",
|
||||
dev_Location = "'. quotes($_REQUEST['location']) .'",
|
||||
dev_Comments = "'. quotes($_REQUEST['comments']) .'",
|
||||
dev_StaticIP = "'. quotes($_REQUEST['staticIP']) .'",
|
||||
dev_ScanCycle = "'. quotes($_REQUEST['scancycle']) .'",
|
||||
dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'",
|
||||
dev_AlertDeviceDown = "'. quotes($_REQUEST['alertdown']) .'",
|
||||
dev_SkipRepeated = "'. quotes($_REQUEST['skiprepeated']) .'",
|
||||
dev_NewDevice = "'. quotes($_REQUEST['newdevice']) .'"
|
||||
WHERE dev_MAC="' . $_REQUEST['mac'] .'"';
|
||||
// update Data
|
||||
$result = $db->query($sql);
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Device updated successfully";
|
||||
} else {
|
||||
echo "Error updating device\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Delete Device
|
||||
//------------------------------------------------------------------------------
|
||||
function deleteDevice() {
|
||||
global $db;
|
||||
|
||||
// sql
|
||||
$sql = 'DELETE FROM Devices WHERE dev_MAC="' . $_REQUEST['mac'] .'"';
|
||||
// execute sql
|
||||
$result = $db->query($sql);
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Device deleted successfully";
|
||||
} else {
|
||||
echo "Error deleting device\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query total numbers of Devices by status
|
||||
//------------------------------------------------------------------------------
|
||||
function queryTotals() {
|
||||
function getDevicesTotals() {
|
||||
global $db;
|
||||
|
||||
// All
|
||||
@@ -42,43 +182,42 @@ function queryTotals() {
|
||||
$devices = $row[0];
|
||||
|
||||
// Connected
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices ' . getDeviceCondition ('connected') );
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected') );
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$connected = $row[0];
|
||||
|
||||
// New
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices ' . getDeviceCondition ('new') );
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new') );
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$newDevices = $row[0];
|
||||
|
||||
// Down Alerts
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices ' . getDeviceCondition ('down'));
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down'));
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$devicesDownAlert = $row[0];
|
||||
|
||||
echo (json_encode (array ($devices, $connected, $newDevices, $devicesDownAlert)));
|
||||
echo (json_encode (array ($devices, $connected, $newDevices,
|
||||
$devicesDownAlert)));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of devices in a determined Status
|
||||
//------------------------------------------------------------------------------
|
||||
function queryList() {
|
||||
function getDevicesList() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
$periodDate = getDateFromPeriod();
|
||||
|
||||
// SQL
|
||||
$condition = getDeviceCondition ($_REQUEST['status']);
|
||||
|
||||
$result = $db->query('SELECT *,
|
||||
CASE WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down"
|
||||
WHEN dev_FirstConnection >= ' . $periodDate . ' THEN "New"
|
||||
WHEN dev_PresentLastScan=1 THEN "On-line"
|
||||
ELSE "Off-line"
|
||||
END AS dev_Status
|
||||
FROM Devices ' . $condition);
|
||||
$sql = 'SELECT *, 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;
|
||||
$result = $db->query($sql);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
@@ -94,7 +233,7 @@ function queryList() {
|
||||
$row['dev_Status'],
|
||||
$row['dev_MAC'], // MAC (hidden)
|
||||
formatIPlong ($row['dev_LastIP']) // IP orderable
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// Control no rows
|
||||
@@ -106,130 +245,13 @@ function queryList() {
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of Owners
|
||||
//------------------------------------------------------------------------------
|
||||
function queryOwners() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT DISTINCT 1 as dev_Order, dev_Owner
|
||||
FROM Devices
|
||||
WHERE dev_Owner <> "(unknown)" AND dev_Owner <> ""
|
||||
AND dev_Favorite = 1
|
||||
UNION
|
||||
SELECT DISTINCT 2 as dev_Order, dev_Owner
|
||||
FROM Devices
|
||||
WHERE dev_Owner <> "(unknown)" AND dev_Owner <> ""
|
||||
AND dev_Favorite = 0
|
||||
AND dev_Owner NOT IN (SELECT dev_Owner FROM Devices WHERE dev_Favorite = 1)
|
||||
ORDER BY 1,2 ');
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_Owner']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of types
|
||||
//------------------------------------------------------------------------------
|
||||
function queryDeviceTypes() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT DISTINCT 9 as dev_Order, dev_DeviceType
|
||||
FROM Devices
|
||||
WHERE dev_DeviceType NOT IN ("",
|
||||
"Smartphone", "Tablet",
|
||||
"Laptop", "Mini PC", "PC", "Printer", "Server",
|
||||
"Game Console", "SmartTV", "TV Decoder", "Virtual Assistance",
|
||||
"Clock", "House Appliance", "Phone", "Radio",
|
||||
"AP", "NAS", "PLC", "Router")
|
||||
|
||||
UNION SELECT 1 as dev_Order, "Smartphone"
|
||||
UNION SELECT 1 as dev_Order, "Tablet"
|
||||
|
||||
UNION SELECT 2 as dev_Order, "Laptop"
|
||||
UNION SELECT 2 as dev_Order, "Mini PC"
|
||||
UNION SELECT 2 as dev_Order, "PC"
|
||||
UNION SELECT 2 as dev_Order, "Printer"
|
||||
UNION SELECT 2 as dev_Order, "Server"
|
||||
|
||||
UNION SELECT 3 as dev_Order, "Game Console"
|
||||
UNION SELECT 3 as dev_Order, "SmartTV"
|
||||
UNION SELECT 3 as dev_Order, "TV Decoder"
|
||||
UNION SELECT 3 as dev_Order, "Virtual Assistance"
|
||||
|
||||
UNION SELECT 4 as dev_Order, "Clock"
|
||||
UNION SELECT 4 as dev_Order, "House Appliance"
|
||||
UNION SELECT 4 as dev_Order, "Phone"
|
||||
UNION SELECT 4 as dev_Order, "Radio"
|
||||
|
||||
UNION SELECT 5 as dev_Order, "AP"
|
||||
UNION SELECT 5 as dev_Order, "NAS"
|
||||
UNION SELECT 5 as dev_Order, "PLC"
|
||||
UNION SELECT 5 as dev_Order, "Router"
|
||||
|
||||
UNION SELECT 10 as dev_Order, "Other"
|
||||
|
||||
ORDER BY 1,2 ');
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_DeviceType']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of groups
|
||||
//------------------------------------------------------------------------------
|
||||
function queryGroups() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT DISTINCT 1 as dev_Order, dev_Group
|
||||
FROM Devices
|
||||
WHERE dev_Group <> "(unknown)" AND dev_Group <> "Others" AND dev_Group <> ""
|
||||
UNION SELECT 1 as dev_Order, "Always on"
|
||||
UNION SELECT 1 as dev_Order, "Friends"
|
||||
UNION SELECT 1 as dev_Order, "Personal"
|
||||
UNION SELECT 2 as dev_Order, "Others"
|
||||
ORDER BY 1,2 ');
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_Group']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of devices for calendar
|
||||
//------------------------------------------------------------------------------
|
||||
function queryCalendarList() {
|
||||
function getDevicesListCalendar() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
$periodDate = getDateFromPeriod();
|
||||
|
||||
// SQL
|
||||
$condition = getDeviceCondition ($_REQUEST['status']);
|
||||
$result = $db->query('SELECT * FROM Devices ' . $condition);
|
||||
@@ -252,67 +274,175 @@ function queryCalendarList() {
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Device Data
|
||||
// Query the List of Owners
|
||||
//------------------------------------------------------------------------------
|
||||
function queryDeviceData() {
|
||||
function getOwners() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
$periodDate = getDateFromPeriod();
|
||||
$mac = $_REQUEST['mac'];
|
||||
|
||||
// Device Data
|
||||
$result = $db->query('SELECT *,
|
||||
CASE WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down"
|
||||
WHEN dev_PresentLastScan=1 THEN "On-line"
|
||||
ELSE "Off-line" END as dev_Status
|
||||
FROM Devices
|
||||
WHERE dev_MAC="' . $mac .'"');
|
||||
|
||||
$row = $result -> fetchArray (SQLITE3_ASSOC);
|
||||
$deviceData = $row;
|
||||
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
|
||||
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
|
||||
|
||||
// Count Totals
|
||||
$condicion = ' WHERE eve_MAC="' . $mac .'" AND eve_DateTime >= ' . $periodDate;
|
||||
|
||||
// Connections
|
||||
$result = $db->query('SELECT COUNT(*) FROM Sessions
|
||||
WHERE ses_MAC="' . $mac .'"
|
||||
AND ( ses_DateTimeConnection >= ' . $periodDate . '
|
||||
OR ses_DateTimeDisconnection >= ' . $periodDate . '
|
||||
OR ses_StillConnected = 1 ) ');
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_Sessions'] = $row[0];
|
||||
|
||||
// Events
|
||||
$result = $db->query('SELECT COUNT(*) FROM Events ' . $condicion . ' AND eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" ');
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_Events'] = $row[0];
|
||||
|
||||
// Donw Alerts
|
||||
$result = $db->query('SELECT COUNT(*) FROM Events ' . $condicion . ' AND eve_EventType = "Device Down"');
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_DownAlerts'] = $row[0];
|
||||
|
||||
// Presence hours
|
||||
$result = $db->query('SELECT SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now")))
|
||||
- julianday (CASE WHEN ses_DateTimeConnection < ' . $periodDate . ' THEN ' . $periodDate . '
|
||||
ELSE ses_DateTimeConnection END)) *24
|
||||
FROM Sessions
|
||||
WHERE ses_MAC="' . $mac .'"
|
||||
AND ses_DateTimeConnection IS NOT NULL
|
||||
AND (ses_DateTimeDisconnection IS NOT NULL OR ses_StillConnected = 1 )
|
||||
AND ( ses_DateTimeConnection >= ' . $periodDate . '
|
||||
OR ses_DateTimeDisconnection >= ' . $periodDate . '
|
||||
OR ses_StillConnected = 1 ) ');
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_PresenceHours'] = round ($row[0]);
|
||||
// SQL
|
||||
$sql = 'SELECT DISTINCT 1 as dev_Order, dev_Owner
|
||||
FROM Devices
|
||||
WHERE dev_Owner <> "(unknown)" AND dev_Owner <> ""
|
||||
AND dev_Favorite = 1
|
||||
UNION
|
||||
SELECT DISTINCT 2 as dev_Order, dev_Owner
|
||||
FROM Devices
|
||||
WHERE dev_Owner <> "(unknown)" AND dev_Owner <> ""
|
||||
AND dev_Favorite = 0
|
||||
AND dev_Owner NOT IN
|
||||
(SELECT dev_Owner FROM Devices WHERE dev_Favorite = 1)
|
||||
ORDER BY 1,2 ';
|
||||
$result = $db->query($sql);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_Owner']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($deviceData));
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of types
|
||||
//------------------------------------------------------------------------------
|
||||
function getDeviceTypes() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$sql = 'SELECT DISTINCT 9 as dev_Order, dev_DeviceType
|
||||
FROM Devices
|
||||
WHERE dev_DeviceType NOT IN ("",
|
||||
"Smartphone", "Tablet",
|
||||
"Laptop", "Mini PC", "PC", "Printer", "Server", "Singleboard Computer (SBC)",
|
||||
"Game Console", "SmartTV", "TV Decoder", "Virtual Assistance",
|
||||
"Clock", "House Appliance", "Phone", "Radio",
|
||||
"AP", "NAS", "PLC", "Router")
|
||||
|
||||
UNION SELECT 1 as dev_Order, "Smartphone"
|
||||
UNION SELECT 1 as dev_Order, "Tablet"
|
||||
|
||||
UNION SELECT 2 as dev_Order, "Laptop"
|
||||
UNION SELECT 2 as dev_Order, "Mini PC"
|
||||
UNION SELECT 2 as dev_Order, "PC"
|
||||
UNION SELECT 2 as dev_Order, "Printer"
|
||||
UNION SELECT 2 as dev_Order, "Server"
|
||||
UNION SELECT 2 as dev_Order, "Singleboard Computer (SBC)"
|
||||
|
||||
UNION SELECT 3 as dev_Order, "Game Console"
|
||||
UNION SELECT 3 as dev_Order, "SmartTV"
|
||||
UNION SELECT 3 as dev_Order, "TV Decoder"
|
||||
UNION SELECT 3 as dev_Order, "Virtual Assistance"
|
||||
|
||||
UNION SELECT 4 as dev_Order, "Clock"
|
||||
UNION SELECT 4 as dev_Order, "House Appliance"
|
||||
UNION SELECT 4 as dev_Order, "Phone"
|
||||
UNION SELECT 4 as dev_Order, "Radio"
|
||||
|
||||
UNION SELECT 5 as dev_Order, "AP"
|
||||
UNION SELECT 5 as dev_Order, "NAS"
|
||||
UNION SELECT 5 as dev_Order, "PLC"
|
||||
UNION SELECT 5 as dev_Order, "Router"
|
||||
|
||||
UNION SELECT 10 as dev_Order, "Other"
|
||||
|
||||
ORDER BY 1,2';
|
||||
$result = $db->query($sql);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_DeviceType']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of groups
|
||||
//------------------------------------------------------------------------------
|
||||
function getGroups() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$sql = 'SELECT DISTINCT 1 as dev_Order, dev_Group
|
||||
FROM Devices
|
||||
WHERE dev_Group NOT IN ("(unknown)", "Others") AND dev_Group <> ""
|
||||
UNION SELECT 1 as dev_Order, "Always on"
|
||||
UNION SELECT 1 as dev_Order, "Friends"
|
||||
UNION SELECT 1 as dev_Order, "Personal"
|
||||
UNION SELECT 2 as dev_Order, "Others"
|
||||
ORDER BY 1,2 ';
|
||||
$result = $db->query($sql);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_Group']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of locations
|
||||
//------------------------------------------------------------------------------
|
||||
function getLocations() {
|
||||
global $db;
|
||||
|
||||
// SQL
|
||||
$sql = 'SELECT DISTINCT 9 as dev_Order, dev_Location
|
||||
FROM Devices
|
||||
WHERE dev_Location <> ""
|
||||
AND dev_Location NOT IN (
|
||||
"Bathroom", "Bedroom", "Dining room", "Hallway",
|
||||
"Kitchen", "Laundry", "Living room", "Study",
|
||||
"Attic", "Basement", "Garage",
|
||||
"Back yard", "Garden", "Terrace",
|
||||
"Other")
|
||||
|
||||
UNION SELECT 1 as dev_Order, "Bathroom"
|
||||
UNION SELECT 1 as dev_Order, "Bedroom"
|
||||
UNION SELECT 1 as dev_Order, "Dining room"
|
||||
UNION SELECT 1 as dev_Order, "Hall"
|
||||
UNION SELECT 1 as dev_Order, "Kitchen"
|
||||
UNION SELECT 1 as dev_Order, "Laundry"
|
||||
UNION SELECT 1 as dev_Order, "Living room"
|
||||
UNION SELECT 1 as dev_Order, "Study"
|
||||
|
||||
UNION SELECT 2 as dev_Order, "Attic"
|
||||
UNION SELECT 2 as dev_Order, "Basement"
|
||||
UNION SELECT 2 as dev_Order, "Garage"
|
||||
|
||||
UNION SELECT 3 as dev_Order, "Back yard"
|
||||
UNION SELECT 3 as dev_Order, "Garden"
|
||||
UNION SELECT 3 as dev_Order, "Terrace"
|
||||
|
||||
UNION SELECT 10 as dev_Order, "Other"
|
||||
ORDER BY 1,2 ';
|
||||
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
$tableData[] = array ('order' => $row['dev_Order'],
|
||||
'name' => $row['dev_Location']);
|
||||
}
|
||||
|
||||
// Return json
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
@@ -320,58 +450,14 @@ function queryDeviceData() {
|
||||
// Status Where conditions
|
||||
//------------------------------------------------------------------------------
|
||||
function getDeviceCondition ($deviceStatus) {
|
||||
// Request Parameters
|
||||
$periodDate = getDateFromPeriod();
|
||||
|
||||
switch ($deviceStatus) {
|
||||
case 'all':
|
||||
return '';
|
||||
case 'connected':
|
||||
return 'WHERE dev_PresentLastScan=1';
|
||||
case 'new':
|
||||
return 'WHERE dev_FirstConnection >= ' . $periodDate;
|
||||
case 'down':
|
||||
return 'WHERE dev_AlertDeviceDown=1 AND dev_PresentLastScan=0';
|
||||
case 'favorites':
|
||||
return 'WHERE dev_Favorite=1';
|
||||
default:
|
||||
return 'WHERE 1=0';
|
||||
case 'all': return ''; break;
|
||||
case 'connected': return 'WHERE dev_PresentLastScan=1'; break;
|
||||
case 'new': return 'WHERE dev_NewDevice=1'; break;
|
||||
case 'down': return 'WHERE dev_AlertDeviceDown=1 AND dev_PresentLastScan=0'; break;
|
||||
case 'favorites': return 'WHERE dev_Favorite=1'; break;
|
||||
default: return 'WHERE 1=0'; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Update Device Data
|
||||
//------------------------------------------------------------------------------
|
||||
function updateDeviceData() {
|
||||
global $db;
|
||||
|
||||
// sql
|
||||
$sql = 'UPDATE Devices SET
|
||||
dev_Name = "'. $_REQUEST['name'] .'",
|
||||
dev_Owner = "'. $_REQUEST['owner'] .'",
|
||||
dev_DeviceType = "'. $_REQUEST['type'] .'",
|
||||
dev_Vendor = "'. $_REQUEST['vendor'] .'",
|
||||
dev_Favorite = "'. $_REQUEST['favorite'] .'",
|
||||
dev_Group = "'. $_REQUEST['group'] .'",
|
||||
dev_Comments = "'. $_REQUEST['comments'] .'",
|
||||
dev_StaticIP = "'. $_REQUEST['staticIP'] .'",
|
||||
dev_ScanCycle = "'. $_REQUEST['scancycle'] .'",
|
||||
dev_AlertEvents = "'. $_REQUEST['alertevents'] .'",
|
||||
dev_AlertDeviceDown = "'. $_REQUEST['alertdown'] .'",
|
||||
dev_SkipRepeated = "'. $_REQUEST['skiprepeated'] .'"
|
||||
WHERE dev_MAC="' . $_REQUEST['mac'] .'"';
|
||||
// update Data
|
||||
$result = $db->query($sql);
|
||||
|
||||
// check result
|
||||
if ($result == TRUE) {
|
||||
echo "Device updated successfully";
|
||||
} else {
|
||||
echo "Error updating device\n\n". $sql .'\n\n' . $db->lastErrorMsg();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// Pi.Alert
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// events.php - Front module. Server side. Manage Events
|
||||
//------------------------------------------------------------------------------
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// External files
|
||||
require 'db.php';
|
||||
require 'util.php';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -17,13 +28,13 @@
|
||||
if (isset ($_REQUEST['action']) && !empty ($_REQUEST['action'])) {
|
||||
$action = $_REQUEST['action'];
|
||||
switch ($action) {
|
||||
case 'totals': queryTotals(); break;
|
||||
case 'list': queryList(); break;
|
||||
case 'deviceSessions': queryDeviceSessions(); break;
|
||||
case 'devicePresence': queryDevicePresence(); break;
|
||||
case 'deviceEvents': queryDeviceEvents(); break;
|
||||
case 'calendarPresence': queryCalendarPresence(); break;
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
case 'getEventsTotals': getEventsTotals(); break;
|
||||
case 'getEvents': getEvents(); break;
|
||||
case 'getDeviceSessions': getDeviceSessions(); break;
|
||||
case 'getDevicePresence': getDevicePresence(); break;
|
||||
case 'getDeviceEvents': getDeviceEvents(); break;
|
||||
case 'getEventsCalendar': getEventsCalendar(); break;
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +42,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Query total numbers of Events
|
||||
//------------------------------------------------------------------------------
|
||||
function queryTotals() {
|
||||
function getEventsTotals() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
@@ -86,7 +97,7 @@ function queryTotals() {
|
||||
//------------------------------------------------------------------------------
|
||||
// Query the List of events
|
||||
//------------------------------------------------------------------------------
|
||||
function queryList() {
|
||||
function getEvents() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
@@ -104,30 +115,18 @@ function queryList() {
|
||||
|
||||
// SQL Variations for status
|
||||
switch ($type) {
|
||||
case 'all':
|
||||
$SQL = $SQL1;
|
||||
break;
|
||||
case 'all': $SQL = $SQL1; break;
|
||||
case 'sessions':
|
||||
$SQL = $SQL2 . ' WHERE ( ses_DateTimeConnection >= '. $periodDate .'
|
||||
OR ses_DateTimeDisconnection >= '. $periodDate .'
|
||||
OR ses_StillConnected = 1 ) ';
|
||||
$SQL = $SQL2 . ' WHERE ( ses_DateTimeConnection >= '. $periodDate .' OR ses_DateTimeDisconnection >= '. $periodDate .' OR ses_StillConnected = 1 ) ';
|
||||
break;
|
||||
case 'missing':
|
||||
$SQL = $SQL2 . ' WHERE (ses_DateTimeConnection IS NULL AND ses_DateTimeDisconnection >= '. $periodDate .' )
|
||||
OR (ses_DateTimeDisconnection IS NULL AND ses_StillConnected = 0 AND ses_DateTimeConnection >= '. $periodDate .' )';
|
||||
break;
|
||||
case 'voided':
|
||||
$SQL = $SQL1 .' AND eve_EventType LIKE "VOIDED%" ';
|
||||
break;
|
||||
case 'new':
|
||||
$SQL = $SQL1 .' AND eve_EventType = "New Device" ';
|
||||
break;
|
||||
case 'down':
|
||||
$SQL = $SQL1 .' AND eve_EventType = "Device Down" ';
|
||||
break;
|
||||
default:
|
||||
$SQL = $SQL1 .' AND 1==0 ';
|
||||
break;
|
||||
case 'voided': $SQL = $SQL1 .' AND eve_EventType LIKE "VOIDED%" '; break;
|
||||
case 'new': $SQL = $SQL1 .' AND eve_EventType = "New Device" '; break;
|
||||
case 'down': $SQL = $SQL1 .' AND eve_EventType = "Device Down" '; break;
|
||||
default: $SQL = $SQL1 .' AND 1==0 '; break;
|
||||
}
|
||||
|
||||
// Query
|
||||
@@ -187,7 +186,7 @@ function queryList() {
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Device Sessions
|
||||
//------------------------------------------------------------------------------
|
||||
function queryDeviceSessions() {
|
||||
function getDeviceSessions() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
@@ -195,16 +194,17 @@ function queryDeviceSessions() {
|
||||
$periodDate = getDateFromPeriod();
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT IFNULL (ses_DateTimeConnection, ses_DateTimeDisconnection) ses_DateTimeOrder,
|
||||
ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_StillConnected,
|
||||
ses_IP, ses_AdditionalInfo
|
||||
FROM Sessions
|
||||
WHERE ses_MAC="' . $mac .'"
|
||||
AND ( ses_DateTimeConnection >= '. $periodDate .'
|
||||
OR ses_DateTimeDisconnection >= '. $periodDate .'
|
||||
OR ses_StillConnected = 1 ) ');
|
||||
|
||||
$SQL = 'SELECT IFNULL (ses_DateTimeConnection, ses_DateTimeDisconnection) ses_DateTimeOrder,
|
||||
ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_StillConnected,
|
||||
ses_IP, ses_AdditionalInfo
|
||||
FROM Sessions
|
||||
WHERE ses_MAC="' . $mac .'"
|
||||
AND ( ses_DateTimeConnection >= '. $periodDate .'
|
||||
OR ses_DateTimeDisconnection >= '. $periodDate .'
|
||||
OR ses_StillConnected = 1 ) ';
|
||||
$result = $db->query($SQL);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
@@ -228,7 +228,7 @@ function queryDeviceSessions() {
|
||||
if ($row['ses_EventTypeConnection'] == '<missing event>' || $row['ses_EventTypeDisconnection'] == '<missing event>') {
|
||||
$dur = '...';
|
||||
} elseif ($row['ses_StillConnected'] == true) {
|
||||
$dur = formatDateDiff ($row['ses_DateTimeConnection'], ''); //*******************************************************************************************
|
||||
$dur = formatDateDiff ($row['ses_DateTimeConnection'], ''); //***********
|
||||
} else {
|
||||
$dur = formatDateDiff ($row['ses_DateTimeConnection'], $row['ses_DateTimeDisconnection']);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ function queryDeviceSessions() {
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Device Presence Calendar
|
||||
//------------------------------------------------------------------------------
|
||||
function queryDevicePresence() {
|
||||
function getDevicePresence() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
@@ -266,24 +266,26 @@ function queryDevicePresence() {
|
||||
$endDate = '"'. formatDateISO ($_REQUEST ['end']) .'"';
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo,
|
||||
|
||||
CASE WHEN ses_EventTypeConnection = "<missing event>" THEN
|
||||
IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour"))
|
||||
ELSE ses_DateTimeConnection
|
||||
END AS ses_DateTimeConnectionCorrected,
|
||||
$SQL = 'SELECT ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo,
|
||||
|
||||
CASE
|
||||
WHEN ses_EventTypeConnection = "<missing event>" THEN
|
||||
IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour"))
|
||||
ELSE ses_DateTimeConnection
|
||||
END AS ses_DateTimeConnectionCorrected,
|
||||
|
||||
CASE WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||
ELSE ses_DateTimeDisconnection
|
||||
END AS ses_DateTimeDisconnectionCorrected
|
||||
CASE
|
||||
WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||
ELSE ses_DateTimeDisconnection
|
||||
END AS ses_DateTimeDisconnectionCorrected
|
||||
|
||||
FROM Sessions AS SES1
|
||||
WHERE ses_MAC="' . $mac .'"
|
||||
AND (ses_DateTimeConnectionCorrected <= date('. $endDate .')
|
||||
AND (ses_DateTimeDisconnectionCorrected >= date('. $startDate .') OR ses_StillConnected = 1 ))
|
||||
');
|
||||
FROM Sessions AS SES1
|
||||
WHERE ses_MAC="' . $mac .'"
|
||||
AND (ses_DateTimeConnectionCorrected <= date('. $endDate .')
|
||||
AND (ses_DateTimeDisconnectionCorrected >= date('. $startDate .') OR ses_StillConnected = 1 )) ';
|
||||
$result = $db->query($SQL);
|
||||
|
||||
// arrays of rows
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
@@ -300,10 +302,6 @@ function queryDevicePresence() {
|
||||
'IP: ' . $row['ses_IP'];
|
||||
|
||||
// Save row data
|
||||
// 'start' => formatDateISO ($row['ses_DateTimeConnectionCorrected']),
|
||||
// 'end' => formatDateISO ($row['ses_DateTimeDisconnectionCorrected']),
|
||||
// 'start' => $row['ses_DateTimeConnectionCorrected'],
|
||||
// 'end' => $row['ses_DateTimeDisconnectionCorrected'],
|
||||
$tableData[] = array(
|
||||
'title' => '',
|
||||
'start' => formatDateISO ($row['ses_DateTimeConnectionCorrected']),
|
||||
@@ -326,32 +324,33 @@ function queryDevicePresence() {
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Presence Calendar for all Devices
|
||||
//------------------------------------------------------------------------------
|
||||
function queryCalendarPresence() {
|
||||
function getEventsCalendar() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
$periodDate = getDateFromPeriod();
|
||||
$startDate = '"'. $_REQUEST ['start'] .'"';
|
||||
$endDate = '"'. $_REQUEST ['end'] .'"';
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT ses_MAC, ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo,
|
||||
|
||||
CASE WHEN ses_EventTypeConnection = "<missing event>" THEN
|
||||
IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour"))
|
||||
ELSE ses_DateTimeConnection
|
||||
END AS ses_DateTimeConnectionCorrected,
|
||||
$SQL = 'SELECT ses_MAC, ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection, ses_IP, ses_AdditionalInfo,
|
||||
|
||||
CASE
|
||||
WHEN ses_EventTypeConnection = "<missing event>" THEN
|
||||
IFNULL ((SELECT MAX(ses_DateTimeDisconnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeDisconnection < SES1.ses_DateTimeDisconnection), DATETIME(ses_DateTimeDisconnection, "-1 hour"))
|
||||
ELSE ses_DateTimeConnection
|
||||
END AS ses_DateTimeConnectionCorrected,
|
||||
|
||||
CASE WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||
ELSE ses_DateTimeDisconnection
|
||||
END AS ses_DateTimeDisconnectionCorrected
|
||||
CASE
|
||||
WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||
ELSE ses_DateTimeDisconnection
|
||||
END AS ses_DateTimeDisconnectionCorrected
|
||||
|
||||
FROM Sessions AS SES1
|
||||
WHERE ( ses_DateTimeConnectionCorrected <= Date('. $endDate .')
|
||||
AND (ses_DateTimeDisconnectionCorrected >= Date('. $startDate .') OR ses_StillConnected = 1 ))
|
||||
');
|
||||
FROM Sessions AS SES1
|
||||
WHERE ( ses_DateTimeConnectionCorrected <= Date('. $endDate .')
|
||||
AND (ses_DateTimeDisconnectionCorrected >= Date('. $startDate .') OR ses_StillConnected = 1 )) ';
|
||||
$result = $db->query($SQL);
|
||||
|
||||
// arrays of rows
|
||||
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
@@ -392,7 +391,7 @@ function queryCalendarPresence() {
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Device events
|
||||
//------------------------------------------------------------------------------
|
||||
function queryDeviceEvents() {
|
||||
function getDeviceEvents() {
|
||||
global $db;
|
||||
|
||||
// Request Parameters
|
||||
@@ -401,13 +400,13 @@ function queryDeviceEvents() {
|
||||
$hideConnections = $_REQUEST ['hideConnections'];
|
||||
|
||||
// SQL
|
||||
$result = $db->query('SELECT eve_DateTime, eve_EventType, eve_IP, eve_AdditionalInfo
|
||||
FROM Events
|
||||
WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate .'
|
||||
AND ( (eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" AND
|
||||
eve_EventType <> "VOIDED - Connected" AND eve_EventType <> "VOIDED - Disconnected")
|
||||
OR "'. $hideConnections .'" = "false" )
|
||||
');
|
||||
$SQL = 'SELECT eve_DateTime, eve_EventType, eve_IP, eve_AdditionalInfo
|
||||
FROM Events
|
||||
WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate .'
|
||||
AND ( (eve_EventType <> "Connected" AND eve_EventType <> "Disconnected" AND
|
||||
eve_EventType <> "VOIDED - Connected" AND eve_EventType <> "VOIDED - Disconnected")
|
||||
OR "'. $hideConnections .'" = "false" ) ';
|
||||
$result = $db->query($SQL);
|
||||
|
||||
// arrays of rows
|
||||
$tableData = array();
|
||||
@@ -425,5 +424,4 @@ function queryDeviceEvents() {
|
||||
echo (json_encode ($tableData));
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
88
front/php/server/parameters.php
Normal file
88
front/php/server/parameters.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// Pi.Alert
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// parameters.php - Front module. Server side. Manage Parameters
|
||||
//------------------------------------------------------------------------------
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// External files
|
||||
require 'db.php';
|
||||
require 'util.php';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
//------------------------------------------------------------------------------
|
||||
// Set maximum execution time to 15 seconds
|
||||
ini_set ('max_execution_time','15');
|
||||
|
||||
// Open DB
|
||||
OpenDB();
|
||||
|
||||
// Action functions
|
||||
if (isset ($_REQUEST['action']) && !empty ($_REQUEST['action'])) {
|
||||
$action = $_REQUEST['action'];
|
||||
switch ($action) {
|
||||
case 'get': getParameter(); break;
|
||||
case 'set': setParameter(); break;
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Get Parameter Value
|
||||
//------------------------------------------------------------------------------
|
||||
function getParameter() {
|
||||
global $db;
|
||||
|
||||
$parameter = $_REQUEST['parameter'];
|
||||
$sql = 'SELECT par_Value FROM Parameters
|
||||
WHERE par_ID="'. quotes($_REQUEST['parameter']) .'"';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$value = $row[0];
|
||||
|
||||
echo (json_encode ($value));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Set Parameter Value
|
||||
//------------------------------------------------------------------------------
|
||||
function setParameter() {
|
||||
global $db;
|
||||
|
||||
// Update value
|
||||
$sql = 'UPDATE Parameters SET par_Value="'. quotes ($_REQUEST['value']) .'"
|
||||
WHERE par_ID="'. quotes($_REQUEST['parameter']) .'"';
|
||||
$result = $db->query($sql);
|
||||
|
||||
if (! $result == TRUE) {
|
||||
echo "Error updating parameter\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
return;
|
||||
}
|
||||
|
||||
$changes = $db->changes();
|
||||
if ($changes == 0) {
|
||||
// Insert new value
|
||||
$sql = 'INSERT INTO Parameters (par_ID, par_Value)
|
||||
VALUES ("'. quotes($_REQUEST['parameter']) .'",
|
||||
"'. quotes($_REQUEST['value']) .'")';
|
||||
$result = $db->query($sql);
|
||||
|
||||
if (! $result == TRUE) {
|
||||
echo "Error creating parameter\n\n$sql \n\n". $db->lastErrorMsg();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
echo 'OK';
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
//------------------------------------------------------------------------------
|
||||
// Pi.Alert
|
||||
// Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
//
|
||||
// util.php - Front module. Server side. Common generic functions
|
||||
//------------------------------------------------------------------------------
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Formatting data functions
|
||||
@@ -37,12 +46,16 @@ function formatIPlong ($IP) {
|
||||
//------------------------------------------------------------------------------
|
||||
function getDateFromPeriod () {
|
||||
$period = $_REQUEST['period'];
|
||||
return '"'. date ('Y-m-d', strtotime ('+1 day -'.$period) ) .'"';
|
||||
return '"'. date ('Y-m-d', strtotime ('+1 day -'. $period) ) .'"';
|
||||
}
|
||||
|
||||
function quotes ($text) {
|
||||
return str_replace ('"','""',$text);
|
||||
}
|
||||
|
||||
function logServerConsole ($text) {
|
||||
$x = array();
|
||||
$y = $x['__________'. $text .'__________'];
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Pi.Alert
|
||||
# Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
#
|
||||
# footer.php - Front module. Common footer to all the front pages
|
||||
# footer.php - Front module. Common footer to all the web pages
|
||||
#-------------------------------------------------------------------------------
|
||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
#--------------------------------------------------------------------------- -->
|
||||
@@ -11,9 +11,7 @@
|
||||
<footer class="main-footer">
|
||||
<!-- Default to the left -->
|
||||
|
||||
<!--
|
||||
© 2020 Puche
|
||||
-->
|
||||
<!-- © 2020 Puche -->
|
||||
<?php
|
||||
$conf_file = '../config/version.conf';
|
||||
$conf_data = parse_ini_file($conf_file);
|
||||
@@ -23,9 +21,7 @@
|
||||
<!-- To the right -->
|
||||
<div class="pull-right no-hidden-xs">
|
||||
|
||||
<!--
|
||||
Pi.Alert  2.50  <small>(2019-12-30)</small>
|
||||
-->
|
||||
<!-- Pi.Alert 2.50 <small>(2019-12-30)</small> -->
|
||||
<?php
|
||||
$conf_file = '../config/version.conf';
|
||||
$conf_data = parse_ini_file($conf_file);
|
||||
@@ -34,34 +30,36 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- Control Sidebar -->
|
||||
<!-- DELETED -->
|
||||
<!-- DELETED -->
|
||||
|
||||
</div>
|
||||
<!-- ./wrapper -->
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- REQUIRED JS SCRIPTS -->
|
||||
|
||||
<!-- jQuery 3 -->
|
||||
<script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
<script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<script src="lib/AdminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<script src="lib/AdminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- AdminLTE App -->
|
||||
<script src="lib/AdminLTE/dist/js/adminlte.min.js"></script>
|
||||
<script src="lib/AdminLTE/dist/js/adminlte.min.js"></script>
|
||||
|
||||
<!-- Optionally, you can add Slimscroll and FastClick plugins.
|
||||
Both of these plugins are recommended to enhance the
|
||||
user experience. -->
|
||||
|
||||
<!-- SlimScroll -->
|
||||
<script src="lib/AdminLTE/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
|
||||
<!-- <script src="lib/AdminLTE/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script> -->
|
||||
<!-- FastClick -->
|
||||
<script src="lib/AdminLTE/bower_components/fastclick/lib/fastclick.js"></script>
|
||||
<!-- <script src="lib/AdminLTE/bower_components/fastclick/lib/fastclick.js"></script> -->
|
||||
|
||||
<!-- Pi.Alert -------------------------------------------------------------- -->
|
||||
<script src="js/pialert_common.js"></script>
|
||||
|
||||
<script src="js/pialert_common.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -2,52 +2,58 @@
|
||||
# Pi.Alert
|
||||
# Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
#
|
||||
# header.php - Front module. Common header to all the front pages
|
||||
# header.php - Front module. Common header to all the web pages
|
||||
#-------------------------------------------------------------------------------
|
||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
#--------------------------------------------------------------------------- -->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Pi.Alert</title>
|
||||
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<link rel="stylesheet" href="lib/AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css">
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="lib/AdminLTE/bower_components/font-awesome/css/font-awesome.min.css">
|
||||
|
||||
<!-- Ionicons -->
|
||||
<link rel="stylesheet" href="lib/AdminLTE/bower_components/Ionicons/css/ionicons.min.css">
|
||||
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="lib/AdminLTE/dist/css/AdminLTE.min.css">
|
||||
|
||||
<!-- AdminLTE Skins. We have chosen the skin-blue for this starter
|
||||
page. However, you can choose any other skin. Make sure you
|
||||
apply the skin class to the body tag so the changes take effect. -->
|
||||
<link rel="stylesheet" href="lib/AdminLTE/dist/css/skins/skin-yellow-light.min.css">
|
||||
|
||||
|
||||
<!-- Pi.Alert CSS -->
|
||||
<link rel="stylesheet" href="css/pialert.css">
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<!-- Google Font -->
|
||||
<link rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
|
||||
|
||||
<!-- Page Icon -->
|
||||
<link rel="icon" type="image/png" sizes="160x160" href="img/pialertLogoGray80.png" />
|
||||
</head>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- Layout Boxed Yellow -->
|
||||
<body class="hold-transition skin-yellow-light layout-boxed sidebar-mini" style="background-image: url('img/background.png');">
|
||||
<!-- Site wrapper -->
|
||||
@@ -56,6 +62,7 @@
|
||||
<!-- Main Header -->
|
||||
<header class="main-header">
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- Logo -->
|
||||
<a href="/" class="logo">
|
||||
<!-- mini logo for sidebar mini 50x50 pixels -->
|
||||
@@ -64,6 +71,7 @@
|
||||
<span class="logo-lg">Pi<b>.Alert</b></span>
|
||||
</a>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- Header Navbar -->
|
||||
<nav class="navbar navbar-static-top" role="navigation">
|
||||
<!-- Sidebar toggle button-->
|
||||
@@ -90,12 +98,12 @@
|
||||
<!-- The user image in the menu -->
|
||||
<li class="user-header">
|
||||
<img src="img/pialertLogoWhite.png" class="img-circle" alt="Pi.Alert Logo" style="border-color:transparent">
|
||||
|
||||
<p>
|
||||
Open Source Network Guard
|
||||
<small>Designed for Raspberry Pi</small>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<!-- Menu Body -->
|
||||
<li class="user-body">
|
||||
<div class="row">
|
||||
@@ -122,6 +130,8 @@
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- Left side column. contains the logo and sidebar -->
|
||||
<aside class="main-sidebar">
|
||||
|
||||
@@ -133,117 +143,10 @@
|
||||
<a href="/" class="logo">
|
||||
<img src="img/pialertLogoGray80.png" class="img-responsive" alt="Pi.Alert Logo"/>
|
||||
</a>
|
||||
<div class="pull-left image">
|
||||
<!--
|
||||
<br><img src="img/pialertLogoBlack.png" class="img-responsive" alt="Pi.Alert Logo" style="display: table; table-layout: fixed;" />
|
||||
-->
|
||||
</div>
|
||||
|
||||
<div class="pull-left info" style="display: none">
|
||||
<p>Status</p>
|
||||
<?php
|
||||
|
||||
$pistatus = exec('sudo pihole status web');
|
||||
$pistatus=1;
|
||||
$FTL=true;
|
||||
$celsius=56.7;
|
||||
$temperatureunit='C';
|
||||
$nproc=2;
|
||||
$loaddata=array();
|
||||
$loaddata[]=1.1;
|
||||
$loaddata[]=1.2;
|
||||
$loaddata[]=1.3;
|
||||
$memory_usage=0.452;
|
||||
if ($pistatus == "1") {
|
||||
echo '<a id="status"><i class="fa fa-circle" style="color:#7FFF00"></i> Active</a>';
|
||||
} elseif ($pistatus == "0") {
|
||||
echo '<a id="status"><i class="fa fa-circle" style="color:#FF0000"></i> Offline</a>';
|
||||
} elseif ($pistatus == "-1") {
|
||||
echo '<a id="status"><i class="fa fa-circle" style="color:#FF0000"></i> DNS service not running</a>';
|
||||
} else {
|
||||
echo '<a id="status"><i class="fa fa-circle" style="color:#ff9900"></i> Unknown</a>';
|
||||
}
|
||||
|
||||
// CPU Temp
|
||||
if($FTL)
|
||||
{
|
||||
if ($celsius >= -273.15) {
|
||||
echo "<a id=\"temperature\"><i class=\"fa fa-fire\" style=\"color:";
|
||||
if ($celsius > 60) {
|
||||
echo "#FF0000";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "#3366FF";
|
||||
}
|
||||
echo "\"></i> Temp: ";
|
||||
if($temperatureunit === "F")
|
||||
{
|
||||
echo round($fahrenheit,1) . " °F";
|
||||
}
|
||||
elseif($temperatureunit === "K")
|
||||
{
|
||||
echo round($kelvin,1) . " K";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo round($celsius,1) . " °C";
|
||||
}
|
||||
echo "</a>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a id=\"temperature\"><i class="fa fa-circle" style="color:#FF0000"></i> FTL offline</a>';
|
||||
}
|
||||
?>
|
||||
<br/>
|
||||
<?php
|
||||
echo "<a title=\"Detected $nproc cores\"><i class=\"fa fa-circle\" style=\"color:";
|
||||
if ($loaddata[0] > $nproc) {
|
||||
echo "#FF0000";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "#7FFF00";
|
||||
}
|
||||
echo "\"></i> Load: " . $loaddata[0] . " " . $loaddata[1] . " ". $loaddata[2] . "</a>";
|
||||
?>
|
||||
<br/>
|
||||
<?php
|
||||
echo "<a><i class=\"fa fa-circle\" style=\"color:";
|
||||
if ($memory_usage > 0.75 || $memory_usage < 0.0) {
|
||||
echo "#FF0000";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "#7FFF00";
|
||||
}
|
||||
if($memory_usage > 0.0)
|
||||
{
|
||||
echo "\"></i> Memory usage: " . sprintf("%.1f",100.0*$memory_usage) . " %</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "\"></i> Memory usage: N/A</a>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- search form (Optional) -->
|
||||
<!--
|
||||
<form action="#" method="get" class="sidebar-form">
|
||||
<div class="input-group">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search...">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
-->
|
||||
<!-- /.search form -->
|
||||
<!-- DELETED -->
|
||||
|
||||
<!-- Sidebar Menu -->
|
||||
<ul class="sidebar-menu" data-widget="tree">
|
||||
|
||||
35
front/php/templates/notification.php
Normal file
35
front/php/templates/notification.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!-- ---------------------------------------------------------------------------
|
||||
# Pi.Alert
|
||||
# Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
#
|
||||
# notificacion.php - Front module. Common notification & modal window
|
||||
#-------------------------------------------------------------------------------
|
||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
#--------------------------------------------------------------------------- -->
|
||||
|
||||
<!-- Modal warning -->
|
||||
<div class="modal modal-warning fade" id="modal-warning" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 id="modal-title" class="modal-title"> Modal Title </h4>
|
||||
</div>
|
||||
|
||||
<div id="modal-message" class="modal-body"> Modal message </div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="modal-cancel" type="button" class="btn btn-outline pull-left" data-dismiss="modal"> Cancel </button>
|
||||
<button id="modal-OK" type="button" class="btn btn-outline" onclick="modalOK()"> OK </button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Alert float -->
|
||||
<div id="notification" class="alert alert-dimissible pa_alert_notification">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<div id="alert-message"> Alert message </div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user