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