aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <>2021-05-12 23:06:40 -0700
committerFChannel <>2021-05-12 23:06:40 -0700
commitd46dc93dce176e8e2c054a1454c097123a08b4af (patch)
tree022698ceec742efbd55ffcaf7919dd370dd2fdba /main.go
parent88521d92e6228a5bbfe1b0a5303bb1bd9cb5d955 (diff)
admin tripcode
Diffstat (limited to 'main.go')
-rw-r--r--main.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/main.go b/main.go
index 43ea539..c5229dc 100644
--- a/main.go
+++ b/main.go
@@ -289,6 +289,12 @@ func main() {
return
}
+ if(r.FormValue("inReplyTo") == "" && file == nil) {
+ w.Write([]byte("Media is required for new posts"))
+ return
+ }
+
+
if(r.FormValue("inReplyTo") == "" || file == nil) {
if(r.FormValue("comment") == "" && r.FormValue("subject") == ""){
w.Write([]byte("Comment or Subject required"))
@@ -331,7 +337,10 @@ func main() {
for key, r0 := range r.Form {
if(key == "captcha") {
err := we.WriteField(key, r.FormValue("captchaCode") + ":" + r.FormValue("captcha"))
- CheckError(err, "error with writing field")
+ CheckError(err, "error with writing captcha field")
+ }else if(key == "name") {
+ err := we.WriteField(key, CreateNameTripCode(r))
+ CheckError(err, "error with writing name field")
}else{
err := we.WriteField(key, r0[0])
CheckError(err, "error with writing field")
@@ -931,11 +940,19 @@ func CreateTripCode(input string) string {
return code[0]
}
-func CreateNameTripCode(input string) string {
+func CreateNameTripCode(r *http.Request) string {
+ input := r.FormValue("name")
re := regexp.MustCompile("#.+")
chunck := re.FindString(input)
- hash := CreateTripCode(chunck)
- return re.ReplaceAllString(input, "!" + hash[42:50])
+ ce := regexp.MustCompile(`(?i)#Admin`)
+ admin := ce.MatchString(chunck)
+ _, modcred := GetPasswordFromSession(r)
+ if(admin && modcred != "" ) {
+ return re.ReplaceAllString(input, "#Admin")
+ } else {
+ hash := CreateTripCode(chunck)
+ return re.ReplaceAllString(input, "!" + hash[42:50])
+ }
}
func GetActorFromPath(db *sql.DB, location string, prefix string) Actor {