Merge remote-tracking branch 'origin/develop' into ent-12607-faltan-botones-de-desacoplar-y-minimizar-en-consola-sonora-command-center

Conflicts:
	pandora_console/include/javascript/pandora.js
This commit is contained in:
daniel 2023-12-19 14:41:12 +01:00
commit d57f0971b6
133 changed files with 28147 additions and 1357 deletions

View File

@ -520,18 +520,18 @@ execute_cmd "systemctl restart mysql" "Configuring and restarting database engin
#Define packages
if [ "$PANDORA_LTS" -eq '1' ] ; then
[ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_server-7.0NG.tar.gz"
[ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_console-7.0NG.tar.gz"
[ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_server-7.0NG.tar.gz"
[ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/LTS/pandorafms_console-7.0NG.tar.gz"
[ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz"
elif [ "$PANDORA_LTS" -ne '1' ] ; then
[ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_server-7.0NG.tar.gz"
[ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_console-7.0NG.tar.gz"
[ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_server-7.0NG.tar.gz"
[ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_console-7.0NG.tar.gz"
[ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE=" https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz"
fi
if [ "$PANDORA_BETA" -eq '1' ] ; then
PANDORA_SERVER_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.tar.gz"
PANDORA_CONSOLE_PACKAGE="http://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.tar.gz"
PANDORA_SERVER_PACKAGE="https://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_server-latest.tar.gz"
PANDORA_CONSOLE_PACKAGE="https://firefly.pandorafms.com/pandora_enterprise_nightlies/pandorafms_console-latest.tar.gz"
PANDORA_AGENT_PACKAGE="https://firefly.pandorafms.com/pandorafms/latest/Tarball/pandorafms_agent_linux-7.0NG.x86_64.tar.gz"
fi
@ -837,7 +837,7 @@ echo "@hourly root bash -c /etc/cron.hourly/pandora_db" >> /etc/cront
## Enabling agent adn configuring Agente
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE"
execute_cmd "/etc/init.d/pandora_agent_daemon start" "Starting PandoraFSM Agent"
execute_cmd "/etc/init.d/pandora_agent_daemon restart" "Starting PandoraFSM Agent"
systemctl enable pandora_agent_daemon &>> "$LOGFILE"
#fix path phantomjs

View File

@ -0,0 +1 @@
dist

View File

@ -0,0 +1,10 @@
# Makefile for winexe.py.
.PHONY: all build_image pandora_security_win.py
all: build_image pandora_security_win.py
build_image:
docker build -t pandora_security_win docker/
pandora_security_win.py:
docker run --rm -t -v`pwd`:/pybuild pandora_security_win

View File

@ -0,0 +1,5 @@
#!/bin/bash
# Build the winexe binary.
wine pip install -r src/requirements.txt
wine pyinstaller --onefile src/pandora_security_win.py
rm -rf build/ __pycache__/ pandora_security_win.spec

View File

@ -0,0 +1,34 @@
FROM i386/debian
# Update the package list.
RUN apt-get update
# Install needed packages.
RUN apt-get install --yes \
gnupg2 \
unzip \
software-properties-common \
wget \
xvfb
# Install WineHQ.
RUN wget -q https://dl.winehq.org/wine-builds/winehq.key -O- | apt-key add -
RUN apt-add-repository https://dl.winehq.org/wine-builds/debian/; apt-get update
RUN apt-get install --yes --install-recommends wine
# Use Windows 10.
COPY winetricks /tmp/winetricks
RUN /bin/bash /tmp/winetricks win10; rm -f /tmp/winetricks
# Install Python.
RUN wget https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe
RUN xvfb-run wine python-3.8.10.exe /quiet Include_doc=0 Include_dev=0 Include_test=0 InstallAllUsers=1 PrependPath=1 TargetDir=c:\python; echo
ENV WINEPATH="c:\\python;c:\\python\Scripts"
# Install Python modules..
RUN wine pip.exe install wheel
RUN wine pip.exe install pyinstaller
VOLUME ["/pybuild"]
WORKDIR "/pybuild"
ENTRYPOINT ["/bin/bash", "/pybuild/build.sh"]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,406 @@
import wmi, sys, winreg, os, subprocess, json, re
from datetime import datetime, timedelta
## Define modules
modules=[]
def print_module(module, print_flag=None):
"""Returns module in XML format. Accepts only {dict}.\n
- Only works with one module at a time: otherwise iteration is needed.
- Module "value" field accepts str type or [list] for datalists.
- Use print_flag to show modules' XML in STDOUT.
"""
data = dict(module)
module_xml = ("<module>\n"
"\t<name><![CDATA[" + str(data["name"]) + "]]></name>\n"
"\t<type>" + str(data["type"]) + "</type>\n"
)
if type(data["type"]) is not str and "string" not in data["type"]: #### Strip spaces if module not generic_data_string
data["value"] = data["value"].strip()
if isinstance(data["value"], list): # Checks if value is a list
module_xml += "\t<datalist>\n"
for value in data["value"]:
if type(value) is dict and "value" in value:
module_xml += "\t<data>\n"
module_xml += "\t\t<value><![CDATA[" + str(value["value"]) + "]]></value>\n"
if "timestamp" in value:
module_xml += "\t\t<timestamp><![CDATA[" + str(value["timestamp"]) + "]]></timestamp>\n"
module_xml += "\t</data>\n"
module_xml += "\t</datalist>\n"
else:
module_xml += "\t<data><![CDATA[" + str(data["value"]) + "]]></data>\n"
if "desc" in data:
module_xml += "\t<description><![CDATA[" + str(data["desc"]) + "]]></description>\n"
if "unit" in data:
module_xml += "\t<unit><![CDATA[" + str(data["unit"]) + "]]></unit>\n"
if "interval" in data:
module_xml += "\t<module_interval><![CDATA[" + str(data["interval"]) + "]]></module_interval>\n"
if "tags" in data:
module_xml += "\t<tags>" + str(data["tags"]) + "</tags>\n"
if "module_group" in data:
module_xml += "\t<module_group>" + str(data["module_group"]) + "</module_group>\n"
if "module_parent" in data:
module_xml += "\t<module_parent>" + str(data["module_parent"]) + "</module_parent>\n"
if "min_warning" in data:
module_xml += "\t<min_warning><![CDATA[" + str(data["min_warning"]) + "]]></min_warning>\n"
if "min_warning_forced" in data:
module_xml += "\t<min_warning_forced><![CDATA[" + str(data["min_warning_forced"]) + "]]></min_warning_forced>\n"
if "max_warning" in data:
module_xml += "\t<max_warning><![CDATA[" + str(data["max_warning"]) + "]]></max_warning>\n"
if "max_warning_forced" in data:
module_xml += "\t<max_warning_forced><![CDATA[" + str(data["max_warning_forced"]) + "]]></max_warning_forced>\n"
if "min_critical" in data:
module_xml += "\t<min_critical><![CDATA[" + str(data["min_critical"]) + "]]></min_critical>\n"
if "min_critical_forced" in data:
module_xml += "\t<min_critical_forced><![CDATA[" + str(data["min_critical_forced"]) + "]]></min_critical_forced>\n"
if "max_critical" in data:
module_xml += "\t<max_critical><![CDATA[" + str(data["max_critical"]) + "]]></max_critical>\n"
if "max_critical_forced" in data:
module_xml += "\t<max_critical_forced><![CDATA[" + str(data["max_critical_forced"]) + "]]></max_critical_forced>\n"
if "str_warning" in data:
module_xml += "\t<str_warning><![CDATA[" + str(data["str_warning"]) + "]]></str_warning>\n"
if "str_warning_forced" in data:
module_xml += "\t<str_warning_forced><![CDATA[" + str(data["str_warning_forced"]) + "]]></str_warning_forced>\n"
if "str_critical" in data:
module_xml += "\t<str_critical><![CDATA[" + str(data["str_critical"]) + "]]></str_critical>\n"
if "str_critical_forced" in data:
module_xml += "\t<str_critical_forced><![CDATA[" + str(data["str_critical_forced"]) + "]]></str_critical_forced>\n"
if "critical_inverse" in data:
module_xml += "\t<critical_inverse><![CDATA[" + str(data["critical_inverse"]) + "]]></critical_inverse>\n"
if "warning_inverse" in data:
module_xml += "\t<warning_inverse><![CDATA[" + str(data["warning_inverse"]) + "]]></warning_inverse>\n"
if "max" in data:
module_xml += "\t<max><![CDATA[" + str(data["max"]) + "]]></max>\n"
if "min" in data:
module_xml += "\t<min><![CDATA[" + str(data["min"]) + "]]></min>\n"
if "post_process" in data:
module_xml += "\t<post_process><![CDATA[" + str(data["post_process"]) + "]]></post_process>\n"
if "disabled" in data:
module_xml += "\t<disabled><![CDATA[" + str(data["disabled"]) + "]]></disabled>\n"
if "min_ff_event" in data:
module_xml += "\t<min_ff_event><![CDATA[" + str(data["min_ff_event"]) + "]]></min_ff_event>\n"
if "status" in data:
module_xml += "\t<status><![CDATA[" + str(data["status"]) + "]]></status>\n"
if "timestamp" in data:
module_xml += "\t<timestamp><![CDATA[" + str(data["timestamp"]) + "]]></timestamp>\n"
if "custom_id" in data:
module_xml += "\t<custom_id><![CDATA[" + str(data["custom_id"]) + "]]></custom_id>\n"
if "critical_instructions" in data:
module_xml += "\t<critical_instructions><![CDATA[" + str(data["critical_instructions"]) + "]]></critical_instructions>\n"
if "warning_instructions" in data:
module_xml += "\t<warning_instructions><![CDATA[" + str(data["warning_instructions"]) + "]]></warning_instructions>\n"
if "unknown_instructions" in data:
module_xml += "\t<unknown_instructions><![CDATA[" + str(data["unknown_instructions"]) + "]]></unknown_instructions>\n"
if "quiet" in data:
module_xml += "\t<quiet><![CDATA[" + str(data["quiet"]) + "]]></quiet>\n"
if "module_ff_interval" in data:
module_xml += "\t<module_ff_interval><![CDATA[" + str(data["module_ff_interval"]) + "]]></module_ff_interval>\n"
if "crontab" in data:
module_xml += "\t<crontab><![CDATA[" + str(data["crontab"]) + "]]></crontab>\n"
if "min_ff_event_normal" in data:
module_xml += "\t<min_ff_event_normal><![CDATA[" + str(data["min_ff_event_normal"]) + "]]></min_ff_event_normal>\n"
if "min_ff_event_warning" in data:
module_xml += "\t<min_ff_event_warning><![CDATA[" + str(data["min_ff_event_warning"]) + "]]></min_ff_event_warning>\n"
if "min_ff_event_critical" in data:
module_xml += "\t<min_ff_event_critical><![CDATA[" + str(data["min_ff_event_critical"]) + "]]></min_ff_event_critical>\n"
if "ff_type" in data:
module_xml += "\t<ff_type><![CDATA[" + str(data["ff_type"]) + "]]></ff_type>\n"
if "ff_timeout" in data:
module_xml += "\t<ff_timeout><![CDATA[" + str(data["ff_timeout"]) + "]]></ff_timeout>\n"
if "each_ff" in data:
module_xml += "\t<each_ff><![CDATA[" + str(data["each_ff"]) + "]]></each_ff>\n"
if "module_parent_unlink" in data:
module_xml += "\t<module_parent_unlink><![CDATA[" + str(data["parent_unlink"]) + "]]></module_parent_unlink>\n"
if "global_alerts" in data:
for alert in data["alert"]:
module_xml += "\t<alert_template><![CDATA[" + alert + "]]></alert_template>\n"
module_xml += "</module>\n"
if print_flag:
print (module_xml)
return (module_xml)
def check_antivirus_status():
try:
wmi_obj = wmi.WMI(namespace="root/SecurityCenter2")
antivirus_products = wmi_obj.query("SELECT * FROM AntivirusProduct")
for product in antivirus_products:
display_name = product.displayName
product_state = product.productState
product_state_hex = hex(product_state)
last_update = product.timestamp
atv_status = int(product_state_hex[3:5])
atv_uptodate = int(product_state_hex[5:7])
atv_status = 1 if atv_status in [10, 11] else 0
atv_uptodate = 1 if atv_uptodate in [00,] else 0
#print(f"{display_name}, product_state: {product_state}, product_state_hex: {product_state_hex}, last_update: {last_update}, status: {atv_status}, uptodate: {atv_uptodate}")
modules.append({
"name" : f"{display_name} Antivirus status",
"type" : "generic_proc",
"value": atv_status,
"module_group": "security",
"desc" : f"{display_name} state: {product_state}, last update: {last_update}",
})
modules.append({
"name" : f"{display_name} Antivirus up to date",
"type" : "generic_proc",
"value": atv_uptodate,
"module_group": "security",
"desc" : f"{display_name} state: {product_state}, last update: {last_update}",
})
except Exception as e:
print(f"Error check antivirus: {e}", file=sys.stderr)
def is_lock_screen_enabled():
try:
# Open the registry key
key_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path) as key:
# Query the value of the DisableLockScreen key
value_name = "DisableLockScreen"
value, _ = winreg.QueryValueEx(key, value_name)
# Check if the lock screen is enabled (0 means enabled)
status = value == 0
if status == False: return status
except FileNotFoundError:
# If the registry key or value is not found, consider it as enabled
status = True
except Exception as e:
print(f"Error check lockscreen: {e}", file=sys.stderr)
status = False
try:
# Define the registry key for the lock screen settings
reg_key_path = r"SOFTWARE\Policies\Microsoft\Windows\Personalization"
reg_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_key_path)
# Query the "NoLockScreen" DWORD value
value_name = "NoLockScreen"
value, _ = winreg.QueryValueEx(reg_key, value_name)
# Check if the "NoLockScreen" value is 0 (enabled)
status = value == 0
if status == False: return status
except FileNotFoundError:
# If the registry key or value is not found, consider it as enabled
status = True
except Exception as e:
print(f"Error check lockscreen: {e}", file=sys.stderr)
status = False
return status
def check_locksreen_enables():
status = is_lock_screen_enabled()
value = 1 if status == True else 0
modules.append({
"name" : "Lockscreen status",
"type" : "generic_proc",
"value": value,
"module_group": "security",
"desc" : f"Check lockscreen enable",
})
def convert_to_human_readable_date(timestamp_str):
try:
# Parse the timestamp string without the time zone
timestamp = datetime.strptime(timestamp_str, '%Y%m%d%H%M%S')
# Convert to a human-readable format
human_readable_date = timestamp.strftime('%Y-%m-%d %H:%M:%S %z')
return human_readable_date.strip()
except Exception as e:
print(f"Error converting date: {e}", file=sys.stderr)
return None
def check_time_difference(timestamp, timedays=10):
try:
# Convert the timestamp string to a datetime object
given_timestamp = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S')
# Get the current time
current_time = datetime.now()
#Calculate the time difference
time_difference = current_time - given_timestamp
# Check if the time difference is greater than one hour
if time_difference < timedelta(days=timedays):
return "1"
else:
return "0"
except Exception as e:
print(f"Error check time difference: {e}", file=sys.stderr)
return 0
def get_windows_update_info(limit=5):
try:
# Connect to the Win32_ReliabilityRecords class in the root/cimv2 namespace
wmi_conn = wmi.WMI()
# Query the Win32_ReliabilityRecords class for Windows Update information
query = "SELECT * FROM Win32_ReliabilityRecords WHERE sourcename = 'Microsoft-Windows-WindowsUpdateClient'"
result = wmi_conn.query(query)
# Extract relevant information and format output
update_info = [
{
"date": convert_to_human_readable_date(record.timegenerated.split('.')[0]),
"update": record.message
}
for record in result[:limit]
]
last_update_date=update_info[0]['date']
value=check_time_difference(last_update_date)
modules.append({
"name" : "Microsoft Update system status",
"type" : "generic_proc",
"value": value,
"module_group": "security",
"desc" : f"Check if system was updated in the last 10 days. last update: {last_update_date}",
})
return True
except Exception as e:
print(f"Error windows update check: {e}", file=sys.stderr)
return False
def is_firewall_enabled():
try:
# Run PowerShell command to check if the Windows Firewall is enabled
result = subprocess.run(
['powershell', 'Get-NetFirewallProfile |Select-Object profile, enabled | ConvertTo-Json'],
capture_output=True,
text=True
)
result_json= json.loads(result.stdout)
for profile in result_json:
modules.append({
"name" : f"Firewall profile: {profile['Profile']} status",
"type" : "generic_proc",
"value": profile["Enabled"],
"module_group": "security",
"desc" : f"Check if firewall profile {profile['Profile']} is enabled",
})
return True
except Exception as e:
print(f"Error firewall check: {e}", file=sys.stderr)
return False
def check_password_enforcement():
enforce_pass = 1
counter = 0
try:
# Connect to the WMI service
wmi_service = wmi.WMI()
# Query for user accounts
users = wmi_service.Win32_UserAccount()
# Check if each user enforces password
for user in users:
# username = user.Name
# password_required = user.PasswordRequired
if user.PasswordRequired == False :
enforce_pass = 0
counter += 1
#print(f"User: {username}, Password Required: {password_required}")
modules.append({
"name" : "All users enforced password",
"type" : "generic_proc",
"value": enforce_pass,
"module_group": "security",
"desc" : f"Check if all users has enforced password, not secure users = {counter}",
})
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
print("Failed to check password enforcement for users.", file=sys.stderr)
def check_login_audit_policy():
try:
# Run the auditpol command to check the audit policy for Logon/Logoff
cmd_command = "auditpol /get /subcategory:Logon"
result = subprocess.run(cmd_command, shell=True, capture_output=True, text=True, check=True)
last_line = result.stdout.strip().split('\n')[-1]
cleaned_line = re.sub(' +', ' ', last_line)
# Interpret the result
if "Success and Failure" in result.stdout:
result = 1
elif "Aciertos y errores" in result.stdout:
result = 1
elif "No Auditing" in result.stdout:
result = 0
elif "Sin auditoría" in result.stdout:
result = 0
else:
print("Unable to determine audit policy for Logon/Logoff events.", file=sys.stderr)
result = 0
modules.append({
"name" : "Check logon event audited",
"type" : "generic_proc",
"value": result,
"module_group": "security",
"desc" : f"Check if the logon events audit log is enables, status:{cleaned_line}",
})
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
print("Failed to check audit policy using auditpol command.", file=sys.stderr)
return
if __name__ == "__main__":
check_antivirus_status()
check_locksreen_enables()
get_windows_update_info()
is_firewall_enabled()
check_password_enforcement()
check_login_audit_policy()
for module in modules:
print_module(module, True)
# Windows Defender status values:
# 0: No action needed
# 266240: Antivirus is up to date
# 266256: Antivirus is out of date
# 266304: Antivirus is not monitoring
# 393216 (0x60000): No action needed.
# 393232 (0x60010): Antivirus is up to date.
# 393240 (0x60018): Antivirus is out of date.
# 393216 (0x60030): Antivirus is not monitoring.
# 397312 (0x61000): Antivirus is disabled.
# AVG Internet Security 2012 (from antivirusproduct WMI)
# 262144 (040000) = disabled and up to date
# 266240 (041000) = enabled and up to date
# AVG Internet Security 2012 (from firewallproduct WMI)
# 266256 (041010) = firewall enabled - (last two blocks not relevant it seems for firewall)
# 262160 (040010) = firewall disabled - (last two blocks not relevant it seems for firewall)
# Windows Defender
# 393472 (060100) = disabled and up to date
# 397584 (061110) = enabled and out of date
# 397568 (061100) = enabled and up to date
# Microsoft Security Essentials
# 397312 (061000) = enabled and up to date
# 393216 (060000) = disabled and up to date

View File

@ -0,0 +1 @@
WMI==1.5.1

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.774-231215
Version: 7.0NG.774-231219
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.774-231215"
pandora_version="7.0NG.774-231219"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1039,7 +1039,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.774';
use constant AGENT_BUILD => '231215';
use constant AGENT_BUILD => '231219';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231215
%define release 231219
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231215
%define release 231219
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231215
%define release 231219
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231215
%define release 231219
Summary: Pandora FMS Linux agent, binary version
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231215
%define release 231219
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.774"
PI_BUILD="231215"
PI_BUILD="231219"
OS_NAME=`uname -s`
FORCE=0

View File

@ -538,3 +538,8 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default
#module_regexp C:\server\logs\xserver.log
#module_pattern .*
#module_end
# Pandora basic security check plugin for windows.
#module_begin
#module_plugin "%PROGRAMFILES%\Pandora_Agent\util\pandora_security_win.exe"
#module_end

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c58891fbd16bf80f288e0ff4751801aa02dbf4e6c914625b4d49a364c7e0b511
size 7829249

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{231215}
{231219}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.774 Build 231215")
#define PANDORA_VERSION ("7.0NG.774 Build 231219")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.774(Build 231215))"
VALUE "ProductVersion", "(7.0NG.774(Build 231219))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.774-231215
Version: 7.0NG.774-231219
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.774-231215"
pandora_version="7.0NG.774-231219"
package_pear=0
package_pandora=1

View File

@ -1007,7 +1007,7 @@ function mainAgentsModules()
echo "<td class='center' style='text-align:left;'>";
$win_handle = dechex(crc32($module_id.$module['name']));
$graph_type = return_graphtype(modules_get_agentmodule_type($module_id));
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)";
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&id='.$module_id.'&period_graph=0&refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)";
echo '<a href="javascript:'.$link.'">';

View File

@ -1,286 +0,0 @@
<?php
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
function pandora_files_repo_install()
{
global $config;
if (isset($config['files_repo_installed']) && $config['files_repo_installed'] == 1) {
return;
}
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
$full_sql_dir = $full_extensions_dir.'files_repo/sql/';
$file_path = '';
switch ($config['dbtype']) {
case 'mysql':
$file_path = $full_sql_dir.'files_repo.sql';
break;
case 'postgresql':
$file_path = $full_sql_dir.'files_repo.postgreSQL.sql';
break;
case 'oracle':
$file_path = $full_sql_dir.'files_repo.oracle.sql';
break;
}
if (!empty($file_path)) {
$result = db_process_file($file_path);
if ($result) {
// Configuration values
$values = [
'token' => 'files_repo_installed',
'value' => 1,
];
db_process_sql_insert('tconfig', $values);
}
}
}
function pandora_files_repo_uninstall()
{
global $config;
switch ($config['dbtype']) {
case 'mysql':
db_process_sql('DROP TABLE `tfiles_repo_group`');
db_process_sql('DROP TABLE `tfiles_repo`');
db_process_sql(
'DELETE FROM `tconfig`
WHERE `token` LIKE "files_repo_%"'
);
break;
case 'postgresql':
db_process_sql('DROP TABLE "tfiles_repo_group"');
db_process_sql('DROP TABLE "tfiles_repo"');
db_process_sql(
'DELETE FROM "tconfig"
WHERE "token" LIKE \'files_repo_%\''
);
break;
case 'oracle':
db_process_sql('DROP TRIGGER "tfiles_repo_group_inc"');
db_process_sql('DROP SEQUENCE "tfiles_repo_group_s"');
db_process_sql('DROP TABLE "tfiles_repo_group"');
db_process_sql('DROP TRIGGER "tfiles_repo_inc"');
db_process_sql('DROP SEQUENCE "tfiles_repo_s"');
db_process_sql('DROP TABLE "tfiles_repo"');
db_process_sql(
'DELETE FROM tconfig
WHERE token LIKE \'files_repo_%\''
);
break;
}
if (!empty($config['attachment_store'])) {
delete_dir($config['attachment_store'].'/files_repo');
}
}
function pandora_files_repo_godmode()
{
global $config;
if (!isset($config['files_repo_installed']) || !$config['files_repo_installed']) {
ui_print_error_message(__('Extension not installed'));
}
// ACL Check
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access to Files repository'
);
include 'general/noaccess.php';
return;
}
// Header tabs.
$godmode['text'] = '<a href="index.php?sec=godmode/extensions&sec2=extensions/files_repo">'.html_print_image('images/configuration@svg.svg', true, ['title' => __('Administration view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
$godmode['godmode'] = 1;
$godmode['active'] = 1;
$operation['text'] = '<a href="index.php?sec=extensions&sec2=extensions/files_repo">'.html_print_image('images/see-details@svg.svg', true, ['title' => __('Operation view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
$operation['operation'] = 1;
$onheader = [
'godmode' => $godmode,
'operation' => $operation,
];
// Header.
ui_print_standard_header(
__('Extensions'),
'images/extensions.png',
false,
'',
true,
$onheader,
[
[
'link' => '',
'label' => __('Admin tools'),
],
[
'link' => '',
'label' => __('Extension manager'),
],
[
'link' => '',
'label' => __('Files repository manager'),
],
]
);
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
include_once $full_extensions_dir.'files_repo/functions_files_repo.php';
// Directory files_repo check.
if (!files_repo_check_directory(true)) {
return;
}
$server_content_length = 0;
if (isset($_SERVER['CONTENT_LENGTH'])) {
$server_content_length = $_SERVER['CONTENT_LENGTH'];
}
// Check for an anoying error that causes the $_POST and $_FILES arrays.
// were empty if the file is larger than the post_max_size.
if (intval($server_content_length) > 0 && empty($_POST)) {
ui_print_error_message(__('Problem uploading. Please check this PHP runtime variable values: <pre> post_max_size (currently '.ini_get('post_max_size').')</pre>'));
}
// GET and POST parameters.
$file_id = (int) get_parameter('file_id');
$add_file = (bool) get_parameter('add_file');
$update_file = (bool) get_parameter('update_file');
$delete_file = (bool) get_parameter('delete');
// File add or update.
if ($add_file || ($update_file && $file_id > 0)) {
$groups = get_parameter('groups', []);
$public = (bool) get_parameter('public');
$description = io_safe_output((string) get_parameter('description'));
if (mb_strlen($description, 'UTF-8') > 200) {
$description = mb_substr($description, 0, 200, 'UTF-8');
}
$description = io_safe_input($description);
if ($add_file) {
$result = files_repo_add_file('upfile', $description, $groups, $public);
} else if ($update_file) {
$result = files_repo_update_file($file_id, $description, $groups, $public);
$file_id = 0;
}
if ($result['status'] == false) {
ui_print_error_message($result['message']);
}
}
// File delete.
if ($delete_file && $file_id > 0) {
$result = files_repo_delete_file($file_id);
if ($result !== -1) {
ui_print_result_message($result, __('Successfully deleted'), __('Could not be deleted'));
}
$file_id = 0;
}
// FORM.
include $full_extensions_dir.'files_repo/files_repo_form.php';
if (!$file_id) {
// LIST.
$manage = true;
include $full_extensions_dir.'files_repo/files_repo_list.php';
}
}
function pandora_files_repo_operation()
{
global $config;
// Header tabs.
$onheader = [];
if (check_acl($config['id_user'], 0, 'PM')) {
$godmode['text'] = '<a href="index.php?sec=godmode/extensions&sec2=extensions/files_repo">'.html_print_image('images/configuration@svg.svg', true, ['title' => __('Administration view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
$godmode['godmode'] = 1;
$operation['text'] = '<a href="index.php?sec=extensions&sec2=extensions/files_repo">'.html_print_image('images/see-details@svg.svg', true, ['title' => __('Operation view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
$operation['operation'] = 1;
$operation['active'] = 1;
$onheader = [
'godmode' => $godmode,
'operation' => $operation,
];
}
// Header.
ui_print_standard_header(
__('Files repository'),
'images/extensions.png',
false,
'',
false,
$onheader,
[
[
'link' => '',
'label' => __('Admin tools'),
],
[
'link' => '',
'label' => __('Extension manager'),
],
[
'link' => '',
'label' => __('Files repository'),
],
]
);
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
include_once $full_extensions_dir.'files_repo/functions_files_repo.php';
// Directory files_repo check.
if (!files_repo_check_directory(true)) {
return;
}
// LIST.
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
include $full_extensions_dir.'files_repo/files_repo_list.php';
}
extensions_add_operation_menu_option(__('Files repository'), null, null, 'v1r1');
extensions_add_main_function('pandora_files_repo_operation');
extensions_add_godmode_menu_option(__('Files repository manager'), 'PM', null, null, 'v1r1');
extensions_add_godmode_function('pandora_files_repo_godmode');
pandora_files_repo_install();

View File

@ -1,168 +0,0 @@
<?php
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
require_once $full_extensions_dir.'files_repo/functions_files_repo.php';
$offset = (int) get_parameter('offset');
$filter = [];
$filter['limit'] = $config['block_size'];
$filter['offset'] = $offset;
$filter['order'] = [
'field' => 'id',
'order' => 'DESC',
];
$files = files_repo_get_files($filter);
if (!empty($files)) {
if (!isset($manage)) {
$manage = false;
}
// Pagination
if ($manage) {
$url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo');
} else {
$url = ui_get_full_url('index.php?sec=extensions&sec2=extensions/files_repo');
}
$total_files = files_repo_get_files(false, true);
ui_pagination($total_files, $url, $offset);
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
$table->style = [];
$table->style[1] = 'max-width: 200px;';
$table->style[4] = 'text-align: center;';
$table->head = [];
$table->head[0] = __('Name');
$table->head[1] = __('Description');
$table->head[2] = __('Size');
$table->head[3] = __('Last modification');
$table->head[4] = '';
$table->data = [];
foreach ($files as $file_id => $file) {
$data = [];
// Prepare the filename for the get_file.php script
$document_root = str_replace(
'\\',
'/',
io_safe_output($_SERVER['DOCUMENT_ROOT'])
);
$file['location'] = str_replace(
'\\',
'/',
io_safe_output($file['location'])
);
$relative_path = str_replace($document_root, '', $file['location']);
$file_name = explode('/', $file['location']);
$file_decoded = $file_name[(count($file_name) - 1)];
$file_path = base64_encode($file_decoded);
$hash = md5($file_path.$config['server_unique_identifier']);
$url = ui_get_full_url(
'include/get_file.php?file='.urlencode($file_path).'&hash='.$hash
);
$date_format = ($config['date_format']) ? io_safe_output($config['date_format']) : 'F j, Y - H:m';
$data[0] = "<a href=\"$url\" target=\"_blank\">".$file['name'].'</a>';
// Name
$data[1] = ui_print_truncate_text(
$file['description'],
'description',
true,
true
);
// Description
$data[2] = ui_format_filesize($file['size']);
// Size
$data[3] = date($date_format, $file['mtime']);
// Last modification
// Public URL
$data[4] = '';
$table->cellclass[][4] = 'table_action_buttons';
if (!empty($file['hash'])) {
$public_url = ui_get_full_url(
EXTENSIONS_DIR.'/files_repo/files_repo_get_file.php?file='.$file['hash']
);
$message = __('Copy to clipboard').': Ctrl+C -> Enter';
$action = "window.prompt('$message', '$public_url');";
$data[4] .= "<a href=\"javascript:;\" onclick=\"$action\">";
$data[4] .= html_print_image(
'images/world.png',
true,
['title' => __('Public link')]
);
// Public link image
$data[4] .= '</a> ';
}
$data[4] .= "<a href=\"$url\" target=\"_blank\">";
$data[4] .= html_print_image(
'images/download.png',
true,
[
'title' => __('Download'),
'style' => 'padding:3px',
]
);
// Download image
$data[4] .= '</a>';
if ($manage) {
$config_url = ui_get_full_url(
'index.php?sec=godmode/extensions&sec2=extensions/files_repo&file_id='.$file_id
);
$data[4] .= "<a href=\"$config_url\">";
$data[4] .= html_print_image(
'images/edit.svg',
true,
[
'title' => __('Edit'),
'class' => 'main_menu_icon invert_filter',
]
);
// Edit image
$data[4] .= '</a>';
$delete_url = ui_get_full_url(
'index.php?sec=godmode/extensions&sec2=extensions/files_repo&delete=1&file_id='.$file_id
);
$data[4] .= " <a href=\"$delete_url\" onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\">";
$data[4] .= html_print_image(
'images/delete.svg',
true,
[
'title' => __('Delete'),
'class' => 'main_menu_icon invert_filter',
]
);
// Delete image
$data[4] .= '</a>';
}
$table->data[] = $data;
}
html_print_table($table);
} else {
ui_print_info_message(__('No items'));
}

View File

@ -1,16 +0,0 @@
CREATE TABLE tfiles_repo (
id NUMBER(5, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(255) NOT NULL,
description VARCHAR2(500) NULL,
hash VARCHAR2(8) NULL
);
CREATE SEQUENCE tfiles_repo_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tfiles_repo_inc BEFORE INSERT ON tfiles_repo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_s.nextval INTO :NEW.ID FROM dual; END;;
CREATE TABLE tfiles_repo_group (
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_file NUMBER(5, 0) NOT NULL REFERENCES tfiles_repo(id) ON DELETE CASCADE,
id_group NUMBER(4, 0) NOT NULL
);
CREATE SEQUENCE tfiles_repo_group_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tfiles_repo_group_inc BEFORE INSERT ON tfiles_repo_group REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_group_s.nextval INTO :NEW.ID FROM dual; END;;

View File

@ -1,2 +0,0 @@
CREATE TABLE "tfiles_repo" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(500) NULL default '', "hash" VARCHAR(8) NULL default '');
CREATE TABLE "tfiles_repo_group" ("id" SERIAL NOT NULL PRIMARY KEY, "id_file" INTEGER NOT NULL REFERENCES tfiles_repo("id") ON DELETE CASCADE, "id_group" INTEGER NOT NULL);

View File

@ -1,15 +0,0 @@
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
`id` int(5) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`description` varchar(500) NULL default '',
`hash` varchar(8) NULL default '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_file` int(5) unsigned NOT NULL,
`id_group` int(4) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1720,4 +1720,19 @@ include/functions_integriaims.php
include/ajax/integria_incidents.ajax.php
enterprise/operation/log/log_source.php
enterprise/include/class/LogSource.class.php
include/chart_generator.php
include/chart_generator.php
enterprise/extensions/translate_string.php
enterprise/extensions/translate_string/functions.php
enterprise/extensions/translate_string/translate_string.oracle.sql
enterprise/extensions/translate_string/translate_string.postgresql.sql
enterprise/extensions/translate_string/translate_string.sql
enterprise/extensions/translate_string
extensions/files_repo.php
extensions/files_repo/files_repo_form.php
extensions/files_repo/files_repo_get_file.php
extensions/files_repo/files_repo_list.php
extensions/files_repo/functions_files_repo.php
extensions/files_repo/sql/files_repo.oracle.sql
extensions/files_repo/sql/files_repo.postgreSQL.sql
extensions/files_repo/sql/files_repo.sql
extensions/files_repo

View File

@ -0,0 +1,18 @@
pandorafms.aws.ec2;Amazon EC2;cloud;1;pandorafms.aws.ec2.png;https://pandorafms.com/library/aws-ec2-discovery/
pandorafms.aws.rds;Amazon RDS;cloud;1;pandorafms.aws.rds.png;https://pandorafms.com/library/aws-rds-discovery/
pandorafms.aws.s3;Amazon S3;cloud;1;pandorafms.aws.s3.png;https://pandorafms.com/library/aws-s3-discovery/
pandorafms.azure.mc;Azure Microsoft Compute;cloud;1;pandorafms.azure.mc.png;https://pandorafms.com/library/aws-azure-discovery/
pandorafms.db2;DB2;app;1;pandorafms.db2.png;https://pandorafms.com/library/db2-discovery/
pandorafms.gcp.ce;Google Cloud Compute Engine;cloud;1;pandorafms.gcp.ce.png;https://pandorafms.com/library/google-cloud-discovery/
pandorafms.mssql;Microsoft SQL Server;app;1;pandorafms.mssql.png;https://pandorafms.com/library/mssql-discovery/
pandorafms.mysql;MySQL;app;1;pandorafms.mysql.png;https://pandorafms.com/library/mysql-discovery/
pandorafms.oracle;Oracle;app;1;pandorafms.oracle.png;https://pandorafms.com/library/oracle-discovery/
pandorafms.proxmox;Proxmox;app;0;pandorafms.proxmox.png;https://pandorafms.com/library/proxmox-discovery/
pandorafms.sap.deset;SAP R3 - Deset;app;1;pandorafms.sap.deset.png;https://pandorafms.com/library/sap-discovery/
pandorafms.vmware;VMware;app;1;pandorafms.vmware.png;https://pandorafms.com/library/vmware-discovery/
pandorafms.kubernetes;Kubernetes;app;1;pandorafms.kubernetes.png;https://pandorafms.com/library/kubernetes-discovery/
pandorafms.mongodb;MongoDB;app;1;pandorafms.mongodb.png;https://pandorafms.com/library/mongodb-discovery/
pandorafms.ovh;OVH;cloud;1;pandorafms.ovh.png;https://pandorafms.com/library/ovh-discovery/
pandorafms.vulnscan;Vulnerability Scanner;app;1;pandorafms.vulnscan.png;https://pandorafms.com/library/pandora-vulnerability-discovery/
pandorafms.postgresql;PostgreSQL;app;1;pandorafms.postgresql.png;https://pandorafms.com/library/postgresql-discovery/
pandorafms.xenserver;Xenserver;app;1;pandorafms.xenserver.png;https://pandorafms.com/library/xenserver-discovery/
1 pandorafms.aws.ec2 Amazon EC2 cloud 1 pandorafms.aws.ec2.png https://pandorafms.com/library/aws-ec2-discovery/
2 pandorafms.aws.rds Amazon RDS cloud 1 pandorafms.aws.rds.png https://pandorafms.com/library/aws-rds-discovery/
3 pandorafms.aws.s3 Amazon S3 cloud 1 pandorafms.aws.s3.png https://pandorafms.com/library/aws-s3-discovery/
4 pandorafms.azure.mc Azure Microsoft Compute cloud 1 pandorafms.azure.mc.png https://pandorafms.com/library/aws-azure-discovery/
5 pandorafms.db2 DB2 app 1 pandorafms.db2.png https://pandorafms.com/library/db2-discovery/
6 pandorafms.gcp.ce Google Cloud Compute Engine cloud 1 pandorafms.gcp.ce.png https://pandorafms.com/library/google-cloud-discovery/
7 pandorafms.mssql Microsoft SQL Server app 1 pandorafms.mssql.png https://pandorafms.com/library/mssql-discovery/
8 pandorafms.mysql MySQL app 1 pandorafms.mysql.png https://pandorafms.com/library/mysql-discovery/
9 pandorafms.oracle Oracle app 1 pandorafms.oracle.png https://pandorafms.com/library/oracle-discovery/
10 pandorafms.proxmox Proxmox app 0 pandorafms.proxmox.png https://pandorafms.com/library/proxmox-discovery/
11 pandorafms.sap.deset SAP R3 - Deset app 1 pandorafms.sap.deset.png https://pandorafms.com/library/sap-discovery/
12 pandorafms.vmware VMware app 1 pandorafms.vmware.png https://pandorafms.com/library/vmware-discovery/
13 pandorafms.kubernetes Kubernetes app 1 pandorafms.kubernetes.png https://pandorafms.com/library/kubernetes-discovery/
14 pandorafms.mongodb MongoDB app 1 pandorafms.mongodb.png https://pandorafms.com/library/mongodb-discovery/
15 pandorafms.ovh OVH cloud 1 pandorafms.ovh.png https://pandorafms.com/library/ovh-discovery/
16 pandorafms.vulnscan Vulnerability Scanner app 1 pandorafms.vulnscan.png https://pandorafms.com/library/pandora-vulnerability-discovery/
17 pandorafms.postgresql PostgreSQL app 1 pandorafms.postgresql.png https://pandorafms.com/library/postgresql-discovery/
18 pandorafms.xenserver Xenserver app 1 pandorafms.xenserver.png https://pandorafms.com/library/xenserver-discovery/

View File

@ -1,5 +1,34 @@
START TRANSACTION;
DELETE FROM `tconfig` WHERE `token` LIKE 'translate_string_extension_installed';
CREATE TABLE IF NOT EXISTS `textension_translate_string` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`lang` VARCHAR(10) NOT NULL ,
`string` TEXT ,
`translation` TEXT ,
PRIMARY KEY (`id`),
KEY `lang_index` (`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
DELETE FROM `tconfig` WHERE `token` LIKE 'files_repo_installed';
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
`id` int(5) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`description` varchar(500) NULL default '',
`hash` varchar(8) NULL default '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_file` int(5) unsigned NOT NULL,
`id_group` int(4) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tncm_queue`
ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`;
@ -1068,6 +1097,10 @@ SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_a
prepare stmt from @sqlstmt;
execute stmt;
ALTER TABLE `tlayout_template_data` ADD COLUMN `title` TEXT default '';
ALTER TABLE `tlayout_data` ADD COLUMN `period_chart_options` TEXT default '';
ALTER TABLE `tlayout_template_data` ADD COLUMN `period_chart_options` TEXT default '';
ALTER TABLE `tdashboard`
ADD COLUMN `date_range` TINYINT NOT NULL DEFAULT 0 AFTER `cells_slideshow`,
ADD COLUMN `date_from` INT NOT NULL DEFAULT 0 AFTER `date_range`,
@ -1109,4 +1142,10 @@ UPDATE talert_actions SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ /
UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.vmware';
ALTER TABLE `tagente_modulo` ADD COLUMN `ignore_unknown` TINYINT NOT NULL DEFAULT 0;
ALTER TABLE `tpolicy_modules` ADD COLUMN `ignore_unknown` TINYINT NOT NULL DEFAULT 0;
ALTER TABLE `tagente` ADD COLUMN `ignore_unknown` TINYINT NOT NULL DEFAULT 0;
ALTER TABLE `tmetaconsole_agent` ADD COLUMN `ignore_unknown` TINYINT NOT NULL DEFAULT 0;
COMMIT;

View File

@ -235,6 +235,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$header_autorefresh = '';
$header_autorefresh_counter = '';
$header_setup = '';
if (($_GET['sec2'] !== 'operation/visual_console/render_view')) {
if ($autorefresh_list !== null
@ -352,7 +353,6 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$display_counter = 'display:none';
}
$header_setup = '';
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$header_setup .= '<div id="header_logout"><a class="white" href="'.ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup&section=general').'">';
$header_setup .= html_print_image(
@ -927,8 +927,6 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
<?php if (enterprise_installed() === false) { ?>
$('.header_left').on('click', function(){
// Hidden tips modal.
$(".window").css("display", "none");
jQuery.post(
"ajax.php",
{

View File

@ -1074,6 +1074,17 @@ if (enterprise_installed() === true) {
);
}
$tableAdvancedAgent->data['ignore_unknown'][] = html_print_label_input_block(
__('Ignore unknown').ui_print_help_tip(__('This disables the calculation of the unknown state in the agent and any of its modules, so it will never transition to unknown. The state it reflects is the last known status.'), true),
html_print_checkbox_switch(
'ignore_unknown',
1,
$ignore_unknown,
true,
false
)
);
ui_toggle(
html_print_table($tableAdvancedAgent, true),

View File

@ -232,6 +232,7 @@ if ($create_agent) {
$cps = (int) get_parameter_switch('cps', -1);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
$ignore_unknown = (int) get_parameter_switch('ignore_unknown', 0);
$agent_version = $config['current_package'];
$secondary_groups = (array) get_parameter('secondary_groups_selected', '');
$fields = db_get_all_fields_in_table('tagent_custom_fields');
@ -300,6 +301,7 @@ if ($create_agent) {
'cps' => $cps,
'fixed_ip' => $fixed_ip,
'vul_scan_enabled' => $vul_scan_enabled,
'ignore_unknown' => $ignore_unknown,
'agent_version' => $agent_version,
]
);
@ -1016,6 +1018,7 @@ if ($update_agent) {
$satellite_server = (int) get_parameter('satellite_server', 0);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
$ignore_unknown = (int) get_parameter_switch('ignore_unknown', 0);
$security_vunerability = (int) get_parameter_switch('security_vunerability', 0);
$security_hardening = (int) get_parameter_switch('security_hardening', 0);
$security_monitoring = (int) get_parameter_switch('security_monitoring', 0);
@ -1150,6 +1153,7 @@ if ($update_agent) {
'satellite_server' => $satellite_server,
'fixed_ip' => $fixed_ip,
'vul_scan_enabled' => $vul_scan_enabled,
'ignore_unknown' => $ignore_unknown,
];
if ($config['metaconsole_agent_cache'] == 1) {
@ -1383,6 +1387,7 @@ if ($id_agente) {
$satellite_server = (int) $agent['satellite_server'];
$fixed_ip = (int) $agent['fixed_ip'];
$vul_scan_enabled = (int) $agent['vul_scan_enabled'];
$ignore_unknown = (int) $agent['ignore_unknown'];
if (strpos($agent['agent_version'], '(')) {
$agent_version = (int) explode('.', explode('(', $agent['agent_version'])[0])[2];
} else {
@ -1633,6 +1638,7 @@ if ($update_module === true || $create_module === true) {
$custom_id = (string) get_parameter('custom_id');
$history_data = (int) get_parameter('history_data');
$ignore_unknown = (int) get_parameter('ignore_unknown');
$dynamic_interval = (int) get_parameter('dynamic_interval');
$dynamic_max = (int) get_parameter('dynamic_max');
$dynamic_min = (int) get_parameter('dynamic_min');
@ -1841,6 +1847,7 @@ if ($update_module) {
'max_retries' => $max_retries,
'custom_id' => $custom_id,
'history_data' => $history_data,
'ignore_unknown' => $ignore_unknown,
'dynamic_interval' => $dynamic_interval,
'dynamic_max' => $dynamic_max,
'dynamic_min' => $dynamic_min,
@ -2042,6 +2049,7 @@ if ($create_module) {
'id_modulo' => $id_module,
'custom_id' => $custom_id,
'history_data' => $history_data,
'ignore_unknown' => $ignore_unknown,
'dynamic_interval' => $dynamic_interval,
'dynamic_max' => $dynamic_max,
'dynamic_min' => $dynamic_min,

View File

@ -305,6 +305,7 @@ if ($id_agent_module) {
$max_retries = $module['max_retries'];
$custom_id = $module['custom_id'];
$history_data = $module['history_data'];
$ignore_unknown = $module['ignore_unknown'];
$dynamic_interval = $module['dynamic_interval'];
$dynamic_max = $module['dynamic_max'];
$dynamic_min = $module['dynamic_min'];
@ -443,6 +444,7 @@ if ($id_agent_module) {
$plugin_parameter = '';
$custom_id = '';
$history_data = 1;
$ignore_unknown = 0;
$dynamic_interval = 0;
$dynamic_min = 0;
$dynamic_max = 0;

View File

@ -645,6 +645,15 @@ if ($disabledBecauseInPolicy) {
);
}
$table_simple->data['caption_ignore_unknown'][0] = __('Ignore unknown').ui_print_help_tip(_('This disables the module\'s state calculation to unknown, so it will never transition to unknown. The state it reflects is the last known status.'), true);
$table_simple->data['ignore_unknown'][0] = html_print_checkbox_switch(
'ignore_unknown',
1,
$ignore_unknown,
true,
false
);
// Business Logic for Advanced Part.
global $__code_from;
// Code comes from module_editor.
@ -1426,7 +1435,7 @@ if ($__code_from === 'modules') {
$throw_unknown_events_check = policy_module_is_disable_type_event($__id_pol_mod, EVENTS_GOING_UNKNOWN);
}
$table_advanced->data['caption_discard_unknown'][0] = __('Discard unknown events');
$table_advanced->data['caption_discard_unknown'][0] = __('Discard unknown events').ui_print_help_tip(__('With this mode, the unknown state will be detected, but it will not generate events.'), true);
$table_advanced->data['discard_unknown'][0] = html_print_checkbox_switch(
'throw_unknown_events',
1,

View File

@ -0,0 +1,167 @@
<?php
/**
* File repository
*
* @category Files repository
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
global $config;
// ACL Check.
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access to Files repository'
);
include 'general/noaccess.php';
return;
}
$tab = get_parameter('tab', '');
$url = 'index.php?sec=extensions&sec2=godmode/files_repo/files_repo';
// Header tabs.
$godmode['text'] = '<a href="'.$url.'&tab=configuration">';
$godmode['text'] .= html_print_image(
'images/configuration@svg.svg',
true,
[
'title' => __('Administration view'),
'class' => 'main_menu_icon invert_filter',
]
);
$godmode['text'] .= '</a>';
$godmode['godmode'] = 1;
$operation['text'] = '<a href="'.$url.'">';
$operation['text'] .= html_print_image(
'images/see-details@svg.svg',
true,
[
'title' => __('Operation view'),
'class' => 'main_menu_icon invert_filter',
]
);
$operation['text'] .= '</a>';
$operation['operation'] = 1;
$operation['active'] = 1;
$godmode['active'] = 0;
if ($tab === 'configuration') {
$godmode['active'] = 1;
$operation['active'] = 0;
}
$onheader = [
'godmode' => $godmode,
'operation' => $operation,
];
// Header.
ui_print_standard_header(
__('Extensions'),
'images/extensions.png',
false,
'',
true,
$onheader,
[
[
'link' => '',
'label' => __('Tools'),
],
[
'link' => '',
'label' => __('Files repository'),
],
]
);
require_once __DIR__.'/../../include/functions_files_repository.php';
// Directory files_repo check.
if (files_repo_check_directory() === false) {
return;
}
$server_content_length = 0;
if (isset($_SERVER['CONTENT_LENGTH'])) {
$server_content_length = $_SERVER['CONTENT_LENGTH'];
}
// Check for an anoying error that causes the $_POST and $_FILES arrays.
// were empty if the file is larger than the post_max_size.
if (intval($server_content_length) > 0 && empty($_POST)) {
ui_print_error_message(
__('Problem uploading. Please check this PHP runtime variable values: <pre> post_max_size (currently '.ini_get('post_max_size').')</pre>')
);
}
// GET and POST parameters.
$file_id = (int) get_parameter('file_id');
$add_file = (bool) get_parameter('add_file');
$update_file = (bool) get_parameter('update_file');
$delete_file = (bool) get_parameter('delete');
// File add or update.
if ($add_file === true || ($update_file === true && $file_id > 0)) {
$groups = get_parameter('groups', []);
$public = (bool) get_parameter('public');
$description = io_safe_output((string) get_parameter('description'));
if (mb_strlen($description, 'UTF-8') > 200) {
$description = mb_substr($description, 0, 200, 'UTF-8');
}
$description = io_safe_input($description);
if ($add_file === true) {
$result = files_repo_add_file('upfile', $description, $groups, $public);
} else if ($update_file === true) {
$result = files_repo_update_file($file_id, $description, $groups, $public);
$file_id = 0;
}
if ($result['status'] == false) {
ui_print_error_message($result['message']);
} else {
if ($add_file === true) {
ui_print_success_message(__('Successfully created'));
} else if ($update_file === true) {
ui_print_success_message(__('Successfully updated'));
}
}
}
// File delete.
if ($delete_file === true && $file_id > 0) {
$result = files_repo_delete_file($file_id);
if ($result !== -1) {
ui_print_result_message($result, __('Successfully deleted'), __('Could not be deleted'));
}
$file_id = 0;
}
$operation['active'] = 1;
if ($tab === 'configuration') {
include_once __DIR__.'/files_repo_form.php';
} else {
include_once __DIR__.'/files_repo_list.php';
}

View File

@ -1,20 +1,27 @@
<?php
/**
* File repository Form
*
* @category Files repository
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
require_once $full_extensions_dir.'files_repo/functions_files_repo.php';
$file = [];
$file['name'] = '';
@ -117,6 +124,10 @@ if ($file_id > 0) {
'file_id',
$file_id,
true
).html_print_input_hidden(
'update_file',
1,
true
)
);
} else {
@ -150,8 +161,8 @@ if ($file_id > 0) {
$table->data[] = $row;
$url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo');
echo "<form method='post' action='$url' enctype='multipart/form-data'>";
$url = ui_get_full_url('index.php?sec=extensions&sec2=godmode/files_repo/files_repo');
echo '<form method="post" action="'.$url.'" enctype="multipart/form-data">';
html_print_table($table);
html_print_action_buttons($submit_button);
echo '</form>';

View File

@ -1,54 +1,60 @@
<?php
/**
* Get public file repository.
*
* @category Files repository
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once '../../include/config.php';
$file_hash = (string) get_parameter('file');
// Only allow 1 parameter in the request
// Only allow 1 parameter in the request.
$check_request = (count($_REQUEST) === 1) ? true : false;
$check_get = (count($_GET) === 1) ? true : false;
$check_post = (count($_POST) === 0) ? true : false;
// Only allow the parameter 'file'
$check_parameter = (!empty($file_hash)) ? true : false;
// Only allow the parameter 'file'.
$check_parameter = (empty($file_hash) === false) ? true : false;
$check_string = (preg_match('/^[0-9a-zA-Z]{8}$/', $file_hash) === 1) ? true : false;
$checks = ($check_request && $check_get && $check_post && $check_parameter && $check_string);
if (!$checks) {
throw_error(15);
// ERROR
}
// Get the db file row
// Get the db file row.
$file = db_get_row_filter('tfiles_repo', ['hash' => $file_hash]);
if (!$file) {
throw_error(10);
// ERROR
}
// Case sensitive check
// Case sensitive check.
$check_hash = ($file['hash'] == $file_hash) ? true : false;
if (!$check_hash) {
throw_error(10);
// ERROR
}
// Get the location
// Get the location.
$files_repo_path = io_safe_output($config['attachment_store']).'/files_repo';
$location = $files_repo_path.'/'.$file['id'].'_'.$file['name'];
if (!file_exists($location) || !is_readable($location) || !is_file($location)) {
throw_error(5);
// ERROR
}
// All checks are fine. Download the file!
@ -58,6 +64,13 @@ header('Content-Disposition: attachment; filename="'.$file['name'].'"');
readfile($location);
/**
* Show errors
*
* @param integer $time Sleep.
*
* @return void
*/
function throw_error($time=15)
{
sleep($time);

View File

@ -0,0 +1,157 @@
<?php
/**
* File repository List
*
* @category Files repository
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
global $config;
$offset = (int) get_parameter('offset');
$filter = [];
$filter['limit'] = $config['block_size'];
$filter['offset'] = $offset;
$filter['order'] = [
'field' => 'id',
'order' => 'DESC',
];
$files = files_repo_get_files($filter);
if (empty($files) === false) {
$url = ui_get_full_url('index.php?sec=extensions&sec2=godmode/files_repo/files_repo');
$total_files = files_repo_get_files(false, true);
ui_pagination($total_files, $url, $offset);
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
$table->style = [];
$table->style[1] = 'max-width: 200px;';
$table->style[4] = 'text-align: center;';
$table->head = [];
$table->head[0] = __('Name');
$table->head[1] = __('Description');
$table->head[2] = __('Size');
$table->head[3] = __('Last modification');
$table->head[4] = '';
$table->data = [];
foreach ($files as $file_id => $file) {
$data = [];
// Prepare the filename for the get_file.php script.
$document_root = str_replace(
'\\',
'/',
io_safe_output($_SERVER['DOCUMENT_ROOT'])
);
$file['location'] = str_replace(
'\\',
'/',
io_safe_output($file['location'])
);
$relative_path = str_replace($document_root, '', $file['location']);
$file_name = explode('/', $file['location']);
$file_decoded = $file_name[(count($file_name) - 1)];
$file_path = base64_encode($file_decoded);
$hash = md5($file_path.$config['server_unique_identifier']);
$url_get_file = ui_get_full_url(
'include/get_file.php?file='.urlencode($file_path).'&hash='.$hash
);
$date_format = (isset($config['date_format']) === true) ? io_safe_output($config['date_format']) : 'F j, Y - H:m';
$data[0] = '<a href="'.$url_get_file.'" target="_blank">'.$file['name'].'</a>';
// Name.
$data[1] = ui_print_truncate_text(
$file['description'],
'description',
true,
true
);
// Description.
$data[2] = ui_format_filesize($file['size']);
// Size.
$data[3] = date($date_format, $file['mtime']);
// Last modification.
// Public URL.
$data[4] = '';
$table->cellclass[][4] = 'table_action_buttons';
if (empty($file['hash']) === false) {
$url_get_public_file = ui_get_full_url(
'godmode/files_repo/files_repo_get_file.php?file='.$file['hash']
);
$message = __('Copy to clipboard').': Ctrl+C -> Enter';
$action = 'window.prompt(\''.$message.'\', \''.$url_get_public_file.'\');';
$data[4] .= '<a href="javascript:;" onclick="'.$action.'">';
$data[4] .= html_print_image(
'images/world.png',
true,
['title' => __('Public link')]
);
// Public link image.
$data[4] .= '</a> ';
}
$data[4] .= '<a href="'.$url_get_file.'" target="_blank">';
$data[4] .= html_print_image(
'images/download.png',
true,
[
'title' => __('Download'),
'style' => 'padding:3px',
]
);
// Download image.
$data[4] .= '</a>';
$config_url = $url.'&tab=configuration&file_id='.$file_id;
$data[4] .= '<a href="'.$config_url.'">';
$data[4] .= html_print_image(
'images/edit.svg',
true,
[
'title' => __('Edit'),
'class' => 'main_menu_icon invert_filter',
]
);
// Edit image.
$data[4] .= '</a>';
$delete_url = $url.'&delete=1&file_id='.$file_id;
$data[4] .= '<a href="'.$delete_url.'" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_image(
'images/delete.svg',
true,
[
'title' => __('Delete'),
'class' => 'main_menu_icon invert_filter',
]
);
// Delete image.
$data[4] .= '</a>';
$table->data[] = $data;
}
html_print_table($table);
} else {
ui_print_info_message(__('No items'));
}

View File

@ -194,6 +194,10 @@ if ($update_agents) {
$values['safe_mode_module'] = '0';
}
if (get_parameter('ignore_unknown', '') != '') {
$values['ignore_unknown'] = get_parameter('ignore_unknown');
}
$secondary_groups_added = (array) get_parameter(
'secondary_groups_added',
[]
@ -1183,6 +1187,24 @@ $table->data[7][1] .= html_print_select(
true
);
$table->data[8][0] = __('Ignore unknown').ui_print_help_tip(_('This disables the calculation of the unknown state in the agent and any of its modules, so it will never transition to unknown. The state it reflects is the last known status.'), true);
$table->data[8][1] = html_print_select(
[
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No'),
],
'ignore_unknown',
'',
'',
'',
'',
true,
false,
false,
'w100p'
);
ui_toggle(html_print_table($table, true), __('Advanced options'));
unset($table);

View File

@ -1319,7 +1319,7 @@ $table->data[29][0] = html_print_label_input_block(
);
$table->data[29][1] = html_print_label_input_block(
__('Discard unknown events'),
__('Discard unknown events').ui_print_help_tip(__('With this mode, the unknown state will be detected, but it will not generate events.'), true),
html_print_select(
[
'' => __('No change'),
@ -1544,6 +1544,26 @@ $table->data[40][0] = html_print_label_input_block(
)
);
$table->data[40][1] = html_print_label_input_block(
__('Ignore unknown').ui_print_help_tip(_('This disables the module\'s state calculation to unknown, so it will never transition to unknown. The state it reflects is the last known status.'), true),
html_print_select(
[
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No'),
],
'ignore_unknown',
'',
'',
'',
'',
true,
false,
false,
'w100p'
)
);
echo '<form method="post" class="max_floating_element_size" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" id="form_edit">';
html_print_table($table);
@ -2358,6 +2378,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'plugin_pass',
'id_export',
'history_data',
'ignore_unknown',
'critical_inverse',
'warning_inverse',
'percentage_warning',

View File

@ -508,6 +508,8 @@ if ($access_console_node === true) {
enterprise_hook('skins_submenu');
enterprise_hook('translate_string_submenu');
$menu_godmode['gsetup']['sub'] = $sub;
}
}
@ -711,15 +713,25 @@ if ($access_console_node === true) {
}
if ($access_console_node === true) {
// Tools
// Tools.
$menu_godmode['tools']['text'] = __('Tools');
$menu_godmode['tools']['sec2'] = 'operation/extensions';
$menu_godmode['tools']['id'] = 'oper-extensions';
$sub = [];
$sub['operation/agentes/exportdata']['text'] = __('Export data');
$sub['operation/agentes/exportdata']['id'] = 'export_data';
$sub['extensions/files_repo']['text'] = __('File repository');
$sub['extensions/files_repo']['id'] = 'file_repository';
if (check_acl($config['id_user'], 0, 'RR')
|| check_acl($config['id_user'], 0, 'RW')
|| check_acl($config['id_user'], 0, 'RM')
) {
$sub['operation/agentes/exportdata']['text'] = __('Export data');
$sub['operation/agentes/exportdata']['id'] = 'export_data';
}
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
$sub['godmode/files_repo/files_repo']['text'] = __('File repository');
$sub['godmode/files_repo/files_repo']['id'] = 'file_repository';
}
$menu_godmode['tools']['sub'] = $sub;
// About.

View File

@ -236,17 +236,39 @@ if ($add_module === true) {
$id_modules
);
$id_agent_modules = db_get_all_rows_sql(
'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')"
$sql = sprintf(
'SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente IN (%s)
AND nombre IN ("%s")',
implode(',', $id_agents),
implode('","', $id_modules)
);
$id_agent_modules = db_get_all_rows_sql($sql);
if (count($id_agent_modules) > 0 && $id_agent_modules != '') {
$order = db_get_row_sql("SELECT `field_order` from tgraph_source WHERE id_graph=$id_graph ORDER BY `field_order` DESC");
$sql_order = sprintf(
'SELECT `field_order`
FROM tgraph_source
WHERE id_graph=%d
ORDER BY `field_order` DESC',
$id_graph
);
$order = db_get_row_sql($sql_order);
$order = $order['field_order'];
foreach ($id_agent_modules as $id_agent_module) {
$order++;
$result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module['id_agente_modulo'], 'weight' => $weight, 'field_order' => $order]);
$result = db_process_sql_insert(
'tgraph_source',
[
'id_graph' => $id_graph,
'id_agent_module' => $id_agent_module['id_agente_modulo'],
'weight' => $weight,
'field_order' => $order,
]
);
}
} else {
$result = false;

View File

@ -154,6 +154,14 @@ $image_threshold = false;
$time_compare_overlapped = false;
$unknowns_graph = false;
$periodicity_chart = false;
$period_maximum = true;
$period_minimum = true;
$period_average = true;
$period_summatory = false;
$period_slice_chart = SECONDS_1HOUR;
$period_mode = CUSTOM_GRAPH_VBARS;
// Added for events items.
$server_multiple = [0];
$show_summary_group = false;
@ -353,11 +361,19 @@ switch ($action) {
break;
case 'simple_graph':
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$fullscale = (isset($style['fullscale']) === true) ? (bool) $style['fullscale'] : 0;
$percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0;
$image_threshold = (isset($style['image_threshold']) === true) ? (bool) $style['image_threshold'] : false;
$graph_render = $item['graph_render'];
$unknowns_graph = $item['check_unknowns_graph'];
$periodicity_chart = (isset($style['periodicity_chart']) === true) ? $style['periodicity_chart'] : false;
$period_maximum = (isset($style['period_maximum']) === true) ? $style['period_maximum'] : true;
$period_minimum = (isset($style['period_minimum']) === true) ? $style['period_minimum'] : true;
$period_average = (isset($style['period_average']) === true) ? $style['period_average'] : true;
$period_summatory = (isset($style['period_summatory']) === true) ? $style['period_summatory'] : false;
$period_slice_chart = (isset($style['period_slice_chart']) === true) ? $style['period_slice_chart'] : SECONDS_1HOUR;
$period_mode = (isset($style['period_mode']) === true) ? $style['period_mode'] : CUSTOM_GRAPH_VBARS;
// The break hasn't be forgotten.
case 'simple_baseline_graph':
case 'projection_graph':
@ -3050,6 +3066,22 @@ if (is_metaconsole() === true) {
</td>
</tr>
<tr id="row_periodicity_chart" class="datos">
<td class="bolder"><?php echo __('Sliced mode'); ?></td>
<td >
<?php
html_print_checkbox_switch(
'periodicity_chart',
1,
(bool) $periodicity_chart,
false,
false,
'showPeriodicityOptions(this)'
);
?>
</td>
</tr>
<tr id="row_graph_render" class="datos">
<td class="bolder">
<?php
@ -3197,6 +3229,111 @@ if (is_metaconsole() === true) {
</td>
</tr>
<tr id="row_period_maximum" class="datos">
<td class="bolder"><?php echo __('Maximum'); ?></td>
<td >
<?php
html_print_checkbox_switch(
'period_maximum',
1,
(bool) $period_maximum,
false
);
?>
</td>
</tr>
<tr id="row_period_minimum" class="datos">
<td class="bolder"><?php echo __('Minimum'); ?></td>
<td >
<?php
html_print_checkbox_switch(
'period_minimum',
1,
(bool) $period_minimum,
false
);
?>
</td>
</tr>
<tr id="row_period_average" class="datos">
<td class="bolder"><?php echo __('Average'); ?></td>
<td >
<?php
html_print_checkbox_switch(
'period_average',
1,
(bool) $period_average,
false
);
?>
</td>
</tr>
<tr id="row_period_summatory" class="datos">
<td class="bolder"><?php echo __('Summatory'); ?></td>
<td >
<?php
html_print_checkbox_switch(
'period_summatory',
1,
(bool) $period_summatory,
false
);
?>
</td>
</tr>
<tr id="row_period_slice_chart" class="datos">
<td class="bolder"><?php echo __('Slice'); ?></td>
<td >
<?php
html_print_extended_select_for_time(
'period_slice_chart',
(string) $period_slice_chart,
'',
'',
0,
7,
false,
false,
true,
'',
false,
[
SECONDS_1HOUR => __('1 hour'),
SECONDS_1DAY => __('1 day'),
SECONDS_1WEEK => __('1 week'),
SECONDS_1MONTH => __('1 month'),
]
);
?>
</td>
</tr>
<tr id="row_period_mode" class="datos">
<td class="bolder"><?php echo __('Mode'); ?></td>
<td >
<?php
$options_period_mode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
];
html_print_select(
$options_period_mode,
'period_mode',
$period_mode,
'',
'',
0,
false,
false,
false
);
?>
</td>
</tr>
<tr id="row_exception_condition" class="datos">
<td class="bolder"><?php echo __('Condition'); ?></td>
<td>
@ -7305,6 +7442,13 @@ function chooseType() {
$("#row_filter_search").hide();
$("#row_filter_exclude").hide();
$("#row_percentil").hide();
$("#row_periodicity_chart").hide();
$("#row_period_maximum").hide();
$("#row_period_minimum").hide();
$("#row_period_average").hide();
$("#row_period_summatory").hide();
$("#row_period_slice_chart").hide();
$("#row_period_mode").hide();
$("#log_help_tip").css("visibility", "hidden");
$("#agents_row").hide();
$("#agents_modules_row").hide();
@ -7448,12 +7592,23 @@ function chooseType() {
break;
case 'simple_graph':
$("#row_time_compare_overlapped").show();
$("#row_fullscale").show();
$("#row_image_threshold").show();
$("#row_graph_render").show();
$("#row_percentil").show();
$("#row_unknowns_graph").show();
$("#row_periodicity_chart").show();
var periodicity_chart = $("input[name='periodicity_chart']").prop("checked");
if(periodicity_chart){
$("#row_period_maximum").show();
$("#row_period_minimum").show();
$("#row_period_average").show();
$("#row_period_summatory").show();
$("#row_period_slice_chart").show();
$("#row_period_mode").show();
} else {
$("#row_time_compare_overlapped").show();
$("#row_fullscale").show();
$("#row_image_threshold").show();
$("#row_graph_render").show();
$("#row_percentil").show();
$("#row_unknowns_graph").show();
}
// Force type.
if('<?php echo $action; ?>' === 'new'){

View File

@ -2523,6 +2523,15 @@ switch ($action) {
$style['image_threshold'] = (int) get_parameter(
'image_threshold'
);
$style['periodicity_chart'] = (int) get_parameter_checkbox('periodicity_chart', 0);
$style['period_maximum'] = (int) get_parameter_checkbox('period_maximum', 1);
$style['period_minimum'] = (int) get_parameter_checkbox('period_minimum', 1);
$style['period_average'] = (int) get_parameter_checkbox('period_average', 1);
$style['period_summatory'] = (int) get_parameter_checkbox('period_summatory', 0);
$style['period_slice_chart'] = get_parameter('period_slice_chart', SECONDS_1HOUR);
$style['period_mode'] = get_parameter('period_mode', CUSTOM_GRAPH_VBARS);
if ($label != '') {
$style['label'] = $label;
} else {
@ -3512,6 +3521,15 @@ switch ($action) {
$style['image_threshold'] = (int) get_parameter(
'image_threshold'
);
$style['periodicity_chart'] = (int) get_parameter_checkbox('periodicity_chart', 0);
$style['period_maximum'] = (int) get_parameter_checkbox('period_maximum', 1);
$style['period_minimum'] = (int) get_parameter_checkbox('period_minimum', 1);
$style['period_average'] = (int) get_parameter_checkbox('period_average', 1);
$style['period_summatory'] = (int) get_parameter_checkbox('period_summatory', 0);
$style['period_slice_chart'] = get_parameter('period_slice_chart', SECONDS_1HOUR);
$style['period_mode'] = get_parameter('period_mode', CUSTOM_GRAPH_VBARS);
if ($label != '') {
$style['label'] = $label;
} else {

View File

@ -212,6 +212,27 @@ class Applications extends Wizard
Wizard::printBigButtonsList($wiz_data);
$not_defined_extensions = $extensions->loadExtensions(true);
$output = html_print_div(
[
'class' => 'agent_details_line',
'content' => ui_toggle(
Wizard::printBigButtonsList($not_defined_extensions, true),
'<span class="subsection_header_title">'.__('Not installed').'</span>',
'not_defined_apps',
'not_defined_apps',
false,
true,
'',
'',
'box-flat white_table_graph w100p'
),
],
);
echo $output;
echo '<div class="app_mssg"><i>*'.__('All company names used here are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.').'</i></div>';
}

View File

@ -232,6 +232,27 @@ class Cloud extends Wizard
Wizard::printBigButtonsList($wiz_data);
$not_defined_extensions = $extensions->loadExtensions(true);
$output = html_print_div(
[
'class' => 'agent_details_line',
'content' => ui_toggle(
Wizard::printBigButtonsList($not_defined_extensions, true),
'<span class="subsection_header_title">'.__('Not installed').'</span>',
'not_defined_apps',
'not_defined_apps',
false,
true,
'',
'',
'box-flat white_table_graph w100p'
),
],
);
echo $output;
echo '<div class="app_mssg"><i>*'.__('All company names used here are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.').'</i></div>';
}

View File

@ -135,6 +135,27 @@ class Custom extends Wizard
Wizard::printBigButtonsList($wiz_data);
$not_defined_extensions = $extensions->loadExtensions(true);
$output = html_print_div(
[
'class' => 'agent_details_line',
'content' => ui_toggle(
Wizard::printBigButtonsList($not_defined_extensions, true),
'<span class="subsection_header_title">'.__('Not installed').'</span>',
'not_defined_apps',
'not_defined_apps',
false,
true,
'',
'',
'box-flat white_table_graph w100p'
),
],
);
echo $output;
echo '<div class="app_mssg"><i>*'.__('All company names used here are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.').'</i></div>';
return $result;
}

View File

@ -697,6 +697,9 @@ class ManageExtensions extends HTML
$order,
);
$appsMetadata = self::loadDiscoveryAppsMetadata();
$flattenMetadata = array_merge(...array_values($appsMetadata));
$count = db_get_num_rows($sqlCount);
foreach ($data as $key => $row) {
@ -705,6 +708,15 @@ class ManageExtensions extends HTML
$logo = $this->defaultLogo;
}
$metadataImage = $flattenMetadata[$row['short_name']]['image'];
if (isset($metadataImage) === true
&& file_exists($config['homedir'].'/images/discovery/'.$metadataImage) === true
&& file_exists($this->path.'/'.$row['short_name'].'/logo.png') === false
) {
$logo = '/images/discovery/'.$metadataImage;
}
$logo = html_print_image($logo, true, ['style' => 'max-width: 30px; margin-right: 15px;']);
$data[$key]['name'] = $logo.io_safe_output($row['name']);
$data[$key]['short_name'] = $row['short_name'];
@ -1490,4 +1502,55 @@ class ManageExtensions extends HTML
}
/**
* Read metadata CSV from system and store data structure in memory.
*
* @return array Data structure.
*/
private static function loadDiscoveryAppsMetadata()
{
global $config;
// Open the CSV file for reading.
$fileHandle = fopen($config['homedir'].'/extras/discovery/DiscoveryApps.csv', 'r');
// Check if the file was opened successfully.
if ($fileHandle !== false) {
$csvData = [];
// Loop through each line in the CSV file.
while (($data = fgetcsv($fileHandle)) !== false) {
$csvData[] = explode(';', $data[0]);
}
// Close the file handle.
fclose($fileHandle);
}
$groupedArray = [];
foreach ($csvData as $item) {
$key = $item[2];
if (isset($groupedArray[$key]) === false) {
$groupedArray[$key] = [];
}
$itemShortName = $item[0];
unset($item[0]);
unset($item[2]);
$itemIns = [
'name' => $item[1],
'enterprise' => $item[3],
'image' => $item[4],
'url' => $item[5],
];
$groupedArray[$key][$itemShortName] = $itemIns;
}
return $groupedArray;
}
}

View File

@ -492,14 +492,43 @@ class Wizard
$data['url'] = '#';
}
$cnt_class = 'data_container';
$ent_icon = '';
$label_class = '';
if (isset($data['ghost_mode']) === true
&& $data['ghost_mode'] === true
) {
$cnt_class .= ' alpha50';
}
if (isset($data['mark_as_enterprise']) === true
&& $data['mark_as_enterprise'] === true
) {
$ent_icon .= html_print_div(
[
'class' => 'w20px inline margin-lr-10',
'content' => html_print_image(
'images/ent_icon.png',
true,
['class' => 'max-width-100p height_auto_important']
),
],
true
);
$label_class = 'inline';
}
?>
<li class="discovery">
<a href="<?php echo $data['url']; ?>">
<div class="data_container">
<div class="<?php echo $cnt_class; ?> ">
<?php html_print_image($data['icon']); ?>
<br><label id="text_wizard">
<br><label id="text_wizard" class="<?php echo $label_class; ?>">
<?php echo io_safe_output($data['label']); ?>
</label>
<?php echo $ent_icon; ?>
</div>
</a>
</li>
@ -514,11 +543,19 @@ class Wizard
*
* @return void Print the full list.
*/
public static function printBigButtonsList($list_data)
public static function printBigButtonsList($list_data, $return=false)
{
if ($return === true) {
ob_start();
}
echo '<ul class="bigbuttonlist">';
array_map('self::printBigButtonElement', $list_data);
echo '</ul>';
if ($return === true) {
return ob_get_clean();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -1310,7 +1310,7 @@ if (check_login()) {
}
if (is_snapshot_data($module['datos']) === false) {
$link = 'winopeng_var(\'operation/agentes/stat_win.php?type='.$graph_type.'&amp;period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;refresh='.SECONDS_10MINUTES.'&amp;draw_events='.$draw_events.'\', \'day_'.$win_handle.'\', 800, 480)';
$link = 'winopeng_var(\'operation/agentes/stat_win.php?type='.$graph_type.'&amp;period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;refresh='.SECONDS_10MINUTES.'&amp;period_graph=0&amp;draw_events='.$draw_events.'\', \'day_'.$win_handle.'\', 800, 480)';
$graphButtons[] = html_print_anchor(
[
'href' => 'javascript:'.$link,
@ -1529,9 +1529,14 @@ if (check_login()) {
$output = '';
$graph_data = get_parameter('graph_data', '');
$params = json_decode(base64_decode($graph_data), true);
$form_data = json_decode(base64_decode(get_parameter('form_data', [])), true);
$server_id = (int) get_parameter('server_id', 0);
include_once $config['homedir'].'/include/functions_graph.php';
$tab_active = get_parameter('active', 'tabs-chart-module-graph');
$output .= draw_form_stat_win($form_data, $tab_active);
// Metaconsole connection to the node.
if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
@ -1583,7 +1588,23 @@ if (check_login()) {
$output .= $graph['chart'];
$output .= '</div>';
} else {
$output .= grafico_modulo_sparse($params);
if ($tab_active === 'tabs-chart-module-graph') {
$output .= grafico_modulo_sparse($params);
} else {
$output .= '<div class="container-periodicity-graph">';
$output .= '<div>';
$output .= graphic_periodicity_module($params);
$output .= '</div>';
$output .= '</div>';
if ($params['compare'] === 'separated') {
$params['date'] = ($params['date'] - $params['period']);
$output .= '<div class="container-periodicity-graph">';
$output .= '<div>';
$output .= graphic_periodicity_module($params);
$output .= '</div>';
$output .= '</div>';
}
}
}
}

View File

@ -195,28 +195,200 @@ class ExtensionsDiscovery extends Wizard
/**
* Return array extensions filtered by section
*
* @return array Extensions for
* @param boolean $not_defined_only Get only those extensions that are defined in the metadata CSV and not in db.
*
* @return array Extensions
*/
public function loadExtensions()
public function loadExtensions($not_defined_only=false)
{
global $config;
// Check access.
check_login();
$extensions = [];
$rows = $this->getExtensionsApps();
foreach ($rows as $key => $extension) {
$logo = $this->path.'/'.$extension['short_name'].'/'.$this->icon;
if (file_exists($config['homedir'].$logo) === false) {
$logo = $this->defaultLogo;
define('NOT_FOUND_MSG', 1);
define('ENTERPRISE_MSG', 2);
define('URL_MSG', 3);
$appsMetadata = self::loadDiscoveryAppsMetadata();
$sectionMetadata = $appsMetadata[$this->section];
$anchor = html_print_anchor(
[
'href' => 'index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert',
'content' => __('here'),
],
true
);
// Print JS required for message management.
echo '<script>
function showExtensionMsg(msgs, url, title) {
var msgs_json = JSON.parse(msgs);
var url_str = "";
if (url != false) {
url_str = `<a target="_blank" class="link-important" href="${url}">'.__('here').'</a>`;
}
$extensions[] = [
'icon' => $logo,
'label' => $extension['name'],
'url' => ui_get_full_url(
var markup = "<ul class=\'\'>";
if (msgs_json.includes('.NOT_FOUND_MSG.')) {
markup += "<li>&nbsp;&nbsp;&nbsp;'.__('The required files for the application were not found.').'</li>";
}
if (msgs_json.includes('.ENTERPRISE_MSG.')) {
markup += "<li>&nbsp;&nbsp;&nbsp;'.__('This discovery application is for Enterprise customers only.').'</li>";
}
if (msgs_json.includes('.URL_MSG.')) {
markup += \'<li>&nbsp;&nbsp;&nbsp;'.__('You can download this application from').' \'+url_str+\'.</li>\';
}
markup += "</ul>";
confirmDialog({
title: title,
message: markup,
hideOkButton: true,
ok: "'.__('OK').'",
cancel: "'.__('Cancel').'",
size: 550,
maxHeight: 500
});
}
</script>';
if ($not_defined_only === true) {
// Case: search for those extensions defined in metadata CSV which are not in database.
$short_names_list = array_column($rows, 'short_name');
// Traverse apps in CSV metadata file and set properly those that do not exist in database.
foreach ($sectionMetadata as $short_name => $val) {
if (in_array($short_name, $short_names_list) === false) {
$logo = $this->path.'/'.$short_name.'/'.$val['image'];
if (file_exists($config['homedir'].$logo) === false) {
$logo = $this->defaultLogo;
}
$error_msgs = [];
if (isset($val['image']) === true
&& file_exists($config['homedir'].'/images/discovery/'.$val['image']) === true
&& file_exists($config['homedir'].$this->path.'/'.$short_name.'/'.$val['image']) === false
) {
$logo = '/images/discovery/'.$val['image'];
}
$url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz='.$this->section.'&mode='.$extension['short_name']
);
if (enterprise_installed() === false && ((bool) $val['enterprise'] === true)) {
// Display enterprise message if console is open and extension is enterprise.
$error_msgs[] = ENTERPRISE_MSG;
}
$url_href = false;
if (isset($val['url']) === true
&& $val['url'] !== ''
) {
$url_href = $val['url'];
// Display URL message if an URL is defined in the metadata.
$error_msgs[] = URL_MSG;
}
if (empty($error_msgs) === false) {
$json_errors = json_encode($error_msgs);
// Display messages dialog if there are some.
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\', \''.io_safe_input($val['name']).'\');';
}
$extensions[] = [
'icon' => $logo,
'label' => io_safe_input($val['name']),
'url' => $url,
'ghost_mode' => true,
'mark_as_enterprise' => (bool) $val['enterprise'],
'defined' => false,
];
}
}
} else {
foreach ($rows as $key => $extension) {
$error_msgs = [];
$logo = $this->path.'/'.$extension['short_name'].'/'.$this->icon;
if (file_exists($config['homedir'].$logo) === false) {
$logo = $this->defaultLogo;
}
$mark_as_enterprise = false;
$ghostMode = false;
$url = ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz='.$this->section.'&mode='.$extension['short_name']
),
];
);
$url_href = false;
$iniFileExists = self::iniFileExists($extension['short_name']);
// Access metadata for current extension.
if (isset($sectionMetadata[$extension['short_name']]) === true) {
$itemData = $sectionMetadata[$extension['short_name']];
if (isset($itemData) === true) {
if (isset($itemData['image']) === true
&& file_exists($config['homedir'].'/images/discovery/'.$itemData['image']) === true
&& file_exists($config['homedir'].$this->path.'/'.$extension['short_name'].'/'.$this->icon) === false
) {
$logo = '/images/discovery/'.$itemData['image'];
}
$mark_as_enterprise = (bool) $itemData['enterprise'];
if ($iniFileExists === false
&& isset($itemData['url']) === true
&& $itemData['url'] !== ''
) {
$url_href = $itemData['url'];
// Display URL message if an URL is defined in the metadata.
$error_msgs[] = URL_MSG;
}
if (enterprise_installed() === false
&& (bool) $itemData['enterprise'] === true
) {
// Set ghost mode and display enterprise message if console is open and extension is enterprise.
$error_msgs[] = ENTERPRISE_MSG;
$ghostMode = true;
}
$itemName = $itemData['name'];
}
}
if ($iniFileExists === false) {
// Set ghost mode and display not found message if ini file does not exist for extension.
$error_msgs[] = NOT_FOUND_MSG;
$ghostMode = true;
}
if (empty($error_msgs) === false) {
$json_errors = json_encode($error_msgs);
// Display messages dialog if there are some.
$url = 'javascript: showExtensionMsg(\''.$json_errors.'\', \''.$url_href.'\', \''.io_safe_input($itemName).'\');';
}
$extensions[] = [
'icon' => $logo,
'label' => $extension['name'],
'url' => $url,
'ghost_mode' => $ghostMode,
'mark_as_enterprise' => $mark_as_enterprise,
'defined' => true,
];
}
}
return $extensions;
@ -2553,4 +2725,71 @@ class ExtensionsDiscovery extends Wizard
}
/**
* Read metadata CSV from system and store data structure in memory.
*
* @return array Data structure.
*/
private static function loadDiscoveryAppsMetadata()
{
global $config;
// Open the CSV file for reading.
$fileHandle = fopen($config['homedir'].'/extras/discovery/DiscoveryApps.csv', 'r');
// Check if the file was opened successfully.
if ($fileHandle !== false) {
$csvData = [];
// Loop through each line in the CSV file.
while (($data = fgetcsv($fileHandle)) !== false) {
$csvData[] = explode(';', $data[0]);
}
// Close the file handle.
fclose($fileHandle);
}
$groupedArray = [];
foreach ($csvData as $item) {
$key = $item[2];
if (isset($groupedArray[$key]) === false) {
$groupedArray[$key] = [];
}
$itemShortName = $item[0];
unset($item[0]);
unset($item[2]);
$itemIns = [
'name' => $item[1],
'enterprise' => $item[3],
'image' => $item[4],
'url' => $item[5],
];
$groupedArray[$key][$itemShortName] = $itemIns;
}
return $groupedArray;
}
/**
* Check if ini file exists for extension.
*
* @param string $shortName Extension short name.
*
* @return boolean Whether or not ini file exists.
*/
public static function iniFileExists($shortName)
{
global $config;
$path = $config['homedir'].'/attachment/discovery/'.$shortName.'/discovery_definition.ini';
return file_exists($path);
}
}

View File

@ -492,6 +492,7 @@ class HTML
$class = '';
}
$style_li = '';
if (empty($input['style']) === false) {
$style_li = $input['style'];
}

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC231215';
$build_version = 'PC231219';
$pandora_version = 'v7.0NG.774';
// Do not overwrite default timezone set if defined.

View File

@ -4049,6 +4049,7 @@ function series_type_graph_array($data, $show_elements_graph)
$i = 0;
if (isset($data) && is_array($data)) {
foreach ($data as $key => $value) {
$str = '';
if ($show_elements_graph['compare'] == 'overlapped') {
if ($key == 'sum2') {
$str = ' ('.__('Previous').')';
@ -4132,7 +4133,7 @@ function series_type_graph_array($data, $show_elements_graph)
} else {
$name_legend = '';
if ($show_elements_graph['graph_analytics'] === true) {
if (isset($show_elements_graph['graph_analytics']) === true && $show_elements_graph['graph_analytics'] === true) {
$name_legend .= '<div class="graph-analytics-legend-main">';
$name_legend .= '<div class="graph-analytics-legend-square" style="background-color: '.$color_series[$i]['color'].';">';
$name_legend .= '<span class="square-value">';
@ -6799,3 +6800,169 @@ function csv_format_delimiter(?string $str)
// TODO: a setup option that enables user to choose a delimiter character would probably be desirable in the future.
return '"'.$str.'"';
}
/**
* Get List translate string.
*
* @param string $language Language.
* @param string $text Text.
* @param integer $page Page.
*
* @return array List.
*/
function getListStringsTranslate($language, $text='', $page=0)
{
global $config;
$fileLanguage = $config['homedir'].'/include/languages/'.$language.'.po';
$file = file($fileLanguage);
$listStrings = [];
$readingOriginal = false;
$readingTranslation = false;
$original = '';
$translation = '';
foreach ($file as $line) {
// Jump empty lines.
if (strlen(trim($line)) == 0) {
continue;
}
// Jump comment lines.
if (preg_match('/^#.*$/', $line) > 0) {
continue;
}
if (preg_match('/^msgid "(.*)"/', $line, $match) == 1) {
if (empty($original) === false && (preg_match('/.*'.$text.'.*/', $original) >= 1)) {
$listStrings[$original] = [];
$listStrings[$original]['po'] = $translation;
$listStrings[$original]['ext'] = '';
}
$original = '';
$readingOriginal = false;
$readingTranslation = false;
if (strlen($match[1]) > 0) {
$original = $match[1];
} else {
$readingOriginal = true;
}
} else if (preg_match('/^msgstr "(.*)"/', $line, $match) == 1) {
if (strlen($match[1]) > 0) {
$translation = $match[1];
} else {
$readingOriginal = false;
$readingTranslation = true;
$translation = '';
}
} else if (preg_match('/^"(.*)"/', $line, $match) == 1) {
if ($readingOriginal) {
$original = $original.$match[1];
} else {
$translation = $translation.$match[1];
}
}
}
if (empty($original) === false && (preg_match('/.*'.$text.'.*/', $original) >= 1)) {
$listStrings[$original] = [];
$listStrings[$original]['po'] = $translation;
$listStrings[$original]['ext'] = '';
}
$sql = sprintf(
'SELECT *
FROM textension_translate_string
WHERE lang = "%s"',
$language
);
$dbListStrings = db_get_all_rows_sql($sql);
if ($dbListStrings === false) {
$dbListStrings = [];
}
foreach ($dbListStrings as $row) {
if (array_key_exists(io_safe_output($row['string']), $listStrings)) {
$listStrings[io_safe_output($row['string'])]['ext'] = io_safe_output($row['translation']);
}
}
return $listStrings;
}
/**
* Translate.
*
* @param string $string String.
*
* @return mixed
*/
function get_defined_translation($string)
{
global $config;
static $cache = [];
static $cache_translation = [];
$language = get_user_language();
if (func_num_args() !== 1) {
$args = func_get_args();
array_shift($args);
}
// Try with the cache.
if (isset($cache[$language]) === true) {
if (isset($cache[$language][$string]) === true) {
if (func_num_args() === 1) {
return $cache[$language][$string];
} else {
return vsprintf($cache[$language][$string], $args);
}
}
}
if (is_array($cache_translation) === true && count($cache_translation) === 0) {
$cache_translation_all = db_get_all_rows_sql(
sprintf(
'SELECT translation, string
FROM textension_translate_string
WHERE lang = "%s"',
$language
)
);
$cache_translation = false;
if ($cache_translation_all !== false) {
foreach ($cache_translation_all as $key => $value) {
$cache_translation[md5(io_safe_output($value['string']))] = $value['translation'];
}
}
} else {
if ($cache_translation === false) {
return false;
}
if (empty($cache_translation[md5($string)]) === false) {
$translation = $cache_translation[md5($string)];
} else {
return false;
}
}
if (empty($translation) === true) {
return false;
} else {
$cache[$language][$string] = io_safe_output($translation);
if (func_num_args() === 1) {
return $cache[$language][$string];
} else {
return vsprintf($cache[$language][$string], $args);
}
}
}

View File

@ -3676,6 +3676,7 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3)
'critical_inverse' => $other['data'][28],
'warning_inverse' => $other['data'][29],
'ff_type' => $other['data'][30],
'ignore_unknown' => $other['data'][32],
];
if (! $values['descripcion']) {
@ -3840,6 +3841,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3)
'warning_inverse',
'policy_linked',
'ff_type',
'ignore_unknown',
];
$values = [];
@ -3853,7 +3855,6 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3)
}
$values['policy_linked'] = 0;
$result_update = modules_update_agent_module($id_module, $values);
if ($result_update < 0) {
@ -3954,6 +3955,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3)
'critical_inverse' => $other['data'][33],
'warning_inverse' => $other['data'][34],
'ff_type' => $other['data'][35],
'ignore_unknown' => $other['data'][37],
];
$plugin = db_get_row('tplugin', 'id', $values['id_plugin']);
@ -4115,6 +4117,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
'warning_inverse',
'policy_linked',
'ff_type',
'ignore_unknown',
];
$values = [];
@ -4241,6 +4244,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3)
'critical_inverse' => $other['data'][24],
'warning_inverse' => $other['data'][25],
'ff_type' => $other['data'][26],
'ignore_unknown' => $other['data'][27],
];
if (! $values['descripcion']) {
@ -4763,6 +4767,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
'warning_inverse',
'policy_linked',
'ff_type',
'ignore_unknown',
];
$values = [];
@ -4903,6 +4908,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
'min_ff_event_warning' => $other['data'][32],
'min_ff_event_critical' => $other['data'][33],
'ff_type' => $other['data'][34],
'ignore_unknown' => $other['data'][36],
];
} else {
$values = [
@ -4935,6 +4941,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
'min_ff_event_warning' => $other['data'][26],
'min_ff_event_critical' => $other['data'][27],
'ff_type' => $other['data'][28],
'ignore_unknown' => $other['data'][29],
];
}
@ -5103,6 +5110,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
'min_ff_event_critical',
'policy_linked',
'ff_type',
'ignore_unknown',
];
} else {
$snmp_module_fields = [
@ -5135,6 +5143,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
'min_ff_event_critical',
'policy_linked',
'ff_type',
'ignore_unknown',
];
}
@ -7982,6 +7991,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3)
'configuration_data',
'disabled_types_event',
'module_macros',
'ignore_unknown',
];
$cont = 0;
@ -8120,6 +8130,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3)
$values['min_ff_event_warning'] = $other['data'][25];
$values['min_ff_event_critical'] = $other['data'][26];
$values['ff_type'] = $other['data'][27];
$values['ignore_unknown'] = $other['data'][28];
if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) {
@ -8222,6 +8233,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3)
'custom_id',
'disabled_types_event',
'module_macros',
'ignore_unknown',
];
$cont = 0;
@ -8338,6 +8350,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3)
$values['min_ff_event_warning'] = $other['data'][30];
$values['min_ff_event_critical'] = $other['data'][31];
$values['ff_type'] = $other['data'][32];
$values['ignore_unknown'] = $other['data'][33];
if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) {
@ -8464,6 +8477,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3)
'disabled_types_event',
'macros',
'module_macros',
'ignore_unknown',
];
$cont = 0;
@ -8782,6 +8796,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
'min_ff_event_warning' => $other['data'][31],
'min_ff_event_critical' => $other['data'][32],
'ff_type' => $other['data'][33],
'ignore_unknown' => $other['data'][34],
];
} else {
$values = [
@ -8812,6 +8827,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
'min_ff_event_warning' => $other['data'][25],
'min_ff_event_critical' => $other['data'][26],
'ff_type' => $other['data'][27],
'ignore_unknown' => $other['data'][28],
];
}
@ -8944,6 +8960,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3)
'plugin_parameter',
'plugin_user',
'plugin_pass',
'ignore_unknown',
];
} else {
$fields_snmp_module = [
@ -8968,6 +8985,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3)
'max',
'custom_id',
'description',
'ignore_unknown',
];
}

View File

@ -169,13 +169,21 @@ function extensions_get_extensions($enterprise=false, $rel_path='')
$file = readdir($handle);
}
// Load extensions in enterprise directory
if (! $enterprise && file_exists($master_dir)) {
return array_merge($extensions, extensions_get_extensions(true, $rel_path));
if (isset($extensions['ipam.php']) === true) {
unset($extensions['ipam.php']);
}
if (isset($extensions['ipam.php'])) {
unset($extensions['ipam.php']);
if (isset($extensions['translate_string.php']) === true) {
unset($extensions['translate_string.php']);
}
if (isset($extensions['files_repo.php']) === true) {
unset($extensions['files_repo.php']);
}
// Load extensions in enterprise directory.
if (! $enterprise && file_exists($master_dir)) {
return array_merge($extensions, extensions_get_extensions(true, $rel_path));
}
return $extensions;

View File

@ -1,17 +1,34 @@
<?php
/**
* Functions File repository
*
* @category Files repository
* @package Pandora FMS
* @subpackage Enterprise
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
* This code is NOT free software. This code is NOT licenced under GPL2 licence
* You cannnot redistribute it without written permission of copyright holder.
* ============================================================================
*/
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
function files_repo_check_directory($print_messages=false)
global $config;
/**
* Check repository writable.
*
* @return mixed
*/
function files_repo_check_directory()
{
global $config;
@ -21,11 +38,18 @@ function files_repo_check_directory($print_messages=false)
$result = false;
$messages = '';
// attachment/ check
if (!is_writable($attachment_path)) {
$msg_error = __('Attachment directory is not writable by HTTP Server');
$msg_error .= '</h3><p>';
$msg_error .= sprintf(
__('Please check that the web server has write rights on the %s directory'),
$attachment_path
);
// Attachment/ check.
if (is_writable($attachment_path) === false) {
$messages .= ui_print_error_message(
[
'message' => __('Attachment directory is not writable by HTTP Server').'</h3>'.'<p>'.sprinf(__('Please check that the web server has write rights on the %s directory'), $attachment_path),
'message' => $msg_error,
'no_close' => true,
'force_style' => 'color: #000000 !important',
],
@ -33,17 +57,17 @@ function files_repo_check_directory($print_messages=false)
true
);
} else {
// attachment/agent_packages/ check
if (!file_exists($files_repo_path) || !is_writable($files_repo_path)) {
// Create the directoty if not exist
if (!file_exists($files_repo_path)) {
// Attachment/agent_packages/ check.
if (file_exists($files_repo_path) === false || is_writable($files_repo_path) === false) {
// Create the directoty if not exist.
if (file_exists($files_repo_path) === false) {
mkdir($files_repo_path);
}
if (!is_writable($files_repo_path)) {
if (is_writable($files_repo_path) === false) {
$messages .= ui_print_error_message(
[
'message' => __('Attachment directory is not writable by HTTP Server').'</h3>'.'<p>'.sprintf(__('Please check that the web server has write rights on the %s directory'), $attachment_path),
'message' => $msg_error,
'no_close' => true,
'force_style' => 'color: #000000 !important',
],
@ -58,48 +82,60 @@ function files_repo_check_directory($print_messages=false)
}
}
if ($print_messages) {
echo $messages;
}
echo $messages;
return $result;
}
function files_repo_check_file_acl($file_id, $user_id=false, $file_groups=false, $user_groups=false)
{
/**
* Check acl file
*
* @param integer $file_id ID.
* @param boolean $user_id Users.
* @param boolean $file_groups File Groups.
* @param boolean $user_groups User Groups.
*
* @return boolean
*/
function files_repo_check_file_acl(
$file_id,
$user_id=false,
$file_groups=false,
$user_groups=false
) {
global $config;
$result = false;
if (!$user_id) {
if (empty($user_id) === true) {
$user_id = $config['id_user'];
}
if (is_user_admin($user_id)) {
if (is_user_admin($user_id) === true) {
return true;
}
if (!$file_groups) {
$file_groups = files_repo_get_file_groups($file_id);
if (empty($file_groups)) {
if (empty($file_groups) === true) {
$file_groups = [];
}
}
if (in_array(0, $file_groups)) {
if (in_array(0, $file_groups) === true) {
return true;
}
if (!$user_groups) {
$user_groups = users_get_groups($user_id, false, true);
if (empty($user_groups)) {
if (empty($user_groups) === true) {
$user_groups = [];
}
}
foreach ($file_groups as $group_id) {
// $user_groups has the id in the array keys
if (in_array($group_id, $user_groups)) {
// $user_groups has the id in the array keys.
if (in_array($group_id, $user_groups) === true) {
$result = true;
break;
}
@ -109,13 +145,19 @@ function files_repo_check_file_acl($file_id, $user_id=false, $file_groups=false,
}
/**
* File groups.
*
* @param integer $file_id File.
*
* @return array
*/
function files_repo_get_file_groups($file_id)
{
$groups = [];
$filter = ['id_file' => $file_id];
$result = db_get_all_rows_filter('tfiles_repo_group', $filter, 'id_group');
if (!empty($result)) {
if (empty($result) === false) {
foreach ($result as $key => $value) {
$groups[] = $value['id_group'];
}
@ -125,13 +167,19 @@ function files_repo_get_file_groups($file_id)
}
/**
* File user groups.
*
* @param string $user_id User id.
*
* @return array
*/
function files_repo_get_user_groups($user_id)
{
$groups = [];
$filter = ['id_usuario' => $user_id];
$result = db_get_all_rows_filter('tusuario_perfil', $filter, 'id_grupo');
if (!empty($result)) {
if (empty($result) === false) {
foreach ($result as $key => $value) {
$groups[] = $value['id_grupo'];
}
@ -141,7 +189,15 @@ function files_repo_get_user_groups($user_id)
}
function files_repo_get_files($filter=false, $count=false)
/**
* Get files.
*
* @param array $filter Filters.
* @param boolean $count Count.
*
* @return array
*/
function files_repo_get_files($filter=[], $count=false)
{
global $config;
@ -171,9 +227,9 @@ function files_repo_get_files($filter=false, $count=false)
$data['name'] = $file['name'];
$data['description'] = $file['description'];
$data['location'] = $files_repo_path.'/'.$file['id'].'_'.$data['name'];
// Size in bytes
// Size in bytes.
$data['size'] = filesize($data['location']);
// Last modification time in unix timestamp
// Last modification time in unix timestamp.
$data['mtime'] = filemtime($data['location']);
$data['groups'] = $file_groups;
$data['hash'] = $file['hash'];
@ -188,6 +244,16 @@ function files_repo_get_files($filter=false, $count=false)
}
/**
* Add file.
*
* @param string $file_input_name Name.
* @param string $description Description.
* @param array $groups Groups.
* @param boolean $public Mode.
*
* @return array
*/
function files_repo_add_file($file_input_name='upfile', $description='', $groups=[], $public=false)
{
global $config;
@ -210,10 +276,10 @@ function files_repo_add_file($file_input_name='upfile', $description='', $groups
$invalid_extensions = '/^(php|php1|php2|php3|php4|php5|php7|php8|phar|phptml|phps)$/i';
if (preg_match($invalid_extensions, $extension) === 0) {
// Replace conflictive characters
// Replace conflictive characters.
$filename = str_replace([' ', '=', '?', '&'], '_', $filename);
$filename = filter_var($filename, FILTER_SANITIZE_URL);
// The filename should not be larger than 200 characters
// The filename should not be larger than 200 characters.
if (mb_strlen($filename, 'UTF-8') > 200) {
$filename = mb_substr($filename, 0, 200, 'UTF-8');
}
@ -267,6 +333,16 @@ function files_repo_add_file($file_input_name='upfile', $description='', $groups
}
/**
* Update file.
*
* @param string $file_id File Name.
* @param string $description Description.
* @param array $groups Groups.
* @param boolean $public Mode.
*
* @return array
*/
function files_repo_update_file($file_id, $description='', $groups=[], $public=false)
{
global $config;
@ -308,6 +384,13 @@ function files_repo_update_file($file_id, $description='', $groups=[], $public=f
}
/**
* Delete File
*
* @param string $file_id File Name.
*
* @return mixed
*/
function files_repo_delete_file($file_id)
{
global $config;

View File

@ -2424,6 +2424,150 @@ function graphic_combined_module(
}
/**
* Draw periodicity graph
*
* @param array $params Params for draw chart.
*
* @return string Html output.
*/
function graphic_periodicity_module(array $params): string
{
if (isset($params['date']) === false || !$params['date']) {
$params['date'] = get_system_time();
}
$date_array = [];
$date_array['period'] = $params['period'];
$date_array['final_date'] = $params['date'];
$date_array['start_date'] = ($params['date'] - $params['period']);
$array_data = fullscale_data(
$params['agent_module_id'],
$date_array,
false,
false,
1,
false,
$params['period_slice_chart'],
0
);
if (empty($array_data) === false) {
$graph_labels = [];
$multiple_labels = [];
foreach ($array_data['sum1']['slice_data'] as $time => $array_data) {
$graph_labels[] = date('H:i', ($time / 1000));
$avg = [
'y' => $array_data['avg'],
'x' => $time,
];
$max = [
'y' => $array_data['max'],
'x' => $time,
];
$min = [
'y' => $array_data['min'],
'x' => $time,
];
$sum = [
'y' => $array_data['sum'],
'x' => $time,
];
if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS) {
$avg = [
'x' => $array_data['avg'],
'y' => $time,
];
$max = [
'x' => $array_data['max'],
'y' => $time,
];
$min = [
'x' => $array_data['min'],
'y' => $time,
];
$sum = [
'x' => $array_data['sum'],
'y' => $time,
];
}
$graph_values_avg[] = $avg;
$graph_values_max[] = $max;
$graph_values_min[] = $min;
$graph_values_sum[] = $sum;
}
if ((bool) $params['period_average'] === true) {
$graph_values['avg'] = $graph_values_avg;
$multiple_labels['avg'] = [
'label' => __('Average'),
'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false,
];
}
if ((bool) $params['period_maximum'] === true) {
$graph_values['max'] = $graph_values_max;
$multiple_labels['max'] = [
'label' => __('Maximun'),
'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false,
];
}
if ((bool) $params['period_minimum'] === true) {
$graph_values['min'] = $graph_values_min;
$multiple_labels['min'] = [
'label' => __('Minimum'),
'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false,
];
}
if ((bool) $params['period_summatory'] === true) {
$graph_values['sum'] = $graph_values_sum;
$multiple_labels['sum'] = [
'label' => __('Summatory'),
'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false,
];
}
}
$options = [
'height' => (isset($params['height']) === true) ? $params['height'] : 200,
'waterMark' => true,
'legend' => ['display' => true],
'labels' => $graph_labels,
'multiple' => $multiple_labels,
'legend' => [
'display' => (isset($params['show_legend'])) ? $params['show_legend'] : true,
],
'ttl' => (isset($params['ttl']) === true) ? $params['ttl'] : 1,
];
if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS
|| (int) $params['period_mode'] === CUSTOM_GRAPH_VBARS
) {
if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS) {
$options['axis'] = 'y';
}
$output = vbar_graph($graph_values, $options);
} else {
$output = line_graph($graph_values, $options);
}
return $output;
}
/**
* Function for convert data summatory.
*
@ -3847,6 +3991,7 @@ function fullscale_data(
}
$data['sum'.$series_suffix]['slice_data'][$real_date]['avg'] = ($sum_data / $count_data);
$data['sum'.$series_suffix]['slice_data'][$real_date]['sum'] = $sum_data;
if ($max_value != (-PHP_INT_MAX)) {
$data['sum'.$series_suffix]['slice_data'][$real_date]['max'] = $max_value;
@ -4112,6 +4257,7 @@ function fullscale_data(
$data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = 0;
if (isset($count_data) === true) {
$data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = ($sum_data / $count_data);
$data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['sum'] = $sum_data;
}
$data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['max'] = $max_value;
@ -5300,3 +5446,397 @@ function graph_analytics_filter_select()
return $result;
}
function draw_form_stat_win(array $form_data, string $tab_active)
{
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;font-weight: bold;font-size:8.5pt;line-height:30pt;';
$table->style[1] = 'text-align:left;font-weight: bold;line-height:30pt;';
$table->style[2] = 'text-align:left;font-weight: bold;line-height:30pt;';
$table->style[3] = 'text-align:left;font-weight: bold;line-height:30pt;';
$table->class = 'table_modal_alternate';
$table->data = [];
if ((bool) $form_data['histogram'] === true || $tab_active === 'tabs-chart-period-graph') {
$table->data[0][0] = __('Refresh time');
$table->data[0][1] = '<div class="small-input-select2">'.html_print_extended_select_for_time(
'refresh',
$form_data['refresh'],
'',
'',
0,
7,
true
).'</div>';
$table->data[0][2] = '';
$table->data[0][3] = '';
$table->data[1][0] = __('Begin date');
$table->data[1][1] = html_print_input_text(
'start_date',
$form_data['start_date'],
'',
10,
20,
true,
false,
false,
'',
'small-input'
);
$table->data[1][2] = __('Begin time');
$table->data[1][3] = html_print_input_text(
'start_time',
$form_data['start_time'],
'',
10,
10,
true,
false,
false,
'',
'small-input'
);
$table->data[2][0] = __('Time range');
$table->data[2][1] = '<div class="small-input-select2">'.html_print_extended_select_for_time(
'period',
$form_data['period'],
'',
'',
0,
7,
true
).'</div>';
$table->data[3][0] = __('Time compare (Separated)');
$table->data[3][1] = html_print_checkbox_switch(
'time_compare_separated',
1,
(bool) $form_data['time_compare_separated'],
true
);
$table->data[3][2] = '';
$table->data[3][3] = '';
if ($tab_active === 'tabs-chart-period-graph') {
$table->data[4][0] = __('Maximum');
$table->data[4][1] = html_print_checkbox_switch(
'period_maximum',
1,
(bool) $form_data['period_maximum'],
true
);
$table->data[4][2] = __('Minimum');
$table->data[4][3] = html_print_checkbox_switch(
'period_minimum',
1,
(bool) $form_data['period_minimum'],
true
);
$table->data[5][0] = __('Average');
$table->data[5][1] = html_print_checkbox_switch(
'period_average',
1,
(bool) $form_data['period_average'],
true
);
$table->data[5][2] = __('Summatory');
$table->data[5][3] = html_print_checkbox_switch(
'period_summatory',
1,
(bool) $form_data['period_summatory'],
true
);
$table->data[6][0] = __('Slice');
$table->data[6][1] = '<div class="small-input-select2">'.html_print_extended_select_for_time(
'period_slice_chart',
(string) $form_data['period_slice_chart'],
'',
'',
0,
7,
true,
false,
true,
'',
false,
[
SECONDS_1HOUR => __('1 hour'),
SECONDS_1DAY => __('1 day'),
SECONDS_1WEEK => __('1 week'),
SECONDS_1MONTH => __('1 month'),
]
).'</div>';
$table->data[6][2] = __('Mode');
$options_period_mode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
// CUSTOM_GRAPH_HBARS => __('Horizontal bars'),
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
];
$table->data[6][3] = '<div class="small-input-select2">'.html_print_select(
$options_period_mode,
'period_mode',
$form_data['period_mode'],
'',
'',
0,
true,
false,
false
).'</div>';
}
} else {
$table->data[0][0] = __('Refresh time');
$table->data[0][1] = '<div class="small-input-select2">'.html_print_extended_select_for_time(
'refresh',
$form_data['refresh'],
'',
'',
0,
7,
true
).'</div>';
$table->data[0][2] = __('Show events');
$disabled = false;
$table->data[0][3] = html_print_checkbox_switch(
'draw_events',
1,
(bool) $form_data['draw_events'],
true,
$disabled
);
$table->data[1][0] = __('Begin date');
$table->data[1][1] = html_print_input_text(
'start_date',
$form_data['start_date'],
'',
10,
20,
true,
false,
false,
'',
'small-input'
);
$table->data[1][2] = __('Show alerts');
$table->data[1][3] = html_print_checkbox_switch(
'draw_alerts',
1,
(bool) $form_data['draw_alerts'],
true
);
$table->data[2][0] = __('Begin time');
$table->data[2][1] = html_print_input_text(
'start_time',
$form_data['start_time'],
'',
10,
10,
true,
false,
false,
'',
'small-input'
);
$table->data[2][2] = __('Show unknown graph');
$table->data[2][3] = html_print_checkbox_switch(
'unknown_graph',
1,
(bool) $form_data['unknown_graph'],
true
);
$table->data[3][0] = __('Time range');
$table->data[3][1] = '<div class="small-input-select2">'.html_print_extended_select_for_time(
'period',
$form_data['period'],
'',
'',
0,
7,
true
).'</div>';
$table->data[3][2] = '';
$table->data[3][3] = '';
if (!modules_is_boolean($form_data['id'])) {
$table->data[4][0] = __('Zoom');
$options = [];
$options[$form_data['zoom']] = 'x'.$form_data['zoom'];
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
$options[5] = 'x5';
$table->data[4][1] = '<div class="small-input-select2">'.html_print_select(
$options,
'zoom',
$form_data['zoom'],
'',
'',
0,
true,
false,
false
).'</div>';
$table->data[4][2] = __('Show percentil');
$table->data[4][3] = html_print_checkbox_switch(
'show_percentil',
1,
(bool) $form_data['show_percentil'],
true
);
}
$table->data[5][0] = __('Time compare (Overlapped)');
$table->data[5][1] = html_print_checkbox_switch(
'time_compare_overlapped',
1,
(bool) $form_data['time_compare_overlapped'],
true
);
$table->data[5][2] = __('Time compare (Separated)');
$table->data[5][3] = html_print_checkbox_switch(
'time_compare_separated',
1,
(bool) $form_data['time_compare_separated'],
true
);
$table->data[6][0] = __('Show AVG/MAX/MIN data series in graph');
$table->data[6][1] = html_print_checkbox_switch(
'type_mode_graph',
1,
(bool) $form_data['type_mode_graph'],
true,
false
);
$table->data[6][2] = __('Show full scale graph (TIP)');
$table->data[6][2] .= ui_print_help_tip(
__('TIP mode charts do not support average - maximum - minimum series, you can only enable TIP or average, maximum or minimum series'),
true
);
$table->data[6][3] = html_print_checkbox_switch(
'fullscale',
1,
(bool) $form_data['fullscale'],
true,
false
);
$table->data[7][0] = __('Projection graph');
$table->data[7][0] .= ui_print_help_tip(
__('Projection graph take as begin date the current time'),
true
);
$table->data[7][1] = html_print_checkbox_switch(
'enable_projected_period',
1,
(bool) $form_data['enable_projected_period'],
true
);
$table->data[7][2] = __('Projection period');
$table->data[7][3] = '<div class="small-input-select2">'.html_print_extended_select_for_time(
'period_projected',
$form_data['period_projected'],
'',
'',
0,
7,
true
).'</div>';
}
$form_table = html_print_table($table, true);
$form_table .= html_print_div(
[
'class' => 'action-buttons-right-forced margin-top-10',
'content' => html_print_submit_button(
__('Reload'),
'submit',
false,
[
'icon' => 'search',
'mode' => 'secondary mini',
'class' => 'float-right',
],
true
),
],
true
);
$output = '<form method="GET" action="stat_win.php" style="margin-bottom: 0">';
$output .= html_print_input_hidden('id', $form_data['id'], true);
$output .= html_print_input_hidden('label', $form_data['label'], true);
if (empty($server_id) === false) {
$output .= html_print_input_hidden('server', $form_data['server_id'], true);
}
$output .= html_print_input_hidden('histogram', $form_data['histogram'], true);
$output .= html_print_input_hidden('period_graph', $form_data['period_graph'], true);
$output .= html_print_input_hidden('type', $form_data['type'], true);
$output .= ui_toggle(
$form_table,
'<span class="subsection_header_title">'.__('Graph configuration menu').'</span>'.ui_print_help_tip(
__('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'),
true
),
'',
'',
true,
true,
'',
'white-box-content',
'box-flat pdd_10px',
'images/arrow@svg.svg',
'images/arrow@svg.svg',
true
);
$output .= '</form>';
return $output;
}
function draw_container_chart_stat_win(?string $name='stat-win-module-graph')
{
$output = '<div class="margin-lr-10" id="'.$name.'">';
$output .= '<div id="'.$name.'-spinner" class="stat-win-spinner">';
$output .= html_print_image('images/spinner_charts.gif', true);
$output .= '</div>';
$output .= '<div id="'.$name.'-content">';
$output .= '</div>';
$output .= '</div>';
return $output;
}

View File

@ -5871,7 +5871,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$output .= html_print_radio_button_extended(
$data['name'],
$data['value'],
$data['label'],
((isset($data['label']) === true) ? $data['label'] : ''),
((isset($data['checkedvalue']) === true) ? $data['checkedvalue'] : 1),
((isset($data['disabled']) === true) ? $data['disabled'] : ''),
((isset($data['script']) === true) ? $data['script'] : ''),
@ -5928,7 +5928,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
}
$params = [];
$params['disabled'] = $data['disabled'];
$params['disabled'] = ($data['disabled'] ?? false);
$params['return'] = $data['return'];
$params['show_helptip'] = false;
$params['input_name'] = $data['name'];
@ -5993,11 +5993,11 @@ function html_print_input($data, $wrapper='div', $input_only=false)
];
} else {
$string_filter = '';
if ($data['get_only_string_modules'] === true) {
if (isset($data['get_only_string_modules']) === true && $data['get_only_string_modules'] === true) {
$string_filter = 'AND id_tipo_modulo IN (17,23,3,10,33,36)';
}
if ($data['from_wux'] === true) {
if (isset($data['from_wux']) === true && $data['from_wux'] === true) {
$string_filter = ' AND id_tipo_modulo = 25';
}

View File

@ -410,32 +410,14 @@ function __($string /*, variable arguments */)
global $config;
if (defined('METACONSOLE')) {
enterprise_include_once('meta/include/functions_meta.php');
enterprise_include_once('include/functions_setup.php');
$tranlateString = call_user_func_array(
'get_defined_translation',
array_values(func_get_args())
);
$tranlateString = call_user_func_array(
'meta_get_defined_translation',
array_values(func_get_args())
);
if ($tranlateString !== false) {
return $tranlateString;
}
} else if (enterprise_installed()
&& isset($config['translate_string_extension_installed'])
&& $config['translate_string_extension_installed'] == 1
&& array_key_exists('translate_string.php', $extensions)
) {
enterprise_include_once('extensions/translate_string/functions.php');
$tranlateString = call_user_func_array(
'get_defined_translation',
array_values(func_get_args())
);
if ($tranlateString !== false) {
return $tranlateString;
}
if ($tranlateString !== false) {
return $tranlateString;
}
if ($string == '') {

View File

@ -1338,8 +1338,9 @@ if (is_ajax()) {
<tbody>
<tr>
<th style="width: 40%; border: 0px;">
<a href="https://pandorafms.com/" target="_blank">
<a href="javascript:christmas_click('.$config['eastern_eggs_disabled'].')">
<img src="'.$image_about.'" alt="logo" width="70%">
<input id="count_click" type="hidden" value="0" />
</a>
</th>
<th style="width: 60%; text-align: left; border: 0px;">

View File

@ -3857,11 +3857,11 @@ function get_modules_agents(
$modules = array_reduce(
$modules,
function ($carry, $item) use ($id_agents, $selection) {
function ($carry, $item) use ($id_agents, $selection, $useName) {
if (count($id_agents) > 1 && (bool) $selection === true) {
$carry[$item['id_agente_modulo']] = $item['alias'].' &raquo; '.$item['nombre'];
$carry[($useName === true) ? io_safe_output($item['nombre']) : $item['id_agente_modulo']] = $item['alias'].' &raquo; '.$item['nombre'];
} else {
$carry[$item['id_agente_modulo']] = $item['nombre'];
$carry[($useName === true) ? io_safe_output($item['nombre']) : $item['id_agente_modulo']] = $item['nombre'];
}
return $carry;

View File

@ -11370,6 +11370,41 @@ function reporting_simple_graph(
$fullscale = (bool) $content['style']['fullscale'];
}
$periodicity_chart = false;
if (isset($content['style']['periodicity_chart'])) {
$periodicity_chart = (bool) $content['style']['periodicity_chart'];
}
$period_maximum = true;
if (isset($content['style']['period_maximum'])) {
$period_maximum = (bool) $content['style']['period_maximum'];
}
$period_minimum = true;
if (isset($content['style']['period_minimum'])) {
$period_minimum = (bool) $content['style']['period_minimum'];
}
$period_average = true;
if (isset($content['style']['period_average'])) {
$period_average = (bool) $content['style']['period_average'];
}
$period_summatory = false;
if (isset($content['style']['period_summatory'])) {
$period_summatory = (bool) $content['style']['period_summatory'];
}
$period_slice_chart = SECONDS_1HOUR;
if (isset($content['style']['period_slice_chart'])) {
$period_slice_chart = $content['style']['period_slice_chart'];
}
$period_mode = CUSTOM_GRAPH_VBARS;
if (isset($content['style']['period_mode'])) {
$period_mode = $content['style']['period_mode'];
}
$image_threshold = false;
if (isset($content['style']['image_threshold'])) {
$image_threshold = (bool) $content['style']['image_threshold'];
@ -11432,10 +11467,28 @@ function reporting_simple_graph(
'image_threshold' => $image_threshold,
];
if ((bool) $periodicity_chart === true) {
$params['width'] = null;
$params['period_maximum'] = $period_maximum;
$params['period_minimum'] = $period_minimum;
$params['period_average'] = $period_average;
$params['period_summatory'] = $period_summatory;
$params['period_slice_chart'] = $period_slice_chart;
$params['period_mode'] = $period_mode;
}
if ($only_image === false) {
$return['chart'] = grafico_modulo_sparse($params);
if ((bool) $periodicity_chart === false) {
$return['chart'] = \grafico_modulo_sparse($params);
} else {
$return['chart'] = \graphic_periodicity_module($params);
}
} else {
$return['chart'] = '<img src="data:image/png;base64,'.grafico_modulo_sparse($params).'" />';
if ((bool) $periodicity_chart === false) {
$return['chart'] = '<img src="data:image/png;base64,'.\grafico_modulo_sparse($params).'" />';
} else {
$return['chart'] = '<img src="data:image/png;base64,'.\graphic_periodicity_module($params).'" />';
}
}
break;

View File

@ -82,10 +82,9 @@ if (empty($file) === true || empty($hash) === true || $hash !== md5($file_raw.$c
$downloadable_file = $_SERVER['DOCUMENT_ROOT'].'/pandora_console/'.$file;
break;
case 'extensions/files_repo':
case 'godmode/files_repo/files_repo':
$attachment_path = io_safe_output($config['attachment_store']);
$downloadable_file = $attachment_path.'/files_repo/'.$file;
// $downloadable_file = $_SERVER['DOCUMENT_ROOT'].'/pandora_console/attachment/files_repo/'.$file;
break;
case 'godmode/servers/plugin':

View File

@ -697,6 +697,7 @@ function get_build_setup_charts($type, $options, $data)
if (isset($options['waterMark']) === true
&& empty($options['waterMark']) === false
&& isset($options['waterMark']['url']) === true
) {
// WaterMark.
$chart->defaults()->getWaterMark()->setWidth(88);
@ -1283,12 +1284,12 @@ function get_build_setup_charts($type, $options, $data)
case 'BAR':
if (isset($options['multiple']) === true && empty($options['multiple']) === false) {
$i = 0;
foreach ($options['multiple'] as $key_label => $label) {
foreach ($options['multiple'] as $key_label => $info) {
$dataSet = $chart->createDataSet();
$dataSet->setLabel($label);
$dataSet->setBackgroundColor($colors[$i]);
$dataSet->setBorderColor($borders[$i]);
$dataSet->setBorderWidth(2);
$dataSet->setLabel(($info['label'] ?? '--'));
$dataSet->setBackgroundColor(($info['backgroundColor'] ?? $colors[$i]));
$dataSet->setBorderColor(($info['borderColor'] ?? $borders[$i]));
$dataSet->setBorderWidth(($info['borderWidth'] ?? 2));
$dataSet->data()->exchangeArray(array_values($data[$key_label]));
$chart->addDataSet($dataSet);
$i++;
@ -1338,19 +1339,32 @@ function get_build_setup_charts($type, $options, $data)
break;
case 'LINE':
$chart->labels()->exchangeArray($options['labels']);
foreach ($data as $key => $dataset) {
$dataSet1 = $chart->createDataSet();
$dataSet1->setLabel($dataset['label']);
$dataSet1->setBackgroundColor($dataset['backgroundColor']);
$dataSet1->setBorderColor($dataset['borderColor']);
$dataSet1->setPointBackgroundColor($dataset['pointBackgroundColor']);
$dataSet1->setPointBorderColor($dataset['pointBorderColor']);
$dataSet1->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']);
$dataSet1->setPointHoverBorderColor($dataset['pointHoverBorderColor']);
$dataSet1->data()->exchangeArray($dataset['data']);
$chart->addDataSet($dataSet1);
if (isset($options['multiple']) === true && empty($options['multiple']) === false) {
$i = 0;
foreach ($options['multiple'] as $key_label => $info) {
$dataSet = $chart->createDataSet();
$dataSet->setLabel(($info['label'] ?? '--'));
$dataSet->setBackgroundColor(($info['backgroundColor'] ?? $colors[$i]));
$dataSet->setBorderColor(($info['borderColorColor'] ?? $borders[$i]));
$dataSet->setFill(($info['fill'] ?? false));
$dataSet->data()->exchangeArray(array_values($data[$key_label]));
$chart->addDataSet($dataSet);
$i++;
}
} else {
$chart->labels()->exchangeArray($options['labels']);
foreach ($data as $key => $dataset) {
$dataSet = $chart->createDataSet();
$dataSet->setLabel($dataset['label']);
$dataSet->setBackgroundColor($dataset['backgroundColor']);
$dataSet->setBorderColor($dataset['borderColor']);
$dataSet->setPointBackgroundColor($dataset['pointBackgroundColor']);
$dataSet->setPointBorderColor($dataset['pointBorderColor']);
$dataSet->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']);
$dataSet->setPointHoverBorderColor($dataset['pointHoverBorderColor']);
$dataSet->data()->exchangeArray($dataset['data']);
$chart->addDataSet($dataSet);
}
}
break;

View File

@ -277,7 +277,7 @@ function flot_area_graph(
'></div>";
$return .= "<div id='$graph_id' class='";
if ($params['type'] == 'area_simple') {
if (isset($params['type']) === true && $params['type'] == 'area_simple') {
$return .= 'noresizevc ';
}
@ -287,10 +287,12 @@ function flot_area_graph(
$width = 'width: '.$params['width'].';';
}
if (strpos($params['graph_width'], '%') === false) {
$width = 'width: '.$params['graph_width'].'px;';
} else {
$width = 'width: '.$params['graph_width'].';';
if (isset($params['graph_width']) === true) {
if (strpos($params['graph_width'], '%') === false) {
$width = 'width: '.$params['graph_width'].'px;';
} else {
$width = 'width: '.$params['graph_width'].';';
}
}
$return .= 'graph'.$params['adapt_key']."'
@ -346,10 +348,6 @@ function flot_area_graph(
$array_events_alerts = json_encode($array_events_alerts);
// Javascript code.
if ($font_size == '') {
$font_size = '\'\'';
}
$return .= "<script type='text/javascript'>";
$return .= "pandoraFlotArea(\n";

View File

@ -2566,6 +2566,40 @@ function WarningPeriodicityModal(title, message) {
});
}
function showPeriodicityOptions(element) {
if ($(element).is(":checked") === true) {
$("#row_period_maximum").show();
$("#row_period_minimum").show();
$("#row_period_average").show();
$("#row_period_summatory").show();
$("#row_period_slice_chart").show();
$("#row_period_mode").show();
$("#li-row_period_type").show();
$("#row_time_compare_overlapped").hide();
$("#row_fullscale").hide();
$("#row_image_threshold").hide();
$("#row_graph_render").hide();
$("#row_percentil").hide();
$("#MGgraphType").hide();
$("#row_unknowns_graph").hide();
} else {
$("#row_time_compare_overlapped").show();
$("#row_fullscale").show();
$("#row_image_threshold").show();
$("#row_graph_render").show();
$("#row_percentil").show();
$("#MGgraphType").show();
$("#row_unknowns_graph").show();
$("#row_period_maximum").hide();
$("#row_period_minimum").hide();
$("#row_period_average").hide();
$("#row_period_summatory").hide();
$("#row_period_slice_chart").hide();
$("#row_period_mode").hide();
$("#li-row_period_type").hide();
}
}
function checkExistParameterUrl(url, parameter) {
var regex = new RegExp(
"[?&]" + encodeURIComponent(parameter) + "(=([^&#]*)|&|#|$)"
@ -2575,3 +2609,15 @@ function checkExistParameterUrl(url, parameter) {
return exists;
}
function christmas_click(flagEasternEgg) {
let counter = $("#count_click").val();
counter++;
$("#count_click").val(counter);
if (counter == 25 && flagEasternEgg == true) {
$("#container-snow").removeClass("invisible");
setTimeout(() => {
$("#container-snow").addClass("invisible");
}, 120000);
}
}

View File

@ -1,4 +1,4 @@
/* globals $, GridStack, load_modal, TreeController, forced_title_callback, createVisualConsole, tinyMCE*/
/* globals $, GridStack, load_modal, TreeController, forced_title_callback, createVisualConsole, UndefineTinyMCE*/
// eslint-disable-next-line no-unused-vars
function show_option_dialog(settings) {
load_modal({
@ -1034,6 +1034,7 @@ function processTreeSearch(settings) {
});
}
// eslint-disable-next-line no-unused-vars
function processServiceTree(settings) {
var treeController = TreeController.getController();
@ -1606,6 +1607,38 @@ function showManualThresholds(element) {
}
}
// eslint-disable-next-line no-unused-vars
function showPeriodicityOptions(element) {
if ($(element).is(":checked") === true) {
$("#div_projection_switch").hide();
$("#div_type_mode_graph").hide();
$("#div_color_chart").hide();
$("#div_type_graph").hide();
$("#div_period_maximum").show();
$("#div_period_minimum").show();
$("#div_period_average").show();
$("#div_period_summatory").show();
$("#div_period_slice_chart").show();
$("#div_period_mode").show();
} else {
$("#div_projection_switch").show();
$("#div_type_mode_graph").show();
$("#div_color_chart").show();
$("#div_type_graph").show();
if ($("#projection_switch").is(":checked")) {
$("#div_projection_period").show();
} else {
$("#div_projection_period").hide();
}
$("#div_period_maximum").hide();
$("#div_period_minimum").hide();
$("#div_period_average").hide();
$("#div_period_summatory").hide();
$("#div_period_slice_chart").hide();
$("#div_period_mode").hide();
}
}
/**
* @return {void}
*/
@ -1637,6 +1670,7 @@ function type_change() {
}
// Show/Hide period for projection on agent module graph.
// eslint-disable-next-line no-unused-vars
function show_projection_period() {
if ($("#projection_switch").is(":checked")) {
$("#div_projection_period").show();

View File

@ -648,41 +648,15 @@ function createVisualConsole(
item.setMeta({ isUpdating: false });
var itemRetrieved = item.props;
if (itemRetrieved["type"] == 13 || itemRetrieved["type"] == 21) {
var startIsLeft =
itemRetrieved["startPosition"]["x"] -
itemRetrieved["endPosition"]["x"] <=
0;
var startIsTop =
itemRetrieved["startPosition"]["y"] -
itemRetrieved["endPosition"]["y"] <=
0;
itemRetrieved["startX"] = startIsLeft
? itemRetrieved["x"] + 20
: itemRetrieved["width"] + itemRetrieved["x"] + 20;
itemRetrieved["startY"] = startIsTop
? itemRetrieved["y"] + 20
: itemRetrieved["height"] + itemRetrieved["y"] + 20;
itemRetrieved["endX"] = startIsLeft
? itemRetrieved["width"] + itemRetrieved["x"] + 20
: itemRetrieved["x"] + 20;
itemRetrieved["endY"] = startIsTop
? itemRetrieved["height"] + itemRetrieved["y"] + 20
: itemRetrieved["y"] + 20;
} else {
itemRetrieved["x"] = itemRetrieved["x"] + 20;
itemRetrieved["y"] = itemRetrieved["y"] + 20;
}
itemRetrieved["receivedAt"] = new Date();
itemRetrieved["id"] = data;
var newItem = visualConsole.addElement(itemRetrieved);
newItem.setMeta({ editMode: true, isSelected: true });
var newItemData = JSON.parse(data);
newItemData["receivedAt"] = new Date();
var newItem = visualConsole.addElement(newItemData);
newItem.setMeta({
editMode: true,
isSelected: true,
isUpdating: false
});
visualConsole.buildRelations();
visualConsole.selectItem(newItem.props.id);
done();
@ -1232,7 +1206,7 @@ function cleanupDOM() {
$("#modalVCItemForm").empty();
}
/* Defined in operations/visual_console/view.php */
/* global $, load_modal, tinyMCE */
/* global $, load_modal, UndefineTinyMCE */
function createOrUpdateVisualConsoleItem(
visualConsole,
asyncTaskManager,
@ -1415,12 +1389,23 @@ function typeModuleGraph(type) {
$("#MGshowLegend").show();
$("#MGcustomGraph").hide();
$("#customGraphId").val(0);
$("#row_periodicity_chart").show();
if ($("#periodicityChart").is(":checked") === true) {
$("#MGgraphType").hide();
$("#li-row_period_type").show();
$("#row_period_slice_chart").show();
$("#row_period_mode").show();
}
} else if (type == "custom") {
$("#MGautoCompleteAgent").hide();
$("#MGautoCompleteModule").hide();
$("#MGgraphType").hide();
$("#MGshowLegend").hide();
$("#MGcustomGraph").show();
$("#row_periodicity_chart").hide();
$("#li-row_period_type").hide();
$("#row_period_slice_chart").hide();
$("#row_period_mode").hide();
}
}

View File

@ -431,15 +431,34 @@ class AgentHive extends Widget
$output .= '</div>';
$style = 'font-size: 6pt; display: flex; justify-content: start;
align-items: start; color: #9FA5B1; font-weight: 600;
line-height:normal; text-align:left;';
$style_div = $style.' margin-bottom: 15px;';
// OS description.
$output .= html_print_div(
[
'content' => (empty($data['os_version']) === true)
? get_os_name((int) $data['id_os'])
: $data['os_version'],
'style' => 'font-size: 6pt; display:
flex;justify-content: start;align-items: start;
color: #9FA5B1; font-weight: 600;margin-bottom: 5px',
? ui_print_truncate_text(
get_os_name((int) $data['id_os']),
32,
false,
true,
true,
'&hellip;',
$style
)
: ui_print_truncate_text(
$data['os_version'],
32,
false,
true,
true,
'&hellip;',
$style
),
'style' => $style_div,
],
true
);
@ -455,8 +474,10 @@ class AgentHive extends Widget
true,
'&hellip;',
),
'style' => 'text-align: left;min-height: 42px;
font-size: 8pt;max-height: 42px; margin-bottom: 10px',
'style' => 'text-align: left;
min-height: 42px; font-size: 8pt;
max-height: 42px; line-height: normal;
margin: 2px 0px 2px 0px',
],
true
);
@ -466,7 +487,9 @@ class AgentHive extends Widget
[
'content' => $data['direccion'],
'style' => 'font-size: 10pt;color: #14524f;
font-weight: 600; text-align: left',
font-weight: 600;
text-align: left;
margin-top: 5px',
],
true
);

View File

@ -269,6 +269,10 @@ class SingleGraphWidget extends Widget
$values['showLegend'] = $decoder['showLegend'];
}
if (isset($decoder['type_mode_graph']) === true) {
$values['type_mode_graph'] = $decoder['type_mode_graph'];
}
if (isset($decoder['projection_switch']) === true) {
$values['projection_switch'] = $decoder['projection_switch'];
}
@ -277,6 +281,42 @@ class SingleGraphWidget extends Widget
$values['period_projection'] = $decoder['period_projection'];
}
if (isset($decoder['periodicity_chart']) === true) {
$values['periodicity_chart'] = $decoder['periodicity_chart'];
}
if (isset($decoder['period_maximum']) === true) {
$values['period_maximum'] = $decoder['period_maximum'];
}
if (isset($decoder['period_minimum']) === true) {
$values['period_minimum'] = $decoder['period_minimum'];
}
if (isset($decoder['period_average']) === true) {
$values['period_average'] = $decoder['period_average'];
}
if (isset($decoder['period_summatory']) === true) {
$values['period_summatory'] = $decoder['period_summatory'];
}
if (isset($decoder['period_slice_chart']) === true) {
$values['period_slice_chart'] = $decoder['period_slice_chart'];
}
if (isset($decoder['period_mode']) === true) {
$values['period_mode'] = $decoder['period_mode'];
}
if (isset($decoder['color_chart']) === true) {
$values['color_chart'] = $decoder['color_chart'];
}
if (isset($decoder['type_graph']) === true) {
$values['type_graph'] = $decoder['type_graph'];
}
return $values;
}
@ -290,6 +330,7 @@ class SingleGraphWidget extends Widget
*/
public function getFormInputs(): array
{
global $config;
$values = $this->values;
// Retrieve global - common inputs.
@ -308,8 +349,49 @@ class SingleGraphWidget extends Widget
$values['showLegend'] = 1;
}
if (isset($values['type_graph']) === false) {
$values['type_graph'] = CUSTOM_GRAPH_AREA;
}
if (isset($values['period_maximum']) === false) {
$values['period_maximum'] = 1;
}
if (isset($values['period_minimum']) === false) {
$values['period_minimum'] = 1;
}
if (isset($values['period_average']) === false) {
$values['period_average'] = 1;
}
if (isset($values['period_slice_chart']) === false) {
$values['period_slice_chart'] = SECONDS_1HOUR;
}
if (isset($values['period_mode']) === false) {
$values['period_mode'] = CUSTOM_GRAPH_VBARS;
}
if (empty($values['color_chart']) === true) {
$values['color_chart'] = $config['graph_color1'];
}
$blocks = [
'row1',
'row2',
];
$inputs['blocks'] = $blocks;
foreach ($inputs as $kInput => $vInput) {
$inputs['inputs']['row1'][] = $vInput;
}
$display_periodicity_chart = ($values['periodicity_chart'] === true) ? '' : 'display:none';
// Autocomplete agents.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => __('Agent'),
'arguments' => [
'type' => 'autocomplete_agent',
@ -327,7 +409,7 @@ class SingleGraphWidget extends Widget
];
// Autocomplete module.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => __('Module').ui_print_help_tip(__('Warning, this requires to have data for a mid-term (days/weeks) of the source data, if not, projection will not be reliable.'), true),
'arguments' => [
'type' => 'autocomplete_module',
@ -340,11 +422,12 @@ class SingleGraphWidget extends Widget
'style' => 'width: inherit;',
'nothing' => __('None'),
'nothing_value' => 0,
'required' => 1,
],
];
// Show legend.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => __('Show legend'),
'arguments' => [
'name' => 'showLegend',
@ -355,7 +438,7 @@ class SingleGraphWidget extends Widget
];
// Period.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => __('Interval'),
'arguments' => [
'name' => 'period',
@ -369,9 +452,65 @@ class SingleGraphWidget extends Widget
],
];
$inputs['inputs']['row1'][] = [
'label' => __('Sliced mode'),
'arguments' => [
'name' => 'periodicity_chart',
'id' => 'periodicity_chart',
'type' => 'switch',
'value' => $values['periodicity_chart'],
'onclick' => 'showPeriodicityOptions(this)',
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Chart color'),
'id' => 'div_color_chart',
'style' => ($values['periodicity_chart'] === true) ? 'display:none' : '',
'arguments' => [
'wrapper' => 'div',
'name' => 'color_chart',
'type' => 'color',
'value' => $values['color_chart'],
'return' => true,
],
];
$options_mode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
];
$inputs['inputs']['row2'][] = [
'label' => __('Type graph'),
'id' => 'div_type_graph',
'style' => ($values['periodicity_chart'] === true) ? 'display:none' : '',
'arguments' => [
'type' => 'select',
'fields' => $options_mode,
'name' => 'type_graph',
'selected' => $values['type_graph'],
'return' => true,
],
];
$inputs['inputs']['row2'][] = [
'label' => __('AVG/MAX/MIN'),
'id' => 'div_type_mode_graph',
'style' => ($values['periodicity_chart'] === true) ? 'display:none' : '',
'arguments' => [
'name' => 'type_mode_graph',
'id' => 'type_mode_graph',
'type' => 'switch',
'value' => $values['type_mode_graph'],
],
];
// Projection.
$inputs[] = [
$inputs['inputs']['row2'][] = [
'label' => __('Projection Graph'),
'id' => 'div_projection_switch',
'style' => ($values['periodicity_chart'] === true) ? 'display:none' : '',
'arguments' => [
'name' => 'projection_switch',
'id' => 'projection_switch',
@ -383,7 +522,7 @@ class SingleGraphWidget extends Widget
// Period Projection.
$display_projection = ($values['projection_switch'] === true) ? '' : 'display:none';
$inputs[] = [
$inputs['inputs']['row2'][] = [
'label' => __('Period Projection'),
'id' => 'div_projection_period',
'style' => $display_projection,
@ -396,6 +535,90 @@ class SingleGraphWidget extends Widget
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Maximum'),
'id' => 'div_period_maximum',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_maximum',
'id' => 'period_maximum',
'type' => 'switch',
'value' => $values['period_maximum'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Minimum'),
'id' => 'div_period_minimum',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_minimum',
'id' => 'period_minimum',
'type' => 'switch',
'value' => $values['period_minimum'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Average'),
'id' => 'div_period_average',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_average',
'id' => 'period_average',
'type' => 'switch',
'value' => $values['period_average'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Summatory'),
'id' => 'div_period_summatory',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_summatory',
'id' => 'period_summatory',
'type' => 'switch',
'value' => $values['period_summatory'],
],
];
$inputs['inputs']['row2'][] = [
'label' => __('Slice period'),
'id' => 'div_period_slice_chart',
'style' => $display_periodicity_chart,
'arguments' => [
'name' => 'period_slice_chart',
'type' => 'interval',
'value' => (string) $values['period_slice_chart'],
'custom_fields' => [
SECONDS_1HOUR => __('1 hour'),
SECONDS_1DAY => __('1 day'),
SECONDS_1WEEK => __('1 week'),
SECONDS_1MONTH => __('1 month'),
],
],
];
$options_period_mode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
];
$inputs['inputs']['row2'][] = [
'label' => __('Type chart'),
'id' => 'div_period_mode',
'style' => $display_periodicity_chart,
'arguments' => [
'type' => 'select',
'fields' => $options_period_mode,
'name' => 'period_mode',
'selected' => $values['period_mode'],
'return' => true,
],
];
return $inputs;
}
@ -407,6 +630,7 @@ class SingleGraphWidget extends Widget
*/
public function getPost():array
{
global $config;
// Retrieve global - common inputs.
$values = parent::getPost();
@ -414,9 +638,21 @@ class SingleGraphWidget extends Widget
$values['metaconsoleId'] = \get_parameter('metaconsoleId', 0);
$values['moduleId'] = \get_parameter('moduleId', 0);
$values['period'] = \get_parameter('period', 0);
$values['type_graph'] = \get_parameter('type_graph', CUSTOM_GRAPH_AREA);
$values['showLegend'] = \get_parameter_switch('showLegend');
$values['projection_switch'] = (boolean) get_parameter_switch('projection_switch');
$values['type_mode_graph'] = \get_parameter_switch('type_mode_graph');
$values['projection_switch'] = (boolean) \get_parameter_switch('projection_switch');
$values['period_projection'] = \get_parameter('period_projection', 0);
$values['color_chart'] = \get_parameter('color_chart', $config['graph_color1']);
// Values periodicity chart.
$values['periodicity_chart'] = (boolean) \get_parameter_switch('periodicity_chart');
$values['period_maximum'] = (boolean) \get_parameter_switch('period_maximum');
$values['period_minimum'] = (boolean) \get_parameter_switch('period_minimum');
$values['period_average'] = (boolean) \get_parameter_switch('period_average');
$values['period_summatory'] = (boolean) \get_parameter_switch('period_summatory');
$values['period_slice_chart'] = \get_parameter('period_slice_chart', SECONDS_1HOUR);
$values['period_mode'] = \get_parameter('period_mode', CUSTOM_GRAPH_VBARS);
return $values;
}
@ -447,7 +683,7 @@ class SingleGraphWidget extends Widget
$trickHight = 0;
if ($this->values['showLegend'] === 1) {
// Needed for legend.
$trickHight = 60;
$trickHight = 30;
}
$output = '<div class="container-center widget-mrgn-0px">';
@ -479,21 +715,69 @@ class SingleGraphWidget extends Widget
);
$output .= $return['chart'];
} else {
if ($this->values['showLegend'] === 1 && (bool) $this->values['type_mode_graph'] === true) {
$trickHight *= 3;
}
if (isset($this->values['color_chart']) === false
|| empty($this->values['color_chart']) === true
) {
$this->values['color_chart'] = $config['graph_color1'];
}
if (isset($this->values['type_graph']) === false
|| empty($this->values['type_graph']) === true
) {
$this->values['type_graph'] = CUSTOM_GRAPH_AREA;
}
$params = [
'agent_module_id' => $this->values['moduleId'],
'width' => '100%',
'height' => ((int) $size['height'] - $trickHight),
'period' => $this->values['period'],
'title' => $module_name,
'unit' => $units_name,
'homeurl' => $config['homeurl'],
'backgroundColor' => 'transparent',
'show_legend' => $this->values['showLegend'],
'show_title' => $module_name,
'menu' => false,
'dashboard' => true,
'agent_module_id' => $this->values['moduleId'],
'width' => '100%',
'height' => ((int) $size['height'] - $trickHight),
'period' => $this->values['period'],
'title' => $module_name,
'unit' => $units_name,
'homeurl' => $config['homeurl'],
'backgroundColor' => 'transparent',
'show_legend' => $this->values['showLegend'],
'show_title' => $module_name,
'menu' => false,
'dashboard' => true,
'type_graph' => (int) $this->values['type_graph'],
'type_mode_graph' => $this->values['type_mode_graph'],
'period_maximum' => $this->values['period_maximum'],
'period_minimum' => $this->values['period_minimum'],
'period_average' => $this->values['period_average'],
'period_summatory' => $this->values['period_summatory'],
'period_slice_chart' => $this->values['period_slice_chart'],
'period_mode' => $this->values['period_mode'],
'array_colors' => [
[
'border' => '#000000',
'color' => $this->values['color_chart'].'80',
'alpha' => 75,
],
[
'border' => '#000000',
'color' => $this->values['color_chart'],
'alpha' => 50,
],
[
'border' => '#000000',
'color' => $this->values['color_chart'].'60',
'alpha' => 25,
],
],
];
$output .= \grafico_modulo_sparse($params);
if ((bool) $this->values['periodicity_chart'] === false) {
$output .= \grafico_modulo_sparse($params);
} else {
$params['width'] = null;
$params['height'] = (int) $size['height'];
$output .= \graphic_periodicity_module($params);
}
}
$output .= '</div>';
@ -531,7 +815,7 @@ class SingleGraphWidget extends Widget
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'width' => 800,
'height' => 430,
];

View File

@ -49,6 +49,7 @@ class Group extends Entity
'groupEventsByAgent',
'loadInfoAgent',
'getAgentsByGroup',
'getGroupsName',
];
@ -751,4 +752,30 @@ class Group extends Entity
}
/**
* Get groups name.
*
* @return void
*/
public static function getGroupsName()
{
$groups = get_parameter('groups', []);
$sql = sprintf(
'SELECT id_grupo, nombre FROM tgrupo WHERE id_grupo IN (%s)',
implode(',', $groups)
);
$result = db_get_all_rows_sql($sql);
$array_groups = [];
foreach ($result as $value) {
$array_groups[$value['id_grupo']] = $value['nombre'];
}
echo json_encode($array_groups);
exit;
}
}

View File

@ -22,6 +22,7 @@
namespace PandoraFMS\TacticalView;
use DateTimeZone;
use Exception;
use PandoraFMS\View;
@ -163,17 +164,25 @@ class GeneralTacticalView
private function getWelcomeMessage():string
{
global $config;
$user = users_get_user_by_id($config['id_user']);
if (is_array($user) === true && count($user) > 0) {
$name = $user['fullname'];
} else {
$name = '';
}
if (empty($name) === true) {
$message = __('Welcome back! 👋');
$flag_eastern_egg = $config['eastern_eggs_disabled'];
if ((bool) $flag_eastern_egg === true) {
$message = $this->randomWelcomeMessage();
} else {
$message = __('Welcome back %s! 👋', $name);
$user = users_get_user_by_id($config['id_user']);
if (is_array($user) === true && count($user) > 0) {
$name = $user['fullname'];
} else {
$name = $user['firstname'];
}
// 👋
if (empty($name) === true) {
$message = __('Welcome back! 👋');
} else {
$message = __('Welcome back %s! 👋', $name);
}
}
return html_print_div(
@ -186,4 +195,88 @@ class GeneralTacticalView
}
/**
* Return random welcome message.
*
* @return string
*/
private function randomWelcomeMessage() : string
{
global $config;
$welcome = [];
$user = users_get_user_by_id($config['id_user']);
if (is_array($user) === true && count($user) > 0) {
$name = $user['fullname'];
} else {
$name = $user['firstname'];
}
// Config user time zone.
if (!empty($user['timezone'])) {
$timezone = $user['timezone'];
} else {
$timezone = date_default_timezone_get();
}
date_default_timezone_set($timezone);
$date_zone = new DateTimeZone($timezone);
$zone_location = $date_zone->getLocation();
$latitude = $zone_location['latitude'];
$emojiOptions = [
'have_good_day' => __('Have a good day %s ✌', $name),
'welcome_back' => __('Welcome back! %s 👋', $name),
'merry_christmas' => __('Welcome back! %s 🎅', $name),
'good_morning' => __('Good morning, %s! ☕', $name),
'good_evening' => __('Good evening, %s 🌇', $name),
'good_night' => __('Good night, %s 🌕', $name),
'happy_summer' => __('Happy summer, %s 🌞', $name),
'happy_winter' => __('Happy winter, %s ⛄', $name),
'happy_autumn' => __('Happy autumn, %s 🍂', $name),
'happy_spring' => __('Happy spring, %s 🌻', $name),
];
// Welcome back.
$user_last_connect = $user['last_connect'];
$user_last_day = date('d', $user_last_connect);
$day = date('d', strtotime('now'));
if ($user_last_day === $day) {
$welcome[] = $emojiOptions['welcome_back'];
}
// Morning, evening, night.
$date = date('H');
if ($date < 13) {
$welcome[] = $emojiOptions['good_morning'];
} else if ($date < 18) {
$welcome[] = $emojiOptions['good_evening'];
} else {
$welcome[] = $emojiOptions['good_night'];
}
// Seasons.
$mes = date('m');
if (($latitude > 0 && ($mes >= 3 && $mes <= 5)) || ($latitude < 0 && ($mes >= 9 && $mes <= 11))) {
$welcome[] = $emojiOptions['happy_spring'];
} else if (($latitude > 0 && ($mes >= 6 && $mes <= 8)) || ($latitude < 0 && ($mes >= 12 || $mes <= 2))) {
$welcome[] = $emojiOptions['happy_summer'];
} else if (($latitude > 0 && ($mes >= 9 && $mes <= 11)) || ($latitude < 0 && ($mes >= 3 && $mes <= 5))) {
$welcome[] = $emojiOptions['happy_autumn'];
} else {
$welcome[] = $emojiOptions['happy_winter'];
}
if ($mes === '12' && $day === '25') {
unset($welcome);
$welcome[] = $emojiOptions['merry_christmas'];
}
$length = count($welcome);
$possition = rand(0, ($length - 1));
return $welcome[$possition];
}
}

View File

@ -95,7 +95,7 @@ if ($doLogin === true) {
if ($visualConsoleId) {
// Retrieve the visual console.
$visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId], $ratio);
$visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]);
$visualConsoleData = $visualConsole->toArray();
$vcGroupId = $visualConsoleData['groupId'];
@ -307,18 +307,19 @@ if ($getVisualConsole === true) {
}
unset($data['id']);
$class = VisualConsole::getItemClass((int) $data['type']);
try {
// Save the new item.
$result = $class::create($data);
$itemId = $class::create($data);
$item = VisualConsole::getItemFromDB($itemId);
$result = $item->toArray();
} catch (\Throwable $th) {
// There is no item in the database.
echo false;
return;
}
echo $result;
echo json_encode($result);
return;
} else if ($getImagesVisualConsole) {
$img = get_parameter('nameImg', 'appliance');

View File

@ -2515,7 +2515,7 @@ class Item extends CachedModel
'arguments' => [
'name' => 'linkedLayoutStatusTypeWeight',
'type' => 'number',
'value' => $values['linkedLayoutStatusTypeWeight'],
'value' => ($values['linkedLayoutStatusTypeWeight'] ?? 0),
'return' => true,
'min' => 0,
],

View File

@ -60,9 +60,8 @@ final class ModuleGraph extends Item
protected static function encode(array $data): array
{
$return = parent::encode($data);
$id_custom_graph = static::extractIdCustomGraph($data);
if (!empty($id_custom_graph)) {
if (empty($id_custom_graph) === false) {
if (\is_metaconsole()) {
$explode_custom_graph = explode('|', $id_custom_graph);
$return['id_custom_graph'] = $explode_custom_graph[0];
@ -82,6 +81,18 @@ final class ModuleGraph extends Item
$return['show_statistics'] = static::parseBool($show_legend);
}
$return['period_chart_options'] = json_encode(
[
'periodicityChart' => static::extractPeriodicityChart($data),
'periodMaximum' => static::extractPeriodMaximum($data),
'periodMinimum' => static::extractPeriodMinimum($data),
'periodAverage' => static::extractPeriodAverage($data),
'periodSummatory' => static::extractPeriodSummatory($data),
'periodSliceChart' => static::extractPeriodSliceChart($data),
'periodMode' => static::extractPeriodMode($data),
]
);
return $return;
}
@ -149,6 +160,15 @@ final class ModuleGraph extends Item
$return['period'] = static::extractPeriod($data);
$return['showLegend'] = static::extractShowLegend($data);
$return['periodChartOptions'] = static::extractPeriodChartOptions($data);
$return['periodicityChart'] = static::extractPeriodicityChart($return['periodChartOptions']);
$return['periodMaximum'] = static::extractPeriodMaximum($return['periodChartOptions']);
$return['periodMinimum'] = static::extractPeriodMinimum($return['periodChartOptions']);
$return['periodAverage'] = static::extractPeriodAverage($return['periodChartOptions']);
$return['periodSummatory'] = static::extractPeriodSummatory($return['periodChartOptions']);
$return['periodSliceChart'] = static::extractPeriodSliceChart($return['periodChartOptions']);
$return['periodMode'] = static::extractPeriodMode($return['periodChartOptions']);
$customGraphId = static::extractCustomGraphId($data);
if (empty($customGraphId) === false) {
@ -161,6 +181,30 @@ final class ModuleGraph extends Item
}
/**
* Extract a dynamic data structure from the 'periodChartOptions' field.
*
* @param array $data Unknown input data structure.
*
* @return array Dynamic data structure.
* @throws \InvalidArgumentException If the structure cannot be built.
*/
private static function extractPeriodChartOptions(array $data): array
{
$periodChartOptions = static::notEmptyStringOr($data['period_chart_options'], null);
$result = [];
if ($periodChartOptions !== null) {
try {
$result = \json_decode($periodChartOptions, true);
} catch (\Throwable $e) {
throw new \InvalidArgumentException('invalid dynamic data');
}
}
return $result;
}
/**
* Extract a background type value.
*
@ -216,6 +260,118 @@ final class ModuleGraph extends Item
}
/**
* Extract the "type sliced" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodicityChart(array $data): bool
{
return static::parseBool(
static::issetInArray($data, ['periodicityChart']),
false
);
}
/**
* Extract the "period maximum" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodMaximum(array $data): bool
{
return static::parseBool(
static::issetInArray($data, ['periodMaximum']),
true
);
}
/**
* Extract the "period minimum" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodMinimum(array $data): bool
{
return static::parseBool(
static::issetInArray($data, ['periodMinimum']),
true
);
}
/**
* Extract the "period average" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodAverage(array $data): bool
{
return static::parseBool(
static::issetInArray($data, ['periodAverage']),
true
);
}
/**
* Extract the "period summatory" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodSummatory(array $data): bool
{
return static::parseBool(
static::issetInArray($data, ['periodSummatory']),
false
);
}
/**
* Extract the "period Slice" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodSliceChart(array $data): int
{
return static::parseIntOr(
static::issetInArray($data, ['periodSliceChart']),
SECONDS_1HOUR
);
}
/**
* Extract the "period mode" switch value.
*
* @param array $data Unknown input data structure.
*
* @return boolean
*/
private static function extractPeriodMode(array $data): int
{
return static::parseIntOr(
static::issetInArray($data, ['periodMode']),
CUSTOM_GRAPH_VBARS
);
}
/**
* Extract a custom graph Id value.
*
@ -289,6 +445,15 @@ final class ModuleGraph extends Item
$period = static::extractPeriod($data);
$showLegend = static::extractShowLegend($data);
$periodChartOptions = static::extractPeriodChartOptions($data);
$periodicityChart = static::extractPeriodicityChart($periodChartOptions);
$periodMaximum = static::extractPeriodMaximum($periodChartOptions);
$periodMinimum = static::extractPeriodMinimum($periodChartOptions);
$periodAverage = static::extractPeriodAverage($periodChartOptions);
$periodSummatory = static::extractPeriodSummatory($periodChartOptions);
$periodSliceChart = static::extractPeriodSliceChart($periodChartOptions);
$periodMode = static::extractPeriodMode($periodChartOptions);
$customGraphId = static::extractCustomGraphId($data);
$graphType = static::extractGraphType($data);
$linkedModule = static::extractLinkedModule($data);
@ -425,7 +590,23 @@ final class ModuleGraph extends Item
'server_id' => $metaconsoleId,
];
$chart = \grafico_modulo_sparse($params);
if ($periodicityChart === true) {
$params['width'] = null;
$params['period_maximum'] = $periodMaximum;
$params['period_minimum'] = $periodMinimum;
$params['period_average'] = $periodAverage;
$params['period_summatory'] = $periodSummatory;
$params['period_slice_chart'] = $periodSliceChart;
$params['period_mode'] = $periodMode;
}
if ($periodicityChart === false) {
$chart = \grafico_modulo_sparse($params);
} else {
$chart = '<div style="background:'.$params['backgroundColor'].'; width: inherit; height: inherit;">';
$chart .= \graphic_periodicity_module($params);
$chart .= '</div>';
}
}
$data['html'] = $chart;
@ -505,6 +686,26 @@ final class ModuleGraph extends Item
$values['showLegend'] = true;
}
if (isset($values['periodMaximum']) === false) {
$values['periodMaximum'] = true;
}
if (isset($values['periodMinimum']) === false) {
$values['periodMinimum'] = true;
}
if (isset($values['periodAverage']) === false) {
$values['periodAverage'] = true;
}
if (isset($values['periodSliceChart']) === false) {
$values['periodSliceChart'] = SECONDS_1HOUR;
}
if (isset($values['periodMode']) === false) {
$values['periodMode'] = CUSTOM_GRAPH_VBARS;
}
// Background color.
$fields = [
'white' => __('White'),
@ -608,9 +809,13 @@ final class ModuleGraph extends Item
// Custom graph.
$fields = self::getListCustomGraph();
$selected_custom_graph = (\is_metaconsole() === true)
? $values['customGraphId'].'|'.$values['metaconsoleId']
: $values['customGraphId'];
$selected_custom_graph = 0;
if (isset($values['customGraphId']) === true) {
$selected_custom_graph = (\is_metaconsole() === true)
? $values['customGraphId'].'|'.$values['metaconsoleId']
: $values['customGraphId'];
}
$inputs[] = [
'id' => 'MGcustomGraph',
'hidden' => $hiddenCustom,
@ -640,25 +845,6 @@ final class ModuleGraph extends Item
],
];
// Graph Type.
$fields = [
'line' => __('Line'),
'area' => __('Area'),
];
$inputs[] = [
'id' => 'MGgraphType',
'hidden' => $hiddenModule,
'label' => __('Graph Type'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'graphType',
'selected' => $values['graphType'],
'return' => true,
],
];
// Show legend.
$inputs[] = [
'id' => 'MGshowLegend',
@ -672,6 +858,124 @@ final class ModuleGraph extends Item
],
];
$inputs[] = [
'label' => __('Sliced mode'),
'id' => 'row_periodicity_chart',
'hidden' => $hiddenModule,
'arguments' => [
'name' => 'periodicityChart',
'id' => 'periodicityChart',
'type' => 'switch',
'value' => $values['periodicityChart'],
'onclick' => 'showPeriodicityOptions(this)',
],
];
// Graph Type.
$fields = [
'line' => __('Line'),
'area' => __('Area'),
];
$inputs[] = [
'label' => __('Graph Type'),
'id' => 'MGgraphType',
'style' => ($values['periodicityChart'] === false) ? '' : 'display:none',
'hidden' => $hiddenModule,
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'graphType',
'selected' => $values['graphType'],
'return' => true,
],
];
$displayPeriodicityChart = ($values['periodicityChart'] === true) ? '' : 'display:none';
$inputs[] = [
'block_id' => 'row_period_type',
'class' => 'flex-row flex-start w100p',
'style' => $displayPeriodicityChart,
'hidden' => $hiddenModule,
'direct' => 1,
'block_content' => [
[
'label' => __('Maximum'),
'arguments' => [
'name' => 'periodMaximum',
'id' => 'periodMaximum',
'type' => 'switch',
'value' => $values['periodMaximum'],
],
],
[
'label' => __('Minimum'),
'arguments' => [
'name' => 'periodMinimum',
'id' => 'periodMinimum',
'type' => 'switch',
'value' => $values['periodMinimum'],
],
],
[
'label' => __('Average'),
'arguments' => [
'name' => 'periodAverage',
'id' => 'periodAverage',
'type' => 'switch',
'value' => $values['periodAverage'],
],
],
[
'label' => __('Summatory'),
'arguments' => [
'name' => 'periodSummatory',
'id' => 'periodSummatory',
'type' => 'switch',
'value' => $values['periodSummatory'],
],
],
],
];
$inputs[] = [
'label' => __('Slice period'),
'id' => 'row_period_slice_chart',
'style' => $displayPeriodicityChart,
'hidden' => $hiddenModule,
'arguments' => [
'name' => 'periodSliceChart',
'type' => 'interval',
'value' => (string) $values['periodSliceChart'],
'custom_fields' => [
SECONDS_1HOUR => __('1 hour'),
SECONDS_1DAY => __('1 day'),
SECONDS_1WEEK => __('1 week'),
SECONDS_1MONTH => __('1 month'),
],
],
];
$optionsPeriodMode = [
CUSTOM_GRAPH_AREA => __('Area'),
CUSTOM_GRAPH_LINE => __('Line'),
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
];
$inputs[] = [
'label' => __('Type chart'),
'id' => 'row_period_mode',
'style' => $displayPeriodicityChart,
'hidden' => $hiddenModule,
'arguments' => [
'type' => 'select',
'fields' => $optionsPeriodMode,
'name' => 'periodMode',
'selected' => $values['periodMode'],
'return' => true,
],
];
// Inputs LinkedVisualConsole.
$inputsLinkedVisualConsole = self::inputsLinkedVisualConsole(
$values

View File

@ -341,6 +341,13 @@ class View extends \HTML
$data['graphType'] = \get_parameter('graphType');
$data['showLegend'] = \get_parameter_switch('showLegend');
$data['period'] = \get_parameter('period');
$data['periodicityChart'] = \get_parameter_switch('periodicityChart');
$data['periodMaximum'] = \get_parameter_switch('periodMaximum');
$data['periodMinimum'] = \get_parameter_switch('periodMinimum');
$data['periodAverage'] = \get_parameter_switch('periodAverage');
$data['periodSummatory'] = \get_parameter_switch('periodSummatory');
$data['periodSliceChart'] = \get_parameter('periodSliceChart');
$data['periodMode'] = \get_parameter('periodMode');
break;
case SIMPLE_VALUE:

Some files were not shown because too many files have changed in this diff Show More