add website datenbank user agent

reduce redundancy and fix sublties in StaticFile()
This commit is contained in:
Azareal 2020-03-21 17:44:33 +10:00
parent 3d7f04b92b
commit 22ec566a2c
10 changed files with 155 additions and 150 deletions

View File

@ -16,7 +16,7 @@ var SettingBox atomic.Value // An atomic value pointing to a SettingBox
type SettingMap map[string]interface{} type SettingMap map[string]interface{}
type SettingStore interface { type SettingStore interface {
ParseSetting(sname, scontent, stype, sconstraint string) string ParseSetting(name, content, typ, constraint string) string
BypassGet(name string) (*Setting, error) BypassGet(name string) (*Setting, error)
BypassGetAll(name string) ([]*Setting, error) BypassGetAll(name string) ([]*Setting, error)
} }
@ -55,10 +55,10 @@ func init() {
}) })
} }
func (s *Setting) Copy() (out *Setting) { func (s *Setting) Copy() (o *Setting) {
out = &Setting{Name: ""} o = &Setting{Name: ""}
*out = *s *o = *s
return out return o
} }
func LoadSettings() error { func LoadSettings() error {
@ -80,18 +80,18 @@ func LoadSettings() error {
} }
// TODO: Add better support for HTML attributes (html-attribute). E.g. Meta descriptions. // TODO: Add better support for HTML attributes (html-attribute). E.g. Meta descriptions.
func (sBox SettingMap) ParseSetting(sname, scontent, stype, constraint string) (err error) { func (sBox SettingMap) ParseSetting(name, content, typ, constraint string) (err error) {
ssBox := map[string]interface{}(sBox) ssBox := map[string]interface{}(sBox)
switch stype { switch typ {
case "bool": case "bool":
ssBox[sname] = (scontent == "1") ssBox[name] = (content == "1")
case "int": case "int":
ssBox[sname], err = strconv.Atoi(scontent) ssBox[name], err = strconv.Atoi(content)
if err != nil { if err != nil {
return errors.New("You were supposed to enter an integer x.x") return errors.New("You were supposed to enter an integer x.x")
} }
case "int64": case "int64":
ssBox[sname], err = strconv.ParseInt(scontent, 10, 64) ssBox[name], err = strconv.ParseInt(content, 10, 64)
if err != nil { if err != nil {
return errors.New("You were supposed to enter an integer x.x") return errors.New("You were supposed to enter an integer x.x")
} }
@ -107,17 +107,17 @@ func (sBox SettingMap) ParseSetting(sname, scontent, stype, constraint string) (
return errors.New("Invalid contraint! The constraint field wasn't an integer!") return errors.New("Invalid contraint! The constraint field wasn't an integer!")
} }
value, err := strconv.Atoi(scontent) val, err := strconv.Atoi(content)
if err != nil { if err != nil {
return errors.New("Only integers are allowed in this setting x.x") return errors.New("Only integers are allowed in this setting x.x")
} }
if value < con1 || value > con2 { if val < con1 || val > con2 {
return errors.New("Only integers between a certain range are allowed in this setting") return errors.New("Only integers between a certain range are allowed in this setting")
} }
ssBox[sname] = value ssBox[name] = val
default: default:
ssBox[sname] = scontent ssBox[name] = content
} }
return nil return nil
} }

View File

@ -590,36 +590,37 @@ var agentMapEnum = map[string]int{
"exabot": 16, "exabot": 16,
"mojeek": 17, "mojeek": 17,
"cliqz": 18, "cliqz": 18,
"baidu": 19, "datenbank": 19,
"sogou": 20, "baidu": 20,
"toutiao": 21, "sogou": 21,
"haosou": 22, "toutiao": 22,
"duckduckgo": 23, "haosou": 23,
"seznambot": 24, "duckduckgo": 24,
"discord": 25, "seznambot": 25,
"twitter": 26, "discord": 26,
"facebook": 27, "twitter": 27,
"cloudflare": 28, "facebook": 28,
"archive_org": 29, "cloudflare": 29,
"uptimebot": 30, "archive_org": 30,
"slackbot": 31, "uptimebot": 31,
"apple": 32, "slackbot": 32,
"discourse": 33, "apple": 33,
"alexa": 34, "discourse": 34,
"lynx": 35, "alexa": 35,
"blank": 36, "lynx": 36,
"malformed": 37, "blank": 37,
"suspicious": 38, "malformed": 38,
"semrush": 39, "suspicious": 39,
"dotbot": 40, "semrush": 40,
"ahrefs": 41, "dotbot": 41,
"proximic": 42, "ahrefs": 42,
"majestic": 43, "proximic": 43,
"blexbot": 44, "majestic": 44,
"aspiegel": 45, "blexbot": 45,
"mail_ru": 46, "aspiegel": 46,
"zgrab": 47, "mail_ru": 47,
"curl": 48, "zgrab": 48,
"curl": 49,
} }
var reverseAgentMapEnum = map[int]string{ var reverseAgentMapEnum = map[int]string{
0: "unknown", 0: "unknown",
@ -641,36 +642,37 @@ var reverseAgentMapEnum = map[int]string{
16: "exabot", 16: "exabot",
17: "mojeek", 17: "mojeek",
18: "cliqz", 18: "cliqz",
19: "baidu", 19: "datenbank",
20: "sogou", 20: "baidu",
21: "toutiao", 21: "sogou",
22: "haosou", 22: "toutiao",
23: "duckduckgo", 23: "haosou",
24: "seznambot", 24: "duckduckgo",
25: "discord", 25: "seznambot",
26: "twitter", 26: "discord",
27: "facebook", 27: "twitter",
28: "cloudflare", 28: "facebook",
29: "archive_org", 29: "cloudflare",
30: "uptimebot", 30: "archive_org",
31: "slackbot", 31: "uptimebot",
32: "apple", 32: "slackbot",
33: "discourse", 33: "apple",
34: "alexa", 34: "discourse",
35: "lynx", 35: "alexa",
36: "blank", 36: "lynx",
37: "malformed", 37: "blank",
38: "suspicious", 38: "malformed",
39: "semrush", 39: "suspicious",
40: "dotbot", 40: "semrush",
41: "ahrefs", 41: "dotbot",
42: "proximic", 42: "ahrefs",
43: "majestic", 43: "proximic",
44: "blexbot", 44: "majestic",
45: "aspiegel", 45: "blexbot",
46: "mail_ru", 46: "aspiegel",
47: "zgrab", 47: "mail_ru",
48: "curl", 48: "zgrab",
49: "curl",
} }
var markToAgent = map[string]string{ var markToAgent = map[string]string{
"OPR": "opera", "OPR": "opera",
@ -699,6 +701,7 @@ var markToAgent = map[string]string{
"Exabot": "exabot", "Exabot": "exabot",
"MojeekBot": "mojeek", "MojeekBot": "mojeek",
"Cliqzbot": "cliqz", "Cliqzbot": "cliqz",
"netEstate": "datenbank",
"SeznamBot": "seznambot", "SeznamBot": "seznambot",
"CloudFlare": "cloudflare", "CloudFlare": "cloudflare",
"archive": "archive_org", "archive": "archive_org",
@ -731,18 +734,18 @@ var markToID = map[string]int{
"MSIE": 6, "MSIE": 6,
"Trident": 7, "Trident": 7,
"Edge": 5, "Edge": 5,
"Lynx": 35, "Lynx": 36,
"SamsungBrowser": 10, "SamsungBrowser": 10,
"UCBrowser": 11, "UCBrowser": 11,
"Google": 12, "Google": 12,
"Googlebot": 12, "Googlebot": 12,
"yandex": 13, "yandex": 13,
"DuckDuckBot": 23, "DuckDuckBot": 24,
"DuckDuckGo": 23, "DuckDuckGo": 24,
"Baiduspider": 19, "Baiduspider": 20,
"Sogou": 20, "Sogou": 21,
"ToutiaoSpider": 21, "ToutiaoSpider": 22,
"360Spider": 22, "360Spider": 23,
"bingbot": 14, "bingbot": 14,
"BingPreview": 14, "BingPreview": 14,
"msnbot": 14, "msnbot": 14,
@ -750,29 +753,30 @@ var markToID = map[string]int{
"Exabot": 16, "Exabot": 16,
"MojeekBot": 17, "MojeekBot": 17,
"Cliqzbot": 18, "Cliqzbot": 18,
"SeznamBot": 24, "netEstate": 19,
"CloudFlare": 28, "SeznamBot": 25,
"archive": 29, "CloudFlare": 29,
"Uptimebot": 30, "archive": 30,
"Slackbot": 31, "Uptimebot": 31,
"Slack": 31, "Slackbot": 32,
"Discordbot": 25, "Slack": 32,
"Twitterbot": 26, "Discordbot": 26,
"facebookexternalhit": 27, "Twitterbot": 27,
"Facebot": 27, "facebookexternalhit": 28,
"Applebot": 32, "Facebot": 28,
"Discourse": 33, "Applebot": 33,
"ia_archiver": 34, "Discourse": 34,
"SemrushBot": 39, "ia_archiver": 35,
"DotBot": 40, "SemrushBot": 40,
"AhrefsBot": 41, "DotBot": 41,
"proximic": 42, "AhrefsBot": 42,
"MJ12bot": 43, "proximic": 43,
"BLEXBot": 44, "MJ12bot": 44,
"AspiegelBot": 45, "BLEXBot": 45,
"RU_Bot": 46, "AspiegelBot": 46,
"zgrab": 47, "RU_Bot": 47,
"curl": 48, "zgrab": 48,
"curl": 49,
} }
/*var agentRank = map[string]int{ /*var agentRank = map[string]int{
"opera":9, "opera":9,
@ -902,7 +906,7 @@ func (r *GenRouter) SuspiciousRequest(req *http.Request, pre string) {
pre += "\n" pre += "\n"
} }
r.DumpRequest(req,pre+"Suspicious Request") r.DumpRequest(req,pre+"Suspicious Request")
co.AgentViewCounter.Bump(38) co.AgentViewCounter.Bump(39)
} }
func isLocalHost(h string) bool { func isLocalHost(h string) bool {
@ -917,7 +921,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200) // 400 w.WriteHeader(200) // 400
w.Write([]byte("")) w.Write([]byte(""))
r.DumpRequest(req,"Malformed Request T"+strconv.Itoa(typ)) r.DumpRequest(req,"Malformed Request T"+strconv.Itoa(typ))
co.AgentViewCounter.Bump(37) co.AgentViewCounter.Bump(38)
} }
// Split the Host and Port string // Split the Host and Port string
@ -1060,7 +1064,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ua := strings.TrimSpace(strings.Replace(strings.TrimPrefix(req.UserAgent(),"Mozilla/5.0 ")," Safari/537.36","",-1)) // Noise, no one's going to be running this and it would require some sort of agent ranking system to determine which identifier should be prioritised over another ua := strings.TrimSpace(strings.Replace(strings.TrimPrefix(req.UserAgent(),"Mozilla/5.0 ")," Safari/537.36","",-1)) // Noise, no one's going to be running this and it would require some sort of agent ranking system to determine which identifier should be prioritised over another
if ua == "" { if ua == "" {
co.AgentViewCounter.Bump(36) co.AgentViewCounter.Bump(37)
if c.Dev.DebugMode { if c.Dev.DebugMode {
var pre string var pre string
for _, char := range req.UserAgent() { for _, char := range req.UserAgent() {
@ -1141,7 +1145,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if strings.Contains(ua,"rv:11") { if strings.Contains(ua,"rv:11") {
agent = 6 agent = 6
} }
case 47: case 48:
r.SuspiciousRequest(req,"Vulnerability Scanner") r.SuspiciousRequest(req,"Vulnerability Scanner")
} }

View File

@ -204,6 +204,7 @@
"exabot":"Exabot", "exabot":"Exabot",
"mojeek":"MojeekBot", "mojeek":"MojeekBot",
"cliqz":"Cliqzbot", "cliqz":"Cliqzbot",
"datenbank":"Website Datenbank",
"sogou":"Sogou", "sogou":"Sogou",
"toutiao":"Toutiao", "toutiao":"Toutiao",
"haosou":"Qihoo 360 Search", "haosou":"Qihoo 360 Search",

View File

@ -250,6 +250,7 @@ func main() {
"exabot", "exabot",
"mojeek", "mojeek",
"cliqz", "cliqz",
"datenbank",
"baidu", "baidu",
"sogou", "sogou",
"toutiao", "toutiao",
@ -315,6 +316,7 @@ func main() {
"Exabot", "Exabot",
"MojeekBot", "MojeekBot",
"Cliqzbot", "Cliqzbot",
"netEstate",
"SeznamBot", "SeznamBot",
"CloudFlare", "CloudFlare",
"archive", //archive.org_bot "archive", //archive.org_bot
@ -369,6 +371,7 @@ func main() {
"Exabot": "exabot", "Exabot": "exabot",
"MojeekBot": "mojeek", "MojeekBot": "mojeek",
"Cliqzbot": "cliqz", "Cliqzbot": "cliqz",
"netEstate":"datenbank",
"SeznamBot": "seznambot", "SeznamBot": "seznambot",
"CloudFlare": "cloudflare", // Track alwayson specifically in case there are other bots? "CloudFlare": "cloudflare", // Track alwayson specifically in case there are other bots?
"archive": "archive_org", //archive.org_bot "archive": "archive_org", //archive.org_bot

View File

@ -88,7 +88,7 @@ func ShowAttachment(w http.ResponseWriter, r *http.Request, user *c.User, filena
return nil return nil
} }
func deleteAttachment(w http.ResponseWriter, r *http.Request, user *c.User, aid int, js bool) c.RouteError { func deleteAttachment(w http.ResponseWriter, r *http.Request, u *c.User, aid int, js bool) c.RouteError {
err := c.DeleteAttachment(aid) err := c.DeleteAttachment(aid)
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
return c.NotFoundJSQ(w, r, nil, js) return c.NotFoundJSQ(w, r, nil, js)
@ -101,15 +101,15 @@ func deleteAttachment(w http.ResponseWriter, r *http.Request, user *c.User, aid
// TODO: Stop duplicating this code // TODO: Stop duplicating this code
// TODO: Use a transaction here // TODO: Use a transaction here
// TODO: Move this function to neutral ground // TODO: Move this function to neutral ground
func uploadAttachment(w http.ResponseWriter, r *http.Request, user *c.User, sid int, stable string, oid int, otable, extra string) (pathMap map[string]string, rerr c.RouteError) { func uploadAttachment(w http.ResponseWriter, r *http.Request, u *c.User, sid int, stable string, oid int, otable, extra string) (pathMap map[string]string, rerr c.RouteError) {
pathMap = make(map[string]string) pathMap = make(map[string]string)
files, rerr := uploadFilesWithHash(w, r, user, "./attachs/") files, rerr := uploadFilesWithHash(w, r, u, "./attachs/")
if rerr != nil { if rerr != nil {
return nil, rerr return nil, rerr
} }
for _, filename := range files { for _, filename := range files {
aid, err := c.Attachments.Add(sid, stable, oid, otable, user.ID, filename, extra) aid, err := c.Attachments.Add(sid, stable, oid, otable, u.ID, filename, extra)
if err != nil { if err != nil {
return nil, c.InternalError(err, w, r) return nil, c.InternalError(err, w, r)
} }

View File

@ -30,26 +30,23 @@ func StaticFile(w http.ResponseWriter, r *http.Request) {
if file.Length > 300 { if file.Length > 300 {
if h.Get("Range") != "" { if h.Get("Range") != "" {
h.Set("Vary", "Accept-Encoding")
if len(file.Sha256) != 0 {
h.Set("Cache-Control", cacheControlMaxAgeWeek)
} else {
h.Set("Cache-Control", cacheControlMaxAge) //Cache-Control: max-age=31536000
}
if file.GzipLength > 300 && strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { if file.GzipLength > 300 && strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
if len(file.Sha256) != 0 {
h.Set("Cache-Control", cacheControlMaxAgeWeek)
} else {
h.Set("Cache-Control", cacheControlMaxAge) //Cache-Control: max-age=31536000
}
h.Set("Content-Encoding", "gzip") h.Set("Content-Encoding", "gzip")
h.Set("Content-Length", file.StrGzipLength) h.Set("Content-Length", file.StrGzipLength)
http.ServeContent(w, r, r.URL.Path, file.Info.ModTime(), bytes.NewReader(file.GzipData)) http.ServeContent(w, r, r.URL.Path, file.Info.ModTime(), bytes.NewReader(file.GzipData))
return return
} else if file.GzipLength == 0 {
if len(file.Sha256) != 0 {
h.Set("Cache-Control", cacheControlMaxAgeWeek)
} else {
h.Set("Cache-Control", cacheControlMaxAge) //Cache-Control: max-age=31536000
}
h.Set("Content-Length", file.StrLength)
http.ServeContent(w, r, r.URL.Path, file.Info.ModTime(), bytes.NewReader(file.Data))
return
} }
h.Set("Content-Length", file.StrLength)
http.ServeContent(w, r, r.URL.Path, file.Info.ModTime(), bytes.NewReader(file.Data))
return
} }
} }
@ -79,13 +76,13 @@ func StaticFile(w http.ResponseWriter, r *http.Request) {
// Other options instead of io.Copy: io.CopyN(), w.Write(), http.ServeContent() // Other options instead of io.Copy: io.CopyN(), w.Write(), http.ServeContent()
} }
func Overview(w http.ResponseWriter, r *http.Request, user *c.User, h *c.Header) c.RouteError { func Overview(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header) c.RouteError {
h.Title = phrases.GetTitlePhrase("overview") h.Title = phrases.GetTitlePhrase("overview")
h.Zone = "overview" h.Zone = "overview"
return renderTemplate("overview", w, r, h, c.Page{h, tList, nil}) return renderTemplate("overview", w, r, h, c.Page{h, tList, nil})
} }
func CustomPage(w http.ResponseWriter, r *http.Request, user *c.User, h *c.Header, name string) c.RouteError { func CustomPage(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header, name string) c.RouteError {
h.Zone = "custom_page" h.Zone = "custom_page"
name = c.SanitiseSingleLine(name) name = c.SanitiseSingleLine(name)
page, err := c.Pages.GetByName(name) page, err := c.Pages.GetByName(name)

View File

@ -309,7 +309,7 @@ func ForumsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user *c.User,
} }
// A helper function for the Advanced portion of the Forum Perms Editor // A helper function for the Advanced portion of the Forum Perms Editor
func forumPermsExtractDash(paramList string) (fid int, gid int, err error) { func forumPermsExtractDash(paramList string) (fid, gid int, err error) {
params := strings.Split(paramList, "-") params := strings.Split(paramList, "-")
if len(params) != 2 { if len(params) != 2 {
return fid, gid, errors.New("Parameter count mismatch") return fid, gid, errors.New("Parameter count mismatch")

View File

@ -12,8 +12,8 @@ import (
) )
// TODO: Link the usernames for successful registrations to the profiles // TODO: Link the usernames for successful registrations to the profiles
func LogsRegs(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { func LogsRegs(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
basePage, ferr := buildBasePage(w, r, user, "registration_logs", "logs") basePage, ferr := buildBasePage(w, r, u, "registration_logs", "logs")
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
@ -115,8 +115,8 @@ func adminlogsElementType(action, elementType string, elementID int, actor *c.Us
switch elementType { switch elementType {
// TODO: Record more detail for this, e.g. which field/s was changed // TODO: Record more detail for this, e.g. which field/s was changed
case "user": case "user":
targetUser := handleUnknownUser(c.Users.Get(elementID)) tu := handleUnknownUser(c.Users.Get(elementID))
out = p.GetTmplPhrasef("panel_logs_admin_action_user_"+action, targetUser.Link, targetUser.Name, actor.Link, actor.Name) out = p.GetTmplPhrasef("panel_logs_admin_action_user_"+action, tu.Link, tu.Name, actor.Link, actor.Name)
case "group": case "group":
g, err := c.Groups.Get(elementID) g, err := c.Groups.Get(elementID)
if err != nil { if err != nil {
@ -168,8 +168,8 @@ func adminlogsElementType(action, elementType string, elementID int, actor *c.Us
return out return out
} }
func LogsMod(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { func LogsMod(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
basePage, ferr := buildBasePage(w, r, user, "mod_logs", "logs") basePage, ferr := buildBasePage(w, r, u, "mod_logs", "logs")
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
@ -193,8 +193,8 @@ func LogsMod(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError
return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_modlogs", pi}) return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_modlogs", pi})
} }
func LogsAdmin(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { func LogsAdmin(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
basePage, ferr := buildBasePage(w, r, user, "admin_logs", "logs") basePage, ferr := buildBasePage(w, r, u, "admin_logs", "logs")
if ferr != nil { if ferr != nil {
return ferr return ferr
} }

View File

@ -8,8 +8,8 @@ import (
c "github.com/Azareal/Gosora/common" c "github.com/Azareal/Gosora/common"
) )
func Pages(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { func Pages(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
basePage, ferr := buildBasePage(w, r, user, "pages", "pages") basePage, ferr := buildBasePage(w, r, u, "pages", "pages")
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
@ -71,8 +71,8 @@ func PagesCreateSubmit(w http.ResponseWriter, r *http.Request, user *c.User) c.R
return nil return nil
} }
func PagesEdit(w http.ResponseWriter, r *http.Request, user *c.User, spid string) c.RouteError { func PagesEdit(w http.ResponseWriter, r *http.Request, u *c.User, spid string) c.RouteError {
basePage, ferr := buildBasePage(w, r, user, "pages_edit", "pages") basePage, ferr := buildBasePage(w, r, u, "pages_edit", "pages")
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
@ -82,7 +82,7 @@ func PagesEdit(w http.ResponseWriter, r *http.Request, user *c.User, spid string
pid, err := strconv.Atoi(spid) pid, err := strconv.Atoi(spid)
if err != nil { if err != nil {
return c.LocalError("Page ID needs to be an integer", w, r, user) return c.LocalError("Page ID needs to be an integer", w, r, u)
} }
page, err := c.Pages.Get(pid) page, err := c.Pages.Get(pid)
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
@ -138,21 +138,21 @@ func PagesEditSubmit(w http.ResponseWriter, r *http.Request, user *c.User, spid
return nil return nil
} }
func PagesDeleteSubmit(w http.ResponseWriter, r *http.Request, user *c.User, spid string) c.RouteError { func PagesDeleteSubmit(w http.ResponseWriter, r *http.Request, u *c.User, spid string) c.RouteError {
_, ferr := c.SimplePanelUserCheck(w, r, user) _, ferr := c.SimplePanelUserCheck(w, r, u)
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
pid, err := strconv.Atoi(spid) pid, err := strconv.Atoi(spid)
if err != nil { if err != nil {
return c.LocalError("Page ID needs to be an integer", w, r, user) return c.LocalError("Page ID needs to be an integer", w, r, u)
} }
err = c.Pages.Delete(pid) err = c.Pages.Delete(pid)
if err != nil { if err != nil {
return c.InternalError(err, w, r) return c.InternalError(err, w, r)
} }
err = c.AdminLogs.Create("delete", pid, "page", user.GetIP(), user.ID) err = c.AdminLogs.Create("delete", pid, "page", u.GetIP(), u.ID)
if err != nil { if err != nil {
return c.InternalError(err, w, r) return c.InternalError(err, w, r)
} }

View File

@ -8,13 +8,13 @@ import (
c "github.com/Azareal/Gosora/common" c "github.com/Azareal/Gosora/common"
) )
func Plugins(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { func Plugins(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
basePage, ferr := buildBasePage(w, r, user, "plugins", "plugins") basePage, ferr := buildBasePage(w, r, u, "plugins", "plugins")
if ferr != nil { if ferr != nil {
return ferr return ferr
} }
if !user.Perms.ManagePlugins { if !u.Perms.ManagePlugins {
return c.NoPermissions(w, r, user) return c.NoPermissions(w, r, u)
} }
var pluginList []interface{} var pluginList []interface{}