We now show requests to non-existent routes on the Route Analytics Page.

The filter now catches more odd requests for statistical purposes.

More progress on poll posts.
Dropped the polls_voters table and added the polls_votes one. The two have different definitions.
This commit is contained in:
Azareal 2018-01-26 05:53:34 +00:00
parent 59754b489d
commit 1bd3d7d104
19 changed files with 568 additions and 290 deletions

View File

@ -56,6 +56,7 @@ type TopicPage struct {
Header *HeaderVars
ItemList []ReplyUser
Topic TopicUser
Poll Poll
Page int
LastPage int
}

View File

@ -1,7 +1,11 @@
package common
import "database/sql"
import "../query_gen/lib"
import (
"database/sql"
"encoding/json"
"../query_gen/lib"
)
var Polls PollStore
@ -11,9 +15,19 @@ type Poll struct {
//AntiCheat bool // Apply various mitigations for cheating
// GroupPower map[gid]points // The number of points a group can spend in this poll, defaults to 1
Options []string
Results map[int]int // map[optionIndex]points
VoteCount int
Options map[int]string
Results map[int]int // map[optionIndex]points
QuickOptions []PollOption // TODO: Fix up the template transpiler so we don't need to use this hack anymore
VoteCount int
}
func (poll *Poll) Copy() Poll {
return *poll
}
type PollOption struct {
ID int
Value string
}
type Pollable interface {
@ -23,7 +37,7 @@ type Pollable interface {
type PollStore interface {
Get(id int) (*Poll, error)
Exists(id int) bool
Create(parent Pollable, pollType int, pollOptions []string) (int, error)
Create(parent Pollable, pollType int, pollOptions map[int]string) (int, error)
Reload(id int) error
//GlobalCount() int
@ -72,8 +86,14 @@ func (store *DefaultPollStore) Get(id int) (*Poll, error) {
poll = &Poll{ID: id}
var optionTxt []byte
err = store.get.QueryRow(id).Scan(&poll.Type, optionTxt, &poll.VoteCount)
err = store.get.QueryRow(id).Scan(&poll.Type, &optionTxt, &poll.VoteCount)
if err != nil {
return nil, err
}
err = json.Unmarshal(optionTxt, &poll.Options)
if err == nil {
poll.QuickOptions = store.unpackOptionsMap(poll.Options)
store.cache.Set(poll)
}
return poll, err
@ -82,17 +102,38 @@ func (store *DefaultPollStore) Get(id int) (*Poll, error) {
func (store *DefaultPollStore) Reload(id int) error {
poll := &Poll{ID: id}
var optionTxt []byte
err := store.get.QueryRow(id).Scan(&poll.Type, optionTxt, &poll.VoteCount)
err := store.get.QueryRow(id).Scan(&poll.Type, &optionTxt, &poll.VoteCount)
if err != nil {
store.cache.Remove(id)
return err
}
err = json.Unmarshal(optionTxt, &poll.Options)
if err != nil {
store.cache.Remove(id)
return err
}
poll.QuickOptions = store.unpackOptionsMap(poll.Options)
_ = store.cache.Set(poll)
return nil
}
func (store *DefaultPollStore) Create(parent Pollable, pollType int, pollOptions []string) (id int, err error) {
res, err := store.create.Exec(pollType, pollOptions)
func (store *DefaultPollStore) unpackOptionsMap(rawOptions map[int]string) []PollOption {
options := make([]PollOption, len(rawOptions))
for id, option := range rawOptions {
options[id] = PollOption{id, option}
}
return options
}
func (store *DefaultPollStore) Create(parent Pollable, pollType int, pollOptions map[int]string) (id int, err error) {
pollOptionsTxt, err := json.Marshal(pollOptions)
if err != nil {
return 0, err
}
res, err := store.create.Exec(pollType, pollOptionsTxt) //pollOptionsTxt
if err != nil {
return 0, err
}

View File

@ -108,12 +108,16 @@ func compileTemplates() error {
log.Print("Compiling the templates")
var now = time.Now()
topic := TopicUser{1, "blah", "Blah", "Hey there!", 0, false, false, now, RelativeTime(now), now, RelativeTime(now), 0, "", "127.0.0.1", 0, 1, "classname", "weird-data", BuildProfileURL("fake-user", 62), "Fake User", Config.DefaultGroup, "", 0, "", "", "", "", "", 58, false}
poll := Poll{ID: 1, Type: 0, Options: map[int]string{0: "Nothing", 1: "Something"}, Results: map[int]int{0: 5, 1: 2}, QuickOptions: []PollOption{
PollOption{0, "Nothing"},
PollOption{1, "Something"},
}, VoteCount: 7}
topic := TopicUser{1, "blah", "Blah", "Hey there!", 0, false, false, now, RelativeTime(now), now, RelativeTime(now), 0, "", "127.0.0.1", 0, 1, "classname", poll.ID, "weird-data", BuildProfileURL("fake-user", 62), "Fake User", Config.DefaultGroup, "", 0, "", "", "", "", "", 58, false}
var replyList []ReplyUser
replyList = append(replyList, ReplyUser{0, 0, "Yo!", "Yo!", 0, "alice", "Alice", Config.DefaultGroup, now, RelativeTime(now), 0, 0, "", "", 0, "", "", "", "", 0, "127.0.0.1", false, 1, "", ""})
var varList = make(map[string]tmpl.VarItem)
tpage := TopicPage{"Title", user, headerVars, replyList, topic, 1, 1}
tpage := TopicPage{"Title", user, headerVars, replyList, topic, poll, 1, 1}
topicIDTmpl, err := c.Compile("topic.html", "templates/", "common.TopicPage", tpage, varList)
if err != nil {
return err

View File

@ -41,6 +41,7 @@ type Topic struct {
PostCount int
LikeCount int
ClassName string // CSS Class Name
Poll int
Data string // Used for report metadata
}
@ -63,6 +64,7 @@ type TopicUser struct {
PostCount int
LikeCount int
ClassName string
Poll int
Data string // Used for report metadata
UserLink string
@ -146,8 +148,8 @@ func init() {
setPoll: acc.Update("topics").Set("content = '', parsed_content = '', poll = ?").Where("tid = ? AND poll = 0").Prepare(),
createActionReply: acc.Insert("replies").Columns("tid, actionType, ipaddress, createdBy, createdAt, lastUpdated, content, parsed_content").Fields("?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),'',''").Prepare(),
getTopicUser: acc.SimpleLeftJoin("topics", "users", "topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level", "topics.createdBy = users.uid", "tid = ?", "", ""),
getByReplyID: acc.SimpleLeftJoin("replies", "topics", "topics.tid, topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, topics.data", "replies.tid = topics.tid", "rid = ?", "", ""),
getTopicUser: acc.SimpleLeftJoin("topics", "users", "topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, topics.poll, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level", "topics.createdBy = users.uid", "tid = ?", "", ""),
getByReplyID: acc.SimpleLeftJoin("replies", "topics", "topics.tid, topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, topics.poll, topics.data", "replies.tid = topics.tid", "rid = ?", "", ""),
}
return acc.FirstError()
})
@ -283,7 +285,7 @@ func (topic *Topic) Copy() Topic {
func TopicByReplyID(rid int) (*Topic, error) {
topic := Topic{ID: 0}
err := topicStmts.getByReplyID.QueryRow(rid).Scan(&topic.ID, &topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Data)
err := topicStmts.getByReplyID.QueryRow(rid).Scan(&topic.ID, &topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Poll, &topic.Data)
topic.Link = BuildTopicURL(NameToSlug(topic.Title), topic.ID)
return &topic, err
}
@ -316,13 +318,13 @@ func GetTopicUser(tid int) (TopicUser, error) {
}
tu := TopicUser{ID: tid}
err := topicStmts.getTopicUser.QueryRow(tid).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.IsClosed, &tu.Sticky, &tu.ParentID, &tu.IPAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
err := topicStmts.getTopicUser.QueryRow(tid).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.IsClosed, &tu.Sticky, &tu.ParentID, &tu.IPAddress, &tu.PostCount, &tu.LikeCount, &tu.Poll, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
tu.Link = BuildTopicURL(NameToSlug(tu.Title), tu.ID)
tu.UserLink = BuildProfileURL(NameToSlug(tu.CreatedByName), tu.CreatedBy)
tu.Tag = Groups.DirtyGet(tu.Group).Tag
if tcache != nil {
theTopic := Topic{ID: tu.ID, Link: tu.Link, Title: tu.Title, Content: tu.Content, CreatedBy: tu.CreatedBy, IsClosed: tu.IsClosed, Sticky: tu.Sticky, CreatedAt: tu.CreatedAt, LastReplyAt: tu.LastReplyAt, ParentID: tu.ParentID, IPAddress: tu.IPAddress, PostCount: tu.PostCount, LikeCount: tu.LikeCount}
theTopic := Topic{ID: tu.ID, Link: tu.Link, Title: tu.Title, Content: tu.Content, CreatedBy: tu.CreatedBy, IsClosed: tu.IsClosed, Sticky: tu.Sticky, CreatedAt: tu.CreatedAt, LastReplyAt: tu.LastReplyAt, ParentID: tu.ParentID, IPAddress: tu.IPAddress, PostCount: tu.PostCount, LikeCount: tu.LikeCount, Poll: tu.Poll}
//log.Printf("theTopic: %+v\n", theTopic)
_ = tcache.Add(&theTopic)
}
@ -351,6 +353,7 @@ func copyTopicToTopicUser(topic *Topic, user *User) (tu TopicUser) {
tu.IPAddress = topic.IPAddress
tu.PostCount = topic.PostCount
tu.LikeCount = topic.LikeCount
tu.Poll = topic.Poll
tu.Data = topic.Data
return tu

View File

@ -56,7 +56,7 @@ func NewDefaultTopicStore(cache TopicCache) (*DefaultTopicStore, error) {
}
return &DefaultTopicStore{
cache: cache,
get: acc.Select("topics").Columns("title, content, createdBy, createdAt, lastReplyAt, is_closed, sticky, parentID, ipaddress, postCount, likeCount, data").Where("tid = ?").Prepare(),
get: acc.Select("topics").Columns("title, content, createdBy, createdAt, lastReplyAt, is_closed, sticky, parentID, ipaddress, postCount, likeCount, poll, data").Where("tid = ?").Prepare(),
exists: acc.Select("topics").Columns("tid").Where("tid = ?").Prepare(),
topicCount: acc.Count("topics").Prepare(),
create: acc.Insert("topics").Columns("parentID, title, content, parsed_content, createdAt, lastReplyAt, lastReplyBy, ipaddress, words, createdBy").Fields("?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,?").Prepare(),
@ -70,7 +70,7 @@ func (mts *DefaultTopicStore) DirtyGet(id int) *Topic {
}
topic = &Topic{ID: id}
err = mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Data)
err = mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Poll, &topic.Data)
if err == nil {
topic.Link = BuildTopicURL(NameToSlug(topic.Title), id)
_ = mts.cache.Add(topic)
@ -87,7 +87,7 @@ func (mts *DefaultTopicStore) Get(id int) (topic *Topic, err error) {
}
topic = &Topic{ID: id}
err = mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Data)
err = mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Poll, &topic.Data)
if err == nil {
topic.Link = BuildTopicURL(NameToSlug(topic.Title), id)
_ = mts.cache.Add(topic)
@ -98,14 +98,14 @@ func (mts *DefaultTopicStore) Get(id int) (topic *Topic, err error) {
// BypassGet will always bypass the cache and pull the topic directly from the database
func (mts *DefaultTopicStore) BypassGet(id int) (*Topic, error) {
topic := &Topic{ID: id}
err := mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Data)
err := mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Poll, &topic.Data)
topic.Link = BuildTopicURL(NameToSlug(topic.Title), id)
return topic, err
}
func (mts *DefaultTopicStore) Reload(id int) error {
topic := &Topic{ID: id}
err := mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Data)
err := mts.get.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.LastReplyAt, &topic.IsClosed, &topic.Sticky, &topic.ParentID, &topic.IPAddress, &topic.PostCount, &topic.LikeCount, &topic.Poll, &topic.Data)
if err == nil {
topic.Link = BuildTopicURL(NameToSlug(topic.Title), id)
_ = mts.cache.Set(topic)

View File

@ -107,6 +107,7 @@ var RouteMap = map[string]interface{}{
"routeRegisterSubmit": routeRegisterSubmit,
"routeDynamic": routeDynamic,
"routeUploads": routeUploads,
"BadRoute": BadRoute,
}
// ! NEVER RELY ON THESE REMAINING THE SAME BETWEEN COMMITS
@ -202,6 +203,7 @@ var routeMapEnum = map[string]int{
"routeRegisterSubmit": 88,
"routeDynamic": 89,
"routeUploads": 90,
"BadRoute": 91,
}
var reverseRouteMapEnum = map[int]string{
0: "routeAPI",
@ -295,6 +297,7 @@ var reverseRouteMapEnum = map[int]string{
88: "routeRegisterSubmit",
89: "routeDynamic",
90: "routeUploads",
91: "BadRoute",
}
var agentMapEnum = map[string]int{
"unknown": 0,
@ -315,6 +318,7 @@ var agentMapEnum = map[string]int{
"lynx": 15,
"blank": 16,
"malformed": 17,
"suspicious": 18,
}
var reverseAgentMapEnum = map[int]string{
0: "unknown",
@ -335,6 +339,7 @@ var reverseAgentMapEnum = map[int]string{
15: "lynx",
16: "blank",
17: "malformed",
18: "suspicious",
}
// TODO: Stop spilling these into the package scope?
@ -397,7 +402,7 @@ func (router *GenRouter) RemoveFunc(pattern string) error {
func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
w.WriteHeader(405)
w.WriteHeader(200) // 405
w.Write([]byte(""))
log.Print("Malformed Request")
log.Print("UA: ", req.UserAgent())
@ -432,10 +437,12 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Print("req.URL.RawQuery: ", req.URL.RawQuery)
log.Print("req.Referer(): ", req.Referer())
log.Print("req.RemoteAddr: ", req.RemoteAddr)
common.AgentViewCounter.Bump(18)
break
}
}
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") {
// TODO: Flag any requests which has a dot with anything but a number after that
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") || strings.Contains(req.URL.Path,".php") || strings.Contains(req.URL.Path,".asp") || strings.Contains(req.URL.Path,".cgi") {
log.Print("Suspicious UA: ", req.UserAgent())
log.Print("Method: ", req.Method)
for key, value := range req.Header {
@ -448,6 +455,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Print("req.URL.RawQuery: ", req.URL.RawQuery)
log.Print("req.Referer(): ", req.Referer())
log.Print("req.RemoteAddr: ", req.RemoteAddr)
common.AgentViewCounter.Bump(18)
}
}
@ -1522,6 +1530,8 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
return
}
common.NotFound(w,req) // TODO: Collect all the error view counts so we can add a replacement for GlobalViewCounter by adding up the view counts of every route? Complex and may be inaccurate, collecting it globally and locally would at-least help find places we aren't capturing views
common.RouteViewCounter.Bump(91)
common.NotFound(w,req)
}
}

View File

@ -591,8 +591,25 @@ $(document).ready(function(){
if(event.which == 39) this.querySelectorAll("#nextFloat a")[0].click();
};
function addPollInput() {
console.log("clicked on pollinputinput");
let dataPollInput = $(this).parent().attr("data-pollinput");
console.log("dataPollInput: ", dataPollInput);
if(dataPollInput == undefined) return;
if(dataPollInput != (pollInputIndex-1)) return;
$(".poll_content_row .formitem").append("<div class='pollinput' data-pollinput='"+pollInputIndex+"'><input type='checkbox' disabled /><label class='pollinputlabel'></label><input form='topic_create_form_form' name='pollinputitem["+pollInputIndex+"]' class='pollinputinput' type='text' placeholder='Add new poll option' /></div>");
pollInputIndex++;
console.log("new pollInputIndex: ", pollInputIndex);
$(".pollinputinput").off("click");
$(".pollinputinput").click(addPollInput);
}
var pollInputIndex = 1;
$("#add_poll_button").click(function(event){
event.preventDefault();
$(".poll_content_row").removeClass("auto_hide");
$("#has_poll_input").val("1");
$(".pollinputinput").click(addPollInput);
});
});

View File

@ -230,11 +230,13 @@ func createTables(adapter qgen.Adapter) error {
},
)
qgen.Install.CreateTable("polls_voters", "utf8mb4", "utf8mb4_general_ci",
qgen.Install.CreateTable("polls_votes", "utf8mb4", "utf8mb4_general_ci",
[]qgen.DBTableColumn{
qgen.DBTableColumn{"pollID", "int", 0, false, false, ""},
qgen.DBTableColumn{"uid", "int", 0, false, false, ""},
qgen.DBTableColumn{"option", "int", 0, false, false, "0"},
qgen.DBTableColumn{"castAt", "createdAt", 0, false, false, ""},
qgen.DBTableColumn{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"},
},
[]qgen.DBTableKey{},
)

View File

@ -155,6 +155,7 @@ func main() {
// Stubs for us to refer to these routes through
mapIt("routeDynamic")
mapIt("routeUploads")
mapIt("BadRoute")
tmplVars.AllRouteNames = allRouteNames
tmplVars.AllRouteMap = allRouteMap
tmplVars.AllAgentNames = []string{
@ -177,6 +178,7 @@ func main() {
"lynx",
"blank",
"malformed",
"suspicious",
}
tmplVars.AllAgentMap = make(map[string]int)
@ -279,7 +281,7 @@ func (router *GenRouter) RemoveFunc(pattern string) error {
func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
w.WriteHeader(405)
w.WriteHeader(200) // 405
w.Write([]byte(""))
log.Print("Malformed Request")
log.Print("UA: ", req.UserAgent())
@ -314,10 +316,12 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Print("req.URL.RawQuery: ", req.URL.RawQuery)
log.Print("req.Referer(): ", req.Referer())
log.Print("req.RemoteAddr: ", req.RemoteAddr)
common.AgentViewCounter.Bump({{.AllAgentMap.suspicious}})
break
}
}
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") {
// TODO: Flag any requests which has a dot with anything but a number after that
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") || strings.Contains(req.URL.Path,".php") || strings.Contains(req.URL.Path,".asp") || strings.Contains(req.URL.Path,".cgi") {
log.Print("Suspicious UA: ", req.UserAgent())
log.Print("Method: ", req.Method)
for key, value := range req.Header {
@ -330,6 +334,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Print("req.URL.RawQuery: ", req.URL.RawQuery)
log.Print("req.Referer(): ", req.Referer())
log.Print("req.RemoteAddr: ", req.RemoteAddr)
common.AgentViewCounter.Bump({{.AllAgentMap.suspicious}})
}
}
@ -518,7 +523,9 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
return
}
common.NotFound(w,req) // TODO: Collect all the error view counts so we can add a replacement for GlobalViewCounter by adding up the view counts of every route? Complex and may be inaccurate, collecting it globally and locally would at-least help find places we aren't capturing views
common.RouteViewCounter.Bump({{.AllRouteMap.BadRoute}})
common.NotFound(w,req)
}
}
`

View File

@ -45,6 +45,8 @@ func routeDynamic() {
}
func routeUploads() {
}
func BadRoute() {
}
// GET functions
func routeStatic(w http.ResponseWriter, r *http.Request) {
@ -484,9 +486,18 @@ func routeTopicID(w http.ResponseWriter, r *http.Request, user common.User, urlB
topic.Avatar = strings.Replace(common.Config.Noavatar, "{id}", strconv.Itoa(topic.CreatedBy), 1)
}
var poll *common.Poll
if topic.Poll != 0 {
poll, err = common.Polls.Get(topic.Poll)
if err != nil {
log.Print("Couldn't find the attached poll for topic " + strconv.Itoa(topic.ID))
return common.InternalError(err, w, r)
}
}
// Calculate the offset
offset, page, lastPage := common.PageOffset(topic.PostCount, page, common.Config.ItemsPerPage)
tpage := common.TopicPage{topic.Title, user, headerVars, replyList, topic, page, lastPage}
tpage := common.TopicPage{topic.Title, user, headerVars, replyList, topic, poll.Copy(), page, lastPage}
// Get the replies..
rows, err := stmts.getTopicRepliesOffset.Query(topic.ID, offset, common.Config.ItemsPerPage)

View File

@ -133,8 +133,54 @@ func CreateTopicSubmit(w http.ResponseWriter, r *http.Request, user common.User)
return common.LocalError("This topic doesn't have a title", w, r, user)
case common.ErrNoBody:
return common.LocalError("This topic doesn't have a body", w, r, user)
default:
return common.InternalError(err, w, r)
}
return common.InternalError(err, w, r)
}
topic, err := common.Topics.Get(tid)
if err != nil {
return common.LocalError("Unable to load the topic", w, r, user)
}
if r.PostFormValue("has_poll") == "1" {
var maxPollOptions = 10
var pollInputItems = make(map[int]string)
var pollInputCount = 0
for key, values := range r.Form {
//if common.Dev.SuperDebug {
log.Print("key: ", key)
log.Printf("values: %+v\n", values)
//}
for _, value := range values {
if strings.HasPrefix(key, "pollinputitem[") {
halves := strings.Split(key, "[")
if len(halves) != 2 {
return common.LocalError("Malformed pollinputitem", w, r, user)
}
halves[1] = strings.TrimSuffix(halves[1], "]")
index, err := strconv.Atoi(halves[1])
if err != nil {
return common.LocalError("Malformed pollinputitem", w, r, user)
}
// If there are duplicates, then something has gone horribly wrong, so let's ignore them, this'll likely happen during an attack
_, exists := pollInputItems[index]
if !exists {
pollInputCount++
pollInputItems[index] = html.EscapeString(value)
if len(pollInputItems) >= maxPollOptions {
break
}
}
}
}
}
pollType := 0 // Basic single choice
_, err := common.Polls.Create(topic, pollType, pollInputItems)
if err != nil {
return common.LocalError("Failed to add poll to topic", w, r, user) // TODO: Might need to be an internal error as it could leave phantom polls?
}
}

View File

@ -0,0 +1,7 @@
CREATE TABLE [polls_votes] (
[pollID] int not null,
[uid] int not null,
[option] int DEFAULT 0 not null,
[castAt] datetime not null,
[ipaddress] nvarchar (200) DEFAULT '0.0.0.0.0' not null
);

View File

@ -0,0 +1,7 @@
CREATE TABLE `polls_votes` (
`pollID` int not null,
`uid` int not null,
`option` int DEFAULT 0 not null,
`castAt` datetime not null,
`ipaddress` varchar(200) DEFAULT '0.0.0.0.0' not null
) CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;

View File

@ -0,0 +1,7 @@
CREATE TABLE `polls_votes` (
`pollID` int not null,
`uid` int not null,
`option` int DEFAULT 0 not null,
`castAt` timestamp not null,
`ipaddress` varchar (200) DEFAULT '0.0.0.0.0' not null
);

View File

@ -350,171 +350,209 @@ var topic_alt_20 = []byte(`
</div>
<div class="rowblock post_container">
`)
var topic_alt_21 = []byte(`
<article class="rowitem passive deletable_block editable_parent post_item top_post">
<div class="userinfo" aria-label="The information on the poster">
<div class="avatar_item" style="background-image: url(`)
var topic_alt_22 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
<a href="`)
var topic_alt_23 = []byte(`" class="the_name" rel="author">`)
var topic_alt_24 = []byte(`</a>
`)
var topic_alt_25 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_26 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_27 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_28 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_29 = []byte(`
</div>
<div class="content_container">
<div class="hide_on_edit topic_content user_content" itemprop="text">
`)
var topic_alt_30 = []byte(`
<div class="poll_option">
<input id="poll_option_`)
var topic_alt_31 = []byte(`" name="poll_option_input" type="checkbox" value="`)
var topic_alt_32 = []byte(`" />
<label class="poll_option_label" for="poll_option_`)
var topic_alt_33 = []byte(`">
<div class="sel"></div>
</label>
<span class="poll_option_text">`)
var topic_alt_34 = []byte(`</span>
</div>
`)
var topic_alt_35 = []byte(`
</div>
</div>
</article>
`)
var topic_alt_36 = []byte(`
<article itemscope itemtype="http://schema.org/CreativeWork" class="rowitem passive deletable_block editable_parent post_item top_post" aria-label="The opening post for this topic">
<div class="userinfo" aria-label="The information on the poster">
<div class="avatar_item" style="background-image: url(`)
var topic_alt_21 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
var topic_alt_37 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
<a href="`)
var topic_alt_22 = []byte(`" class="the_name" rel="author">`)
var topic_alt_23 = []byte(`</a>
var topic_alt_38 = []byte(`" class="the_name" rel="author">`)
var topic_alt_39 = []byte(`</a>
`)
var topic_alt_24 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_25 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_26 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_27 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_28 = []byte(`
var topic_alt_40 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_41 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_42 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_43 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_44 = []byte(`
</div>
<div class="content_container">
<div class="hide_on_edit topic_content user_content" itemprop="text">`)
var topic_alt_29 = []byte(`</div>
var topic_alt_45 = []byte(`</div>
<textarea name="topic_content" class="show_on_edit topic_content_input">`)
var topic_alt_30 = []byte(`</textarea>
var topic_alt_46 = []byte(`</textarea>
<div class="button_container">
`)
var topic_alt_31 = []byte(`<a href="/topic/like/submit/`)
var topic_alt_32 = []byte(`?session=`)
var topic_alt_33 = []byte(`" class="action_button like_item add_like" aria-label="Like this post" data-action="like"></a>`)
var topic_alt_34 = []byte(`<a href="/topic/edit/`)
var topic_alt_35 = []byte(`" class="action_button open_edit" aria-label="Edit this post" data-action="edit"></a>`)
var topic_alt_36 = []byte(`<a href="/topic/delete/submit/`)
var topic_alt_37 = []byte(`?session=`)
var topic_alt_38 = []byte(`" class="action_button delete_item" aria-label="Delete this post" data-action="delete"></a>`)
var topic_alt_39 = []byte(`<a href='/topic/unlock/submit/`)
var topic_alt_40 = []byte(`?session=`)
var topic_alt_41 = []byte(`' class="action_button unlock_item" data-action="unlock"></a>`)
var topic_alt_42 = []byte(`<a href='/topic/lock/submit/`)
var topic_alt_43 = []byte(`?session=`)
var topic_alt_44 = []byte(`' class="action_button lock_item" data-action="lock"></a>`)
var topic_alt_45 = []byte(`<a href='/topic/unstick/submit/`)
var topic_alt_46 = []byte(`?session=`)
var topic_alt_47 = []byte(`' class="action_button unpin_item" data-action="unpin"></a>`)
var topic_alt_48 = []byte(`<a href='/topic/stick/submit/`)
var topic_alt_49 = []byte(`?session=`)
var topic_alt_50 = []byte(`' class="action_button pin_item" data-action="pin"></a>`)
var topic_alt_51 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_52 = []byte(`" title="IP Address" class="action_button ip_item_button hide_on_big" aria-label="This user's IP" data-action="ip"></a>`)
var topic_alt_53 = []byte(`
var topic_alt_47 = []byte(`<a href="/topic/like/submit/`)
var topic_alt_48 = []byte(`?session=`)
var topic_alt_49 = []byte(`" class="action_button like_item add_like" aria-label="Like this post" data-action="like"></a>`)
var topic_alt_50 = []byte(`<a href="/topic/edit/`)
var topic_alt_51 = []byte(`" class="action_button open_edit" aria-label="Edit this post" data-action="edit"></a>`)
var topic_alt_52 = []byte(`<a href="/topic/delete/submit/`)
var topic_alt_53 = []byte(`?session=`)
var topic_alt_54 = []byte(`" class="action_button delete_item" aria-label="Delete this post" data-action="delete"></a>`)
var topic_alt_55 = []byte(`<a href='/topic/unlock/submit/`)
var topic_alt_56 = []byte(`?session=`)
var topic_alt_57 = []byte(`' class="action_button unlock_item" data-action="unlock"></a>`)
var topic_alt_58 = []byte(`<a href='/topic/lock/submit/`)
var topic_alt_59 = []byte(`?session=`)
var topic_alt_60 = []byte(`' class="action_button lock_item" data-action="lock"></a>`)
var topic_alt_61 = []byte(`<a href='/topic/unstick/submit/`)
var topic_alt_62 = []byte(`?session=`)
var topic_alt_63 = []byte(`' class="action_button unpin_item" data-action="unpin"></a>`)
var topic_alt_64 = []byte(`<a href='/topic/stick/submit/`)
var topic_alt_65 = []byte(`?session=`)
var topic_alt_66 = []byte(`' class="action_button pin_item" data-action="pin"></a>`)
var topic_alt_67 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_68 = []byte(`" title="IP Address" class="action_button ip_item_button hide_on_big" aria-label="This user's IP" data-action="ip"></a>`)
var topic_alt_69 = []byte(`
<a href="/report/submit/`)
var topic_alt_54 = []byte(`?session=`)
var topic_alt_55 = []byte(`&type=topic" class="action_button report_item" aria-label="Report this post" data-action="report"></a>
var topic_alt_70 = []byte(`?session=`)
var topic_alt_71 = []byte(`&type=topic" class="action_button report_item" aria-label="Report this post" data-action="report"></a>
<a href="#" class="action_button button_menu"></a>
`)
var topic_alt_56 = []byte(`
var topic_alt_72 = []byte(`
<div class="action_button_right`)
var topic_alt_57 = []byte(` has_likes`)
var topic_alt_58 = []byte(`">
var topic_alt_73 = []byte(` has_likes`)
var topic_alt_74 = []byte(`">
`)
var topic_alt_59 = []byte(`<a class="action_button like_count hide_on_micro">`)
var topic_alt_60 = []byte(`</a>`)
var topic_alt_61 = []byte(`
var topic_alt_75 = []byte(`<a class="action_button like_count hide_on_micro">`)
var topic_alt_76 = []byte(`</a>`)
var topic_alt_77 = []byte(`
<a class="action_button created_at hide_on_mobile">`)
var topic_alt_62 = []byte(`</a>
var topic_alt_78 = []byte(`</a>
`)
var topic_alt_63 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_64 = []byte(`" title="IP Address" class="action_button ip_item hide_on_mobile">`)
var topic_alt_65 = []byte(`</a>`)
var topic_alt_66 = []byte(`
var topic_alt_79 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_80 = []byte(`" title="IP Address" class="action_button ip_item hide_on_mobile">`)
var topic_alt_81 = []byte(`</a>`)
var topic_alt_82 = []byte(`
</div>
</div>
</div><div style="clear:both;"></div>
</article>
`)
var topic_alt_67 = []byte(`
var topic_alt_83 = []byte(`
<article itemscope itemtype="http://schema.org/CreativeWork" class="rowitem passive deletable_block editable_parent post_item `)
var topic_alt_68 = []byte(`action_item`)
var topic_alt_69 = []byte(`">
var topic_alt_84 = []byte(`action_item`)
var topic_alt_85 = []byte(`">
<div class="userinfo" aria-label="The information on the poster">
<div class="avatar_item" style="background-image: url(`)
var topic_alt_70 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
var topic_alt_86 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
<a href="`)
var topic_alt_71 = []byte(`" class="the_name" rel="author">`)
var topic_alt_72 = []byte(`</a>
var topic_alt_87 = []byte(`" class="the_name" rel="author">`)
var topic_alt_88 = []byte(`</a>
`)
var topic_alt_73 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_74 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_75 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_76 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_77 = []byte(`
var topic_alt_89 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_90 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_91 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_92 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_93 = []byte(`
</div>
<div class="content_container" `)
var topic_alt_78 = []byte(`style="margin-left: 0px;"`)
var topic_alt_79 = []byte(`>
var topic_alt_94 = []byte(`style="margin-left: 0px;"`)
var topic_alt_95 = []byte(`>
`)
var topic_alt_80 = []byte(`
var topic_alt_96 = []byte(`
<span class="action_icon" style="font-size: 18px;padding-right: 5px;">`)
var topic_alt_81 = []byte(`</span>
var topic_alt_97 = []byte(`</span>
<span itemprop="text">`)
var topic_alt_82 = []byte(`</span>
var topic_alt_98 = []byte(`</span>
`)
var topic_alt_83 = []byte(`
var topic_alt_99 = []byte(`
<div class="editable_block user_content" itemprop="text">`)
var topic_alt_84 = []byte(`</div>
var topic_alt_100 = []byte(`</div>
<div class="button_container">
`)
var topic_alt_85 = []byte(`<a href="/reply/like/submit/`)
var topic_alt_86 = []byte(`?session=`)
var topic_alt_87 = []byte(`" class="action_button like_item add_like" aria-label="Like this post" data-action="like"></a>`)
var topic_alt_88 = []byte(`<a href="/reply/edit/submit/`)
var topic_alt_89 = []byte(`?session=`)
var topic_alt_90 = []byte(`" class="action_button edit_item" aria-label="Edit this post" data-action="edit"></a>`)
var topic_alt_91 = []byte(`<a href="/reply/delete/submit/`)
var topic_alt_92 = []byte(`?session=`)
var topic_alt_93 = []byte(`" class="action_button delete_item" aria-label="Delete this post" data-action="delete"></a>`)
var topic_alt_94 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_95 = []byte(`" title="IP Address" class="action_button ip_item_button hide_on_big" aria-label="This user's IP Address" data-action="ip"></a>`)
var topic_alt_96 = []byte(`
var topic_alt_101 = []byte(`<a href="/reply/like/submit/`)
var topic_alt_102 = []byte(`?session=`)
var topic_alt_103 = []byte(`" class="action_button like_item add_like" aria-label="Like this post" data-action="like"></a>`)
var topic_alt_104 = []byte(`<a href="/reply/edit/submit/`)
var topic_alt_105 = []byte(`?session=`)
var topic_alt_106 = []byte(`" class="action_button edit_item" aria-label="Edit this post" data-action="edit"></a>`)
var topic_alt_107 = []byte(`<a href="/reply/delete/submit/`)
var topic_alt_108 = []byte(`?session=`)
var topic_alt_109 = []byte(`" class="action_button delete_item" aria-label="Delete this post" data-action="delete"></a>`)
var topic_alt_110 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_111 = []byte(`" title="IP Address" class="action_button ip_item_button hide_on_big" aria-label="This user's IP Address" data-action="ip"></a>`)
var topic_alt_112 = []byte(`
<a href="/report/submit/`)
var topic_alt_97 = []byte(`?session=`)
var topic_alt_98 = []byte(`&type=reply" class="action_button report_item" aria-label="Report this post" data-action="report"></a>
var topic_alt_113 = []byte(`?session=`)
var topic_alt_114 = []byte(`&type=reply" class="action_button report_item" aria-label="Report this post" data-action="report"></a>
<a href="#" class="action_button button_menu"></a>
`)
var topic_alt_99 = []byte(`
var topic_alt_115 = []byte(`
<div class="action_button_right`)
var topic_alt_100 = []byte(` has_likes`)
var topic_alt_101 = []byte(`">
var topic_alt_116 = []byte(` has_likes`)
var topic_alt_117 = []byte(`">
`)
var topic_alt_102 = []byte(`<a class="action_button like_count hide_on_micro">`)
var topic_alt_103 = []byte(`</a>`)
var topic_alt_104 = []byte(`
var topic_alt_118 = []byte(`<a class="action_button like_count hide_on_micro">`)
var topic_alt_119 = []byte(`</a>`)
var topic_alt_120 = []byte(`
<a class="action_button created_at hide_on_mobile">`)
var topic_alt_105 = []byte(`</a>
var topic_alt_121 = []byte(`</a>
`)
var topic_alt_106 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_107 = []byte(`" title="IP Address" class="action_button ip_item hide_on_mobile">`)
var topic_alt_108 = []byte(`</a>`)
var topic_alt_109 = []byte(`
var topic_alt_122 = []byte(`<a href="/users/ips/?ip=`)
var topic_alt_123 = []byte(`" title="IP Address" class="action_button ip_item hide_on_mobile">`)
var topic_alt_124 = []byte(`</a>`)
var topic_alt_125 = []byte(`
</div>
</div>
`)
var topic_alt_110 = []byte(`
var topic_alt_126 = []byte(`
</div>
<div style="clear:both;"></div>
</article>
`)
var topic_alt_111 = []byte(`</div>
var topic_alt_127 = []byte(`</div>
`)
var topic_alt_112 = []byte(`
var topic_alt_128 = []byte(`
<div class="rowblock topic_reply_container">
<div class="userinfo" aria-label="The information on the poster">
<div class="avatar_item" style="background-image: url(`)
var topic_alt_113 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
var topic_alt_129 = []byte(`), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
<a href="`)
var topic_alt_114 = []byte(`" class="the_name" rel="author">`)
var topic_alt_115 = []byte(`</a>
var topic_alt_130 = []byte(`" class="the_name" rel="author">`)
var topic_alt_131 = []byte(`</a>
`)
var topic_alt_116 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_117 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_118 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_119 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_120 = []byte(`
var topic_alt_132 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">`)
var topic_alt_133 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_134 = []byte(`<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level `)
var topic_alt_135 = []byte(`</div><div class="tag_post"></div></div>`)
var topic_alt_136 = []byte(`
</div>
<div class="rowblock topic_reply_form quick_create_form">
<form id="reply_form" enctype="multipart/form-data" action="/reply/create/?session=`)
var topic_alt_121 = []byte(`" method="post"></form>
var topic_alt_137 = []byte(`" method="post"></form>
<input form="reply_form" name="tid" value='`)
var topic_alt_122 = []byte(`' type="hidden" />
var topic_alt_138 = []byte(`' type="hidden" />
<div class="formrow real_first_child">
<div class="formitem">
<textarea id="input_content" form="reply_form" name="reply-content" placeholder="What do you think?" required></textarea>
@ -524,17 +562,17 @@ var topic_alt_122 = []byte(`' type="hidden" />
<div class="formitem">
<button form="reply_form" name="reply-button" class="formbutton">Create Reply</button>
`)
var topic_alt_123 = []byte(`
var topic_alt_139 = []byte(`
<input name="upload_files" form="reply_form" id="upload_files" multiple type="file" style="display: none;" />
<label for="upload_files" class="formbutton add_file_button">Add File</label>
<div id="upload_file_dock"></div>`)
var topic_alt_124 = []byte(`
var topic_alt_140 = []byte(`
</div>
</div>
</div>
</div>
`)
var topic_alt_125 = []byte(`
var topic_alt_141 = []byte(`
</main>
@ -874,6 +912,7 @@ var topics_15 = []byte(`
<div class="rowblock topic_create_form quick_create_form" style="display: none;" aria-label="Quick Topic Form">
<form name="topic_create_form_form" id="topic_create_form_form" enctype="multipart/form-data" action="/topic/create/submit/?session=`)
var topics_16 = []byte(`" method="post"></form>
<input form="topic_create_form_form" id="has_poll_input" name="has_poll" value="0" type="hidden" />
<img class="little_row_avatar" src="`)
var topics_17 = []byte(`" height="64" alt="Your Avatar" title="Your Avatar" />
<div class="main_form">
@ -902,10 +941,10 @@ var topics_23 = []byte(`
</div>
<div class="formrow poll_content_row auto_hide">
<div class="formitem">
<div class="pollinput">
<div class="pollinput" data-pollinput="0">
<input type="checkbox" disabled />
<label class="pollinputlabel"></label>
<input type="text" placeholder="Add new poll option" />
<input form="topic_create_form_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="Add new poll option" />
</div>
</div>
</div>

View File

@ -126,232 +126,266 @@ w.Write([]byte(tmpl_topic_alt_vars.Topic.Title))
w.Write(topic_alt_19)
}
w.Write(topic_alt_20)
w.Write([]byte(tmpl_topic_alt_vars.Topic.Avatar))
if tmpl_topic_alt_vars.Poll.ID > 0 {
w.Write(topic_alt_21)
w.Write([]byte(tmpl_topic_alt_vars.Topic.UserLink))
w.Write([]byte(tmpl_topic_alt_vars.Topic.Avatar))
w.Write(topic_alt_22)
w.Write([]byte(tmpl_topic_alt_vars.Topic.CreatedByName))
w.Write([]byte(tmpl_topic_alt_vars.Topic.UserLink))
w.Write(topic_alt_23)
if tmpl_topic_alt_vars.Topic.Tag != "" {
w.Write([]byte(tmpl_topic_alt_vars.Topic.CreatedByName))
w.Write(topic_alt_24)
w.Write([]byte(tmpl_topic_alt_vars.Topic.Tag))
if tmpl_topic_alt_vars.Topic.Tag != "" {
w.Write(topic_alt_25)
} else {
w.Write([]byte(tmpl_topic_alt_vars.Topic.Tag))
w.Write(topic_alt_26)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.Level)))
} else {
w.Write(topic_alt_27)
}
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.Level)))
w.Write(topic_alt_28)
w.Write([]byte(tmpl_topic_alt_vars.Topic.ContentHTML))
w.Write(topic_alt_29)
w.Write([]byte(tmpl_topic_alt_vars.Topic.Content))
w.Write(topic_alt_30)
if tmpl_topic_alt_vars.CurrentUser.Loggedin {
if tmpl_topic_alt_vars.CurrentUser.Perms.LikeItem {
w.Write(topic_alt_31)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_32)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_33)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.EditTopic {
w.Write(topic_alt_29)
if len(tmpl_topic_alt_vars.Poll.QuickOptions) != 0 {
for _, item := range tmpl_topic_alt_vars.Poll.QuickOptions {
w.Write(topic_alt_30)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_31)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_32)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_33)
w.Write([]byte(item.Value))
w.Write(topic_alt_34)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
}
}
w.Write(topic_alt_35)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.DeleteTopic {
w.Write(topic_alt_36)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write([]byte(tmpl_topic_alt_vars.Topic.Avatar))
w.Write(topic_alt_37)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write([]byte(tmpl_topic_alt_vars.Topic.UserLink))
w.Write(topic_alt_38)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.CloseTopic {
if tmpl_topic_alt_vars.Topic.IsClosed {
w.Write([]byte(tmpl_topic_alt_vars.Topic.CreatedByName))
w.Write(topic_alt_39)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
if tmpl_topic_alt_vars.Topic.Tag != "" {
w.Write(topic_alt_40)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write([]byte(tmpl_topic_alt_vars.Topic.Tag))
w.Write(topic_alt_41)
} else {
w.Write(topic_alt_42)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.Level)))
w.Write(topic_alt_43)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
}
w.Write(topic_alt_44)
w.Write([]byte(tmpl_topic_alt_vars.Topic.ContentHTML))
w.Write(topic_alt_45)
w.Write([]byte(tmpl_topic_alt_vars.Topic.Content))
w.Write(topic_alt_46)
if tmpl_topic_alt_vars.CurrentUser.Loggedin {
if tmpl_topic_alt_vars.CurrentUser.Perms.LikeItem {
w.Write(topic_alt_47)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_48)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_49)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.EditTopic {
w.Write(topic_alt_50)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_51)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.DeleteTopic {
w.Write(topic_alt_52)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_53)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_54)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.CloseTopic {
if tmpl_topic_alt_vars.Topic.IsClosed {
w.Write(topic_alt_55)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_56)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_57)
} else {
w.Write(topic_alt_58)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_59)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_60)
}
}
if tmpl_topic_alt_vars.CurrentUser.Perms.PinTopic {
if tmpl_topic_alt_vars.Topic.Sticky {
w.Write(topic_alt_45)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_46)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_47)
} else {
w.Write(topic_alt_48)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_49)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_50)
}
}
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_alt_51)
w.Write([]byte(tmpl_topic_alt_vars.Topic.IPAddress))
w.Write(topic_alt_52)
}
w.Write(topic_alt_53)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_54)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_55)
}
w.Write(topic_alt_56)
if tmpl_topic_alt_vars.Topic.LikeCount > 0 {
w.Write(topic_alt_57)
}
w.Write(topic_alt_58)
if tmpl_topic_alt_vars.Topic.LikeCount > 0 {
w.Write(topic_alt_59)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.LikeCount)))
w.Write(topic_alt_60)
}
w.Write(topic_alt_61)
w.Write([]byte(tmpl_topic_alt_vars.Topic.RelativeCreatedAt))
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_62)
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_63)
w.Write([]byte(tmpl_topic_alt_vars.Topic.IPAddress))
} else {
w.Write(topic_alt_64)
w.Write([]byte(tmpl_topic_alt_vars.Topic.IPAddress))
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_65)
}
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_66)
if len(tmpl_topic_alt_vars.ItemList) != 0 {
for _, item := range tmpl_topic_alt_vars.ItemList {
}
}
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_alt_67)
if item.ActionType != "" {
w.Write([]byte(tmpl_topic_alt_vars.Topic.IPAddress))
w.Write(topic_alt_68)
}
w.Write(topic_alt_69)
w.Write([]byte(item.Avatar))
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_70)
w.Write([]byte(item.UserLink))
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_71)
w.Write([]byte(item.CreatedByName))
}
w.Write(topic_alt_72)
if item.Tag != "" {
if tmpl_topic_alt_vars.Topic.LikeCount > 0 {
w.Write(topic_alt_73)
w.Write([]byte(item.Tag))
}
w.Write(topic_alt_74)
} else {
if tmpl_topic_alt_vars.Topic.LikeCount > 0 {
w.Write(topic_alt_75)
w.Write([]byte(strconv.Itoa(item.Level)))
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.LikeCount)))
w.Write(topic_alt_76)
}
w.Write(topic_alt_77)
if item.ActionType != "" {
w.Write([]byte(tmpl_topic_alt_vars.Topic.RelativeCreatedAt))
w.Write(topic_alt_78)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_alt_79)
if item.ActionType != "" {
w.Write([]byte(tmpl_topic_alt_vars.Topic.IPAddress))
w.Write(topic_alt_80)
w.Write([]byte(item.ActionIcon))
w.Write([]byte(tmpl_topic_alt_vars.Topic.IPAddress))
w.Write(topic_alt_81)
w.Write([]byte(item.ActionType))
}
w.Write(topic_alt_82)
} else {
if len(tmpl_topic_alt_vars.ItemList) != 0 {
for _, item := range tmpl_topic_alt_vars.ItemList {
w.Write(topic_alt_83)
w.Write([]byte(item.ContentHtml))
if item.ActionType != "" {
w.Write(topic_alt_84)
}
w.Write(topic_alt_85)
w.Write([]byte(item.Avatar))
w.Write(topic_alt_86)
w.Write([]byte(item.UserLink))
w.Write(topic_alt_87)
w.Write([]byte(item.CreatedByName))
w.Write(topic_alt_88)
if item.Tag != "" {
w.Write(topic_alt_89)
w.Write([]byte(item.Tag))
w.Write(topic_alt_90)
} else {
w.Write(topic_alt_91)
w.Write([]byte(strconv.Itoa(item.Level)))
w.Write(topic_alt_92)
}
w.Write(topic_alt_93)
if item.ActionType != "" {
w.Write(topic_alt_94)
}
w.Write(topic_alt_95)
if item.ActionType != "" {
w.Write(topic_alt_96)
w.Write([]byte(item.ActionIcon))
w.Write(topic_alt_97)
w.Write([]byte(item.ActionType))
w.Write(topic_alt_98)
} else {
w.Write(topic_alt_99)
w.Write([]byte(item.ContentHtml))
w.Write(topic_alt_100)
if tmpl_topic_alt_vars.CurrentUser.Loggedin {
if tmpl_topic_alt_vars.CurrentUser.Perms.LikeItem {
w.Write(topic_alt_85)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_86)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_87)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.EditReply {
w.Write(topic_alt_88)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_89)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_90)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.DeleteReply {
w.Write(topic_alt_91)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_92)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_93)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_alt_94)
w.Write([]byte(item.IPAddress))
w.Write(topic_alt_95)
}
w.Write(topic_alt_96)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_97)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_98)
}
w.Write(topic_alt_99)
if item.LikeCount > 0 {
w.Write(topic_alt_100)
}
w.Write(topic_alt_101)
if item.LikeCount > 0 {
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_102)
w.Write([]byte(strconv.Itoa(item.LikeCount)))
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_103)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.EditReply {
w.Write(topic_alt_104)
w.Write([]byte(item.RelativeCreatedAt))
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_105)
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_106)
w.Write([]byte(item.IPAddress))
w.Write(topic_alt_107)
w.Write([]byte(item.IPAddress))
w.Write(topic_alt_108)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.DeleteReply {
w.Write(topic_alt_107)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_108)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_109)
}
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_alt_110)
}
}
w.Write([]byte(item.IPAddress))
w.Write(topic_alt_111)
if tmpl_topic_alt_vars.CurrentUser.Perms.CreateReply {
}
w.Write(topic_alt_112)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Avatar))
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_alt_113)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Link))
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_114)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Name))
}
w.Write(topic_alt_115)
if tmpl_topic_alt_vars.CurrentUser.Tag != "" {
if item.LikeCount > 0 {
w.Write(topic_alt_116)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Tag))
}
w.Write(topic_alt_117)
} else {
if item.LikeCount > 0 {
w.Write(topic_alt_118)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.CurrentUser.Level)))
w.Write([]byte(strconv.Itoa(item.LikeCount)))
w.Write(topic_alt_119)
}
w.Write(topic_alt_120)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write([]byte(item.RelativeCreatedAt))
w.Write(topic_alt_121)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
if tmpl_topic_alt_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_alt_122)
if tmpl_topic_alt_vars.CurrentUser.Perms.UploadFiles {
w.Write([]byte(item.IPAddress))
w.Write(topic_alt_123)
}
w.Write([]byte(item.IPAddress))
w.Write(topic_alt_124)
}
w.Write(topic_alt_125)
}
w.Write(topic_alt_126)
}
}
w.Write(topic_alt_127)
if tmpl_topic_alt_vars.CurrentUser.Perms.CreateReply {
w.Write(topic_alt_128)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Avatar))
w.Write(topic_alt_129)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Link))
w.Write(topic_alt_130)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Name))
w.Write(topic_alt_131)
if tmpl_topic_alt_vars.CurrentUser.Tag != "" {
w.Write(topic_alt_132)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Tag))
w.Write(topic_alt_133)
} else {
w.Write(topic_alt_134)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.CurrentUser.Level)))
w.Write(topic_alt_135)
}
w.Write(topic_alt_136)
w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
w.Write(topic_alt_137)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_138)
if tmpl_topic_alt_vars.CurrentUser.Perms.UploadFiles {
w.Write(topic_alt_139)
}
w.Write(topic_alt_140)
}
w.Write(topic_alt_141)
w.Write(footer_0)
w.Write([]byte(common.BuildWidget("footer",tmpl_topic_alt_vars.Header)))
w.Write(footer_1)

View File

@ -23,6 +23,28 @@
</div>
<div class="rowblock post_container">
{{if .Poll.ID}}
<article class="rowitem passive deletable_block editable_parent post_item top_post">
<div class="userinfo" aria-label="The information on the poster">
<div class="avatar_item" style="background-image: url({{.Topic.Avatar}}), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>
<a href="{{.Topic.UserLink}}" class="the_name" rel="author">{{.Topic.CreatedByName}}</a>
{{if .Topic.Tag}}<div class="tag_block"><div class="tag_pre"></div><div class="post_tag">{{.Topic.Tag}}</div><div class="tag_post"></div></div>{{else}}<div class="tag_block"><div class="tag_pre"></div><div class="post_tag post_level">Level {{.Topic.Level}}</div><div class="tag_post"></div></div>{{end}}
</div>
<div class="content_container">
<div class="hide_on_edit topic_content user_content" itemprop="text">
{{range .Poll.QuickOptions}}
<div class="poll_option">
<input id="poll_option_{{.ID}}" name="poll_option_input" type="checkbox" value="{{.ID}}" />
<label class="poll_option_label" for="poll_option_{{.ID}}">
<div class="sel"></div>
</label>
<span class="poll_option_text">{{.Value}}</span>
</div>
{{end}}
</div>
</div>
</article>
{{end}}
<article itemscope itemtype="http://schema.org/CreativeWork" class="rowitem passive deletable_block editable_parent post_item top_post" aria-label="The opening post for this topic">
<div class="userinfo" aria-label="The information on the poster">
<div class="avatar_item" style="background-image: url({{.Topic.Avatar}}), url(/static/white-dot.jpg);background-position: 0px -10px;">&nbsp;</div>

View File

@ -55,6 +55,7 @@
</div>
<div class="rowblock topic_create_form quick_create_form" style="display: none;" aria-label="Quick Topic Form">
<form name="topic_create_form_form" id="topic_create_form_form" enctype="multipart/form-data" action="/topic/create/submit/?session={{.CurrentUser.Session}}" method="post"></form>
<input form="topic_create_form_form" id="has_poll_input" name="has_poll" value="0" type="hidden" />
<img class="little_row_avatar" src="{{.CurrentUser.Avatar}}" height="64" alt="Your Avatar" title="Your Avatar" />
<div class="main_form">
<div class="topic_meta">
@ -76,10 +77,10 @@
</div>
<div class="formrow poll_content_row auto_hide">
<div class="formitem">
<div class="pollinput">
<div class="pollinput" data-pollinput="0">
<input type="checkbox" disabled />
<label class="pollinputlabel"></label>
<input type="text" placeholder="Add new poll option" />
<input form="topic_create_form_form" name="pollinputitem[0]" class="pollinputinput" type="text" placeholder="Add new poll option" />
</div>
</div>
</div>

View File

@ -292,9 +292,6 @@ h1, h3 {
border-radius: 30px;
}
.auto_hide, .show_on_edit {
display: none;
}
.mod_floater {
position: fixed;
bottom: 15px;
@ -506,15 +503,37 @@ input[type=checkbox] {
display: none;
}
input[type=checkbox] + label {
width: 10px;
border: black;
display: inline-block;
width: 12px;
height: 12px;
margin-bottom: -2px;
border: 1px solid var(--element-border-color);
background-color: var(--element-background-color);
}
/*input[type=checkbox]:checked + label {
background-color: purple;
}*/
input[type=checkbox]:checked + label .sel {
display: inline-block;
width: 5px;
height: 5px;
background: var(--element-border-color);
}
.poll_content_row {
padding-left: 20px;
padding-top: 4px;
padding-bottom: 2px;
}
.poll_content_row .formitem {
display: flex;
flex-direction: column;
}
.pollinput:not(:only-child):not(:first-child) {
margin-bottom: 5px;
}
.auto_hide, .show_on_edit {
display: none;
}
.formbutton {
margin-top: 12px;