1
0

4 Коммиты e9d7c537e9 ... 715eab7c1c

Автор SHA1 Сообщение Дата
  AY 715eab7c1c updated 4 лет назад
  AY 02b6d5a637 Updated 4 лет назад
  AY c7abe51c0e update 4 лет назад
  AY 8a1ef05e0d UI update 4 лет назад

+ 23 - 17
mc_add.go

@@ -3,43 +3,49 @@ package main
 import (
 	"net/http"
 	"strconv"
+	"time"
 )
 
 func AddBanIP(w http.ResponseWriter, r *http.Request) {
-	IP, _ := mv(r, "IP", false)
-	Created, _ := mv(r, "Created", false)
-	Source, _ := mv(r, "Source", false)
-	Expires, _ := mv(r, "Expires", false)
-	Reason, _ := mv(r, "Reason", false)
+	IP, _ := mv(r, "ip", false)
+	Created := currentTime()
+	Source := "ArOZ Minecraft Terminal"
+	Expires := "forever"
+	Reason, _ := mv(r, "reason", false)
 	Config.WriteBannedIP(IP, Created, Source, Expires, Reason)
 	sendJSONResponse(w, "OK")
 }
 
 func AddBanPlayer(w http.ResponseWriter, r *http.Request) {
-	UUID, _ := mv(r, "UUID", false)
-	Name, _ := mv(r, "Name", false)
-	Created, _ := mv(r, "Created", false)
-	Source, _ := mv(r, "Source", false)
-	Expires, _ := mv(r, "Expires", false)
-	Reason, _ := mv(r, "Reason", false)
+	UUID, _ := mv(r, "uuid", false)
+	Name, _ := mv(r, "name", false)
+	Created := currentTime()
+	Source := "ArOZ Minecraft Terminal"
+	Expires := "forever"
+	Reason, _ := mv(r, "reason", false)
 	Config.WriteBannedPlayer(UUID, Name, Created, Source, Expires, Reason)
 	sendJSONResponse(w, "OK")
 }
 
 func AddOps(w http.ResponseWriter, r *http.Request) {
-	UUID, _ := mv(r, "UUID", false)
-	Name, _ := mv(r, "Name", false)
-	Level, _ := mv(r, "Level", false)
+	UUID, _ := mv(r, "uuid", false)
+	Name, _ := mv(r, "name", false)
+	Level, _ := mv(r, "level", false)
 	LevelI, _ := strconv.Atoi(Level)
-	BypassesPlayerLimit, _ := mv(r, "BypassesPlayerLimit", false)
+	BypassesPlayerLimit, _ := mv(r, "bypass", false)
 	BypassesPlayerLimitB, _ := strconv.ParseBool(BypassesPlayerLimit)
 	Config.WriteOps(UUID, Name, LevelI, BypassesPlayerLimitB)
 	sendJSONResponse(w, "OK")
 }
 
 func AddWhitelist(w http.ResponseWriter, r *http.Request) {
-	UUID, _ := mv(r, "UUID", false)
-	Name, _ := mv(r, "Name", false)
+	UUID, _ := mv(r, "uuid", false)
+	Name, _ := mv(r, "name", false)
 	Config.WriteWhitelist(UUID, Name)
 	sendJSONResponse(w, "OK")
 }
+
+func currentTime() string {
+	t := time.Now()
+	return t.Format("2006-01-02 15:04:05 -0700")
+}

+ 6 - 6
webroot/setting.html

@@ -42,22 +42,22 @@
         <a class="item" data-tab="6">EULA</a>
     </div>
     <div class="ui bottom attached tab segment active" style="height:100%;width:100%" data-tab="1">
-        <iframe src="/setting/banip.html" style="height:100%;width:100%" title=""></iframe>
+        <iframe src="/setting/banip.html" style="height: calc(100vh - 85px);width:100%" title=""></iframe>
     </div>
     <div class="ui bottom attached tab segment" style="height:100%;width:100%" data-tab="2">
-        <iframe src="/setting/banplayer.html" style="height:100%;width:100%" title=""></iframe>
+        <iframe src="/setting/banplayer.html" style="height: calc(100vh - 85px);width:100%" title=""></iframe>
     </div>
     <div class="ui bottom attached tab segment" style="height:100%;width:100%" data-tab="3">
-        <iframe src="/setting/ops.html" style="height:100%;width:100%" title=""></iframe>
+        <iframe src="/setting/ops.html" style="height: calc(100vh - 85px);width:100%" title=""></iframe>
     </div>
     <div class="ui bottom attached tab segment" style="height:100%;width:100%" data-tab="4">
-        <iframe src="/setting/properties.html" style="height:100%;width:100%" title=""></iframe>
+        <iframe src="/setting/properties.html" style="height: calc(100vh - 85px);width:100%" title=""></iframe>
     </div>
     <div class="ui bottom attached tab segment" style="height:100%;width:100%" data-tab="5">
-        <iframe src="/setting/whitelist.html" style="height:100%;width:100%" title=""></iframe>
+        <iframe src="/setting/whitelist.html" style="height: calc(100vh - 85px);width:100%" title=""></iframe>
     </div>
     <div class="ui bottom attached tab segment" style="height:100%;width:100%" data-tab="6">
-        <iframe src="/setting/eula.html" style="height:100%;width:100%" title=""></iframe>
+        <iframe src="/setting/eula.html" style="height: calc(100vh - 85px);width:100%" title=""></iframe>
     </div>
     <script>
         $('.menu .item')

+ 19 - 6
webroot/setting/banip.html

@@ -20,10 +20,17 @@
 <body>
     <div class="ui divided items" id="userlist">
     </div>
+    <div class="ui fluid input" style="position: fixed;bottom: 10px;width: 99vw;">
+        <input type="text" id="ip" placeholder="IP">
+        <div style="width:10px"></div>
+        <input type="text" id="reason" placeholder="Reason">
+        <div style="width:10px"></div>
+        <div class="ui button" onclick="submit()">Submit</div>
+    </div>
+
 </body>
 <script>
-    var refreshInfo;
-    var currentOnlineUser = [];
+    updateInfo();
     setInterval(function() {
         updateInfo()
     }, 5000);
@@ -51,19 +58,25 @@
                             <span>` + item.reason + `</span>
                         </div>
                     </div>
-                    <div class="ui right floated buttons" style="display:block;margin:auto" username="` + item.ip + `">
+                    <div class="ui right floated buttons" style="display:block;margin:auto" ip="` + item.ip + `">
                         <button onclick="unban(this)" class="ui red button">UnBan</button>
                     </div>
                 </div>
                 `)
             })
-            currentOnlineUser = data.sample;
+            $("#userlist").append('<div style="height:40px"></div>');
         });
     }
 
     function unban(btn) {
-        var username = $(btn).parent().attr("username");
-        sendCmd("ban " + username);
+        var data = $(btn).parent().attr("ip");
+        $.get("/ban-ip/remove?field=ip&search=" + data);
+    }
+
+    function submit() {
+        var ip = $("#ip").val();
+        var reason = $("#reason").val();
+        $.get("/ban-ip/add?ip=" + ip + "&reason=" + reason);
     }
 </script>
 

+ 20 - 5
webroot/setting/banplayer.html

@@ -20,10 +20,18 @@
 <body>
     <div class="ui divided items" id="userlist">
     </div>
+    <div class="ui fluid input" style="position: fixed;bottom: 10px;width: 99vw;">
+        <input type="text" id="uuid" placeholder="UUID">
+        <div style="width:10px"></div>
+        <input type="text" id="name" placeholder="Name">
+        <div style="width:10px"></div>
+        <input type="text" id="reason" placeholder="Reason">
+        <div style="width:10px"></div>
+        <div class="ui button" onclick="submit()">Submit</div>
+    </div>
 </body>
 <script>
-    var refreshInfo;
-    var currentOnlineUser = [];
+    updateInfo();
     setInterval(function() {
         updateInfo()
     }, 5000);
@@ -60,15 +68,22 @@
                 </div>
                 `)
             })
-            currentOnlineUser = data.sample;
+            $("#userlist").append('<div style="height:40px"></div>');
+
         });
     }
 
     function unban(btn) {
-        var username = $(btn).parent().attr("username");
-        sendCmd("ban " + username);
+        var data = $(btn).parent().attr("username");
+        $.get("/ban-player/remove?field=name&search=" + data);
     }
 
+    function submit() {
+        var uuid = $("#uuid").val();
+        var name = $("#name").val();
+        var reason = $("#reason").val();
+        $.get("/ban-player/add?uuid=" + uuid + "&name=" + name + "&reason=" + reason);
+    }
 </script>
 
 </html>

+ 18 - 9
webroot/setting/eula.html

@@ -21,27 +21,36 @@
     <a href="https://account.mojang.com/documents/minecraft_eula">MINECRAFT END USER LICENSE AGREEMENT</a>
     <div id="settings" class="ui form">
     </div>
+    <div class="ui button" onclick="submit()">Update</div>
 </body>
 <script>
-    $.get("/eula", function(data) {
-        if (data.length == 0) {
-            $("#settings").html(`
+    updateInfo();
+
+    function updateInfo() {
+        $.get("/eula", function(data) {
+            if (data.length == 0) {
+                $("#settings").html(`
                         <div class="inline field">
                             <label>No item :(</label>
                         </div>
                         <div class="ui divider"></div>
                     `)
-            return
-        }
-        $("#settings").html(`
+                return
+            }
+            $("#settings").html(`
                 <div class="inline field">
                     <label style="width:46vw">EULA</label>
-                    <input style="width:46vw" type="text" id="EULA" placeholder="` + data + `" value="` + data + `">
+                    <input style="width:46vw" type="text" id="eula" placeholder="` + data + `" value="` + data + `">
                 </div>
                 <div class="ui divider"></div>
         `)
-        currentOnlineUser = data.sample;
-    });
+        });
+    }
+
+    function submit() {
+        var value = $("#eula").val();
+        $.get("/eula/change?value=" + value)
+    }
 </script>
 
 </html>

+ 23 - 6
webroot/setting/ops.html

@@ -20,10 +20,20 @@
 <body>
     <div class="ui divided items" id="userlist">
     </div>
+    <div class="ui fluid input" style="position: fixed;bottom: 10px;width: 99vw;">
+        <input type="text" id="uuid" placeholder="UUID">
+        <div style="width:10px"></div>
+        <input type="text" id="name" placeholder="Name">
+        <div style="width:10px"></div>
+        <input type="text" id="level" placeholder="Level">
+        <div style="width:10px"></div>
+        <input type="text" id="bypass" placeholder="BypassesPlayerLimit">
+        <div style="width:10px"></div>
+        <div class="ui button" onclick="submit()">Submit</div>
+    </div>
 </body>
 <script>
-    var refreshInfo;
-    var currentOnlineUser = [];
+    updateInfo();
     setInterval(function() {
         updateInfo()
     }, 5000);
@@ -60,15 +70,22 @@
                 </div>
                 `)
             })
-            currentOnlineUser = data.sample;
+            $("#userlist").append('<div style="height:40px"></div>');
         });
     }
 
-    function unban(btn) {
-        var username = $(btn).parent().attr("username");
-        sendCmd("ban " + username);
+    function deop(btn) {
+        var data = $(btn).parent().attr("username");
+        $.get("/ops/remove?field=name&search=" + data);
     }
 
+    function submit() {
+        var uuid = $("#uuid").val();
+        var name = $("#name").val();
+        var level = $("#level").val();
+        var bypass = $("#bypass").val();
+        $.get("/ops/add?uuid=" + uuid + "&name=" + name + "&level=" + level + "&bypass=" + bypass);
+    }
 </script>
 
 </html>

+ 22 - 10
webroot/setting/properties.html

@@ -20,30 +20,42 @@
 <body>
     <div id="settings" class="ui form">
     </div>
+    <div class="ui button" onclick="submit()">Update</div>
 </body>
 <script>
-    $.get("/properties", function(data) {
-        if (data.length == 0) {
-            $("#settings").html(`
+    updateInfo()
+
+    function updateInfo() {
+        $.get("/properties", function(data) {
+            if (data.length == 0) {
+                $("#settings").html(`
                         <div class="inline field">
                             <label>No item :(</label>
                         </div>
                         <div class="ui divider"></div>
                     `)
-            return
-        }
-        $("#settings").html("");
-        $.each(data, function(i, item) {
-            $("#settings").append(`
+                return
+            }
+            $("#settings").html("");
+            $.each(data, function(i, item) {
+                $("#settings").append(`
                 <div class="inline field">
                     <label style="width:46vw">` + item.key + `</label>
                     <input style="width:46vw" type="text" id="` + item.key + `" placeholder="` + item.value + `" value="` + item.value + `">
                 </div>
                 <div class="ui divider"></div>
             `)
+            })
+        });
+    }
+
+    function submit() {
+        $.each($("input"), function(i, item) {
+            var key = $(item).attr("id");
+            var value = $(item).val();
+            $.get("/properties/change?key=" + key + "&value=" + value)
         })
-        currentOnlineUser = data.sample;
-    });
+    }
 </script>
 
 </html>

+ 16 - 6
webroot/setting/whitelist.html

@@ -20,10 +20,16 @@
 <body>
     <div class="ui divided items" id="userlist">
     </div>
+    <div class="ui fluid input" style="position: fixed;bottom: 10px;width: 99vw;">
+        <input type="text" id="uuid" placeholder="UUID">
+        <div style="width:10px"></div>
+        <input type="text" id="name" placeholder="Name">
+        <div style="width:10px"></div>
+        <div class="ui button" onclick="submit()">Submit</div>
+    </div>
 </body>
 <script>
-    var refreshInfo;
-    var currentOnlineUser = [];
+    updateInfo();
     setInterval(function() {
         updateInfo()
     }, 5000);
@@ -60,15 +66,19 @@
                 </div>
                 `)
             })
-            currentOnlineUser = data.sample;
         });
     }
 
-    function unban(btn) {
-        var username = $(btn).parent().attr("username");
-        sendCmd("ban " + username);
+    function dewhitelist(btn) {
+        var data = $(btn).parent().attr("username");
+        $.get("/whitelist/remove?field=name&search=" + data);
     }
 
+    function submit() {
+        var uuid = $("#uuid").val();
+        var name = $("#name").val();
+        $.get("/whitelist/add?uuid=" + uuid + "&name=" + name);
+    }
 </script>
 
 </html>