Pavel Loginov 2020-06-15 19:29:49 +02:00
parent 7418694384
commit 0079b79c95
11 changed files with 10675 additions and 113 deletions

View File

@ -505,7 +505,7 @@ def update_db_v_4_3_1(**kwargs):
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: pos' or e == " 1060 (42S21): Duplicate column name 'pos' ":
print('DB was update to 4.3.1')
print('Updating... go to version 4.3.2')
else:
print("An error occurred:", e)
return False
@ -516,9 +516,31 @@ def update_db_v_4_3_1(**kwargs):
con.close()
def update_db_v_4_3_2(**kwargs):
con, cur = get_cur()
sql = """
INSERT INTO settings (param, value, section, `desc`) values('ldap_type', '0', 'ldap', 'If 0 then will be used LDAP, if 1 then will be used LDAPS ');
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: pos' or e == " 1060 (42S21): Duplicate column name 'pos' ":
print('DB was update to 4.3.2')
else:
print("An error occurred:", e)
return False
else:
print("DB was update to 4.3.2")
return True
cur.close()
con.close()
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '4.3.1.0'; """
sql = """update version set version = '4.3.2.0'; """
try:
cur.execute(sql)
con.commit()
@ -546,6 +568,7 @@ def update_all():
update_db_v_4_3()
update_db_v_4_3_0()
update_db_v_4_3_1()
update_db_v_4_3_2()
update_ver()
@ -567,6 +590,7 @@ def update_all_silent():
update_db_v_4_3(silent=1)
update_db_v_4_3_0(silent=1)
update_db_v_4_3_1(silent=1)
update_db_v_4_3_2(silent=1)
update_ver()

View File

@ -743,11 +743,18 @@ def check_haproxy_config(serv):
def show_log(stdout, **kwargs):
i = 0
out = ''
if kwargs.get('grep'):
import re
grep = kwargs.get('grep')
grep = re.sub(r'[?|$|.|!|^|*|\]|\[|,| |]',r'', grep)
for line in stdout:
if kwargs.get("html") != 0:
i = i + 1
if kwargs.get('grep'):
line = line.replace(grep, '<span style="color: red; font-weight: bold;">'+grep+'</span>');
line_class = "line3" if i % 2 == 0 else "line"
out += '<div class="'+line_class+'">' + escape_html(line) + '</div>'
out += '<div class="'+line_class+'">' + line + '</div>'
else:
out += line
@ -756,39 +763,76 @@ def show_log(stdout, **kwargs):
def show_haproxy_log(serv, rows=10, waf='0', grep=None, hour='00', minut='00', hour1='24', minut1='00', service='haproxy', **kwargs):
import sql
exgrep = form.getvalue('exgrep')
date = hour+':'+minut
date1 = hour1+':'+minut1
if grep is not None:
grep_act = '|grep'
grep_act = '|egrep "%s"' % grep
else:
grep_act = ''
grep = ''
syslog_server_enable = sql.get_setting('syslog_server_enable')
if syslog_server_enable is None or syslog_server_enable == "0":
if service == 'nginx':
local_path_logs = sql.get_setting('nginx_path_error_logs')
commands = [ "sudo cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, grep) ]
else:
local_path_logs = sql.get_setting('local_path_logs')
commands = [ "sudo cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, grep) ]
syslog_server = serv
if exgrep is not None:
exgrep_act = '|egrep -v "%s"' % exgrep
else:
commands = [ "sudo cat /var/log/%s/syslog.log | sed '/ %s:00/,/ %s:00/! d' |tail -%s %s %s" % (serv, date, date1, rows, grep_act, grep) ]
syslog_server = sql.get_setting('syslog_server')
if waf == "1":
local_path_logs = '/var/log/modsec_audit.log'
commands = [ "sudo cat %s |tail -%s %s %s" % (local_path_logs, rows, grep_act, grep) ]
if kwargs.get('html') == 0:
a = ssh_command(syslog_server, commands)
return show_log(a, html=0)
else:
return ssh_command(syslog_server, commands, show_log='1')
exgrep_act = ''
if service == 'nginx' or service == 'haproxy':
syslog_server_enable = sql.get_setting('syslog_server_enable')
if syslog_server_enable is None or syslog_server_enable == "0":
if service == 'nginx':
local_path_logs = sql.get_setting('nginx_path_error_logs')
commands = [ "sudo cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, exgrep_act) ]
else:
local_path_logs = sql.get_setting('local_path_logs')
commands = [ "sudo cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, date, date1, rows, grep_act, exgrep_act) ]
syslog_server = serv
else:
commands = [ "sudo cat /var/log/%s/syslog.log | sed '/ %s:00/,/ %s:00/! d' |tail -%s %s %s %s" % (serv, date, date1, rows, grep_act, grep, exgrep_act) ]
syslog_server = sql.get_setting('syslog_server')
if waf == "1":
local_path_logs = '/var/log/modsec_audit.log'
commands = [ "sudo cat %s |tail -%s %s %s" % (local_path_logs, rows, grep_act, exgrep_act) ]
if kwargs.get('html') == 0:
a = ssh_command(syslog_server, commands)
return show_log(a, html=0, grep=grep)
else:
return ssh_command(syslog_server, commands, show_log='1', grep=grep)
elif service == 'apache':
apache_log_path = sql.get_setting('apache_log_path')
if serv == 'haproxy-wi.access.log':
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, exgrep_act)
elif serv == 'haproxy-wi.error.log':
cmd="cat %s| awk '$4>\"%s:00\" && $4<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, exgrep_act)
elif serv == 'fail2ban.log':
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % ("/var/log/"+serv, date, date1, rows, grep_act, exgrep_act)
output, stderr = subprocess_execute(cmd)
return show_log(output, grep=grep)
elif service == 'internal':
log_path = get_config_var('main', 'log_path')
logs_files = get_files(log_path, format="log")
for key, value in logs_files:
if int(serv) == key:
serv = value
break
else:
print('Haha')
sys.exit()
if serv == 'backup.log':
cmd="cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (log_path + serv, date, date1, rows, grep_act, exgrep_act)
else:
cmd="cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (log_path + serv, date, date1, rows, grep_act, exgrep_act)
output, stderr = subprocess_execute(cmd)
return show_log(output, grep=grep)
def haproxy_wi_log(**kwargs):
log_path = get_config_var('main', 'log_path')
@ -837,7 +881,7 @@ def ssh_command(serv, commands, **kwargs):
if kwargs.get("ip") == "1":
show_ip(stdout)
elif kwargs.get("show_log") == "1":
return show_log(stdout)
return show_log(stdout, grep=kwargs.get("grep"))
elif kwargs.get("server_status") == "1":
server_status(stdout)
elif kwargs.get('print_out'):
@ -1000,7 +1044,7 @@ def out_error(e):
error = e
else:
error = e.args[0]
print('<span class="alert alert-danger" style="height: 20px;margin-bottom: 20px;" id="error">An error occurred: ' + error + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
print(error)
def get_users_params(**kwargs):

View File

@ -87,8 +87,11 @@ def check_in_ldap(user, password):
domain = sql.get_setting('ldap_domain')
ldap_search_field = sql.get_setting('ldap_search_field')
ldap_user_attribute = sql.get_setting('ldap_user_attribute')
ldap_type = sql.get_setting('ldap_type')
l = ldap.initialize('ldap://{}:{}/'.format(server, port))
ldap_proto = 'ldap' if ldap_type == "0" else 'ldaps'
l = ldap.initialize('{}://{}:{}/'.format(ldap_proto,server, port))
try:
l.protocol_version = ldap.VERSION3
l.set_option(ldap.OPT_REFERRALS, 0)

View File

@ -10,10 +10,16 @@ if form.getvalue('grep') is None:
else:
grep = form.getvalue('grep')
exgrep = form.getvalue('exgrep') if form.getvalue('exgrep') else ''
if form.getvalue('rows') is None:
rows = 10
else:
rows = form.getvalue('rows')
if form.getvalue('rows1') not is None:
rows = form.getvalue('rows1')
else:
rows = form.getvalue('rows')
hour = form.getvalue('hour')
hour1 = form.getvalue('hour1')
@ -46,6 +52,7 @@ template = template.render(h2 = 1,
serv = form.getvalue('serv'),
rows = rows,
grep = grep,
exgrep = exgrep,
hour = hour,
hour1 = hour1,
minut = minut,

View File

@ -552,9 +552,7 @@ if serv is not None and act == "stats":
servers_with_status.append(h)
template = template.render(out=servers_with_status)
print(template)
print(template)
else:
print(data.decode('utf-8'))
@ -579,65 +577,20 @@ if serv is not None and form.getvalue('rows1') is not None:
minut = form.getvalue('minut')
hour1 = form.getvalue('hour1')
minut1 = form.getvalue('minut1')
date = hour+':'+minut
date1 = hour1+':'+minut1
apache_log_path = sql.get_setting('apache_log_path')
if grep is not None:
grep_act = '|grep'
else:
grep_act = ''
grep = ''
if serv == 'haproxy-wi.access.log':
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, grep)
elif serv == 'haproxy-wi.error.log':
cmd="cat %s| awk '$4>\"%s:00\" && $4<\"%s:00\"' |tail -%s %s %s" % (apache_log_path+"/"+serv, date, date1, rows, grep_act, grep)
elif serv == 'fail2ban.log':
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % ("/var/log/"+serv, date, date1, rows, grep_act, grep)
output, stderr = funct.subprocess_execute(cmd)
print(funct.show_log(output))
print(stderr)
out = funct.show_haproxy_log(serv, rows=rows, waf='0', grep=grep, hour=hour, minut=minut, hour1=hour1, minut1=minut1, service='apache')
print(out)
if form.getvalue('viewlogs') is not None:
viewlog = form.getvalue('viewlogs')
log_path = funct.get_config_var('main', 'log_path')
viewlog = form.getvalue('viewlogs')
rows = form.getvalue('rows')
grep = form.getvalue('grep')
hour = form.getvalue('hour')
minut = form.getvalue('minut')
hour1 = form.getvalue('hour1')
minut1 = form.getvalue('minut1')
date = hour+':'+minut
date1 = hour1+':'+minut1
if grep is not None:
grep_act = '|grep'
else:
grep_act = ''
grep = ''
logs_files = funct.get_files(log_path, format="log")
for key, value in logs_files:
if int(viewlog) == key:
viewlog = value
break
else:
print('Haha')
sys.exit()
if viewlog == 'backup.log':
cmd="cat %s| awk '$2>\"%s:00\" && $2<\"%s:00\"' |tail -%s %s %s" % (log_path + viewlog, date, date1, rows, grep_act, grep)
else:
cmd="cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (log_path + viewlog, date, date1, rows, grep_act, grep)
output, stderr = funct.subprocess_execute(cmd)
print(funct.show_log(output))
print(stderr)
out = funct.show_haproxy_log(serv=viewlog, rows=rows, waf='0', grep=grep, hour=hour, minut=minut, hour1=hour1, minut1=minut1, service='internal')
print(out)
if serv is not None and act == "showMap":

View File

@ -0,0 +1,349 @@
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
direction: ltr;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-fat-cursor-mark {
background-color: rgba(20, 255, 20, 0.5);
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: 0;
overflow: hidden;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 50px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -50px; margin-right: -50px;
padding-bottom: 50px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 50px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -50px;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre.CodeMirror-line,
.CodeMirror-wrap pre.CodeMirror-line-like {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: 0.1px; /* Force widget margins to stay inside of the container */
}
.CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, .4);
}
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }

9844
inc/codemirror/codemirror.js Normal file

File diff suppressed because it is too large Load Diff

179
inc/codemirror/haproxy.js Normal file
View File

@ -0,0 +1,179 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Modified for HAProxy by HAProxy-WI
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("haproxy", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var keywords = words(
/* hapDirectiveControl */ "abuse" +
/* hapDirective */ " log chroot maxconn user group pidfile stats mode option bind retries stats total max balance acl tcp http filter stick tcp timeout daemon table request"
);
var keywords_block = words(
/* hapDirectiveBlock */ "server default_backend use_backend if geo map check ! http roundrobin leastconect queue connect client server forwardfor deny accept socket httplog except redispatch gt ge or and eq ln reject dontlognull admin auth"
);
var keywords_important = words(
/*hapDirectiveImportant */ "listen backend frontend peers cache global defaults userlist"
);
var indentUnit = config.indentUnit, type;
function ret(style, tp) {type = tp; return style;}
function tokenBase(stream, state) {
stream.eatWhile(/[\w\$_]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
return "keyword";
}
else if (keywords_block.propertyIsEnumerable(cur)) {
return "variable-2";
}
else if (keywords_important.propertyIsEnumerable(cur)) {
return "string-2";
}
/**/
var ch = stream.next();
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
else if (ch == "/" && stream.eat("*")) {
state.tokenize = tokenCComment;
return tokenCComment(stream, state);
}
else if (ch == "<" && stream.eat("!")) {
state.tokenize = tokenSGMLComment;
return tokenSGMLComment(stream, state);
}
else if (ch == "=") ret(null, "compare");
else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
else if (ch == "\"" || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
else if (ch == "#") {
stream.skipToEnd();
return ret("comment", "comment");
}
else if (ch == "!") {
stream.match(/^\s*\w*/);
return ret("keyword", "important");
}
else if (/\d/.test(ch)) {
stream.eatWhile(/[\w.%]/);
return ret("number", "unit");
}
else if (/[,.+>*\/]/.test(ch)) {
return ret(null, "select-op");
}
else if (/[;{}:\[\]]/.test(ch)) {
return ret(null, ch);
}
else {
stream.eatWhile(/[\w\\\-]/);
return ret("variable", "variable");
}
}
function tokenCComment(stream, state) {
var maybeEnd = false, ch;
while ((ch = stream.next()) != null) {
if (maybeEnd && ch == "/") {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "*");
}
return ret("comment", "comment");
}
function tokenSGMLComment(stream, state) {
var dashes = 0, ch;
while ((ch = stream.next()) != null) {
if (dashes >= 2 && ch == ">") {
state.tokenize = tokenBase;
break;
}
dashes = (ch == "-") ? dashes + 1 : 0;
}
return ret("comment", "comment");
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, ch;
while ((ch = stream.next()) != null) {
if (ch == quote && !escaped)
break;
escaped = !escaped && ch == "\\";
}
if (!escaped) state.tokenize = tokenBase;
return ret("string", "string");
};
}
return {
startState: function(base) {
return {tokenize: tokenBase,
baseIndent: base || 0,
stack: []};
},
token: function(stream, state) {
if (stream.eatSpace()) return null;
type = null;
var style = state.tokenize(stream, state);
var context = state.stack[state.stack.length-1];
if (type == "hash" && context == "rule") style = "atom";
else if (style == "variable") {
if (context == "rule") style = "number";
else if (!context || context == "@media{") style = "tag";
}
if (context == "rule" && /^[\{\};]$/.test(type))
state.stack.pop();
if (type == "{") {
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
else state.stack.push("{");
}
else if (type == "}") state.stack.pop();
else if (type == "@media") state.stack.push("@media");
else if (context == "{" && type != "comment") state.stack.push("rule");
return style;
},
indent: function(state, textAfter) {
var n = state.stack.length;
if (/^\}/.test(textAfter))
n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
return state.baseIndent + n * indentUnit;
},
electricChars: "}"
};
});
CodeMirror.defineMIME("text/x-haproxy-conf", "haproxy");
});

178
inc/codemirror/nginx.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -296,6 +296,7 @@ function showLog() {
}
var rows = $('#rows').val()
var grep = $('#grep').val()
var exgrep = $('#exgrep').val()
var hour = $('#time_range_out_hour').val()
var minut = $('#time_range_out_minut').val()
var hour1 = $('#time_range_out_hour1').val()
@ -308,6 +309,7 @@ function showLog() {
serv: $("#serv").val(),
waf: waf,
grep: grep,
exgrep: exgrep,
hour: hour,
minut: minut,
hour1: hour1,
@ -320,6 +322,7 @@ function showLog() {
$("#ajax").html(data);
window.history.pushState("Logs", "Logs", cur_url[0]+"?service="+service+"&serv="+$("#serv").val()+
'&rows='+rows+
'&exgrep='+exgrep+
'&grep='+grep+
'&hour='+hour+
'&minut='+minut+
@ -349,27 +352,6 @@ function showMap() {
}
} );
}
function showRuntime() {
if($('#save').prop('checked')) {
saveCheck = "on";
} else {
saveCheck = "";
}
$.ajax( {
url: "options.py",
data: {
servaction: $('#servaction').val(),
serv: $("#serv").val(),
servbackend: $("#servbackend").val(),
save: saveCheck,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
$("#ajaxruntime").html(data);
}
} );
}
function showCompare() {
$.ajax( {
url: "options.py",
@ -467,6 +449,7 @@ function viewLogs() {
} else {
var rows = $('#rows').val()
var grep = $('#grep').val()
var exgrep = $('#exgrep').val()
var hour = $('#time_range_out_hour').val()
var minut = $('#time_range_out_minut').val()
var hour1 = $('#time_range_out_hour1').val()
@ -482,6 +465,7 @@ function viewLogs() {
viewlogs: viewlogs,
rows: rows,
grep: grep,
exgrep: exgrep,
hour: hour,
minut: minut,
hour1: hour1,
@ -494,6 +478,7 @@ function viewLogs() {
window.history.pushState("View logs", "View logs", cur_url[0]+"?viewlogs="+viewlogs+
'&rows='+rows+
'&grep='+grep+
'&exgrep='+exgrep+
'&hour='+hour+
'&minut='+minut+
'&hour1='+hour1+
@ -699,11 +684,6 @@ $( function() {
}
} );
});
$('#runtimeapiform').submit(function() {
showRuntime();
return false;
});
$('#auth').submit(function() {
let searchParams = new URLSearchParams(window.location.search)
if(searchParams.has('ref')) {

View File

@ -371,7 +371,6 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/^\s+|\s+$/g,'');
console.log(data)
if(data == 'Active:') {
$('#cur_haproxy_exp_ver').text('HAProxy expoter is installed');
$('#haproxy_exp_install').text('Update');
@ -395,7 +394,6 @@ $( function() {
type: "POST",
success: function( data ) {
data = data.replace(/^\s+|\s+$/g,'');
console.log(data)
if(data == 'Active:') {
$('#cur_nginx_exp_ver').text('Nginx expoter is installed');
$('#nginx_exp_install').text('Update');
@ -1582,6 +1580,7 @@ function updateBackup(id) {
function showApacheLog(serv) {
var rows = $('#rows').val()
var grep = $('#grep').val()
var exgrep = $('#exgrep').val()
var hour = $('#time_range_out_hour').val()
var minut = $('#time_range_out_minut').val()
var hour1 = $('#time_range_out_hour1').val()
@ -1592,6 +1591,7 @@ function showApacheLog(serv) {
rows1: rows,
serv: serv,
grep: grep,
exgrep: exgrep,
hour: hour,
minut:minut,
hour1: hour1,
@ -1602,6 +1602,7 @@ function showApacheLog(serv) {
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Logs", "Logs", cur_url[0]+"?serv="+serv+"&rows1="+rows+"&grep="+grep+
'&exgrep='+exgrep+
'&hour='+hour+
'&minut='+minut+
'&hour1='+hour1+