aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <>2021-05-13 23:47:42 -0700
committerFChannel <>2021-05-13 23:47:42 -0700
commitfbd5e54c952663d0f0fab352d37d3baeefdb2e53 (patch)
tree938214b4cd24f4a5340ab05d5e349e34e503eb1f /main.go
parent20d0aee3f0bf987eb7e8999977bb25577df7b2d3 (diff)
improved tripcodes
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/main.go b/main.go
index 37fdd0c..378b767 100644
--- a/main.go
+++ b/main.go
@@ -341,8 +341,11 @@ func main() {
err := we.WriteField(key, r.FormValue("captchaCode") + ":" + r.FormValue("captcha"))
CheckError(err, "error with writing captcha field")
}else if(key == "name") {
- err := we.WriteField(key, CreateNameTripCode(r))
+ name, tripcode := CreateNameTripCode(r, db)
+ err := we.WriteField(key, name)
CheckError(err, "error with writing name field")
+ err = we.WriteField("tripcode", tripcode)
+ CheckError(err, "error with writing tripcode field")
}else{
err := we.WriteField(key, r0[0])
CheckError(err, "error with writing field")
@@ -942,18 +945,18 @@ func CreateTripCode(input string) string {
return code[0]
}
-func CreateNameTripCode(r *http.Request) string {
+func CreateNameTripCode(r *http.Request, db *sql.DB) (string, string) {
input := r.FormValue("name")
re := regexp.MustCompile("#.+")
chunck := re.FindString(input)
ce := regexp.MustCompile(`(?i)#Admin`)
admin := ce.MatchString(chunck)
- _, modcred := GetPasswordFromSession(r)
- if(admin && modcred != "" ) {
- return re.ReplaceAllString(input, "#Admin")
+ board, modcred := GetPasswordFromSession(r)
+ if(admin && HasAuth(db, modcred, board)) {
+ return re.ReplaceAllString(input, ""), "#Admin"
} else {
hash := CreateTripCode(chunck)
- return re.ReplaceAllString(input, "!" + hash[42:50])
+ return re.ReplaceAllString(input, ""), "!" + hash[42:50]
}
}