gosora/routes/moderate.go
Azareal 10f4c59cb5 Fixed the Go Version in the Travis file.
Added the Go and Database versions to the Control Panel Debug Page.
Renamed common.TopicsPage to common.TopicListPage.
Renamed *HeaderVars to *Header.
Added the Paginator struct and refactored the code to use it.
io.Writers are now used instead of http.ResponseWriters in transpiled templates for greater flexibility.
Added the alert, menu_alerts, and menu_item templates.
Added support for more integer types in the arithmetic functions for the transpiled templates.
Exported AccSelectBuilder.
Added an Each method to AccSelectBuilder.
Added column quoting to the order by portions of queries for the MySQL Adapter.

Began work on the client side rendering of alerts.
Began work on the Menu Manager and associated functionality.
2018-04-22 13:33:56 +01:00

43 lines
1.2 KiB
Go

package routes
import (
"html"
"net/http"
"../common"
)
func IPSearch(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
header, ferr := common.UserCheck(w, r, &user)
if ferr != nil {
return ferr
}
// TODO: How should we handle the permissions if we extend this into an alt detector of sorts?
if !user.Perms.ViewIPs {
return common.NoPermissions(w, r, user)
}
// TODO: Reject IP Addresses with illegal characters
var ip = html.EscapeString(r.FormValue("ip"))
uids, err := common.IPSearch.Lookup(ip)
if err != nil {
return common.InternalError(err, w, r)
}
// TODO: What if a user is deleted via the Control Panel? We'll cross that bridge when we come to it, although we might lean towards blanking the account and removing the related data rather than purging it
userList, err := common.Users.BulkGetMap(uids)
if err != nil {
return common.InternalError(err, w, r)
}
pi := common.IPSearchPage{common.GetTitlePhrase("ip_search"), user, header, userList, ip}
if common.RunPreRenderHook("pre_render_ip_search", w, r, &user, &pi) {
return nil
}
err = common.RunThemeTemplate(header.Theme.Name, "ip_search", pi, w)
if err != nil {
return common.InternalError(err, w, r)
}
return nil
}