From a4c64444b2b3df780a7a23e65d24f03dc983a188 Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Sun, 17 Jan 2021 12:06:01 -0800 Subject: added go mod and config-init --- .gitignore | 3 +-- Database.go | 8 ++++---- config | 10 ---------- config-init | 10 ++++++++++ go.mod | 3 +++ go.sum | 2 ++ main.go | 17 +++++++++++++++-- 7 files changed, 35 insertions(+), 18 deletions(-) delete mode 100644 config create mode 100644 config-init create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore index c2128de..5e2780e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ *~ #* public/ -backupconfig0 -backupconfig1 +config \ No newline at end of file diff --git a/Database.go b/Database.go index f033a5b..00c6025 100644 --- a/Database.go +++ b/Database.go @@ -228,7 +228,7 @@ func writeActivitytoDB(db *sql.DB, obj ObjectBase) { obj.Content = EscapeString(obj.Content) obj.AttributedTo = EscapeString(obj.AttributedTo) - query := fmt.Sprintf("insert into activitystream (id, type, name, content, published, updated, attributedto, actor) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) + query := fmt.Sprintf("insert into activitystream (id, type, name, content, published, updated, attributedto, actor) values ('%s', '%s', E'%s', E'%s', '%s', '%s', E'%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) _, e := db.Exec(query) @@ -244,7 +244,7 @@ func writeActivitytoDBWithAttachment(db *sql.DB, obj ObjectBase, attachment Obje obj.Content = EscapeString(obj.Content) obj.AttributedTo = EscapeString(obj.AttributedTo) - query := fmt.Sprintf("insert into activitystream (id, type, name, content, attachment, published, updated, attributedto, actor) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) + query := fmt.Sprintf("insert into activitystream (id, type, name, content, attachment, published, updated, attributedto, actor) values ('%s', '%s', E'%s', E'%s', '%s', '%s', '%s', E'%s', '%s')", obj.Id ,obj.Type, obj.Name, obj.Content, attachment.Id, obj.Published, obj.Updated, obj.AttributedTo, obj.Actor.Id) _, e := db.Exec(query) @@ -823,9 +823,9 @@ func DeleteCaptchaCodeDB(db *sql.DB, verify string) { } func EscapeString(text string) string { - re := regexp.MustCompile("(?i)(n)(\\s+)?(i)(\\s+)?(g)(\\s+)?(g)?(\\s+)?(e)(\\s+)?(r)(\\s+)?") + re := regexp.MustCompile("(?i)(n)+(\\s+)?(i)+(\\s+)?(g)+(\\s+)?(e)+?(\\s+)?(r)+(\\s+)?") text = re.ReplaceAllString(text, "I love black people") - re = regexp.MustCompile("(?i)(n)(\\s+)?(i)(\\s+)?(g)(\\s+)?(g)(\\s+)?") + re = regexp.MustCompile("(?i)(n)+(\\s+)?(i)+(\\s+)?(g)(\\s+)?(g)+(\\s+)?") text = re.ReplaceAllString(text, "I love black people") text = strings.Replace(text, "'", "''", -1) text = strings.Replace(text, "<", "<", -1) diff --git a/config b/config deleted file mode 100644 index 2299ea8..0000000 --- a/config +++ /dev/null @@ -1,10 +0,0 @@ -instance:server.fchan.xyz -instancetp:https:// -instanceport:3000 -instancename:FChan -instancesummary:FChan is a federated image board instance. -dbhost:localhost -dbport:5432 -dbname:fchan_server -dbuser:postgres -dbpass:password diff --git a/config-init b/config-init new file mode 100644 index 0000000..2299ea8 --- /dev/null +++ b/config-init @@ -0,0 +1,10 @@ +instance:server.fchan.xyz +instancetp:https:// +instanceport:3000 +instancename:FChan +instancesummary:FChan is a federated image board instance. +dbhost:localhost +dbport:5432 +dbname:fchan_server +dbuser:postgres +dbpass:password diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e5b24f7 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/FChannel/Server + +require github.com/lib/pq v1.9.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a4a764e --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= diff --git a/main.go b/main.go index cda1f97..a1f55d8 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ var Domain = TP + "" + GetConfigValue("instance") var authReq = []string{"captcha","email","passphrase"} -var supportedFiles = []string{"image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/avif","image/apng","video/mp4","video/ogg","video/webm","audio/mpeg","audio/ogg","audio/wav"} +var supportedFiles = []string{"image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/avif","image/apng","video/mp4","video/ogg","video/webm","audio/mpeg","audio/ogg","audio/wav", "audio/wave", "audio/x-wav"} var SiteEmail string //contact@fchan.xyz var SiteEmailPassword string @@ -389,6 +389,17 @@ func CreateTripCode(input string) string { return out.String() } +func CreateNameTripCode(input string) string { + fmt.Println("AHHHHHHHHHH") + re := regexp.MustCompile("#.+") + chunck := re.FindString(input) + fmt.Println(input) + fmt.Println(chunck) + hash := CreateTripCode(chunck) + fmt.Println(hash[0:8]) + return re.ReplaceAllString(input, hash[0:8]) +} + func GetActorFromPath(db *sql.DB, location string, prefix string) Actor { pattern := fmt.Sprintf("%s([^/\n]+)(/.+)?", prefix) re := regexp.MustCompile(pattern) @@ -426,7 +437,7 @@ func GetContentType(location string) string { func RandomID(size int) string { rand.Seed(time.Now().UnixNano()) - domain := "0123456789ABCDEF" + domain := "0123456789ABCDEFG" rng := size newID := "" for i := 0; i < rng; i++ { @@ -1009,3 +1020,5 @@ func IsInStringArray(array []string, value string) bool { } return false } + + -- cgit v1.2.3