cleanup + moving arp-scan setting

This commit is contained in:
Jokob-sk
2023-01-04 19:11:35 +11:00
parent 7678a1a88b
commit 566a5904a6
8 changed files with 110 additions and 184 deletions

View File

@@ -11,13 +11,21 @@ function handleVersion(){
if(release_timestamp > build_timestamp + 600 )
{
console.log("New release!")
// handling the navigation menu icon
$('#version').attr("class", $('#version').attr("class").replace("myhidden", ""))
$('#new-version-text').attr("class", $('#new-version-text').attr("class").replace("myhidden", ""))
maintenanceDiv = $('#new-version-text')
}
else{
console.log("All up-to-date!")
$('#current-version-text').attr("class", $('#current-version-text').attr("class").replace("myhidden", ""))
console.log("All up-to-date!")
maintenanceDiv = $('#current-version-text')
}
// handling the maintenance section message
if(emptyArr.includes(maintenanceDiv) == false && $(maintenanceDiv).length != 0)
{
$(maintenanceDiv).attr("class", $(maintenanceDiv).attr("class").replace("myhidden", ""))
}
}

View File

@@ -10,6 +10,7 @@
// -----------------------------------------------------------------------------
var timerRefreshData = ''
var modalCallbackFunction = '';
var emptyArr = ['undefined', "", undefined, null];
// urlParams = new Proxy(new URLSearchParams(window.location.search), {
// get: (searchParams, prop) => searchParams.get(prop.toString()),
@@ -33,65 +34,6 @@ function setCache(key, data)
}
// -----------------------------------------------------------------------------
function handleVersion(){
release_timestamp = getCookie("release_timestamp")
if(release_timestamp != "")
{
build_timestamp = parseInt($('#version').attr("data-build-time").match( /\d+/g ).join(''))
// if the release_timestamp is older by 10 min or more as the build timestamp then there is a new release available
if(release_timestamp > build_timestamp + 600 )
{
console.log("New release!")
$('#version').attr("class", $('#version').attr("class").replace("myhidden", ""))
}
else{
console.log("All up-to-date!")
$('#current-version-text').attr("class", $('#current-version-text').attr("class").replace("myhidden", ""))
// new-version-text current-version-text
}
}
}
//--------------------------------------------------------------
function getVersion()
{
release_timestamp = getCookie("release_timestamp")
// no cached value available
if(release_timestamp == "")
{
// get parameter value
$.get('https://api.github.com/repos/jokob-sk/Pi.Alert/releases', function(data) {
var releases = data;
if(releases.length > 0)
{
release_datetime = releases[0].published_at;
release_timestamp = new Date(release_datetime).getTime() / 1000;
// cache value
setCookie("release_timestamp", release_timestamp ,5);
handleVersion();
}
});
} else
{
// cache is available, just call the handler
handleVersion()
}
}
// -----------------------------------------------------------------------------
function setCookie (cookie, value, expirationMinutes='') {
// Calc expiration date

View File

@@ -73,16 +73,6 @@ $pia_db = str_replace('front', 'db', getcwd()).'/pialert.db';
$pia_db_size = number_format((filesize($pia_db) / 1000000),2,",",".") . ' MB';
$pia_db_mod = date ("F d Y H:i:s", filemtime($pia_db));
// Pause Arp Scan ---------------------------------------------------------------
if (!file_exists('../db/setting_stoparpscan')) {
$execstring = 'ps -f -u root | grep "sudo arp-scan" 2>&1';
$pia_arpscans = "";
exec($execstring, $pia_arpscans);
$pia_arpscans_result = sizeof($pia_arpscans).' '.lang('Maintenance_arp_status_on');
} else {
$pia_arpscans_result = '<span style="color:red;">arp-Scan '.lang('Maintenance_arp_status_off') .'</span>';
}
// Count and Calc Backups -------------------------------------------------------
@@ -183,12 +173,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<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>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell"><?php echo lang('Maintenance_arp_status');?></div>
<div class="db_info_table_cell">
<?php echo $pia_arpscans_result;?></div>
</div>
</div>
</div>
</div>
<!-- /.box-body -->
@@ -264,13 +249,7 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
<button type="button" class="btn bg-green dbtools-button" id="btnPiaEnableDarkmode" onclick="askPiaEnableDarkmode()"><?php echo lang('Maintenance_Tool_darkmode');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_darkmode_text');?></div>
</div>
<div class="db_info_table_row">
<div class="db_tools_table_cell_a">
<button type="button" class="btn bg-yellow dbtools-button" id="btnPiaToggleArpScan" onclick="askPiaToggleArpScan()"><?php echo lang('Maintenance_Tool_arpscansw');?></button>
</div>
<div class="db_tools_table_cell_b"><?php echo lang('Maintenance_Tool_arpscansw_text');?></div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tab_DBTools">

View File

@@ -559,25 +559,6 @@ function PiaEnableDarkmode() {
}
}
//------------------------------------------------------------------------------
// Toggle on/off Arp-Scans
//------------------------------------------------------------------------------
function PiaToggleArpScan() {
$file = '../../../db/setting_stoparpscan';
global $pia_lang;
if (file_exists($file)) {
echo lang('BackDevices_Arpscan_enabled');
unlink($file);
echo("<meta http-equiv='refresh' content='1'>");
} else {
echo lang('BackDevices_Arpscan_disabled');
$startarpscan = fopen($file, 'w');
echo("<meta http-equiv='refresh' content='1'>");
}
}
//------------------------------------------------------------------------------
// Query total numbers of Devices by status
//------------------------------------------------------------------------------

View File

@@ -276,4 +276,3 @@ if ($ENABLED_DARKMODE === True) {
</script>

View File

@@ -438,6 +438,8 @@ $lang['en_us'] = array(
'settings_imported' => 'Last time settings were imported from the pialert.conf file:',
//General
'ENABLE_ARPSCAN_name' => 'Enable ARP scan',
'ENABLE_ARPSCAN_description' => 'Arp-scan is a command-line tool that uses the ARP protocol to discover and fingerprint IP hosts on the local network. An alternative to ARP scan is to enable the <a href="#PIHOLE_ACTIVE"><code>PIHOLE_ACTIVE</code>PiHole integration settings</a>.',
'SCAN_SUBNETS_name' => 'Subnets to scan',
'SCAN_SUBNETS_description' => '

View File

@@ -247,7 +247,7 @@ CommitDB();
<script>
// number of settings has to be equal to
var settingsNumber = 58;
var settingsNumber = 59;
// Wrong number of settings processing
if(<?php echo count($settings)?> != settingsNumber)