diff options
-rw-r--r-- | OutboxPost.go | 6 | ||||
-rw-r--r-- | main.go | 4 | ||||
-rw-r--r-- | static/catalog.html | 189 | ||||
-rw-r--r-- | static/ncatalog.html | 2 | ||||
-rw-r--r-- | static/posts.html | 9 |
5 files changed, 10 insertions, 200 deletions
diff --git a/OutboxPost.go b/OutboxPost.go index b51e7cc..f509b04 100644 --- a/OutboxPost.go +++ b/OutboxPost.go @@ -503,8 +503,10 @@ func CheckCaptcha(db *sql.DB, captcha string) bool { path := "public/" + parts[0] + ".png" code := GetCaptchaCodeDB(db, path) - DeleteCaptchaCodeDB(db, path) - CreateNewCaptcha(db) + if code != "" { + DeleteCaptchaCodeDB(db, path) + CreateNewCaptcha(db) + } if (code == strings.ToUpper(parts[1])) { return true @@ -243,7 +243,6 @@ func main() { auth := CreateTripCode(verify.Code) auth = CreateTripCode(auth) - if CreateTripCode(auth) == code { w.WriteHeader(http.StatusOK) } else { @@ -266,7 +265,6 @@ func main() { w.WriteHeader(http.StatusForbidden) w.Write([]byte("404 no path")) - }) http.HandleFunc("/post", func(w http.ResponseWriter, r *http.Request){ @@ -780,7 +778,7 @@ func main() { return } - if(!CheckCaptcha(db, captcha)) { + if(r.FormValue("captchaCode") == "" || !CheckCaptcha(db, captcha)) { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("captcha required")) return diff --git a/static/catalog.html b/static/catalog.html deleted file mode 100644 index b5b361e..0000000 --- a/static/catalog.html +++ /dev/null @@ -1,189 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>{{ .Title }}</title> - </head> - <style> - a, a:link, a:visited, a:hover, a:active { - text-decoration: none - } - - a:link, a:visited, a:active { - color: black; - } - - a:hover { - color: #de0808; - } - </style> - <script> - - function getMIMEType(type) - { - re = /\/.+/g - return type.replace(re, "") - } - - function shortURL(url) - { - var check = url.replace("{{.Board.Actor}}/", "") - re = /.+\//g; - temp = re.exec(url) - if(temp[0] == "{{ .Board.Actor }}/") - { - var short = url.replace("https://", ""); - short = short.replace("http://", ""); - short = short.replace("www.", ""); - - var re = /^.{3}/g; - - var u = re.exec(short); - - re = /\w+$/g; - - u = re.exec(short); - - return u; - }else{ - var short = url.replace("https://", ""); - short = short.replace("http://", ""); - short = short.replace("www.", ""); - - var re = /^.{3}/g; - - var u = re.exec(short); - - re = /\w+$/g; - - u = re.exec(short); - - - replace = short.replace(/\/+/g, " ") - replace = replace.replace(u, " ").trim() - re = /\w+$/; - v = re.exec(replace) - - v = "f" + v[0] + "-" + u - - return v; - } - } - - </script> - <body style="background-color: #eef2fe;"> - <ul id="top" style="padding:0; display: inline;"> - {{range .Boards}} - <li style="display: inline;"><a href="{{.Location}}">{{.Name }}</a></li> - {{end}} - </ul> - {{ $board := .Board }} - {{ if $board.IsMod }} - <span style="float: right;"><a href="/{{ .Key }}/{{ .Board.Name }}">[Manage Board]</a></span> - {{ end }} - <div style="margin: 0 auto; width: 400px; margin-bottom: 100px;"> - <h1 style="color: #af0a0f;">/{{ $board.Name }}/ - {{ $board.PrefName }}</h1> - <form id="new-post" action="/post" method="post" enctype="multipart/form-data"> - <label for="name">Name:</label><br> - <input type="text" id="name" name="name" placeholder="Anonymous"><br> - <label for="options">Options:</label><br> - <input type="text" id="options" name="options"><br> - <label for="subject">Subject:</label><br> - <input type="text" id="subject" name="subject"><input type="submit" value="Post"><br> - <label for="comment">Comment:</label><br> - <textarea rows="10" cols="50" id="comment" name="comment"></textarea><br> - <input type="hidden" id="inReplyTo" name="inReplyTo" value="{{ $board.InReplyTo }}"> - <input type="hidden" id="sendTo" name="sendTo" value="{{ $board.To }}"> - <input type="hidden" id="boardName" name="boardName" value="{{ $board.Name }}"> - <input type="hidden" id="captchaCode" name="captchaCode" value="{{ $board.CaptchaCode }}"> - <input type="file" id="file" name="file"><br><br> - <label stye="display: inline-block;" for="captcha">Captcha:</label><br> - <input style="display: inline-block;" type="text" id="captcha" name="captcha"><br> - <div style="height: 65px;"> - <img src="{{ $board.Captcha }}"> - </div> - </form> - </div> - - <hr> - <ul style="margin: 0; padding: 0; display: inline"> - <li style="display: inline"><a href="/{{ $board.Name }}">[Return]</a></li> - <li style="display: inline"><a href="#bottom">[Bottom]</a></li> - <li style="display: inline"><a href="javascript:location.reload()">[Refresh]</a></li> - </ul> - <hr> - - <div style="padding: 10px; text-align: center;"> - {{ range .Posts }} - <div style="overflow: hidden; vertical-align: top; margin: 0 auto; display: inline-block; width: 180px; max-height: 320px; margin-bottom: 10px;"> - {{ if $board.IsMod }} - <a href="/delete?id={{ .Id }}">[Delete Post]</a> - {{ end }} - {{ if .Attachment }} - {{ if $board.IsMod }} - <a href="/deleteattach?id={{ .Id }}">[Delete Attachment]</a> - {{ end }} - <a id="{{ .Id }}-anchor" href="/{{ $board.Name }}/"> - <div id="media-{{ .Id }}"></div> - <script> - media = document.getElementById("media-{{ .Id }}") - if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){ - var img = document.createElement("img"); - img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 150px; max-height: 150px; cursor: move;" - img.setAttribute("id", "img") - img.setAttribute("main", "1") - img.setAttribute("src", "{{ (index .Attachment 0).Href }}") - media.appendChild(img) - } - - if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){ - var audio = document.createElement("audio") - audio.controls = 'controls' - audio.muted = 'muted' - audio.src = '{{ (index .Attachment 0).Href }}' - audio.type = '{{ (index .Attachment 0).MediaType }}' - audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 150px;" - audio.innerText = 'Audio is not supported.' - media.appendChild(audio) - } - - if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ - var video = document.createElement("video") - video.controls = 'controls' - video.muted = 'muted' - video.src = '{{ (index .Attachment 0).Href }}' - video.type = '{{ (index .Attachment 0).MediaType }}' - video.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 150px;" - video.innerText = 'Video is not supported.' - media.appendChild(video) - } - </script> - - - {{ end }} - <div> - {{ $replies := .Replies }} - <span style="display: block">R: {{ $replies.TotalItems }}{{ if $replies.TotalImgs }}/ A: {{ $replies.TotalImgs }}{{ end }}</span> - {{ if .Name }} - <span style="display: block; color: #0f0c5d;"><b>{{ .Name }}</b></span> - {{ end }} - {{ if .Content }} - <span style="display: block">{{.Content}}</span> - {{ end }} - </div> - </a> - </div> - <script> - document.getElementById("{{ .Id }}-anchor").href = "/{{ $board.Name }}/" + shortURL("{{ .Id }}") - </script> - {{ end }} - </div> - <hr> - <ul style="margin: 0; padding: 0; display: inline"> - <li style="display: inline"><a href="/{{ $board.Name }}">[Return]</a></li> - <li style="display: inline"><a id="bottom" href="#top">[Top]</a></li> - <li style="display: inline"><a href="javascript:location.reload()">[Refresh]</a></li> - </ul> - <hr> - </body> -</html> - diff --git a/static/ncatalog.html b/static/ncatalog.html index a57e291..b4e6f76 100644 --- a/static/ncatalog.html +++ b/static/ncatalog.html @@ -49,7 +49,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ var video = document.createElement("video") video.controls = 'controls' - video.preload = 'none' + video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' video.type = '{{ (index .Attachment 0).MediaType }}' diff --git a/static/posts.html b/static/posts.html index e146032..0e381ea 100644 --- a/static/posts.html +++ b/static/posts.html @@ -39,7 +39,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){ var audio = document.createElement("audio") audio.controls = 'controls' - audio.preload = 'none' + audio.preload = 'metadata' audio.src = '{{ (index .Attachment 0).Href }}' audio.type = '{{ (index .Attachment 0).MediaType }}' audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;" @@ -50,7 +50,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ var video = document.createElement("video") video.controls = 'controls' - video.preload = 'none' + video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' video.type = '{{ (index .Attachment 0).MediaType }}' @@ -105,7 +105,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){ var audio = document.createElement("audio") audio.controls = 'controls' - audio.preload = 'none' + audio.preload = 'metadata' audio.src = '{{ (index .Attachment 0).Href }}' audio.type = '{{ (index .Attachment 0).MediaType }}' audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;" @@ -116,7 +116,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ var video = document.createElement("video") video.controls = 'controls' - video.preload = 'none' + video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' video.type = '{{ (index .Attachment 0).MediaType }}' @@ -175,7 +175,6 @@ var content = document.getElementById("{{ .Id }}-content"); content.innerHTML = convertContent('{{$board.Actor}}', content.innerText, '{{ $opId }}') - </script> {{ end }} {{ end }} |