mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
code cleanup
This commit is contained in:
@@ -7,54 +7,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
// ###################################
|
||||
// ## TimeZone processing start
|
||||
// ###################################
|
||||
|
||||
$configFolderPath = "/home/pi/pialert/config/";
|
||||
$config_file = "pialert.conf";
|
||||
$logFolderPath = "/home/pi/pialert/front/log/";
|
||||
$log_file = "pialert_front.log";
|
||||
|
||||
|
||||
$fullConfPath = $configFolderPath.$config_file;
|
||||
|
||||
$config_file_lines = file($fullConfPath);
|
||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||
|
||||
$timeZone = "";
|
||||
|
||||
foreach ($config_file_lines as $line)
|
||||
{
|
||||
if( preg_match('/TIMEZONE(.*?)/', $line, $match) == 1 )
|
||||
{
|
||||
if (preg_match('/\'(.*?)\'/', $line, $match) == 1) {
|
||||
$timeZone = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($timeZone == "")
|
||||
{
|
||||
$timeZone = "Europe/Berlin";
|
||||
}
|
||||
|
||||
date_default_timezone_set($timeZone);
|
||||
|
||||
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||
|
||||
// ###################################
|
||||
// ## TimeZone processing end
|
||||
// ###################################
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// External files
|
||||
require 'db.php';
|
||||
require 'util.php';
|
||||
require '/home/pi/pialert/front/php/templates/timezone.php';
|
||||
require '/home/pi/pialert/front/php/server/db.php';
|
||||
require '/home/pi/pialert/front/php/server/util.php';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Action selector
|
||||
|
||||
@@ -8,57 +8,10 @@
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ###################################
|
||||
// ## TimeZone processing start
|
||||
// ###################################
|
||||
$configFolderPath = "/home/pi/pialert/config/";
|
||||
$config_file = "pialert.conf";
|
||||
$logFolderPath = "/home/pi/pialert/front/log/";
|
||||
$log_file = "pialert_front.log";
|
||||
require '/home/pi/pialert/front/php/templates/timezone.php';
|
||||
require '/home/pi/pialert/front/php/templates/skinUI.php';
|
||||
|
||||
|
||||
$fullConfPath = $configFolderPath.$config_file;
|
||||
|
||||
$config_file_lines = file($fullConfPath);
|
||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||
|
||||
$timeZone = "";
|
||||
|
||||
foreach ($config_file_lines as $line)
|
||||
{
|
||||
if( preg_match('/TIMEZONE(.*?)/', $line, $match) == 1 )
|
||||
{
|
||||
if (preg_match('/\'(.*?)\'/', $line, $match) == 1) {
|
||||
$timeZone = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($timeZone == "")
|
||||
{
|
||||
$timeZone = "Europe/Berlin";
|
||||
}
|
||||
|
||||
date_default_timezone_set($timeZone);
|
||||
|
||||
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||
|
||||
|
||||
// ###################################
|
||||
// ## TimeZone processing end
|
||||
// ###################################
|
||||
// ###################################
|
||||
// ## GUI settings processing start
|
||||
// ###################################
|
||||
foreach (glob("../db/setting_language*") as $filename) {
|
||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||
}
|
||||
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = 'en_us';}
|
||||
require '/home/pi/pialert/front/php/templates/language/'.$pia_lang_selected.'.php';
|
||||
// ###################################
|
||||
// ## GUI settings processing end
|
||||
// ###################################
|
||||
$FUNCTION = [];
|
||||
$SETTINGS = [];
|
||||
|
||||
|
||||
@@ -8,101 +8,11 @@
|
||||
#--------------------------------------------------------------------------- -->
|
||||
|
||||
<?php
|
||||
// ###################################
|
||||
// ## TimeZone processing start
|
||||
// ###################################
|
||||
|
||||
$configFolderPath = "/home/pi/pialert/config/";
|
||||
$config_file = "pialert.conf";
|
||||
$logFolderPath = "/home/pi/pialert/front/log/";
|
||||
$log_file = "pialert_front.log";
|
||||
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';
|
||||
|
||||
|
||||
$fullConfPath = $configFolderPath.$config_file;
|
||||
|
||||
$config_file_lines = file($fullConfPath);
|
||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||
|
||||
$timeZone = "";
|
||||
|
||||
foreach ($config_file_lines as $line)
|
||||
{
|
||||
if( preg_match('/TIMEZONE(.*?)/', $line, $match) == 1 )
|
||||
{
|
||||
if (preg_match('/\'(.*?)\'/', $line, $match) == 1) {
|
||||
$timeZone = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($timeZone == "")
|
||||
{
|
||||
$timeZone = "Europe/Berlin";
|
||||
}
|
||||
|
||||
date_default_timezone_set($timeZone);
|
||||
|
||||
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||
|
||||
// ###################################
|
||||
// ## TimeZone processing end
|
||||
// ###################################
|
||||
|
||||
|
||||
// ###################################
|
||||
// ## GUI settings processing start
|
||||
// ###################################
|
||||
if (file_exists('../db/setting_darkmode')) {
|
||||
$ENABLED_DARKMODE = True;
|
||||
}
|
||||
foreach (glob("../db/setting_skin*") as $filename) {
|
||||
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
||||
}
|
||||
if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';}
|
||||
|
||||
// ###################################
|
||||
// ## Languages
|
||||
// ###################################
|
||||
|
||||
foreach (glob("../db/setting_language*") as $filename) {
|
||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||
}
|
||||
|
||||
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = 'en_us';}
|
||||
|
||||
require 'php/templates/language/en_us.php';
|
||||
require 'php/templates/language/de_de.php';
|
||||
require 'php/templates/language/es_es.php';
|
||||
|
||||
function lang($key)
|
||||
{
|
||||
global $pia_lang_selected, $lang ;
|
||||
|
||||
// try to get the selected language translation
|
||||
$temp = $lang[$pia_lang_selected][$key];
|
||||
|
||||
if(isset($temp) == FALSE)
|
||||
{
|
||||
// if not found, use English
|
||||
$temp = $lang[$pia_lang_selected]["en_us"];
|
||||
|
||||
// echo $temp;
|
||||
if(isset($temp) == FALSE)
|
||||
{
|
||||
// if not found, in English, use placeholder
|
||||
$temp = "String not found";
|
||||
}
|
||||
}
|
||||
|
||||
// echo $temp;
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
// ###################################
|
||||
// ## GUI settings processing end
|
||||
// ###################################
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
@@ -205,7 +205,7 @@ $lang['de_de'] = array(
|
||||
'DevDetail_Nmap_buttonDetail_text' => 'Detailierter Scan: Standardscan mit aktivierter Betriebssystemerkennung, Versionserkennung, Skript-Scan und Traceroute (bis zu 30 oder mehr Sekunden)',
|
||||
'DevDetail_Nmap_buttonSkipDiscovery' => 'Ohne Erreichbarkeitsprüfung',
|
||||
'DevDetail_Nmap_buttonSkipDiscovery_text' => 'Ohne Erreichbarkeitsprüfung (-Pn Parameter): Standard Scan bei dem nmap annimmt, dass der Host erreichbar ist.',
|
||||
'DevDetail_Nmap_resultsLink' => 'Results will be also available in the <code>pialert_front.log</code> file.',
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Maintenance Page
|
||||
|
||||
@@ -203,7 +203,7 @@ $lang['en_us'] = array(
|
||||
'DevDetail_Nmap_buttonDetail_text' => 'Detailed Scan: Default scan with enabled OS detection, version detection, script scanning and traceroute (up to 30 seconds or more)',
|
||||
'DevDetail_Nmap_buttonSkipDiscovery' => 'Skip host discovery',
|
||||
'DevDetail_Nmap_buttonSkipDiscovery_text' => 'Skip host discovery (-Pn option): Default scan without host discovery',
|
||||
'DevDetail_Nmap_resultsLink' => 'Results will be also available in the <code>pialert_front.log</code> file.',
|
||||
'DevDetail_Nmap_resultsLink' => 'You can leave this page after starting a scan. Results will be also available in the <code>pialert_front.log</code> file.',
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Maintenance Page
|
||||
@@ -212,7 +212,7 @@ $lang['en_us'] = array(
|
||||
'Maintenance_Title' => 'Maintenance tools',
|
||||
'Maintenance_database_path' => 'Database-Path',
|
||||
'Maintenance_database_size' => 'Database-Size',
|
||||
'Maintenance_database_lastmod' => 'last Modification',
|
||||
'Maintenance_database_lastmod' => 'Last Modification',
|
||||
'Maintenance_database_backup' => 'DB Backups',
|
||||
'Maintenance_database_backup_found' => 'backups were found',
|
||||
'Maintenance_database_backup_total' => 'total disk usage',
|
||||
@@ -228,7 +228,7 @@ $lang['en_us'] = array(
|
||||
'Maintenance_lang_en_us' => 'English (US)',
|
||||
'Maintenance_lang_de_de' => 'German (DE)',
|
||||
'Maintenance_lang_es_es' => 'Spanish (ES)',
|
||||
'Maintenance_lang_selector_text' => 'The change takes place on the server side, so it affects all devices in use.',
|
||||
'Maintenance_lang_selector_text' => 'The change takes place on the client side, so it affects only the current browser.',
|
||||
'Maintenance_lang_selector_apply' => 'Apply',
|
||||
'Maintenance_Tools_Tab_Settings' => 'Settings',
|
||||
'Maintenance_Tools_Tab_Tools' => 'Tools',
|
||||
@@ -422,6 +422,9 @@ $lang['en_us'] = array(
|
||||
// Settings
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
'settings_missing' => 'Not all settings loaded, refresh the page!',
|
||||
|
||||
//General
|
||||
'SCAN_SUBNETS_name' => 'Subnets to scan',
|
||||
'SCAN_SUBNETS_description' => '
|
||||
|
||||
@@ -47,7 +47,7 @@ $lang['es_es'] = array(
|
||||
'Navigation_Presence' => 'Historial',
|
||||
'Navigation_Events' => 'Eventos',
|
||||
'Navigation_Maintenance' => 'Cantenimiento',
|
||||
'Navigation_Settings' => 'configuración',
|
||||
'Navigation_Settings' => 'Configuración',
|
||||
'Navigation_Network' => 'Red',
|
||||
'Navigation_HelpFAQ' => 'Ayuda / FAQ',
|
||||
'Device_Title' => 'Dispositivos',
|
||||
@@ -199,7 +199,6 @@ $lang['es_es'] = array(
|
||||
'DevDetail_Nmap_buttonDetail_text' => 'Escaneo detallado: escaneo predeterminado con detección de sistema operativo habilitado, detección de versiones, escaneo de script y traceroute (hasta 30 segundos o más)',
|
||||
'DevDetail_Nmap_buttonSkipDiscovery' => 'Omitir detección de host',
|
||||
'DevDetail_Nmap_buttonSkipDiscovery_text' => 'Omitir detección de host (-Pn opción): Escaneo predeterminado sin detección de host',
|
||||
'DevDetail_Nmap_resultsLink' => 'Results will be also available in the <code>pialert_front.log</code> file.',
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Maintenance Page - Update by @TeroRERO 07ago2022
|
||||
|
||||
43
front/php/templates/language/lang.php
Normal file
43
front/php/templates/language/lang.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
// ###################################
|
||||
// ## Languages
|
||||
// ###################################
|
||||
|
||||
if(!isset($_COOKIE["language"])) {
|
||||
$pia_lang_selected = "en_us";
|
||||
} else {
|
||||
$pia_lang_selected = $_COOKIE["language"];
|
||||
}
|
||||
|
||||
if (isset($pia_lang_selected) == FALSE or (strlen($pia_lang_selected) == 0)) {$pia_lang_selected = 'en_us';}
|
||||
|
||||
require 'en_us.php';
|
||||
require 'de_de.php';
|
||||
require 'es_es.php';
|
||||
|
||||
function lang($key)
|
||||
{
|
||||
global $pia_lang_selected, $lang ;
|
||||
|
||||
// try to get the selected language translation
|
||||
$temp = $lang[$pia_lang_selected][$key];
|
||||
|
||||
if(isset($temp) == FALSE)
|
||||
{
|
||||
// if not found, use English
|
||||
$temp = $lang[$pia_lang_selected]["en_us"];
|
||||
|
||||
// echo $temp;
|
||||
if(isset($temp) == FALSE)
|
||||
{
|
||||
// if not found, in English, use placeholder
|
||||
$temp = "String not found";
|
||||
}
|
||||
}
|
||||
|
||||
// echo $temp;
|
||||
|
||||
return $temp;
|
||||
}
|
||||
?>
|
||||
19
front/php/templates/skinUI.php
Normal file
19
front/php/templates/skinUI.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// ###################################
|
||||
// ## GUI settings processing start
|
||||
// ###################################
|
||||
|
||||
if (file_exists('/home/pi/pialert/db/setting_darkmode')) {
|
||||
$ENABLED_DARKMODE = True;
|
||||
}
|
||||
foreach (glob("/home/pi/pialert/db/setting_skin*") as $filename) {
|
||||
$pia_skin_selected = str_replace('setting_','',basename($filename));
|
||||
}
|
||||
if (isset($pia_skin_selected) == FALSE or (strlen($pia_skin_selected) == 0)) {$pia_skin_selected = 'skin-blue';}
|
||||
|
||||
// ###################################
|
||||
// ## GUI settings processing end
|
||||
// ###################################
|
||||
|
||||
?>
|
||||
44
front/php/templates/timezone.php
Normal file
44
front/php/templates/timezone.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
// ###################################
|
||||
// ## TimeZone processing start
|
||||
// ###################################
|
||||
|
||||
$configFolderPath = "/home/pi/pialert/config/";
|
||||
$config_file = "pialert.conf";
|
||||
$logFolderPath = "/home/pi/pialert/front/log/";
|
||||
$log_file = "pialert_front.log";
|
||||
|
||||
|
||||
$fullConfPath = $configFolderPath.$config_file;
|
||||
|
||||
$config_file_lines = file($fullConfPath);
|
||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||
|
||||
$timeZone = "";
|
||||
|
||||
foreach ($config_file_lines as $line)
|
||||
{
|
||||
if( preg_match('/TIMEZONE(.*?)/', $line, $match) == 1 )
|
||||
{
|
||||
if (preg_match('/\'(.*?)\'/', $line, $match) == 1) {
|
||||
$timeZone = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($timeZone == "")
|
||||
{
|
||||
$timeZone = "Europe/Berlin";
|
||||
}
|
||||
|
||||
date_default_timezone_set($timeZone);
|
||||
|
||||
$date = new DateTime("now", new DateTimeZone($timeZone) );
|
||||
$timestamp = $date->format('Y-m-d_H-i-s');
|
||||
|
||||
// ###################################
|
||||
// ## TimeZone processing end
|
||||
// ###################################
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user