diff --git a/app/add.py b/app/add.py
index a212b0c0..3ead347a 100644
--- a/app/add.py
+++ b/app/add.py
@@ -10,6 +10,11 @@ env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('add.html')
form = cgi.FieldStorage()
+if form.getvalue('add'):
+ c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
+ c["restart"] = form.getvalue('serv')
+ print(c)
+
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
@@ -24,21 +29,20 @@ try:
except:
pass
-output_from_parsed_template = template.render(title = "Add",
- role = sql.get_user_role_by_uuid(user_id.value),
- user = user,
- selects = servers,
- add = form.getvalue('add'),
- conf_add = form.getvalue('conf'),
- group = user_group,
- token = token)
-print(output_from_parsed_template)
-
-hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
-cert_path = sql.get_setting('cert_path')
-haproxy_dir = sql.get_setting('haproxy_dir')
+template = template.render(title = "Add",
+ role = sql.get_user_role_by_uuid(user_id.value),
+ user = user,
+ selects = servers,
+ add = form.getvalue('add'),
+ conf_add = form.getvalue('conf'),
+ group = user_group,
+ token = token)
+print(template)
if form.getvalue('mode') is not None:
+ hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
+ cert_path = sql.get_setting('cert_path')
+ haproxy_dir = sql.get_setting('haproxy_dir')
serv = form.getvalue('serv')
port = form.getvalue('port')
force_close = form.getvalue('force_close')
@@ -189,11 +193,11 @@ if form.getvalue('mode') is not None:
if master[0] != None:
funct.upload_and_restart(master[0], cfg)
- stderr = funct.upload_and_restart(serv, cfg)
+ stderr = funct.upload_and_restart(serv, cfg, just_save="save")
if stderr:
print('
%s
' % stderr)
else:
- print('' % (name, config_add))
+ print('' % (name, config_add, serv))
print('')
diff --git a/app/options.py b/app/options.py
index f42fc383..cfb5e5b2 100644
--- a/app/options.py
+++ b/app/options.py
@@ -15,10 +15,18 @@ backend = form.getvalue('backend')
print('Content-type: text/html\n')
+if act == "checkrestart":
+ servers = sql.get_dick_permit(ip=serv)
+ for server in servers:
+ if server != "":
+ print("ok")
+ sys.exit()
+ sys.exit()
+
if form.getvalue('token') is None:
print("What the fuck?! U r hacker Oo?!")
sys.exit()
-
+
if form.getvalue('getcerts') is not None and serv is not None:
cert_path = sql.get_setting('cert_path')
commands = [ "ls -1t "+cert_path+" |grep pem" ]
diff --git a/app/sql.py b/app/sql.py
index b9fe8b3b..9552b30c 100644
--- a/app/sql.py
+++ b/app/sql.py
@@ -457,6 +457,8 @@ def get_dick_permit(**kwargs):
import os
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_id = cookie.get('uuid')
+ disable = ''
+ ip = ''
con, cur = create_db.get_cur()
sql = """ select * from user where username = '%s' """ % get_user_name_by_uuid(user_id.value)
@@ -466,8 +468,9 @@ def get_dick_permit(**kwargs):
type_ip = "and type_ip = 0"
if kwargs.get('disable') == 0:
disable = 'or enable = 0'
- else:
- disable = ''
+ if kwargs.get('ip'):
+ ip = "and ip = '%s'" % kwargs.get('ip')
+
try:
cur.execute(sql)
@@ -478,7 +481,7 @@ def get_dick_permit(**kwargs):
if group[5] == '1':
sql = """ select * from servers where enable = 1 %s %s """ % (disable, type_ip)
else:
- sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} """.format(group=group[5], disable=disable, type_ip=type_ip)
+ sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} {ip} """.format(group=group[5], disable=disable, type_ip=type_ip, ip=ip)
try:
cur.execute(sql)
except sqltool.Error as e:
diff --git a/app/templates/base.html b/app/templates/base.html
index d2d0dbe3..f0ce8a51 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -192,6 +192,13 @@
{% endif %}
+ {% if role %}
+ {% if role <= 2 %}
+
+ {% endif %}
+ {% endif %}
{% block content %}{% endblock %}
diff --git a/inc/overview.js b/inc/overview.js
index ebe69bf8..bb59b1a5 100644
--- a/inc/overview.js
+++ b/inc/overview.js
@@ -81,6 +81,10 @@ $( function() {
}
});
$('#secIntervals').css('display', 'none');
+ $('#apply_close').click( function() {
+ $("#apply").css('display', 'none');
+ Cookies.remove('restart', { path: '' });
+ });
});
function confirmAjaxAction(action, service, id) {
$( "#dialog-confirm" ).dialog({
@@ -94,6 +98,12 @@ function confirmAjaxAction(action, service, id) {
$( this ).dialog( "close" );
if(service == "hap") {
ajaxActionServers(action, id);
+ if(action == "restart") {
+ if(Cookies.get('restart')) {
+ Cookies.remove('restart', { path: '' });
+ $("#apply").css('display', 'none');
+ }
+ }
} else if (service == "waf") {
ajaxActionWafServers(action, id)
}
diff --git a/inc/script.js b/inc/script.js
index 98b088ae..7b2af799 100644
--- a/inc/script.js
+++ b/inc/script.js
@@ -32,7 +32,32 @@ window.onblur= function() {
}
}
};
-
+if(Cookies.get('restart')) {
+ var ip = Cookies.get('restart');
+ $.ajax( {
+ url: "options.py",
+ data: {
+ act: "checkrestart",
+ serv: ip,
+ token: $('#token').val()
+ },
+ type: "GET",
+ success: function( data ) {
+ if(data.indexOf('ok') != '-1') {
+ $("#apply").css('display', 'block');
+ $("#apply_div").css('width', '850px');
+ if (cur_url[0] == "overview.py") {
+ $("#apply_div").css('width', '650px');
+ $("#apply_div").html("You made changes to the server: "+ip+". Changes will take effect only afterrestartX");
+ $.getScript('/inc/overview.js');
+ } else {
+ $("#apply_div").html("You made changes to the server: "+ip+". Changes will take effect only after restart. Go to Overview page and restartX");
+ $.getScript('/inc/overview.js');
+ }
+ }
+ }
+ } );
+}
function autoRefreshStyle(autoRefresh) {
var margin;
if (cur_url[0] == "overview.py") {
@@ -64,7 +89,7 @@ function autoRefreshStyle(autoRefresh) {
function setRefreshInterval(interval) {
if (interval == "0") {
- Cookies.remove('auto-refresh');
+ Cookies.remove('auto-refresh', { path: '' });
pauseAutoRefresh();
$('.auto-refresh').prepend('
');
$('.auto-refresh').css('margin-top', '-3px');
@@ -156,7 +181,6 @@ function showOverview() {
success: function( data ) {
$("#ajaxstatus").empty();
$("#ajaxstatus").html(data);
- $.getScript('/inc/overview.js');
}
} );
}
@@ -188,7 +212,6 @@ function showOverviewServers() {
type: "GET",
success: function( data ) {
$("#ajaxservers").html(data);
- $.getScript('/inc/overview.js');
}
} );
}
diff --git a/inc/style.css b/inc/style.css
index 587c7603..7b18457a 100644
--- a/inc/style.css
+++ b/inc/style.css
@@ -222,7 +222,7 @@ pre {
padding-left: 10px;
padding-right: 10px;
}
-.line:hover, .line3:hover, tr:hover {
+.line:hover, .line3:hover {
background-color: #f6f8fa;
}
.time-range {
@@ -239,6 +239,9 @@ pre {
.comment {
color: #aaa;
}
+.add-table {
+ width: 100%;
+}
.addName {
background-color: #f6f6f6;
width: 120px;
@@ -269,6 +272,11 @@ pre {
padding-top: 20px;
color: #23527c;
}
+.add-note {
+ width: 30%;
+ padding-left: 10px;
+ font-style: italic;
+}
.tooltip {
font-size: 12px;
padding-bottom: 10px;