From 9ec69d895c8b471f1beccce1e3e10e80fa360594 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Fri, 6 Jan 2023 22:14:50 +1100 Subject: [PATCH] cleanup --- front/deviceDetails.php | 82 +++++++++------------------------------ front/php/server/util.php | 30 +++++++------- 2 files changed, 32 insertions(+), 80 deletions(-) diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 8fd36164..dedfb02f 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -1513,6 +1513,7 @@ function askDeleteDeviceEvents () { '', '', 'deleteDeviceEvents'); } +// ----------------------------------------------------------------------------- function deleteDeviceEvents () { // Check MAC if (mac == '') { @@ -1645,23 +1646,28 @@ function loadNmap() var listData = JSON.parse(data); var order = 1; - tableRows = ""; // for each item listData.forEach(function (item, index) { - tableRows += '' - +item.Index+'' - +item.Time+'' - +item.Port+'' - +item.State+'' - +item.Service+'' - +'
\ - \ - \ + tableRows += '\ + '+item.Index+'\ + '+item.Time+'\ + \ + '+item.Port+'\ + \ + \ + \ + '+item.State+'\ + '+item.Service+'\ + \ +
\ + \ + \
\ - '; - }); + \ + '; + }); $("#tableNmapBody").html($("#tableNmapBody").html()+tableRows); $("#tableNmapPlc").hide(); @@ -1709,58 +1715,6 @@ function loadPholus() }); } -// function loadPholus() -// { -// tableId = "tablePholus"; - - -// $.get('php/server/devices.php?action=getPholus&mac='+ mac, function(data) { - - -// console.log("here URL mac:" + mac) -// console.log("here table mac:" + $("#"+tableId).attr("data-mac")) -// console.log("here") - -// // check if already initialized -// if($("#"+tableId).attr("data-mac") == mac) -// { -// console.log("return") -// return; -// } - - - -// initTable(tableId, mac); - -// data = sanitize(data); - -// if(data != "false" && $.trim(data) != []) -// { -// var listData = JSON.parse(data); -// var order = 1; - -// tableRows = ""; - -// // for each item -// listData.forEach(function (item, index) { -// tableRows += ''+item.Index+''+item.Info+''+item.Time+''+item.IP_v4_or_v6+''+item.Record_Type+''+item.Value+''+item.Extra+''; -// }); - -// $("#tablePholus tbody").first().html(tableRows); -// // $("#tablePholusPlc").attr("style", "display:none"); -// // $("#tablePholusPlc").hide(); -// } -// else -// { -// // console.log("else") -// // $("#tablePholusPlc").show(); -// // $(".deviceSpecific").remove(); -// } - - -// }); -// } - //----------------------------------------------------------------------------------- function initTable(tableId, mac){ diff --git a/front/php/server/util.php b/front/php/server/util.php index e0dcd600..bed02961 100755 --- a/front/php/server/util.php +++ b/front/php/server/util.php @@ -10,28 +10,14 @@ require '/home/pi/pialert/front/php/templates/timezone.php'; require '/home/pi/pialert/front/php/templates/skinUI.php'; -// require '/home/pi/pialert/front/php/templates/language/lang.php'; -// require '/home/pi/pialert/front/php/server/db.php'; - - $FUNCTION = []; $SETTINGS = []; -// displayMessage($_REQUEST); - - -// echo 'hereeeeeeeeeeeeeeeeeeeeee1'; - // init request params if(array_key_exists('function', $_REQUEST) != FALSE) { - displayMessage(array_key_exists('function', $_REQUEST)); - displayMessage(array_key_exists('index', $_REQUEST)); - displayMessage(array_key_exists('value', $_REQUEST)); - $FUNCTION = $_REQUEST['function']; - displayMessage($FUNCTION); - + $FUNCTION = $_REQUEST['function']; } if(array_key_exists('settings', $_REQUEST) != FALSE) @@ -78,18 +64,22 @@ function createArray($input){ return $options; } +// ------------------------------------------------------------------------------------------- function formatDate ($date1) { return date_format (new DateTime ($date1) , 'Y-m-d H:i'); } +// ------------------------------------------------------------------------------------------- function formatDateDiff ($date1, $date2) { return date_diff (new DateTime ($date1), new DateTime ($date2 ) )-> format ('%ad %H:%I'); } +// ------------------------------------------------------------------------------------------- function formatDateISO ($date1) { return date_format (new DateTime ($date1),'c'); } +// ------------------------------------------------------------------------------------------- function formatEventDate ($date1, $eventType) { if (!empty ($date1) ) { $ret = formatDate ($date1); @@ -102,6 +92,7 @@ function formatEventDate ($date1, $eventType) { return $ret; } +// ------------------------------------------------------------------------------------------- function formatIPlong ($IP) { return sprintf('%u', ip2long($IP) ); } @@ -310,20 +301,26 @@ function getString ($codeName, $default) { return $default; } +// ------------------------------------------------------------------------------------------- + function getDateFromPeriod () { $period = $_REQUEST['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 .'__________']; } +// ------------------------------------------------------------------------------------------- + function getNetworkTypes(){ $array = array( @@ -333,6 +330,7 @@ function getNetworkTypes(){ return $array; } +// ------------------------------------------------------------------------------------------- function getDevicesColumns(){ $columns = ["dev_MAC", @@ -375,7 +373,7 @@ function getCache($key) { return ""; } } - +// ------------------------------------------------------------------------------------------- function setCache($key, $value) { setcookie($key, $value, time()+300, "/","", 0); // 5min cache }