pull/19/head
Aidaho12 2018-02-27 19:39:24 +06:00
parent 6854bcda33
commit 209650f914
9 changed files with 79 additions and 42 deletions

View File

@ -277,7 +277,7 @@ print('</select>'
'<td class="addName">IP and Port:</td>'
'<td class="addOption">'
'<input type="text" name="ip" id="ip1" size="15" placeholder="172.28.0.1" class="form-control"><b>:</b>'
'<input type="number" name="port" required title="Port for bind listner" size="5" placeholder="8080" class="form-control">'
'<input type="number" name="port" required title="Port for bind listner" placeholder="8080" class="form-control">'
'<div class="tooltip tooltipTop">IP for bind listner, <b>if empty will be assignet on all IPs</b>. Start typing ip, or press down.</div>'
'</td>'
'</tr>'

View File

@ -37,9 +37,8 @@ def logging(serv, action):
now_utc = datetime.now(timezone(time_zone))
IP = cgi.escape(os.environ["REMOTE_ADDR"])
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
firstName = cookie.get('FirstName')
lastName = cookie.get('LastName')
mess = now_utc.strftime(dateFormat) + " from " + IP + " user: " + firstName.value + " " + lastName.value + " " + action + " for: " + serv + "\n"
login = cookie.get('login')
mess = now_utc.strftime(dateFormat) + " from " + IP + " user: " + login.value + " " + action + " for: " + serv + "\n"
log = open(fullpath + "log/config_edit.log", "a")
log.write(mess)
log.close
@ -57,11 +56,15 @@ def telegram_send_mess(mess):
bot = telegram.Bot(token=token_bot, request=pp)
bot.send_message(chat_id=channel_name, text=mess)
def check_login():
def check_login(**kwargs):
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
login = cookie.get('login')
role = cookie.get('role')
ref = os.environ.get("SCRIPT_NAME")
if kwargs.get("admins_area") == "1" and role.value != "admin":
print('<meta http-equiv="refresh" content="0; url=/">')
if login is None:
print('<meta http-equiv="refresh" content="0; url=login.py?ref=%s">' % ref)
@ -161,8 +164,8 @@ def footer():
print('</center></div>'
'<center>'
'<h3>'
'<a href="#top" title="UP">UP</a>'
'</h3>'
'<a class="ui-button ui-widget ui-corner-all" href="#top" title="Move up">UP</a>'
'</h3><br />'
'</center>'
'<div class="footer">'
'<div class="footer-link">'
@ -414,7 +417,7 @@ def choose_only_select(serv, **kwargs):
print('<option value="%s" %s>%s</option>' % (listhap.get(i), selected, i))
def chooseServer(formName, title, note):
print('<center><h2>' + title + '</h2>')
print('<h2>' + title + '</h2><center>')
print('<h3>Choose server</h3>')
print('<form action=' + formName + ' method="get">')
print('<p><select autofocus required name="serv" id="chooseServer">')

View File

@ -1,3 +1,3 @@
{ "name": "admin", "lists": "all" }
{ "name": "all", "lists": "all" }
{ "name": "mysql", "lists": "mysql" }
{ "name": "web", "lists": "web" }

View File

@ -41,8 +41,6 @@ def login_page(error):
if form.getvalue('logout') is not None:
print("Set-cookie: login=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
print("Set-cookie: FirstName=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
print("Set-cookie: LastName=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
print("Set-cookie: role=; expires=Wed May 18 03:33:20 2003; path=/cgi-bin/; httponly")
print("Content-type: text/html\n")
print('<meta http-equiv="refresh" content="0; url=/">')
@ -58,15 +56,12 @@ if login is not None and password is not None:
c["login"] = login
c["login"]["path"] = "/cgi-bin/"
c["login"]["expires"] = "Wed May 18 03:33:20 2033"
c["FirstName"] = users['firstName']
c["FirstName"]["path"] = "/cgi-bin/"
c["FirstName"]["expires"] = "Wed May 18 03:33:20 2033"
c["LastName"] = users['lastName']
c["LastName"]["path"] = "/cgi-bin/"
c["LastName"]["expires"] = "Wed May 18 03:33:20 2033"
c["role"] = users['role']
c["role"]["path"] = "/cgi-bin/"
c["role"]["expires"] = "Wed May 18 03:33:20 2033"
c["group"] = users['group']
c["group"]["path"] = "/cgi-bin/"
c["group"]["expires"] = "Wed May 18 03:33:20 2033"
print(c)
if form.getvalue('ref') is None:
ref = "/index.html"

View File

@ -18,9 +18,7 @@ path_config = "haproxy-webintarface.config"
config = configparser.ConfigParser()
config.read(path_config)
print('<center>'
'<h2>HAproxy Logs</h2>'
'</center>'
print('<h2>HAproxy Logs</h2>'
'<table class="overview">'
'<tr class="overviewHead">'
'<td class="padding10">Server</td>'
@ -52,8 +50,14 @@ print('</td><td><input type="number" name="rows" %s class="form-control" require
print('<td><input type="text" name="grep" class="form-control" %s >' % grep)
print('</td>'
'<td class="padding10" >'
'<button type="submit">Show</button>'
'</td>'
'<button type="submit">Show</button>')
if form.getvalue('serv') is not None:
print('<span style="float: right; margin-top: 8px;">'
'<a href="" title="Update logs" id="update">'
'<img alt="Update" src="/image/pic/update.png" style="max-width: 20px;">'
'</a>'
'</span>')
print('</td>'
'</form>'
'</tr></table>')

View File

@ -27,11 +27,11 @@ print('<h2>Quick Status </h2>'
if funct.is_admin():
print('<tr class="overviewHead">'
'<td class="padding10">User name</td>'
'<td class="padding10">Login</td>'
'<td>Group</td>'
'<td class="padding10">'
'Role'
'<!--<span class="add-button" title="Just a button, do nothing )">+ Add </span>-->'
'</td><td style="width: 200px;">'
'<span class="add-button">'
'<a href="#" title="Show all users" id="show-all-users" style="color: #fff">'
'Show all'
@ -47,10 +47,10 @@ if funct.is_admin():
users = json.loads(f)
if i is 4:
style = 'style="display: none;" class="show-users"'
print('<tr ' + style + '><td class="padding10">' + users['firstName'] + ' ' + users['lastName'] +'</td><td>')
print('<tr ' + style + '><td class="padding10">' + users['login'] +'</td><td>')
print(users['group']+'</td><td>')
print(users['role'])
print('</td></tr>')
print('</td><td></td></tr>')
print('<tr class="overviewHead">'
'<td class="padding10">Server</td>'
@ -59,10 +59,11 @@ print('<tr class="overviewHead">'
'</td>'
'<td class="padding10">'
'Action'
'<!--<span class="add-button" title="Just a button, do nothing )">+ Add</span>-->'
'<a href="" title="Update status" id="update">'
'<img alt="Update" src="/image/pic/update.png" class="icon" style="margin-left: 20px; float: right">'
'</a></span>'
'</td>'
'<td>'
'<a href="" title="Update status" id="update">'
'<img alt="Update" src="/image/pic/update.png" class="icon" style="padding-right: 8px; float: right">'
'</a></span>'
'</td>'
'</tr>')
@ -70,16 +71,16 @@ listhap = funct.get_dick_after_permit()
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
for i in sorted(listhap):
print('<tr><td class="padding10">' + i + '</td><td>')
print('<tr><td class="padding10"><a href="#%s" title="Go to %s status" style="color: #000">%s</a></td><td>' % (i, i, i))
funct.ssh_command(listhap.get(i), commands, server_status="1")
print('</td><td>')
print('<a href="/cgi-bin/configshow.py?serv=%s&open=open#conf" title="Show config"><img src=/image/pic/show.png alt="show" class="icon"></a>' % listhap.get(i))
print('<a href="/cgi-bin/config.py?serv=%s&open=open#conf" title="Edit config"><img src=/image/pic/edit.png alt="edit" class="icon"></a>' % listhap.get(i))
print('<a href="/cgi-bin/diff.py?serv=%s&open=open#diff" title="Compare config"><img src=/image/pic/compare.png alt="compare" class="icon"></a>' % listhap.get(i))
print('<a href="/cgi-bin/map.py?serv=%s&open=open#map" title="Map listen/frontend/backend"><img src=/image/pic/map.png alt="map" class="icon"></a>' % listhap.get(i))
print('</td></tr>')
print('</td><td></td></tr>')
print('</table><table><tr class="overviewHead">'
print('</table><table class="overview"><tr class="overviewHead">'
'<td class="padding10">Server</td>'
'<td class="padding10">'
'Server status'
@ -87,12 +88,13 @@ print('</table><table><tr class="overviewHead">'
'<a href="" title="Update status" id="update">'
'<img alt="Update" src="/image/pic/update.png" style="max-width: 20px;">'
'</a>'
'</span>'
'</td>'
'</tr>')
print('</td></tr>')
commands = [ "cat /etc/haproxy/haproxy.cfg |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l", "uname -smor", "haproxy -v |head -1", "top -u haproxy -b -n 1" ]
for i in sorted(listhap):
print('<tr><td class="overviewTr"><h3 title="IP ' + listhap.get(i) + '">' + i + ':</h3></td>')
print('<tr><td class="overviewTr"><a name="'+i+'"></a><h3 title="IP ' + listhap.get(i) + '">' + i + ':</h3></td>')
print('<td class="overviewTd"><span style="margin-left: -10px;">Total listen/frontend/backend:</span><pre>')
funct.ssh_command(listhap.get(i), commands)
print('</pre></td></tr>')

View File

@ -1,3 +1,3 @@
{ "firstName": "admin", "lastName": "admin", "login": "admin", "password": "admin", "role": "admin", "group": "admin" }
{ "firstName": "Editor", "lastName": "Editor", "login": "Editor", "password": "Editor@123", "role": "editor", "group": "admin" }
{ "firstName": "Guest", "lastName": "Guest", "login": "Guest", "password": "Guest@123", "role": "guest", "group": "admin" }
{ "login": "admin", "password": "admin", "role": "admin", "group": "all" }
{ "login": "Editor", "password": "Editor@123", "role": "editor", "group": "all" }
{ "login": "Guest", "password": "Guest@123", "role": "guest", "group": "all" }

View File

@ -4,16 +4,17 @@ $( function() {
$( "#tabs" ).tabs( "option", "active", 2 );
} );
$( "select" ).selectmenu();
var tooltips = $( "[title]" ).tooltip({
position: {
my: "left top",
at: "right+5 top-5",
at: "right+5 top-25",
collision: "none"
}
});
$( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio();
$( "#number" ).spinner();
$( ".controlgroup" ).controlgroup();
$( ".configShow" ).accordion({
collapsible: true,
@ -261,4 +262,13 @@ $( function() {
$("#optionsInput2").append(ui.item.value + " ")
}
});
} );
input = $('<tr><td><input type="text" name="login-add" value="" class="form-control"></td> <td><input type="passwrod" name="passwrod-add" value="" class="form-control"></td> <td><input type="text" name="role-add" value="" class="form-control"></td><td><input type="text" name="groups-add" value="" class="form-control"></td></tr>');
$( "#add-user" ).click( function(){
$( "#users-table" ).append(input);
});
} );
function removeUser(id) {
document.getElementById(id).parentNode.removeChild(document.getElementById(id));
return false;
}

View File

@ -150,6 +150,12 @@ iframe {
padding-left: 10px;
padding-right: 10px;
}
.line:hover, .line3:hover, tr:hover {
background-color: #EEEEEE;
}
.overviewHead:hover {
background-color: #EBF1F1
}
.comment {
color: #aaa;
}
@ -164,6 +170,9 @@ iframe {
.addButton {
padding-top: 15px;
}
.addButton:hover {
background-color: #fff;
}
.addSuc {
padding-left: 20px;
padding-top: 20px;
@ -220,12 +229,12 @@ iframe {
.add-button {
background-color: #5CB85C;
border-radius: 5px;
margin-left: 20px;
color: #fff;
padding: 5px;
padding-right: 10px;
padding-left: 10px;
float: right;
margin-right: 10px;
}
.serverDown {
background-color: red;
@ -237,6 +246,16 @@ iframe {
.ro {
border: none;
}
.remove {
color: #fff;
text-shadow: 0 1px 0 rgba(0,0,0,.1);
background-color: #ca4333;
background-image: linear-gradient(180deg,#d44a3a,#bc3829);
background-repeat: repeat-x;
border-color: #d44a3a;
padding: 5px;
border-radius: 3px;
}
.menu {
margin-left: 13%;
font-weight: bold;
@ -319,6 +338,10 @@ iframe {
background-color: #5D9CEB !important;
border-color: #5D9CEB !important;
}
.ui-button {
padding-left: 10px !important;
padding-right: 10px !important;
}
.ui-tooltip, .arrow:after {
background: #33414E !important;
border: 1px solid #33414E !important;