2021-04-03 04:10:37 +00:00
{% extends "base.html" %}
2023-09-17 09:42:39 +00:00
{% block title %}{{ lang.p_s_page.p_s_title }}{% endblock %}
{% block h2 %}{{ lang.p_s_page.p_s_title }}{% endblock %}
2021-04-03 04:10:37 +00:00
{% block content %}
{% from 'include/input_macros.html' import input, checkbox, select %}
2023-09-17 09:42:39 +00:00
< script src = "/inc/overview.js" > < / script >
2021-04-03 04:10:37 +00:00
< style >
.alert-danger {
width: 250px;
display: inline-block;
height: 15px;
padding-top: 0px;
padding-bottom: 8px;
margin-bottom: -20px !important;
}
.ui-checkboxradio-label {
padding-bottom: 5px !important;
padding-top: 5px !important;
}
< / style >
2024-01-06 08:42:32 +00:00
{% if user_subscription['user_status'] == 0 %}
2022-04-29 10:28:48 +00:00
{% include 'include/no_sub.html' %}
{% else %}
2024-01-06 08:42:32 +00:00
{% if 'is not installed' in port_scanner or 'ERROR' in port_scanner %}
2021-04-03 04:10:37 +00:00
< div style = "text-align: center;" >
< br / >
2023-09-17 09:42:39 +00:00
< h3 > {{lang.admin_page.desc.no_ansible}} Port scanner {{lang.words.service}}. {{lang.words.read|title()}} < a href = "https://roxy-wi.org/services/portscanner"
2023-02-13 14:45:45 +00:00
title="Port scanner" target="_blank">{{lang.words.here}}< / a > {{lang.phrases.how_to_install}} Port scanner {{lang.words.service}}< / h3 >
2021-04-03 04:10:37 +00:00
< / div >
{% else %}
< div id = "up-pannel" >
2024-01-17 06:08:27 +00:00
{% if user_params['servers']|length == 0 %}
2021-04-03 04:10:37 +00:00
{% include 'include/getstarted.html' %}
{% endif %}
2024-01-17 06:08:27 +00:00
{% for s in user_params['servers'] %}
2021-05-29 15:24:17 +00:00
< div id = "div-server-{{s.0}}" class = "div-server-hapwi
{%- if port_scanner == 'active' %}
div-server-head-up
{%- else %}
div-server-head-down
{%- endif -%}">
2021-04-03 04:10:37 +00:00
< div class = "server-name" >
< input type = "hidden" id = "server-name-{{s.0}}" value = "{{s.1}}" / >
{% for p in port_scanner_settings %}
{% if port_scanner_settings|length > 0 %}
2021-08-02 08:19:22 +00:00
{% if p.server_id == s.0 and p.enabled == 1 %}
2021-04-03 04:10:37 +00:00
{% if port_scanner == 'active' %}
2023-02-13 14:45:45 +00:00
< span id = "portscanner_enable_status-{{p.server_id}}" class = "serverUp server-status" title = "{{lang.p_s_page.desc.is_enabled_and_up}}" > < / span >
2021-04-03 04:10:37 +00:00
{% else %}
2023-02-13 14:45:45 +00:00
< span id = "portscanner_enable_status-{{p.server_id}}" class = "serverDown server-status" title = "{{lang.p_s_page.desc.is_enabled_and_down}}" > < / span >
2021-04-03 04:10:37 +00:00
{% endif %}
2021-08-02 08:19:22 +00:00
{% elif p.server_id == s.0 and p.enabled == 0 %}
2023-02-13 14:45:45 +00:00
< span id = "portscanner_enable_status-{{p.server_id}}" class = "serverNone server-status" title = "Port scanner {{lang.words.is}} {{lang.words.disabled}}" > < / span >
2021-04-03 04:10:37 +00:00
{% endif %}
{% else %}
2023-02-13 14:45:45 +00:00
< span id = "portscanner_enable_status-{{p.server_id}}" class = "serverNone server-status" title = "Port scanner {{lang.words.is}} {{lang.words.disabled}}" > < / span >
2021-04-03 04:10:37 +00:00
{% endif %}
{% endfor %}
2021-08-02 08:19:22 +00:00
{% if s.0 not in port_scanner_settings|map(attribute='server_id') %}
2023-02-13 14:45:45 +00:00
< span id = "portscanner_enable_status-{{s.0}}" class = "serverNone server-status" title = "Port scanner {{lang.words.is}} {{lang.words.disabled}}" > < / span >
2021-04-03 04:10:37 +00:00
{% endif %}
{% if not serv %}
2023-09-17 09:42:39 +00:00
< a href = "/app/portscanner/history/{{s.2}}" title = "{{lang.words.view|title()}} Port scanner {{lang.words.history2}} {{lang.words.for}} {{s.1}}" style = "color: #5d9ceb" > {{s.1}}< / a >
2021-04-03 04:10:37 +00:00
{% else %}
{{s.1}}
{% endif %}
2024-01-17 06:08:27 +00:00
{% if user_params['role'] < = 2 %}
2021-04-03 04:10:37 +00:00
< span class = "server-action" > < / span >
{% endif %}
< / div >
< div class = "server-desc" >
{{s.11}}
< br / >
IP: {{s.2}}
< br / >
2023-02-13 14:45:45 +00:00
{{lang.words.last|title()}} {{lang.words.scan}}:
2021-04-03 04:10:37 +00:00
{% if count_ports is defined %}
{% for c in count_ports %}
{% if c.0 == s.2 %}
{{c.1.0.1}}
{% endif %}
{% endfor %}
{% endif %}
< br / >
2023-02-13 14:45:45 +00:00
{{lang.p_s_page.desc.total_open_ports}}:
2021-04-03 04:10:37 +00:00
{% if count_ports is defined %}
{% for c in count_ports %}
{% if c.0 == s.2 %}
{{c.1.0.0}}
{% endif %}
{% endfor %}
{% endif %}
< br / >
< / div >
< div class = "server-act-links" id = "server-{{s.0}}" >
2024-01-17 06:08:27 +00:00
{% if user_params['role'] < = 2 %}
2021-04-03 04:10:37 +00:00
{% set portscanner_enable_id = 'portscanner_enable-' + s.0|string() %}
{% set portscanner_notify_id = 'portscanner_notify-' + s.0|string() %}
{% set portscanner_history_id = 'portscanner_history-' + s.0|string() %}
{% if port_scanner_settings|length > 0 %}
{% for p in port_scanner_settings %}
2021-08-02 08:19:22 +00:00
{% if p.server_id == s.0 %}
2021-04-03 04:10:37 +00:00
{% set disabled = 'false' %}
2021-08-02 08:19:22 +00:00
{% if p.enabled == 0 %}
2021-04-03 04:10:37 +00:00
{% set disabled = 'true' %}
{% endif %}
2021-08-02 08:19:22 +00:00
{% if p.enabled == 1 %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_enable_id, title="Port scanner "+lang.words.enabled, checked='checked', desc='Port scanner') }}
2021-04-03 04:10:37 +00:00
{% else %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_enable_id, title="Port scanner "+lang.words.disabled, desc='Port scanner') }}
2021-04-03 04:10:37 +00:00
{% endif %}
2021-08-02 08:19:22 +00:00
{% if p.notify == 1 %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_notify_id, title=lang.words.notification|title()+" "+ lang.words.via +" Telegram/Slack "+lang.words.enabled, checked='checked', desc=lang.words.notify|title()) }}
2021-04-03 04:10:37 +00:00
{% else %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_notify_id, title=lang.words.notification|title()+" "+ lang.words.via +" Telegram/Slack "+lang.words.disabled, desc=lang.words.notify|title(), disabled=disabled) }}
2021-04-03 04:10:37 +00:00
{% endif %}
2021-08-02 08:19:22 +00:00
{% if p.history == 1 %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_history_id, title=lang.words.keeping|title()+" "+ lang.words.history3 + " "+lang.words.enabled, checked='checked', desc=lang.words.keep|title()+' '+lang.words.history2) }}
2021-04-03 04:10:37 +00:00
{% else %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_history_id, title=lang.words.keeping|title()+" "+ lang.words.history3 + " "+lang.words.disabled, desc=lang.words.keep|title()+' '+lang.words.history2, disabled=disabled) }}
2021-04-03 04:10:37 +00:00
{% endif %}
{% endif %}
{% endfor %}
2021-08-02 08:19:22 +00:00
{% if s.0 not in port_scanner_settings|map(attribute='server_id') %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_enable_id, title="Port scanner "+lang.words.disabled, desc='Port scanner') }}
{{ checkbox(portscanner_notify_id, title=lang.words.notification|title()+" "+ lang.words.via +" Telegram/Slack "+lang.words.disabled, desc=lang.words.notify|title(), disabled='true') }}
{{ checkbox(portscanner_history_id, title=lang.words.keeping|title()+" "+ lang.words.history3 + " "+lang.words.disabled, desc=lang.words.keep|title()+' '+lang.words.history2, disabled='true') }}
2021-04-03 04:10:37 +00:00
{% endif %}
{% else %}
2023-02-13 14:45:45 +00:00
{{ checkbox(portscanner_enable_id, title="Port scanner "+lang.words.disabled, desc='Port scanner') }}
{{ checkbox(portscanner_notify_id, title=lang.words.notification|title()+" "+ lang.words.via +""+lang.words.disabled, desc=lang.words.notify|title(), disabled='true') }}
{{ checkbox(portscanner_history_id, title=lang.words.keeping|title()+" "+ lang.words.history3 + " "+lang.words.disabled, desc=lang.words.keep|title()+' '+lang.words.history2, disabled='true') }}
2021-04-03 04:10:37 +00:00
{% endif %}
{% endif %}
< br / >
2023-02-13 14:45:45 +00:00
< button onclick = "scanPorts('{{s.0}}')" title = "{{lang.p_s_page.desc.scanning_ports}} {{s.1}}" > {{lang.words.run|title()}} {{lang.words.scan}}< / button >
2021-04-03 04:10:37 +00:00
< / div >
< / div >
{% endfor %}
< / div >
2024-01-06 08:42:32 +00:00
< div class = "add-note addName alert-info" style = "width: inherit; margin-right: 15px; margin-top: 45%;clear: both;" >
2023-02-13 14:45:45 +00:00
{{lang.words.read|title()}} {{lang.words.about}} Port scanner {{lang.words.service}} {{lang.words.in}} {{lang.words.this2}} < a href = "https://roxy-wi.org/services/portscanner" title = "The Port scanner service description" target = "_blank" > {{lang.words.article}}< / a >
2021-04-03 04:10:37 +00:00
< / div >
{% endif %}
< div id = "show_scans_ports" style = "display: none; padding: 0;" >
< div id = "show_scans_ports_body" > < / div >
< / div >
< script >
function scanPorts(id) {
$.ajax({
2023-09-17 09:42:39 +00:00
url: "/app/portscanner/scan/" + id,
// data: {
// token: $('#token').val()
// },
// type: "POST",
2021-04-03 04:10:37 +00:00
success: function (data) {
data = data.replace(/\s+/g, ' ');
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
toastr.clear();
$("#show_scans_ports_body").html(data);
2023-02-13 14:45:45 +00:00
var close_word = $('#translate').attr('data-close');
2023-09-17 09:42:39 +00:00
$("#show_scans_ports").dialog({
2021-04-03 04:10:37 +00:00
resizable: false,
height: "auto",
width: 360,
modal: true,
2023-02-13 14:45:45 +00:00
title: "{{lang.words.opened|title()}} {{lang.words.ports}}",
buttons: [{
text: close_word,
2023-09-17 09:42:39 +00:00
click: function () {
$(this).dialog("close");
2021-04-03 04:10:37 +00:00
$("#show_scans_ports_body").html('');
}
2023-02-13 14:45:45 +00:00
}]
2021-04-03 04:10:37 +00:00
});
}
}
2023-09-17 09:42:39 +00:00
});
2021-04-03 04:10:37 +00:00
}
$( ".server-act-links" ).change(function() {
var id = $(this).attr('id').split('-');
updatePortScannerSettings(id[1])
});
function updatePortScannerSettings(id) {
var portscanner_enabled = 0;
var portscanner_notify = 0;
var portscanner_history = 0;
if ($('#portscanner_enable-'+id).is(':checked')) {
portscanner_enabled = '1';
$('#portscanner_enable_status-'+id).removeClass('serverDown');
$('#portscanner_enable_status-'+id).removeClass('serverNone');
$('#portscanner_enable_status-'+id).addClass('serverUp');
}
if (portscanner_enabled == '0') {
$('#portscanner_enable_status-'+id).removeClass('serverDown');
$('#portscanner_enable_status-'+id).removeClass('serverUp');
$('#portscanner_enable_status-'+id).addClass('serverNone');
}
if ($('#portscanner_notify-'+id).is(':checked')) {
portscanner_notify = '1';
}
if ($('#portscanner_history-'+id).is(':checked')) {
portscanner_history = '1';
}
if (portscanner_enabled == '1') {
$('#portscanner_notify-'+id).checkboxradio('enable');
$('#portscanner_history-'+id).checkboxradio('enable');
}
if (portscanner_enabled == '0') {
$('#portscanner_notify-'+id).checkboxradio('disable');
$('#portscanner_history-'+id).checkboxradio('disable');
}
2023-09-17 09:42:39 +00:00
$.ajax({
url: "/app/portscanner/settings",
2021-04-03 04:10:37 +00:00
data: {
2023-09-17 09:42:39 +00:00
server_id: id,
enabled: portscanner_enabled,
notify: portscanner_notify,
history: portscanner_history,
2021-04-03 04:10:37 +00:00
token: $('#token').val()
},
type: "POST",
2023-09-17 09:42:39 +00:00
success: function (data) {
data = data.replace(/\s+/g, ' ');
2021-04-03 04:10:37 +00:00
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
toastr.clear();
2023-09-17 09:42:39 +00:00
$("#server-" + id).addClass("update", 1000);
setTimeout(function () {
$("#server-" + id).removeClass("update");
}, 2500);
2021-04-03 04:10:37 +00:00
}
}
} );
}
< / script >
2022-04-29 10:28:48 +00:00
{% endif %}
2021-04-03 04:10:37 +00:00
{% endblock %}