12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package main
- import (
- "encoding/json"
- "net/http"
- "strconv"
- "aytechnology.us/gominecraft/mod/mc"
- )
- func ReadLog(w http.ResponseWriter, r *http.Request) {
- log := MCServer.ReadAllLog()
- jsonData, _ := json.Marshal(log)
- sendJSONResponse(w, string(jsonData))
- }
- func ReadLogFrom(w http.ResponseWriter, r *http.Request) {
- start, _ := mv(r, "start", false)
- startInt, _ := strconv.Atoi(start)
- end := MCServer.LenLog()
- //show only first 3000 record if start ~ end is >= 3000
- if end-startInt > 3000 {
- startInt = end - 3000
- }
- if startInt > MCServer.LenLog()-1 {
- sendJSONResponse(w, "[]")
- } else {
- log := MCServer.ReadRangeLog(startInt, end)
- jsonData, _ := json.Marshal(log)
- sendJSONResponse(w, string(jsonData))
- }
- }
- func ReadBanIP(w http.ResponseWriter, r *http.Request) {
- config := Config.ReadAllBannedIPs()
- jsonData, _ := json.Marshal(config)
- sendJSONResponse(w, string(jsonData))
- }
- func ReadBanPlayer(w http.ResponseWriter, r *http.Request) {
- config := Config.ReadAllBannedPlayers()
- for _, item := range config {
- skin := mc.NewHandler(item.UUID, serverConfig.Folder+"/skin/")
- skin.DownloadSkin()
- }
- jsonData, _ := json.Marshal(config)
- sendJSONResponse(w, string(jsonData))
- }
- func ReadEULA(w http.ResponseWriter, r *http.Request) {
- config := Config.ReadEULA()
- jsonData, _ := json.Marshal(config)
- sendJSONResponse(w, string(jsonData))
- }
- func ReadOps(w http.ResponseWriter, r *http.Request) {
- config := Config.ReadAllOps()
- for _, item := range config {
- skin := mc.NewHandler(item.UUID, serverConfig.Folder+"/skin/")
- skin.DownloadSkin()
- }
- jsonData, _ := json.Marshal(config)
- sendJSONResponse(w, string(jsonData))
- }
- func ReadProperties(w http.ResponseWriter, r *http.Request) {
- config := Config.ReadAllProperties()
- jsonData, _ := json.Marshal(config)
- sendJSONResponse(w, string(jsonData))
- }
- func ReadWhitelist(w http.ResponseWriter, r *http.Request) {
- config := Config.ReadAllWhitelists()
- for _, item := range config {
- skin := mc.NewHandler(item.UUID, serverConfig.Folder+"/skin/")
- skin.DownloadSkin()
- }
- jsonData, _ := json.Marshal(config)
- sendJSONResponse(w, string(jsonData))
- }
|