diff --git a/res/template/admin.html b/res/template/admin.html
index 1cd6c9d..a7ef110 100644
--- a/res/template/admin.html
+++ b/res/template/admin.html
@@ -10,7 +10,12 @@
{{template "page_top" .}}
{{if $isAdmin}}
-
Bandwidth and views
+
+
@@ -29,8 +34,6 @@
bandwidth and views
-
-
Update global settings
Database connection statistics
diff --git a/webcontroller/admin_panel.go b/webcontroller/admin_panel.go
index d566f7c..7604e39 100644
--- a/webcontroller/admin_panel.go
+++ b/webcontroller/admin_panel.go
@@ -96,44 +96,62 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f
return f
}
-// func (wc *WebController) adminFileDeleteForm(td *TemplateData, r *http.Request) (f Form) {
-// if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
-// td.Title = err.Error()
-// return Form{Title: td.Title}
-// } else if !isAdmin.IsAdmin {
-// td.Title = ";)"
-// return Form{Title: td.Title}
-// }
+func (wc *WebController) adminAbuseForm(td *TemplateData, r *http.Request) (f Form) {
+ if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
+ td.Title = err.Error()
+ return Form{Title: td.Title}
+ } else if !isAdmin {
+ td.Title = ";)"
+ return Form{Title: td.Title}
+ }
-// td.Title = "Admin file removal"
-// f = Form{
-// Name: "admin_file_removal",
-// Title: td.Title,
-// PreFormHTML: template.HTML("Paste any pixeldrain file links in here to remove them
"),
-// Fields: []Field{
-// {
-// Name: "files",
-// Label: "Files to delete",
-// Type: FieldTypeTextarea,
-// },
-// },
-// BackLink: "/admin",
-// SubmitLabel: "Submit",
-// }
+ td.Title = "Admin file removal"
+ f = Form{
+ Name: "admin_file_removal",
+ Title: td.Title,
+ PreFormHTML: template.HTML("Paste any pixeldrain file links in here to remove them
"),
+ Fields: []Field{
+ {
+ Name: "text",
+ Label: "Files to delete",
+ Type: FieldTypeTextarea,
+ }, {
+ Name: "type",
+ Label: "Type",
+ DefaultValue: "unknown",
+ Description: "Can be 'unknown', 'copyright', 'terrorism' or 'child_abuse'",
+ Type: FieldTypeText,
+ }, {
+ Name: "reporter",
+ Label: "Reporter",
+ DefaultValue: "pixeldrain",
+ Type: FieldTypeText,
+ },
+ },
+ BackLink: "/admin",
+ SubmitLabel: "Submit",
+ }
-// if f.ReadInput(r) {
-// filesText := f.FieldVal("files")
+ if f.ReadInput(r) {
+ resp, err := td.PixelAPI.AdminBlockFiles(
+ f.FieldVal("text"),
+ f.FieldVal("type"),
+ f.FieldVal("reporter"),
+ )
+ if err != nil {
+ formAPIError(err, &f)
+ return
+ }
-// // Get all links from the text
-// strings.Index(filesText, "/u/")
+ successMsg := template.HTML("The following files were blocked:
")
+ for _, v := range resp.FilesBlocked {
+ successMsg += template.HTML("- pixeldrain.com/u/" + v + "
")
+ }
+ successMsg += ""
-// if len(f.SubmitMessages) == 0 {
-// // Request was a success
-// f.SubmitSuccess = true
-// f.SubmitMessages = []template.HTML{template.HTML(
-// fmt.Sprintf("Success! %d values updated", successfulUpdates),
-// )}
-// }
-// }
-// return f
-// }
+ // Request was a success
+ f.SubmitSuccess = true
+ f.SubmitMessages = []template.HTML{successMsg}
+ }
+ return f
+}
diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go
index 1656288..9612df3 100644
--- a/webcontroller/web_controller.go
+++ b/webcontroller/web_controller.go
@@ -128,6 +128,8 @@ func New(
r.GET(p+"/admin" /* */, wc.serveTemplate("admin_panel", true))
r.GET(p+"/admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, true))
r.POST(p+"/admin/globals" /**/, wc.serveForm(wc.adminGlobalsForm, true))
+ r.GET(p+"/admin/abuse" /* */, wc.serveForm(wc.adminAbuseForm, true))
+ r.POST(p+"/admin/abuse" /**/, wc.serveForm(wc.adminAbuseForm, true))
// Advertising related
r.GET(p+"/click/:id" /* */, wc.serveAdClick)