func ProcessAdminAccountBan(res http.ResponseWriter, req *http.Request, base *BaseController) { name, err := url.QueryUnescape(mux.Vars(req)["name"]) if err != nil { http.Error(res, "Error while getting account name: "+err.Error(), 500) return } account_info := models.GetAccountByName(name) reason := req.PostFormValue("reason") expires := req.PostFormValue("expires") by, err := strconv.Atoi(req.PostFormValue("by")) if err != nil { http.Error(res, "Error while parsing character id: "+err.Error(), 500) return } expires_parsed, err := time.Parse("2006-01-02", expires) if err != nil { http.Error(res, "Error while parsing expiry date: "+err.Error(), 500) return } expires_unix := expires_parsed.Unix() err = models.AddAccountBan(account_info.Id, reason, time.Now().Unix(), expires_unix, int64(by)) if err != nil { http.Error(res, "Error while banning account: "+err.Error(), 500) return } base.Session.SetFlash("Account banned successfully!", "success") http.Redirect(res, req, "/admin/accounts/view/"+url.QueryEscape(account_info.Name), 301) }
func ShowAdminAccountEdit(res http.ResponseWriter, req *http.Request, base *BaseController) { name, err := url.QueryUnescape(mux.Vars(req)["name"]) if err != nil { http.Error(res, "Error while getting account name: "+err.Error(), 500) return } account_info := models.GetAccountByName(name) views.Parser.ExecuteTemplate(res, "admin_account_edit.html", &AdminAccountEditResponse{ account_info, }) }
func ProcessAdminAccountUnban(res http.ResponseWriter, req *http.Request, base *BaseController) { name, err := url.QueryUnescape(mux.Vars(req)["name"]) if err != nil { http.Error(res, "Error while getting account name: "+err.Error(), 500) return } // TODO: add some checking account_info := models.GetAccountByName(name) err = models.RemoveAccountBan(account_info.Id) if err != nil { http.Error(res, "Error while un-banning account: "+err.Error(), 500) return } base.Session.SetFlash("Account un-banned successfully!", "success") http.Redirect(res, req, "/admin/accounts/view/"+url.QueryEscape(account_info.Name), 301) }
func ShowAdminAccountView(res http.ResponseWriter, req *http.Request, base *BaseController) { name, err := url.QueryUnescape(mux.Vars(req)["name"]) if err != nil { http.Error(res, "Error while getting account name: "+err.Error(), 500) return } account_info := models.GetAccountByName(name) account_characters, err := models.GetAccountCharacters(account_info.Id) if err != nil { http.Error(res, "Error while getting account characters: "+err.Error(), 500) return } success := base.Session.GetFlashes("success") views.Parser.ExecuteTemplate(res, "admin_account_view.html", &AdminAccountViewResponse{ account_info, account_characters, models.CheckAccountBanned(account_info.Id), success, }) }