123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Access Control</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
- <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
- <script type="text/javascript" src="../../script/jquery.min.js"></script>
- <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
- <style>
- a.pageFocus {
- background: #222222;
- color: white !important;
- border-radius: 50%;
- -moz-border-radius: 50%;
- -webkit-border-radius: 50%;
- display: inline-block;
- font-weight: bold;
- line-height: 30px;
- margin-right: 2px;
- text-align: center;
- width: 30px;
- }
- .noselect {
- -webkit-touch-callout: none; /* iOS Safari */
- -webkit-user-select: none; /* Safari */
- -khtml-user-select: none; /* Konqueror HTML */
- -moz-user-select: none; /* Old versions of Firefox */
- -ms-user-select: none; /* Internet Explorer/Edge */
- user-select: none; /* Non-prefixed version, currently
- supported by Chrome, Edge, Opera and Firefox */
- }
- </style>
- </head>
- <body>
- <br>
- <div class="ui container" style="height: 100% !important;">
- <div>
- <h3 class="ui header">
- Access Control
- <div class="sub header">Manage IPs from accessing this host</div>
- </h3>
- <div class="ui divider"></div>
- <h3><i class="ui green checkmark icon"></i> Whitelist</h3>
- <div class="ui divider"></div>
- <h3><i class="ui red remove icon"></i> Blacklist</h3>
- <div class="ui toggle checkbox">
- <input type="checkbox" id="enableBlacklist" onchange="updateBlacklistEnableState(this.checked);">
- <label>Enable Blacklist Filtering</label>
- </div>
- <div class="ui inverted green segment" id="blacklistUpdateFeedback" style="display:none;">
- <i class="ui checkmark icon"></i> Status Updated
- </div>
- <div class="ui basic segment">
- <div class="ui grey message">
- <p>Block certain IP or IP range from logging into the system. Syntax Examples:</p>
- <div class="ui bulleted list">
- <div class="item">192.168.1.100</div>
- <div class="item">123.36.53.100</div>
- <div class="item">192.168.0.100 - 192.168.0.250</div>
- </div>
- </div>
- <p>Add or Edit new banned IP range</p>
- <div class="ui action fluid input">
- <input type="text" id="blacklistIpRange" placeholder="192.168.1.100 - 192.168.1.250">
- <button class="ui red button" onclick="blacklistIpRange();"><i class="ui lock icon"></i> Ban</button>
- </div>
- <table class="ui celled table">
- <thead>
- <tr><th>IP Range</th>
- <th>Unban</th>
- </tr></thead>
- <tbody id="blacklisttable">
- </tbody>
- </table>
- </div>
-
-
- <div class="ui divider"></div>
- <h3>Regional Block</h3>
- </div>
-
- <script>
- //Init
- var preloading = true;
- $(".checkbox").checkbox();
- initBlacklist();
- /*
- Blacklist Related
- */
- function initBlacklist(){
- //Get the Blacklist enable state
- $.get("../../system/auth/blacklist/enable", function(data){
- if (data == true){
- //Blacklist is enabled
- $("#enableBlacklist").parent().checkbox("set checked");
- }else{
- $("#enableBlacklist").parent().checkbox("set unchecked");
- }
- preloading = false;
- });
- //Get the Blacklist table
- $("#blacklisttable").html(`<tr>
- <td colspan="3"><i class="loading spinner icon"></i> Loading</td>
- </tr>`);
- $.get("../../system/auth/blacklist/list", function(data){
- $("#blacklisttable").html('');
- data.forEach(entry => {
- //Strip out all space from record
- displayEntry = entry.split(" ").join("");
- $("#blacklisttable").append(`<tr>
- <td>${displayEntry}</td>
- <td><button class="ui green icon button" onclick="removeBlacklistforIpRange(this);" range="${entry}"><i class="ui white lock open icon"></i></button></td>
- </tr>`);
- })
- if (data.length == 0){
- $("#blacklisttable").html(`<tr>
- <td colspan="3"><i class="remove icon"></i> No Banned IPs</td>
- </tr>`);
- }
- })
- }
- function updateBlacklistEnableState(enabled){
- if (preloading){
- //Do not update status during preload stage
- return;
- }
- $.ajax({
- url: "../../system/auth/blacklist/enable",
- method: "POST",
- data: {enable: enabled},
- success: function(data){
- $("#blacklistUpdateFeedback").stop().finish().slideDown("fast").delay(3000).slideUp("fast");
- }
- })
- }
- function blacklistIpRange(){
- var targetIP = $("#blacklistIpRange").val();
- $.ajax({
- url: "../../system/auth/blacklist/ban",
- method: "POST",
- data: {iprange: targetIP},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#blacklistIpRange").val('')
- initBlacklist();
- }
-
- }
- });
- }
- function removeBlacklistforIpRange(object){
- var unbanIpRange = $(object).attr("range");
- $.ajax({
- url: "../../system/auth/blacklist/unban",
- method: "POST",
- data: {iprange: unbanIpRange},
- success: function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#blacklistIpRange").val('')
- initBlacklist();
- }
-
- }
- });
- }
- </script>
- </body>
- </html>
|