Moved routeProfile to routes.ViewProfile.
Requests are now logged as one big chunk to help prevent them getting torn apart and improve log throughput. Newlines are now stripped from dumped requests. Prepared statement logging now only happens in debug mode for speedier server startups. More suspicious request tracking is done outside of debug mode now. Only log the initial message in plugin_markdown in debug mode. Moved the CreateTopicSubmit attachment logging to super debug mode. Removed a couple of unneccesary menu items from the Account Manager menu. Hid the add friend option on the profiles for now. Moved the remaining analytics results loops into a common function. Only log the graph for the analytics routes in debug mode. Every Theme: Added CSS for the Don't have an Account link on the Login Page. Cosora: Fixed the header CSS on mobile. The header CSS now covers optheads on mobile. Revamped the profile comment UI. Shadow: Added CSS for sticky topics. Tempra Simple: Button CSS now applies to type=submit inputs. Fixed the IP Search CSS. Tempra Conflux: Button CSS now applies to type=submit inputs. Fixed the IP Search CSS. Tempra Cursive (Deprecated): Button CSS now applies to type=submit inputs.
This commit is contained in:
parent
0879f56893
commit
8ecc637ab9
|
@ -34,6 +34,8 @@ func NewDefaultTopicViewCounter() (*DefaultTopicViewCounter, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (counter *DefaultTopicViewCounter) Tick() error {
|
func (counter *DefaultTopicViewCounter) Tick() error {
|
||||||
|
// TODO: Fold multiple 1 view topics into one query
|
||||||
|
|
||||||
counter.oddLock.RLock()
|
counter.oddLock.RLock()
|
||||||
oddTopics := counter.oddTopics
|
oddTopics := counter.oddTopics
|
||||||
counter.oddLock.RUnlock()
|
counter.oddLock.RUnlock()
|
||||||
|
|
128
gen_mssql.go
128
gen_mssql.go
|
@ -25,7 +25,6 @@ type Stmts struct {
|
||||||
groupEntryExists *sql.Stmt
|
groupEntryExists *sql.Stmt
|
||||||
getAttachment *sql.Stmt
|
getAttachment *sql.Stmt
|
||||||
getForumTopics *sql.Stmt
|
getForumTopics *sql.Stmt
|
||||||
getProfileReplies *sql.Stmt
|
|
||||||
getWatchers *sql.Stmt
|
getWatchers *sql.Stmt
|
||||||
createReport *sql.Stmt
|
createReport *sql.Stmt
|
||||||
addActivity *sql.Stmt
|
addActivity *sql.Stmt
|
||||||
|
@ -65,289 +64,322 @@ type Stmts struct {
|
||||||
func _gen_mssql() (err error) {
|
func _gen_mssql() (err error) {
|
||||||
common.DebugLog("Building the generated statements")
|
common.DebugLog("Building the generated statements")
|
||||||
|
|
||||||
log.Print("Preparing getPassword statement.")
|
common.DebugLog("Preparing getPassword statement.")
|
||||||
stmts.getPassword, err = db.Prepare("SELECT [password],[salt] FROM [users] WHERE [uid] = ?1")
|
stmts.getPassword, err = db.Prepare("SELECT [password],[salt] FROM [users] WHERE [uid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getPassword statement.")
|
||||||
log.Print("Bad Query: ","SELECT [password],[salt] FROM [users] WHERE [uid] = ?1")
|
log.Print("Bad Query: ","SELECT [password],[salt] FROM [users] WHERE [uid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing isPluginActive statement.")
|
common.DebugLog("Preparing isPluginActive statement.")
|
||||||
stmts.isPluginActive, err = db.Prepare("SELECT [active] FROM [plugins] WHERE [uname] = ?1")
|
stmts.isPluginActive, err = db.Prepare("SELECT [active] FROM [plugins] WHERE [uname] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in isPluginActive statement.")
|
||||||
log.Print("Bad Query: ","SELECT [active] FROM [plugins] WHERE [uname] = ?1")
|
log.Print("Bad Query: ","SELECT [active] FROM [plugins] WHERE [uname] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getUsersOffset statement.")
|
common.DebugLog("Preparing getUsersOffset statement.")
|
||||||
stmts.getUsersOffset, err = db.Prepare("SELECT [uid],[name],[group],[active],[is_super_admin],[avatar] FROM [users] ORDER BY uid ASC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
stmts.getUsersOffset, err = db.Prepare("SELECT [uid],[name],[group],[active],[is_super_admin],[avatar] FROM [users] ORDER BY uid ASC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getUsersOffset statement.")
|
||||||
log.Print("Bad Query: ","SELECT [uid],[name],[group],[active],[is_super_admin],[avatar] FROM [users] ORDER BY uid ASC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
log.Print("Bad Query: ","SELECT [uid],[name],[group],[active],[is_super_admin],[avatar] FROM [users] ORDER BY uid ASC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing isThemeDefault statement.")
|
common.DebugLog("Preparing isThemeDefault statement.")
|
||||||
stmts.isThemeDefault, err = db.Prepare("SELECT [default] FROM [themes] WHERE [uname] = ?1")
|
stmts.isThemeDefault, err = db.Prepare("SELECT [default] FROM [themes] WHERE [uname] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in isThemeDefault statement.")
|
||||||
log.Print("Bad Query: ","SELECT [default] FROM [themes] WHERE [uname] = ?1")
|
log.Print("Bad Query: ","SELECT [default] FROM [themes] WHERE [uname] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getModlogs statement.")
|
common.DebugLog("Preparing getModlogs statement.")
|
||||||
stmts.getModlogs, err = db.Prepare("SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs]")
|
stmts.getModlogs, err = db.Prepare("SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs]")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getModlogs statement.")
|
||||||
log.Print("Bad Query: ","SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs]")
|
log.Print("Bad Query: ","SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs]")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getModlogsOffset statement.")
|
common.DebugLog("Preparing getModlogsOffset statement.")
|
||||||
stmts.getModlogsOffset, err = db.Prepare("SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
stmts.getModlogsOffset, err = db.Prepare("SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getModlogsOffset statement.")
|
||||||
log.Print("Bad Query: ","SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
log.Print("Bad Query: ","SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [moderation_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getAdminlogsOffset statement.")
|
common.DebugLog("Preparing getAdminlogsOffset statement.")
|
||||||
stmts.getAdminlogsOffset, err = db.Prepare("SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [administration_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
stmts.getAdminlogsOffset, err = db.Prepare("SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [administration_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getAdminlogsOffset statement.")
|
||||||
log.Print("Bad Query: ","SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [administration_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
log.Print("Bad Query: ","SELECT [action],[elementID],[elementType],[ipaddress],[actorID],[doneAt] FROM [administration_logs] ORDER BY doneAt DESC OFFSET ?1 ROWS FETCH NEXT ?2 ROWS ONLY")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getTopicFID statement.")
|
common.DebugLog("Preparing getTopicFID statement.")
|
||||||
stmts.getTopicFID, err = db.Prepare("SELECT [parentID] FROM [topics] WHERE [tid] = ?1")
|
stmts.getTopicFID, err = db.Prepare("SELECT [parentID] FROM [topics] WHERE [tid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getTopicFID statement.")
|
||||||
log.Print("Bad Query: ","SELECT [parentID] FROM [topics] WHERE [tid] = ?1")
|
log.Print("Bad Query: ","SELECT [parentID] FROM [topics] WHERE [tid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getUserName statement.")
|
common.DebugLog("Preparing getUserName statement.")
|
||||||
stmts.getUserName, err = db.Prepare("SELECT [name] FROM [users] WHERE [uid] = ?1")
|
stmts.getUserName, err = db.Prepare("SELECT [name] FROM [users] WHERE [uid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getUserName statement.")
|
||||||
log.Print("Bad Query: ","SELECT [name] FROM [users] WHERE [uid] = ?1")
|
log.Print("Bad Query: ","SELECT [name] FROM [users] WHERE [uid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getEmailsByUser statement.")
|
common.DebugLog("Preparing getEmailsByUser statement.")
|
||||||
stmts.getEmailsByUser, err = db.Prepare("SELECT [email],[validated],[token] FROM [emails] WHERE [uid] = ?1")
|
stmts.getEmailsByUser, err = db.Prepare("SELECT [email],[validated],[token] FROM [emails] WHERE [uid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getEmailsByUser statement.")
|
||||||
log.Print("Bad Query: ","SELECT [email],[validated],[token] FROM [emails] WHERE [uid] = ?1")
|
log.Print("Bad Query: ","SELECT [email],[validated],[token] FROM [emails] WHERE [uid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getTopicBasic statement.")
|
common.DebugLog("Preparing getTopicBasic statement.")
|
||||||
stmts.getTopicBasic, err = db.Prepare("SELECT [title],[content] FROM [topics] WHERE [tid] = ?1")
|
stmts.getTopicBasic, err = db.Prepare("SELECT [title],[content] FROM [topics] WHERE [tid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getTopicBasic statement.")
|
||||||
log.Print("Bad Query: ","SELECT [title],[content] FROM [topics] WHERE [tid] = ?1")
|
log.Print("Bad Query: ","SELECT [title],[content] FROM [topics] WHERE [tid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getActivityEntry statement.")
|
common.DebugLog("Preparing getActivityEntry statement.")
|
||||||
stmts.getActivityEntry, err = db.Prepare("SELECT [actor],[targetUser],[event],[elementType],[elementID] FROM [activity_stream] WHERE [asid] = ?1")
|
stmts.getActivityEntry, err = db.Prepare("SELECT [actor],[targetUser],[event],[elementType],[elementID] FROM [activity_stream] WHERE [asid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getActivityEntry statement.")
|
||||||
log.Print("Bad Query: ","SELECT [actor],[targetUser],[event],[elementType],[elementID] FROM [activity_stream] WHERE [asid] = ?1")
|
log.Print("Bad Query: ","SELECT [actor],[targetUser],[event],[elementType],[elementID] FROM [activity_stream] WHERE [asid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing forumEntryExists statement.")
|
common.DebugLog("Preparing forumEntryExists statement.")
|
||||||
stmts.forumEntryExists, err = db.Prepare("SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
stmts.forumEntryExists, err = db.Prepare("SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in forumEntryExists statement.")
|
||||||
log.Print("Bad Query: ","SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
log.Print("Bad Query: ","SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing groupEntryExists statement.")
|
common.DebugLog("Preparing groupEntryExists statement.")
|
||||||
stmts.groupEntryExists, err = db.Prepare("SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
stmts.groupEntryExists, err = db.Prepare("SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in groupEntryExists statement.")
|
||||||
log.Print("Bad Query: ","SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
log.Print("Bad Query: ","SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getAttachment statement.")
|
common.DebugLog("Preparing getAttachment statement.")
|
||||||
stmts.getAttachment, err = db.Prepare("SELECT [sectionID],[sectionTable],[originID],[originTable],[uploadedBy],[path] FROM [attachments] WHERE [path] = ?1 AND [sectionID] = ?2 AND [sectionTable] = ?3")
|
stmts.getAttachment, err = db.Prepare("SELECT [sectionID],[sectionTable],[originID],[originTable],[uploadedBy],[path] FROM [attachments] WHERE [path] = ?1 AND [sectionID] = ?2 AND [sectionTable] = ?3")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getAttachment statement.")
|
||||||
log.Print("Bad Query: ","SELECT [sectionID],[sectionTable],[originID],[originTable],[uploadedBy],[path] FROM [attachments] WHERE [path] = ?1 AND [sectionID] = ?2 AND [sectionTable] = ?3")
|
log.Print("Bad Query: ","SELECT [sectionID],[sectionTable],[originID],[originTable],[uploadedBy],[path] FROM [attachments] WHERE [path] = ?1 AND [sectionID] = ?2 AND [sectionTable] = ?3")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getForumTopics statement.")
|
common.DebugLog("Preparing getForumTopics statement.")
|
||||||
stmts.getForumTopics, err = db.Prepare("SELECT [topics].[tid],[topics].[title],[topics].[content],[topics].[createdBy],[topics].[is_closed],[topics].[sticky],[topics].[createdAt],[topics].[lastReplyAt],[topics].[parentID],[users].[name],[users].[avatar] FROM [topics] LEFT JOIN [users] ON [topics].[createdBy] = [users].[uid] WHERE [topics].[parentID] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC")
|
stmts.getForumTopics, err = db.Prepare("SELECT [topics].[tid],[topics].[title],[topics].[content],[topics].[createdBy],[topics].[is_closed],[topics].[sticky],[topics].[createdAt],[topics].[lastReplyAt],[topics].[parentID],[users].[name],[users].[avatar] FROM [topics] LEFT JOIN [users] ON [topics].[createdBy] = [users].[uid] WHERE [topics].[parentID] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getForumTopics statement.")
|
||||||
log.Print("Bad Query: ","SELECT [topics].[tid],[topics].[title],[topics].[content],[topics].[createdBy],[topics].[is_closed],[topics].[sticky],[topics].[createdAt],[topics].[lastReplyAt],[topics].[parentID],[users].[name],[users].[avatar] FROM [topics] LEFT JOIN [users] ON [topics].[createdBy] = [users].[uid] WHERE [topics].[parentID] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC")
|
log.Print("Bad Query: ","SELECT [topics].[tid],[topics].[title],[topics].[content],[topics].[createdBy],[topics].[is_closed],[topics].[sticky],[topics].[createdAt],[topics].[lastReplyAt],[topics].[parentID],[users].[name],[users].[avatar] FROM [topics] LEFT JOIN [users] ON [topics].[createdBy] = [users].[uid] WHERE [topics].[parentID] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getProfileReplies statement.")
|
common.DebugLog("Preparing getWatchers statement.")
|
||||||
stmts.getProfileReplies, err = db.Prepare("SELECT [users_replies].[rid],[users_replies].[content],[users_replies].[createdBy],[users_replies].[createdAt],[users_replies].[lastEdit],[users_replies].[lastEditBy],[users].[avatar],[users].[name],[users].[group] FROM [users_replies] LEFT JOIN [users] ON [users_replies].[createdBy] = [users].[uid] WHERE [users_replies].[uid] = ?1")
|
|
||||||
if err != nil {
|
|
||||||
log.Print("Bad Query: ","SELECT [users_replies].[rid],[users_replies].[content],[users_replies].[createdBy],[users_replies].[createdAt],[users_replies].[lastEdit],[users_replies].[lastEditBy],[users].[avatar],[users].[name],[users].[group] FROM [users_replies] LEFT JOIN [users] ON [users_replies].[createdBy] = [users].[uid] WHERE [users_replies].[uid] = ?1")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Print("Preparing getWatchers statement.")
|
|
||||||
stmts.getWatchers, err = db.Prepare("SELECT [activity_subscriptions].[user] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
stmts.getWatchers, err = db.Prepare("SELECT [activity_subscriptions].[user] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getWatchers statement.")
|
||||||
log.Print("Bad Query: ","SELECT [activity_subscriptions].[user] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
log.Print("Bad Query: ","SELECT [activity_subscriptions].[user] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing createReport statement.")
|
common.DebugLog("Preparing createReport statement.")
|
||||||
stmts.createReport, err = db.Prepare("INSERT INTO [topics] ([title],[content],[parsed_content],[createdAt],[lastReplyAt],[createdBy],[lastReplyBy],[data],[parentID],[css_class]) VALUES (?,?,?,GETUTCDATE(),GETUTCDATE(),?,?,?,1,'report')")
|
stmts.createReport, err = db.Prepare("INSERT INTO [topics] ([title],[content],[parsed_content],[createdAt],[lastReplyAt],[createdBy],[lastReplyBy],[data],[parentID],[css_class]) VALUES (?,?,?,GETUTCDATE(),GETUTCDATE(),?,?,?,1,'report')")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in createReport statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [topics] ([title],[content],[parsed_content],[createdAt],[lastReplyAt],[createdBy],[lastReplyBy],[data],[parentID],[css_class]) VALUES (?,?,?,GETUTCDATE(),GETUTCDATE(),?,?,?,1,'report')")
|
log.Print("Bad Query: ","INSERT INTO [topics] ([title],[content],[parsed_content],[createdAt],[lastReplyAt],[createdBy],[lastReplyBy],[data],[parentID],[css_class]) VALUES (?,?,?,GETUTCDATE(),GETUTCDATE(),?,?,?,1,'report')")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addActivity statement.")
|
common.DebugLog("Preparing addActivity statement.")
|
||||||
stmts.addActivity, err = db.Prepare("INSERT INTO [activity_stream] ([actor],[targetUser],[event],[elementType],[elementID]) VALUES (?,?,?,?,?)")
|
stmts.addActivity, err = db.Prepare("INSERT INTO [activity_stream] ([actor],[targetUser],[event],[elementType],[elementID]) VALUES (?,?,?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addActivity statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [activity_stream] ([actor],[targetUser],[event],[elementType],[elementID]) VALUES (?,?,?,?,?)")
|
log.Print("Bad Query: ","INSERT INTO [activity_stream] ([actor],[targetUser],[event],[elementType],[elementID]) VALUES (?,?,?,?,?)")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing notifyOne statement.")
|
common.DebugLog("Preparing notifyOne statement.")
|
||||||
stmts.notifyOne, err = db.Prepare("INSERT INTO [activity_stream_matches] ([watcher],[asid]) VALUES (?,?)")
|
stmts.notifyOne, err = db.Prepare("INSERT INTO [activity_stream_matches] ([watcher],[asid]) VALUES (?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in notifyOne statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [activity_stream_matches] ([watcher],[asid]) VALUES (?,?)")
|
log.Print("Bad Query: ","INSERT INTO [activity_stream_matches] ([watcher],[asid]) VALUES (?,?)")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addForumPermsToForum statement.")
|
common.DebugLog("Preparing addForumPermsToForum statement.")
|
||||||
stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)")
|
stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addForumPermsToForum statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)")
|
log.Print("Bad Query: ","INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addPlugin statement.")
|
common.DebugLog("Preparing addPlugin statement.")
|
||||||
stmts.addPlugin, err = db.Prepare("INSERT INTO [plugins] ([uname],[active],[installed]) VALUES (?,?,?)")
|
stmts.addPlugin, err = db.Prepare("INSERT INTO [plugins] ([uname],[active],[installed]) VALUES (?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addPlugin statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [plugins] ([uname],[active],[installed]) VALUES (?,?,?)")
|
log.Print("Bad Query: ","INSERT INTO [plugins] ([uname],[active],[installed]) VALUES (?,?,?)")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addTheme statement.")
|
common.DebugLog("Preparing addTheme statement.")
|
||||||
stmts.addTheme, err = db.Prepare("INSERT INTO [themes] ([uname],[default]) VALUES (?,?)")
|
stmts.addTheme, err = db.Prepare("INSERT INTO [themes] ([uname],[default]) VALUES (?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addTheme statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [themes] ([uname],[default]) VALUES (?,?)")
|
log.Print("Bad Query: ","INSERT INTO [themes] ([uname],[default]) VALUES (?,?)")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing createWordFilter statement.")
|
common.DebugLog("Preparing createWordFilter statement.")
|
||||||
stmts.createWordFilter, err = db.Prepare("INSERT INTO [word_filters] ([find],[replacement]) VALUES (?,?)")
|
stmts.createWordFilter, err = db.Prepare("INSERT INTO [word_filters] ([find],[replacement]) VALUES (?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in createWordFilter statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [word_filters] ([find],[replacement]) VALUES (?,?)")
|
log.Print("Bad Query: ","INSERT INTO [word_filters] ([find],[replacement]) VALUES (?,?)")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing editReply statement.")
|
common.DebugLog("Preparing editReply statement.")
|
||||||
stmts.editReply, err = db.Prepare("UPDATE [replies] SET [content] = ?,[parsed_content] = ? WHERE [rid] = ?")
|
stmts.editReply, err = db.Prepare("UPDATE [replies] SET [content] = ?,[parsed_content] = ? WHERE [rid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in editReply statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [replies] SET [content] = ?,[parsed_content] = ? WHERE [rid] = ?")
|
log.Print("Bad Query: ","UPDATE [replies] SET [content] = ?,[parsed_content] = ? WHERE [rid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updatePlugin statement.")
|
common.DebugLog("Preparing updatePlugin statement.")
|
||||||
stmts.updatePlugin, err = db.Prepare("UPDATE [plugins] SET [active] = ? WHERE [uname] = ?")
|
stmts.updatePlugin, err = db.Prepare("UPDATE [plugins] SET [active] = ? WHERE [uname] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updatePlugin statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [plugins] SET [active] = ? WHERE [uname] = ?")
|
log.Print("Bad Query: ","UPDATE [plugins] SET [active] = ? WHERE [uname] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updatePluginInstall statement.")
|
common.DebugLog("Preparing updatePluginInstall statement.")
|
||||||
stmts.updatePluginInstall, err = db.Prepare("UPDATE [plugins] SET [installed] = ? WHERE [uname] = ?")
|
stmts.updatePluginInstall, err = db.Prepare("UPDATE [plugins] SET [installed] = ? WHERE [uname] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updatePluginInstall statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [plugins] SET [installed] = ? WHERE [uname] = ?")
|
log.Print("Bad Query: ","UPDATE [plugins] SET [installed] = ? WHERE [uname] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateTheme statement.")
|
common.DebugLog("Preparing updateTheme statement.")
|
||||||
stmts.updateTheme, err = db.Prepare("UPDATE [themes] SET [default] = ? WHERE [uname] = ?")
|
stmts.updateTheme, err = db.Prepare("UPDATE [themes] SET [default] = ? WHERE [uname] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateTheme statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [themes] SET [default] = ? WHERE [uname] = ?")
|
log.Print("Bad Query: ","UPDATE [themes] SET [default] = ? WHERE [uname] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateUser statement.")
|
common.DebugLog("Preparing updateUser statement.")
|
||||||
stmts.updateUser, err = db.Prepare("UPDATE [users] SET [name] = ?,[email] = ?,[group] = ? WHERE [uid] = ?")
|
stmts.updateUser, err = db.Prepare("UPDATE [users] SET [name] = ?,[email] = ?,[group] = ? WHERE [uid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateUser statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [users] SET [name] = ?,[email] = ?,[group] = ? WHERE [uid] = ?")
|
log.Print("Bad Query: ","UPDATE [users] SET [name] = ?,[email] = ?,[group] = ? WHERE [uid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateGroupPerms statement.")
|
common.DebugLog("Preparing updateGroupPerms statement.")
|
||||||
stmts.updateGroupPerms, err = db.Prepare("UPDATE [users_groups] SET [permissions] = ? WHERE [gid] = ?")
|
stmts.updateGroupPerms, err = db.Prepare("UPDATE [users_groups] SET [permissions] = ? WHERE [gid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateGroupPerms statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [users_groups] SET [permissions] = ? WHERE [gid] = ?")
|
log.Print("Bad Query: ","UPDATE [users_groups] SET [permissions] = ? WHERE [gid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateGroup statement.")
|
common.DebugLog("Preparing updateGroup statement.")
|
||||||
stmts.updateGroup, err = db.Prepare("UPDATE [users_groups] SET [name] = ?,[tag] = ? WHERE [gid] = ?")
|
stmts.updateGroup, err = db.Prepare("UPDATE [users_groups] SET [name] = ?,[tag] = ? WHERE [gid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateGroup statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [users_groups] SET [name] = ?,[tag] = ? WHERE [gid] = ?")
|
log.Print("Bad Query: ","UPDATE [users_groups] SET [name] = ?,[tag] = ? WHERE [gid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateEmail statement.")
|
common.DebugLog("Preparing updateEmail statement.")
|
||||||
stmts.updateEmail, err = db.Prepare("UPDATE [emails] SET [email] = ?,[uid] = ?,[validated] = ?,[token] = ? WHERE [email] = ?")
|
stmts.updateEmail, err = db.Prepare("UPDATE [emails] SET [email] = ?,[uid] = ?,[validated] = ?,[token] = ? WHERE [email] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateEmail statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [emails] SET [email] = ?,[uid] = ?,[validated] = ?,[token] = ? WHERE [email] = ?")
|
log.Print("Bad Query: ","UPDATE [emails] SET [email] = ?,[uid] = ?,[validated] = ?,[token] = ? WHERE [email] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing verifyEmail statement.")
|
common.DebugLog("Preparing verifyEmail statement.")
|
||||||
stmts.verifyEmail, err = db.Prepare("UPDATE [emails] SET [validated] = 1,[token] = '' WHERE [email] = ?")
|
stmts.verifyEmail, err = db.Prepare("UPDATE [emails] SET [validated] = 1,[token] = '' WHERE [email] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in verifyEmail statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [emails] SET [validated] = 1,[token] = '' WHERE [email] = ?")
|
log.Print("Bad Query: ","UPDATE [emails] SET [validated] = 1,[token] = '' WHERE [email] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing setTempGroup statement.")
|
common.DebugLog("Preparing setTempGroup statement.")
|
||||||
stmts.setTempGroup, err = db.Prepare("UPDATE [users] SET [temp_group] = ? WHERE [uid] = ?")
|
stmts.setTempGroup, err = db.Prepare("UPDATE [users] SET [temp_group] = ? WHERE [uid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in setTempGroup statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [users] SET [temp_group] = ? WHERE [uid] = ?")
|
log.Print("Bad Query: ","UPDATE [users] SET [temp_group] = ? WHERE [uid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateWordFilter statement.")
|
common.DebugLog("Preparing updateWordFilter statement.")
|
||||||
stmts.updateWordFilter, err = db.Prepare("UPDATE [word_filters] SET [find] = ?,[replacement] = ? WHERE [wfid] = ?")
|
stmts.updateWordFilter, err = db.Prepare("UPDATE [word_filters] SET [find] = ?,[replacement] = ? WHERE [wfid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateWordFilter statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [word_filters] SET [find] = ?,[replacement] = ? WHERE [wfid] = ?")
|
log.Print("Bad Query: ","UPDATE [word_filters] SET [find] = ?,[replacement] = ? WHERE [wfid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing bumpSync statement.")
|
common.DebugLog("Preparing bumpSync statement.")
|
||||||
stmts.bumpSync, err = db.Prepare("UPDATE [sync] SET [last_update] = GETUTCDATE()")
|
stmts.bumpSync, err = db.Prepare("UPDATE [sync] SET [last_update] = GETUTCDATE()")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in bumpSync statement.")
|
||||||
log.Print("Bad Query: ","UPDATE [sync] SET [last_update] = GETUTCDATE()")
|
log.Print("Bad Query: ","UPDATE [sync] SET [last_update] = GETUTCDATE()")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing deleteActivityStreamMatch statement.")
|
common.DebugLog("Preparing deleteActivityStreamMatch statement.")
|
||||||
stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?")
|
stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in deleteActivityStreamMatch statement.")
|
||||||
log.Print("Bad Query: ","DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?")
|
log.Print("Bad Query: ","DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing deleteWordFilter statement.")
|
common.DebugLog("Preparing deleteWordFilter statement.")
|
||||||
stmts.deleteWordFilter, err = db.Prepare("DELETE FROM [word_filters] WHERE [wfid] = ?")
|
stmts.deleteWordFilter, err = db.Prepare("DELETE FROM [word_filters] WHERE [wfid] = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in deleteWordFilter statement.")
|
||||||
log.Print("Bad Query: ","DELETE FROM [word_filters] WHERE [wfid] = ?")
|
log.Print("Bad Query: ","DELETE FROM [word_filters] WHERE [wfid] = ?")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing reportExists statement.")
|
common.DebugLog("Preparing reportExists statement.")
|
||||||
stmts.reportExists, err = db.Prepare("SELECT COUNT(*) AS [count] FROM [topics] WHERE [data] = ? AND [data] != '' AND [parentID] = 1")
|
stmts.reportExists, err = db.Prepare("SELECT COUNT(*) AS [count] FROM [topics] WHERE [data] = ? AND [data] != '' AND [parentID] = 1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in reportExists statement.")
|
||||||
log.Print("Bad Query: ","SELECT COUNT(*) AS [count] FROM [topics] WHERE [data] = ? AND [data] != '' AND [parentID] = 1")
|
log.Print("Bad Query: ","SELECT COUNT(*) AS [count] FROM [topics] WHERE [data] = ? AND [data] != '' AND [parentID] = 1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing notifyWatchers statement.")
|
common.DebugLog("Preparing notifyWatchers statement.")
|
||||||
stmts.notifyWatchers, err = db.Prepare("INSERT INTO [activity_stream_matches] ([watcher],[asid]) SELECT [activity_subscriptions].[user],[activity_stream].[asid] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
stmts.notifyWatchers, err = db.Prepare("INSERT INTO [activity_stream_matches] ([watcher],[asid]) SELECT [activity_subscriptions].[user],[activity_stream].[asid] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in notifyWatchers statement.")
|
||||||
log.Print("Bad Query: ","INSERT INTO [activity_stream_matches] ([watcher],[asid]) SELECT [activity_subscriptions].[user],[activity_stream].[asid] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
log.Print("Bad Query: ","INSERT INTO [activity_stream_matches] ([watcher],[asid]) SELECT [activity_subscriptions].[user],[activity_stream].[asid] FROM [activity_stream] INNER JOIN [activity_subscriptions] ON [activity_subscriptions].[targetType] = [activity_stream].[elementType] AND [activity_subscriptions].[targetID] = [activity_stream].[elementID] AND [activity_subscriptions].[user] != [activity_stream].[actor] WHERE [asid] = ?1")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
127
gen_mysql.go
127
gen_mysql.go
|
@ -27,7 +27,6 @@ type Stmts struct {
|
||||||
groupEntryExists *sql.Stmt
|
groupEntryExists *sql.Stmt
|
||||||
getAttachment *sql.Stmt
|
getAttachment *sql.Stmt
|
||||||
getForumTopics *sql.Stmt
|
getForumTopics *sql.Stmt
|
||||||
getProfileReplies *sql.Stmt
|
|
||||||
getWatchers *sql.Stmt
|
getWatchers *sql.Stmt
|
||||||
createReport *sql.Stmt
|
createReport *sql.Stmt
|
||||||
addActivity *sql.Stmt
|
addActivity *sql.Stmt
|
||||||
|
@ -67,249 +66,283 @@ type Stmts struct {
|
||||||
func _gen_mysql() (err error) {
|
func _gen_mysql() (err error) {
|
||||||
common.DebugLog("Building the generated statements")
|
common.DebugLog("Building the generated statements")
|
||||||
|
|
||||||
log.Print("Preparing getPassword statement.")
|
common.DebugLog("Preparing getPassword statement.")
|
||||||
stmts.getPassword, err = db.Prepare("SELECT `password`,`salt` FROM `users` WHERE `uid` = ?")
|
stmts.getPassword, err = db.Prepare("SELECT `password`,`salt` FROM `users` WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getPassword statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing isPluginActive statement.")
|
common.DebugLog("Preparing isPluginActive statement.")
|
||||||
stmts.isPluginActive, err = db.Prepare("SELECT `active` FROM `plugins` WHERE `uname` = ?")
|
stmts.isPluginActive, err = db.Prepare("SELECT `active` FROM `plugins` WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in isPluginActive statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getUsersOffset statement.")
|
common.DebugLog("Preparing getUsersOffset statement.")
|
||||||
stmts.getUsersOffset, err = db.Prepare("SELECT `uid`,`name`,`group`,`active`,`is_super_admin`,`avatar` FROM `users` ORDER BY uid ASC LIMIT ?,?")
|
stmts.getUsersOffset, err = db.Prepare("SELECT `uid`,`name`,`group`,`active`,`is_super_admin`,`avatar` FROM `users` ORDER BY uid ASC LIMIT ?,?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getUsersOffset statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing isThemeDefault statement.")
|
common.DebugLog("Preparing isThemeDefault statement.")
|
||||||
stmts.isThemeDefault, err = db.Prepare("SELECT `default` FROM `themes` WHERE `uname` = ?")
|
stmts.isThemeDefault, err = db.Prepare("SELECT `default` FROM `themes` WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in isThemeDefault statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getModlogs statement.")
|
common.DebugLog("Preparing getModlogs statement.")
|
||||||
stmts.getModlogs, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM `moderation_logs`")
|
stmts.getModlogs, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM `moderation_logs`")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getModlogs statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getModlogsOffset statement.")
|
common.DebugLog("Preparing getModlogsOffset statement.")
|
||||||
stmts.getModlogsOffset, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM `moderation_logs` ORDER BY doneAt DESC LIMIT ?,?")
|
stmts.getModlogsOffset, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM `moderation_logs` ORDER BY doneAt DESC LIMIT ?,?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getModlogsOffset statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getAdminlogsOffset statement.")
|
common.DebugLog("Preparing getAdminlogsOffset statement.")
|
||||||
stmts.getAdminlogsOffset, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM `administration_logs` ORDER BY doneAt DESC LIMIT ?,?")
|
stmts.getAdminlogsOffset, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM `administration_logs` ORDER BY doneAt DESC LIMIT ?,?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getAdminlogsOffset statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getTopicFID statement.")
|
common.DebugLog("Preparing getTopicFID statement.")
|
||||||
stmts.getTopicFID, err = db.Prepare("SELECT `parentID` FROM `topics` WHERE `tid` = ?")
|
stmts.getTopicFID, err = db.Prepare("SELECT `parentID` FROM `topics` WHERE `tid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getTopicFID statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getUserName statement.")
|
common.DebugLog("Preparing getUserName statement.")
|
||||||
stmts.getUserName, err = db.Prepare("SELECT `name` FROM `users` WHERE `uid` = ?")
|
stmts.getUserName, err = db.Prepare("SELECT `name` FROM `users` WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getUserName statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getEmailsByUser statement.")
|
common.DebugLog("Preparing getEmailsByUser statement.")
|
||||||
stmts.getEmailsByUser, err = db.Prepare("SELECT `email`,`validated`,`token` FROM `emails` WHERE `uid` = ?")
|
stmts.getEmailsByUser, err = db.Prepare("SELECT `email`,`validated`,`token` FROM `emails` WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getEmailsByUser statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getTopicBasic statement.")
|
common.DebugLog("Preparing getTopicBasic statement.")
|
||||||
stmts.getTopicBasic, err = db.Prepare("SELECT `title`,`content` FROM `topics` WHERE `tid` = ?")
|
stmts.getTopicBasic, err = db.Prepare("SELECT `title`,`content` FROM `topics` WHERE `tid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getTopicBasic statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getActivityEntry statement.")
|
common.DebugLog("Preparing getActivityEntry statement.")
|
||||||
stmts.getActivityEntry, err = db.Prepare("SELECT `actor`,`targetUser`,`event`,`elementType`,`elementID` FROM `activity_stream` WHERE `asid` = ?")
|
stmts.getActivityEntry, err = db.Prepare("SELECT `actor`,`targetUser`,`event`,`elementType`,`elementID` FROM `activity_stream` WHERE `asid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getActivityEntry statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing forumEntryExists statement.")
|
common.DebugLog("Preparing forumEntryExists statement.")
|
||||||
stmts.forumEntryExists, err = db.Prepare("SELECT `fid` FROM `forums` WHERE `name` = '' ORDER BY fid ASC LIMIT 0,1")
|
stmts.forumEntryExists, err = db.Prepare("SELECT `fid` FROM `forums` WHERE `name` = '' ORDER BY fid ASC LIMIT 0,1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in forumEntryExists statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing groupEntryExists statement.")
|
common.DebugLog("Preparing groupEntryExists statement.")
|
||||||
stmts.groupEntryExists, err = db.Prepare("SELECT `gid` FROM `users_groups` WHERE `name` = '' ORDER BY gid ASC LIMIT 0,1")
|
stmts.groupEntryExists, err = db.Prepare("SELECT `gid` FROM `users_groups` WHERE `name` = '' ORDER BY gid ASC LIMIT 0,1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in groupEntryExists statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getAttachment statement.")
|
common.DebugLog("Preparing getAttachment statement.")
|
||||||
stmts.getAttachment, err = db.Prepare("SELECT `sectionID`,`sectionTable`,`originID`,`originTable`,`uploadedBy`,`path` FROM `attachments` WHERE `path` = ? AND `sectionID` = ? AND `sectionTable` = ?")
|
stmts.getAttachment, err = db.Prepare("SELECT `sectionID`,`sectionTable`,`originID`,`originTable`,`uploadedBy`,`path` FROM `attachments` WHERE `path` = ? AND `sectionID` = ? AND `sectionTable` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getAttachment statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getForumTopics statement.")
|
common.DebugLog("Preparing getForumTopics statement.")
|
||||||
stmts.getForumTopics, err = db.Prepare("SELECT `topics`.`tid`, `topics`.`title`, `topics`.`content`, `topics`.`createdBy`, `topics`.`is_closed`, `topics`.`sticky`, `topics`.`createdAt`, `topics`.`lastReplyAt`, `topics`.`parentID`, `users`.`name`, `users`.`avatar` FROM `topics` LEFT JOIN `users` ON `topics`.`createdBy` = `users`.`uid` WHERE `topics`.`parentID` = ? ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC")
|
stmts.getForumTopics, err = db.Prepare("SELECT `topics`.`tid`, `topics`.`title`, `topics`.`content`, `topics`.`createdBy`, `topics`.`is_closed`, `topics`.`sticky`, `topics`.`createdAt`, `topics`.`lastReplyAt`, `topics`.`parentID`, `users`.`name`, `users`.`avatar` FROM `topics` LEFT JOIN `users` ON `topics`.`createdBy` = `users`.`uid` WHERE `topics`.`parentID` = ? ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getForumTopics statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing getProfileReplies statement.")
|
common.DebugLog("Preparing getWatchers statement.")
|
||||||
stmts.getProfileReplies, err = db.Prepare("SELECT `users_replies`.`rid`, `users_replies`.`content`, `users_replies`.`createdBy`, `users_replies`.`createdAt`, `users_replies`.`lastEdit`, `users_replies`.`lastEditBy`, `users`.`avatar`, `users`.`name`, `users`.`group` FROM `users_replies` LEFT JOIN `users` ON `users_replies`.`createdBy` = `users`.`uid` WHERE `users_replies`.`uid` = ?")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Print("Preparing getWatchers statement.")
|
|
||||||
stmts.getWatchers, err = db.Prepare("SELECT `activity_subscriptions`.`user` FROM `activity_stream` INNER JOIN `activity_subscriptions` ON `activity_subscriptions`.`targetType` = `activity_stream`.`elementType` AND `activity_subscriptions`.`targetID` = `activity_stream`.`elementID` AND `activity_subscriptions`.`user` != `activity_stream`.`actor` WHERE `asid` = ?")
|
stmts.getWatchers, err = db.Prepare("SELECT `activity_subscriptions`.`user` FROM `activity_stream` INNER JOIN `activity_subscriptions` ON `activity_subscriptions`.`targetType` = `activity_stream`.`elementType` AND `activity_subscriptions`.`targetID` = `activity_stream`.`elementID` AND `activity_subscriptions`.`user` != `activity_stream`.`actor` WHERE `asid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in getWatchers statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing createReport statement.")
|
common.DebugLog("Preparing createReport statement.")
|
||||||
stmts.createReport, err = db.Prepare("INSERT INTO `topics`(`title`,`content`,`parsed_content`,`createdAt`,`lastReplyAt`,`createdBy`,`lastReplyBy`,`data`,`parentID`,`css_class`) VALUES (?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,1,'report')")
|
stmts.createReport, err = db.Prepare("INSERT INTO `topics`(`title`,`content`,`parsed_content`,`createdAt`,`lastReplyAt`,`createdBy`,`lastReplyBy`,`data`,`parentID`,`css_class`) VALUES (?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,1,'report')")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in createReport statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addActivity statement.")
|
common.DebugLog("Preparing addActivity statement.")
|
||||||
stmts.addActivity, err = db.Prepare("INSERT INTO `activity_stream`(`actor`,`targetUser`,`event`,`elementType`,`elementID`) VALUES (?,?,?,?,?)")
|
stmts.addActivity, err = db.Prepare("INSERT INTO `activity_stream`(`actor`,`targetUser`,`event`,`elementType`,`elementID`) VALUES (?,?,?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addActivity statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing notifyOne statement.")
|
common.DebugLog("Preparing notifyOne statement.")
|
||||||
stmts.notifyOne, err = db.Prepare("INSERT INTO `activity_stream_matches`(`watcher`,`asid`) VALUES (?,?)")
|
stmts.notifyOne, err = db.Prepare("INSERT INTO `activity_stream_matches`(`watcher`,`asid`) VALUES (?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in notifyOne statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addForumPermsToForum statement.")
|
common.DebugLog("Preparing addForumPermsToForum statement.")
|
||||||
stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO `forums_permissions`(`gid`,`fid`,`preset`,`permissions`) VALUES (?,?,?,?)")
|
stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO `forums_permissions`(`gid`,`fid`,`preset`,`permissions`) VALUES (?,?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addForumPermsToForum statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addPlugin statement.")
|
common.DebugLog("Preparing addPlugin statement.")
|
||||||
stmts.addPlugin, err = db.Prepare("INSERT INTO `plugins`(`uname`,`active`,`installed`) VALUES (?,?,?)")
|
stmts.addPlugin, err = db.Prepare("INSERT INTO `plugins`(`uname`,`active`,`installed`) VALUES (?,?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addPlugin statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing addTheme statement.")
|
common.DebugLog("Preparing addTheme statement.")
|
||||||
stmts.addTheme, err = db.Prepare("INSERT INTO `themes`(`uname`,`default`) VALUES (?,?)")
|
stmts.addTheme, err = db.Prepare("INSERT INTO `themes`(`uname`,`default`) VALUES (?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in addTheme statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing createWordFilter statement.")
|
common.DebugLog("Preparing createWordFilter statement.")
|
||||||
stmts.createWordFilter, err = db.Prepare("INSERT INTO `word_filters`(`find`,`replacement`) VALUES (?,?)")
|
stmts.createWordFilter, err = db.Prepare("INSERT INTO `word_filters`(`find`,`replacement`) VALUES (?,?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in createWordFilter statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing editReply statement.")
|
common.DebugLog("Preparing editReply statement.")
|
||||||
stmts.editReply, err = db.Prepare("UPDATE `replies` SET `content` = ?,`parsed_content` = ? WHERE `rid` = ?")
|
stmts.editReply, err = db.Prepare("UPDATE `replies` SET `content` = ?,`parsed_content` = ? WHERE `rid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in editReply statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updatePlugin statement.")
|
common.DebugLog("Preparing updatePlugin statement.")
|
||||||
stmts.updatePlugin, err = db.Prepare("UPDATE `plugins` SET `active` = ? WHERE `uname` = ?")
|
stmts.updatePlugin, err = db.Prepare("UPDATE `plugins` SET `active` = ? WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updatePlugin statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updatePluginInstall statement.")
|
common.DebugLog("Preparing updatePluginInstall statement.")
|
||||||
stmts.updatePluginInstall, err = db.Prepare("UPDATE `plugins` SET `installed` = ? WHERE `uname` = ?")
|
stmts.updatePluginInstall, err = db.Prepare("UPDATE `plugins` SET `installed` = ? WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updatePluginInstall statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateTheme statement.")
|
common.DebugLog("Preparing updateTheme statement.")
|
||||||
stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?")
|
stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateTheme statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateUser statement.")
|
common.DebugLog("Preparing updateUser statement.")
|
||||||
stmts.updateUser, err = db.Prepare("UPDATE `users` SET `name` = ?,`email` = ?,`group` = ? WHERE `uid` = ?")
|
stmts.updateUser, err = db.Prepare("UPDATE `users` SET `name` = ?,`email` = ?,`group` = ? WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateUser statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateGroupPerms statement.")
|
common.DebugLog("Preparing updateGroupPerms statement.")
|
||||||
stmts.updateGroupPerms, err = db.Prepare("UPDATE `users_groups` SET `permissions` = ? WHERE `gid` = ?")
|
stmts.updateGroupPerms, err = db.Prepare("UPDATE `users_groups` SET `permissions` = ? WHERE `gid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateGroupPerms statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateGroup statement.")
|
common.DebugLog("Preparing updateGroup statement.")
|
||||||
stmts.updateGroup, err = db.Prepare("UPDATE `users_groups` SET `name` = ?,`tag` = ? WHERE `gid` = ?")
|
stmts.updateGroup, err = db.Prepare("UPDATE `users_groups` SET `name` = ?,`tag` = ? WHERE `gid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateGroup statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateEmail statement.")
|
common.DebugLog("Preparing updateEmail statement.")
|
||||||
stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateEmail statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing verifyEmail statement.")
|
common.DebugLog("Preparing verifyEmail statement.")
|
||||||
stmts.verifyEmail, err = db.Prepare("UPDATE `emails` SET `validated` = 1,`token` = '' WHERE `email` = ?")
|
stmts.verifyEmail, err = db.Prepare("UPDATE `emails` SET `validated` = 1,`token` = '' WHERE `email` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in verifyEmail statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing setTempGroup statement.")
|
common.DebugLog("Preparing setTempGroup statement.")
|
||||||
stmts.setTempGroup, err = db.Prepare("UPDATE `users` SET `temp_group` = ? WHERE `uid` = ?")
|
stmts.setTempGroup, err = db.Prepare("UPDATE `users` SET `temp_group` = ? WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in setTempGroup statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateWordFilter statement.")
|
common.DebugLog("Preparing updateWordFilter statement.")
|
||||||
stmts.updateWordFilter, err = db.Prepare("UPDATE `word_filters` SET `find` = ?,`replacement` = ? WHERE `wfid` = ?")
|
stmts.updateWordFilter, err = db.Prepare("UPDATE `word_filters` SET `find` = ?,`replacement` = ? WHERE `wfid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateWordFilter statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing bumpSync statement.")
|
common.DebugLog("Preparing bumpSync statement.")
|
||||||
stmts.bumpSync, err = db.Prepare("UPDATE `sync` SET `last_update` = UTC_TIMESTAMP()")
|
stmts.bumpSync, err = db.Prepare("UPDATE `sync` SET `last_update` = UTC_TIMESTAMP()")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in bumpSync statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing deleteActivityStreamMatch statement.")
|
common.DebugLog("Preparing deleteActivityStreamMatch statement.")
|
||||||
stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM `activity_stream_matches` WHERE `watcher` = ? AND `asid` = ?")
|
stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM `activity_stream_matches` WHERE `watcher` = ? AND `asid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in deleteActivityStreamMatch statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing deleteWordFilter statement.")
|
common.DebugLog("Preparing deleteWordFilter statement.")
|
||||||
stmts.deleteWordFilter, err = db.Prepare("DELETE FROM `word_filters` WHERE `wfid` = ?")
|
stmts.deleteWordFilter, err = db.Prepare("DELETE FROM `word_filters` WHERE `wfid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in deleteWordFilter statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing reportExists statement.")
|
common.DebugLog("Preparing reportExists statement.")
|
||||||
stmts.reportExists, err = db.Prepare("SELECT COUNT(*) AS `count` FROM `topics` WHERE `data` = ? AND `data` != '' AND `parentID` = 1")
|
stmts.reportExists, err = db.Prepare("SELECT COUNT(*) AS `count` FROM `topics` WHERE `data` = ? AND `data` != '' AND `parentID` = 1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in reportExists statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing notifyWatchers statement.")
|
common.DebugLog("Preparing notifyWatchers statement.")
|
||||||
stmts.notifyWatchers, err = db.Prepare("INSERT INTO `activity_stream_matches`(`watcher`,`asid`) SELECT `activity_subscriptions`.`user`, `activity_stream`.`asid` FROM `activity_stream` INNER JOIN `activity_subscriptions` ON `activity_subscriptions`.`targetType` = `activity_stream`.`elementType` AND `activity_subscriptions`.`targetID` = `activity_stream`.`elementID` AND `activity_subscriptions`.`user` != `activity_stream`.`actor` WHERE `asid` = ?")
|
stmts.notifyWatchers, err = db.Prepare("INSERT INTO `activity_stream_matches`(`watcher`,`asid`) SELECT `activity_subscriptions`.`user`, `activity_stream`.`asid` FROM `activity_stream` INNER JOIN `activity_subscriptions` ON `activity_subscriptions`.`targetType` = `activity_stream`.`elementType` AND `activity_subscriptions`.`targetID` = `activity_stream`.`elementID` AND `activity_subscriptions`.`user` != `activity_stream`.`actor` WHERE `asid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in notifyWatchers statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
gen_pgsql.go
36
gen_pgsql.go
|
@ -36,75 +36,87 @@ type Stmts struct {
|
||||||
func _gen_pgsql() (err error) {
|
func _gen_pgsql() (err error) {
|
||||||
common.DebugLog("Building the generated statements")
|
common.DebugLog("Building the generated statements")
|
||||||
|
|
||||||
log.Print("Preparing editReply statement.")
|
common.DebugLog("Preparing editReply statement.")
|
||||||
stmts.editReply, err = db.Prepare("UPDATE `replies` SET `content` = ?,`parsed_content` = ? WHERE `rid` = ?")
|
stmts.editReply, err = db.Prepare("UPDATE `replies` SET `content` = ?,`parsed_content` = ? WHERE `rid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in editReply statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updatePlugin statement.")
|
common.DebugLog("Preparing updatePlugin statement.")
|
||||||
stmts.updatePlugin, err = db.Prepare("UPDATE `plugins` SET `active` = ? WHERE `uname` = ?")
|
stmts.updatePlugin, err = db.Prepare("UPDATE `plugins` SET `active` = ? WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updatePlugin statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updatePluginInstall statement.")
|
common.DebugLog("Preparing updatePluginInstall statement.")
|
||||||
stmts.updatePluginInstall, err = db.Prepare("UPDATE `plugins` SET `installed` = ? WHERE `uname` = ?")
|
stmts.updatePluginInstall, err = db.Prepare("UPDATE `plugins` SET `installed` = ? WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updatePluginInstall statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateTheme statement.")
|
common.DebugLog("Preparing updateTheme statement.")
|
||||||
stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?")
|
stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateTheme statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateUser statement.")
|
common.DebugLog("Preparing updateUser statement.")
|
||||||
stmts.updateUser, err = db.Prepare("UPDATE `users` SET `name` = ?,`email` = ?,`group` = ? WHERE `uid` = ?")
|
stmts.updateUser, err = db.Prepare("UPDATE `users` SET `name` = ?,`email` = ?,`group` = ? WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateUser statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateGroupPerms statement.")
|
common.DebugLog("Preparing updateGroupPerms statement.")
|
||||||
stmts.updateGroupPerms, err = db.Prepare("UPDATE `users_groups` SET `permissions` = ? WHERE `gid` = ?")
|
stmts.updateGroupPerms, err = db.Prepare("UPDATE `users_groups` SET `permissions` = ? WHERE `gid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateGroupPerms statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateGroup statement.")
|
common.DebugLog("Preparing updateGroup statement.")
|
||||||
stmts.updateGroup, err = db.Prepare("UPDATE `users_groups` SET `name` = ?,`tag` = ? WHERE `gid` = ?")
|
stmts.updateGroup, err = db.Prepare("UPDATE `users_groups` SET `name` = ?,`tag` = ? WHERE `gid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateGroup statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateEmail statement.")
|
common.DebugLog("Preparing updateEmail statement.")
|
||||||
stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateEmail statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing verifyEmail statement.")
|
common.DebugLog("Preparing verifyEmail statement.")
|
||||||
stmts.verifyEmail, err = db.Prepare("UPDATE `emails` SET `validated` = 1,`token` = '' WHERE `email` = ?")
|
stmts.verifyEmail, err = db.Prepare("UPDATE `emails` SET `validated` = 1,`token` = '' WHERE `email` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in verifyEmail statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing setTempGroup statement.")
|
common.DebugLog("Preparing setTempGroup statement.")
|
||||||
stmts.setTempGroup, err = db.Prepare("UPDATE `users` SET `temp_group` = ? WHERE `uid` = ?")
|
stmts.setTempGroup, err = db.Prepare("UPDATE `users` SET `temp_group` = ? WHERE `uid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in setTempGroup statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing updateWordFilter statement.")
|
common.DebugLog("Preparing updateWordFilter statement.")
|
||||||
stmts.updateWordFilter, err = db.Prepare("UPDATE `word_filters` SET `find` = ?,`replacement` = ? WHERE `wfid` = ?")
|
stmts.updateWordFilter, err = db.Prepare("UPDATE `word_filters` SET `find` = ?,`replacement` = ? WHERE `wfid` = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in updateWordFilter statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing bumpSync statement.")
|
common.DebugLog("Preparing bumpSync statement.")
|
||||||
stmts.bumpSync, err = db.Prepare("UPDATE `sync` SET `last_update` = LOCALTIMESTAMP()")
|
stmts.bumpSync, err = db.Prepare("UPDATE `sync` SET `last_update` = LOCALTIMESTAMP()")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in bumpSync statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ var RouteMap = map[string]interface{}{
|
||||||
"routeAccountEditUsernameSubmit": routeAccountEditUsernameSubmit,
|
"routeAccountEditUsernameSubmit": routeAccountEditUsernameSubmit,
|
||||||
"routeAccountEditEmail": routeAccountEditEmail,
|
"routeAccountEditEmail": routeAccountEditEmail,
|
||||||
"routeAccountEditEmailTokenSubmit": routeAccountEditEmailTokenSubmit,
|
"routeAccountEditEmailTokenSubmit": routeAccountEditEmailTokenSubmit,
|
||||||
"routeProfile": routeProfile,
|
"routes.ViewProfile": routes.ViewProfile,
|
||||||
"routes.BanUserSubmit": routes.BanUserSubmit,
|
"routes.BanUserSubmit": routes.BanUserSubmit,
|
||||||
"routes.UnbanUser": routes.UnbanUser,
|
"routes.UnbanUser": routes.UnbanUser,
|
||||||
"routes.ActivateUser": routes.ActivateUser,
|
"routes.ActivateUser": routes.ActivateUser,
|
||||||
|
@ -190,7 +190,7 @@ var routeMapEnum = map[string]int{
|
||||||
"routeAccountEditUsernameSubmit": 65,
|
"routeAccountEditUsernameSubmit": 65,
|
||||||
"routeAccountEditEmail": 66,
|
"routeAccountEditEmail": 66,
|
||||||
"routeAccountEditEmailTokenSubmit": 67,
|
"routeAccountEditEmailTokenSubmit": 67,
|
||||||
"routeProfile": 68,
|
"routes.ViewProfile": 68,
|
||||||
"routes.BanUserSubmit": 69,
|
"routes.BanUserSubmit": 69,
|
||||||
"routes.UnbanUser": 70,
|
"routes.UnbanUser": 70,
|
||||||
"routes.ActivateUser": 71,
|
"routes.ActivateUser": 71,
|
||||||
|
@ -293,7 +293,7 @@ var reverseRouteMapEnum = map[int]string{
|
||||||
65: "routeAccountEditUsernameSubmit",
|
65: "routeAccountEditUsernameSubmit",
|
||||||
66: "routeAccountEditEmail",
|
66: "routeAccountEditEmail",
|
||||||
67: "routeAccountEditEmailTokenSubmit",
|
67: "routeAccountEditEmailTokenSubmit",
|
||||||
68: "routeProfile",
|
68: "routes.ViewProfile",
|
||||||
69: "routes.BanUserSubmit",
|
69: "routes.BanUserSubmit",
|
||||||
70: "routes.UnbanUser",
|
70: "routes.UnbanUser",
|
||||||
71: "routes.ActivateUser",
|
71: "routes.ActivateUser",
|
||||||
|
@ -492,19 +492,26 @@ func (router *GenRouter) RemoveFunc(pattern string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (router *GenRouter) StripNewlines(data string) string {
|
||||||
|
// TODO: Strip out all sub-32s?
|
||||||
|
return strings.Replace(strings.Replace(data,"\n","",-1),"\r","",-1)
|
||||||
|
}
|
||||||
|
|
||||||
func (router *GenRouter) DumpRequest(req *http.Request) {
|
func (router *GenRouter) DumpRequest(req *http.Request) {
|
||||||
log.Print("UA: ", req.UserAgent())
|
var heads string
|
||||||
log.Print("Method: ", req.Method)
|
|
||||||
for key, value := range req.Header {
|
for key, value := range req.Header {
|
||||||
for _, vvalue := range value {
|
for _, vvalue := range value {
|
||||||
log.Print("Header '" + key + "': " + vvalue + "!!")
|
heads += "Header '" + router.StripNewlines(key) + "': " + router.StripNewlines(vvalue) + "!!\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Print("req.Host: ", req.Host)
|
|
||||||
log.Print("req.URL.Path: ", req.URL.Path)
|
log.Print("\nUA: " + router.StripNewlines(req.UserAgent()) + "\n" +
|
||||||
log.Print("req.URL.RawQuery: ", req.URL.RawQuery)
|
"Method: " + router.StripNewlines(req.Method) + "\n" + heads +
|
||||||
log.Print("req.Referer(): ", req.Referer())
|
"req.Host: " + router.StripNewlines(req.Host) + "\n" +
|
||||||
log.Print("req.RemoteAddr: ", req.RemoteAddr)
|
"req.URL.Path: " + router.StripNewlines(req.URL.Path) + "\n" +
|
||||||
|
"req.URL.RawQuery: " + router.StripNewlines(req.URL.RawQuery) + "\n" +
|
||||||
|
"req.Referer(): " + router.StripNewlines(req.Referer()) + "\n" +
|
||||||
|
"req.RemoteAddr: " + req.RemoteAddr + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (router *GenRouter) SuspiciousRequest(req *http.Request) {
|
func (router *GenRouter) SuspiciousRequest(req *http.Request) {
|
||||||
|
@ -534,11 +541,6 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
// Deflect malformed requests
|
// Deflect malformed requests
|
||||||
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
|
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
|
||||||
//log.Print("len(req.URL.Path): ",len(req.URL.Path))
|
|
||||||
//log.Print("req.URL.Path[0]: ",req.URL.Path[0])
|
|
||||||
//log.Print("req.Host: ",req.Host)
|
|
||||||
//log.Print("common.Site.Host: ",common.Site.Host)
|
|
||||||
|
|
||||||
w.WriteHeader(200) // 400
|
w.WriteHeader(200) // 400
|
||||||
w.Write([]byte(""))
|
w.Write([]byte(""))
|
||||||
log.Print("Malformed Request")
|
log.Print("Malformed Request")
|
||||||
|
@ -547,8 +549,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if common.Dev.DebugMode {
|
// TODO: Cover more suspicious strings and at a lower layer than this
|
||||||
// TODO: Cover more suspicious strings and at a lower layer than this
|
|
||||||
for _, char := range req.URL.Path {
|
for _, char := range req.URL.Path {
|
||||||
if char != '&' && !(char > 44 && char < 58) && char != '=' && char != '?' && !(char > 64 && char < 91) && char != '\\' && char != '_' && !(char > 96 && char < 123) {
|
if char != '&' && !(char > 44 && char < 58) && char != '=' && char != '?' && !(char > 64 && char < 91) && char != '\\' && char != '_' && !(char > 96 && char < 123) {
|
||||||
router.SuspiciousRequest(req)
|
router.SuspiciousRequest(req)
|
||||||
|
@ -560,7 +561,6 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") || strings.Contains(lowerPath,".php") || strings.Contains(lowerPath,".asp") || strings.Contains(lowerPath,".cgi") || strings.Contains(lowerPath,".py") || strings.Contains(lowerPath,".sql") {
|
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") || strings.Contains(lowerPath,".php") || strings.Contains(lowerPath,".asp") || strings.Contains(lowerPath,".cgi") || strings.Contains(lowerPath,".py") || strings.Contains(lowerPath,".sql") {
|
||||||
router.SuspiciousRequest(req)
|
router.SuspiciousRequest(req)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var prefix, extraData string
|
var prefix, extraData string
|
||||||
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||||
|
@ -1264,7 +1264,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
default:
|
default:
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
counters.RouteViewCounter.Bump(68)
|
counters.RouteViewCounter.Bump(68)
|
||||||
err = routeProfile(w,req,user)
|
err = routes.ViewProfile(w,req,user)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
router.handleError(err,w,req,user)
|
router.handleError(err,w,req,user)
|
||||||
|
|
387
panel_routes.go
387
panel_routes.go
|
@ -619,6 +619,34 @@ func panelAnalyticsTimeRangeToLabelList(timeRange AnalyticsTimeRange) (revLabelL
|
||||||
return revLabelList, labelList, viewMap
|
return revLabelList, labelList, viewMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func panelAnalyticsRowsToViewMap(rows *sql.Rows, labelList []int64, viewMap map[int64]int64) (map[int64]int64, error) {
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var count int64
|
||||||
|
var createdAt time.Time
|
||||||
|
err := rows.Scan(&count, &createdAt)
|
||||||
|
if err != nil {
|
||||||
|
return viewMap, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var unixCreatedAt = createdAt.Unix()
|
||||||
|
// TODO: Bulk log this
|
||||||
|
if common.Dev.SuperDebug {
|
||||||
|
log.Print("count: ", count)
|
||||||
|
log.Print("createdAt: ", createdAt)
|
||||||
|
log.Print("unixCreatedAt: ", unixCreatedAt)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, value := range labelList {
|
||||||
|
if unixCreatedAt > value {
|
||||||
|
viewMap[value] += count
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return viewMap, rows.Err()
|
||||||
|
}
|
||||||
|
|
||||||
func routePanelAnalyticsViews(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
func routePanelAnalyticsViews(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||||
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
|
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
|
@ -634,47 +662,26 @@ func routePanelAnalyticsViews(w http.ResponseWriter, r *http.Request, user commo
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsViews")
|
common.DebugLog("in routePanelAnalyticsViews")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
rows, err := acc.Select("viewchunks").Columns("count, createdAt").Where("route = ''").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query()
|
rows, err := acc.Select("viewchunks").Columns("count, createdAt").Where("route = ''").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query()
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
var viewItems []common.PanelAnalyticsItem
|
var viewItems []common.PanelAnalyticsItem
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range}
|
pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range}
|
||||||
return panelRenderTemplate("panel_analytics_views", w, r, user, &pi)
|
return panelRenderTemplate("panel_analytics_views", w, r, user, &pi)
|
||||||
|
@ -695,48 +702,27 @@ func routePanelAnalyticsRouteViews(w http.ResponseWriter, r *http.Request, user
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsRouteViews")
|
common.DebugLog("in routePanelAnalyticsRouteViews")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
// TODO: Validate the route is valid
|
// TODO: Validate the route is valid
|
||||||
rows, err := acc.Select("viewchunks").Columns("count, createdAt").Where("route = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(route)
|
rows, err := acc.Select("viewchunks").Columns("count, createdAt").Where("route = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(route)
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
var viewItems []common.PanelAnalyticsItem
|
var viewItems []common.PanelAnalyticsItem
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
pi := common.PanelAnalyticsRoutePage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", html.EscapeString(route), graph, viewItems, timeRange.Range}
|
pi := common.PanelAnalyticsRoutePage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", html.EscapeString(route), graph, viewItems, timeRange.Range}
|
||||||
return panelRenderTemplate("panel_analytics_route_views", w, r, user, &pi)
|
return panelRenderTemplate("panel_analytics_route_views", w, r, user, &pi)
|
||||||
|
@ -757,50 +743,25 @@ func routePanelAnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsAgentViews")
|
common.DebugLog("in routePanelAnalyticsAgentViews")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
// TODO: Verify the agent is valid
|
// TODO: Verify the agent is valid
|
||||||
rows, err := acc.Select("viewchunks_agents").Columns("count, createdAt").Where("browser = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(agent)
|
rows, err := acc.Select("viewchunks_agents").Columns("count, createdAt").Where("browser = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(agent)
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
// ? Only allow valid agents? The problem with this is that agents wind up getting renamed and it would take a migration to get them all up to snuff
|
// ? Only allow valid agents? The problem with this is that agents wind up getting renamed and it would take a migration to get them all up to snuff
|
||||||
agent = html.EscapeString(agent)
|
agent = html.EscapeString(agent)
|
||||||
|
@ -828,50 +789,25 @@ func routePanelAnalyticsForumViews(w http.ResponseWriter, r *http.Request, user
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsForumViews")
|
common.DebugLog("in routePanelAnalyticsForumViews")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
// TODO: Verify the agent is valid
|
// TODO: Verify the agent is valid
|
||||||
rows, err := acc.Select("viewchunks_forums").Columns("count, createdAt").Where("forum = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(sfid)
|
rows, err := acc.Select("viewchunks_forums").Columns("count, createdAt").Where("forum = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(sfid)
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
fid, err := strconv.Atoi(sfid)
|
fid, err := strconv.Atoi(sfid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -901,50 +837,25 @@ func routePanelAnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsSystemViews")
|
common.DebugLog("in routePanelAnalyticsSystemViews")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
// TODO: Verify the agent is valid
|
// TODO: Verify the agent is valid
|
||||||
rows, err := acc.Select("viewchunks_systems").Columns("count, createdAt").Where("system = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(system)
|
rows, err := acc.Select("viewchunks_systems").Columns("count, createdAt").Where("system = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(system)
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
system = html.EscapeString(system)
|
system = html.EscapeString(system)
|
||||||
friendlySystem, ok := common.GetOSPhrase(system)
|
friendlySystem, ok := common.GetOSPhrase(system)
|
||||||
|
@ -971,50 +882,25 @@ func routePanelAnalyticsReferrerViews(w http.ResponseWriter, r *http.Request, us
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsReferrerViews")
|
common.DebugLog("in routePanelAnalyticsReferrerViews")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
// TODO: Verify the agent is valid
|
// TODO: Verify the agent is valid
|
||||||
rows, err := acc.Select("viewchunks_referrers").Columns("count, createdAt").Where("domain = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(domain)
|
rows, err := acc.Select("viewchunks_referrers").Columns("count, createdAt").Where("domain = ?").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query(domain)
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", html.EscapeString(domain), "", graph, timeRange.Range}
|
pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", html.EscapeString(domain), "", graph, timeRange.Range}
|
||||||
return panelRenderTemplate("panel_analytics_referrer_views", w, r, user, &pi)
|
return panelRenderTemplate("panel_analytics_referrer_views", w, r, user, &pi)
|
||||||
|
@ -1035,51 +921,26 @@ func routePanelAnalyticsTopics(w http.ResponseWriter, r *http.Request, user comm
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsTopics")
|
common.DebugLog("in routePanelAnalyticsTopics")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
rows, err := acc.Select("topicchunks").Columns("count, createdAt").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query()
|
rows, err := acc.Select("topicchunks").Columns("count, createdAt").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query()
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
var viewItems []common.PanelAnalyticsItem
|
var viewItems []common.PanelAnalyticsItem
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range}
|
pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range}
|
||||||
return panelRenderTemplate("panel_analytics_topics", w, r, user, &pi)
|
return panelRenderTemplate("panel_analytics_topics", w, r, user, &pi)
|
||||||
|
@ -1100,61 +961,57 @@ func routePanelAnalyticsPosts(w http.ResponseWriter, r *http.Request, user commo
|
||||||
}
|
}
|
||||||
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
revLabelList, labelList, viewMap := panelAnalyticsTimeRangeToLabelList(timeRange)
|
||||||
|
|
||||||
var viewList []int64
|
|
||||||
common.DebugLog("in routePanelAnalyticsPosts")
|
common.DebugLog("in routePanelAnalyticsPosts")
|
||||||
|
|
||||||
acc := qgen.Builder.Accumulator()
|
acc := qgen.Builder.Accumulator()
|
||||||
rows, err := acc.Select("postchunks").Columns("count, createdAt").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query()
|
rows, err := acc.Select("postchunks").Columns("count, createdAt").DateCutoff("createdAt", timeRange.Quantity, timeRange.Unit).Query()
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
viewMap, err = panelAnalyticsRowsToViewMap(rows, labelList, viewMap)
|
||||||
var count int64
|
|
||||||
var createdAt time.Time
|
|
||||||
err := rows.Scan(&count, &createdAt)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
var unixCreatedAt = createdAt.Unix()
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("createdAt: ", createdAt)
|
|
||||||
log.Print("unixCreatedAt: ", unixCreatedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, value := range labelList {
|
|
||||||
if unixCreatedAt > value {
|
|
||||||
viewMap[value] += count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewList []int64
|
||||||
var viewItems []common.PanelAnalyticsItem
|
var viewItems []common.PanelAnalyticsItem
|
||||||
for _, value := range revLabelList {
|
for _, value := range revLabelList {
|
||||||
viewList = append(viewList, viewMap[value])
|
viewList = append(viewList, viewMap[value])
|
||||||
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
viewItems = append(viewItems, common.PanelAnalyticsItem{Time: value, Count: viewMap[value]})
|
||||||
}
|
}
|
||||||
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
graph := common.PanelTimeGraph{Series: viewList, Labels: labelList}
|
||||||
log.Printf("graph: %+v\n", graph)
|
common.DebugLogf("graph: %+v\n", graph)
|
||||||
|
|
||||||
pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range}
|
pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range}
|
||||||
return panelRenderTemplate("panel_analytics_posts", w, r, user, &pi)
|
return panelRenderTemplate("panel_analytics_posts", w, r, user, &pi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func panelAnalyticsRowsToNameMap(rows *sql.Rows) (map[string]int, error) {
|
||||||
|
nameMap := make(map[string]int)
|
||||||
|
defer rows.Close()
|
||||||
|
for rows.Next() {
|
||||||
|
var count int
|
||||||
|
var name string
|
||||||
|
err := rows.Scan(&count, &name)
|
||||||
|
if err != nil {
|
||||||
|
return nameMap, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Bulk log this
|
||||||
|
if common.Dev.SuperDebug {
|
||||||
|
log.Print("count: ", count)
|
||||||
|
log.Print("name: ", name)
|
||||||
|
}
|
||||||
|
nameMap[name] += count
|
||||||
|
}
|
||||||
|
return nameMap, rows.Err()
|
||||||
|
}
|
||||||
|
|
||||||
func routePanelAnalyticsForums(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
func routePanelAnalyticsForums(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||||
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
|
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
var forumMap = make(map[string]int)
|
|
||||||
|
|
||||||
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1166,24 +1023,8 @@ func routePanelAnalyticsForums(w http.ResponseWriter, r *http.Request, user comm
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
forumMap, err := panelAnalyticsRowsToNameMap(rows)
|
||||||
var count int
|
|
||||||
var forum string
|
|
||||||
err := rows.Scan(&count, &forum)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("forum: ", forum)
|
|
||||||
}
|
|
||||||
forumMap[forum] += count
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -1215,8 +1056,6 @@ func routePanelAnalyticsRoutes(w http.ResponseWriter, r *http.Request, user comm
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
var routeMap = make(map[string]int)
|
|
||||||
|
|
||||||
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.LocalError(err.Error(), w, r, user)
|
return common.LocalError(err.Error(), w, r, user)
|
||||||
|
@ -1227,24 +1066,8 @@ func routePanelAnalyticsRoutes(w http.ResponseWriter, r *http.Request, user comm
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
routeMap, err := panelAnalyticsRowsToNameMap(rows)
|
||||||
var count int
|
|
||||||
var route string
|
|
||||||
err := rows.Scan(&count, &route)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("route: ", route)
|
|
||||||
}
|
|
||||||
routeMap[route] += count
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -1267,8 +1090,6 @@ func routePanelAnalyticsAgents(w http.ResponseWriter, r *http.Request, user comm
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
var agentMap = make(map[string]int)
|
|
||||||
|
|
||||||
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.LocalError(err.Error(), w, r, user)
|
return common.LocalError(err.Error(), w, r, user)
|
||||||
|
@ -1279,24 +1100,8 @@ func routePanelAnalyticsAgents(w http.ResponseWriter, r *http.Request, user comm
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
agentMap, err := panelAnalyticsRowsToNameMap(rows)
|
||||||
var count int
|
|
||||||
var agent string
|
|
||||||
err := rows.Scan(&count, &agent)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("agent: ", agent)
|
|
||||||
}
|
|
||||||
agentMap[agent] += count
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -1324,8 +1129,6 @@ func routePanelAnalyticsSystems(w http.ResponseWriter, r *http.Request, user com
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
var osMap = make(map[string]int)
|
|
||||||
|
|
||||||
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.LocalError(err.Error(), w, r, user)
|
return common.LocalError(err.Error(), w, r, user)
|
||||||
|
@ -1336,24 +1139,8 @@ func routePanelAnalyticsSystems(w http.ResponseWriter, r *http.Request, user com
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
osMap, err := panelAnalyticsRowsToNameMap(rows)
|
||||||
var count int
|
|
||||||
var system string
|
|
||||||
err := rows.Scan(&count, &system)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("system: ", system)
|
|
||||||
}
|
|
||||||
osMap[system] += count
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -1381,8 +1168,6 @@ func routePanelAnalyticsReferrers(w http.ResponseWriter, r *http.Request, user c
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
var refMap = make(map[string]int)
|
|
||||||
|
|
||||||
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
timeRange, err := panelAnalyticsTimeRange(r.FormValue("timeRange"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.LocalError(err.Error(), w, r, user)
|
return common.LocalError(err.Error(), w, r, user)
|
||||||
|
@ -1393,24 +1178,8 @@ func routePanelAnalyticsReferrers(w http.ResponseWriter, r *http.Request, user c
|
||||||
if err != nil && err != ErrNoRows {
|
if err != nil && err != ErrNoRows {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
refMap, err := panelAnalyticsRowsToNameMap(rows)
|
||||||
var count int
|
|
||||||
var domain string
|
|
||||||
err := rows.Scan(&count, &domain)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Bulk log this
|
|
||||||
if common.Dev.SuperDebug {
|
|
||||||
log.Print("count: ", count)
|
|
||||||
log.Print("domain: ", domain)
|
|
||||||
}
|
|
||||||
refMap[domain] += count
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.InternalError(err, w, r)
|
return common.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ func _markdownParse(msg string, n int) string {
|
||||||
|
|
||||||
var outbytes []byte
|
var outbytes []byte
|
||||||
var lastElement int
|
var lastElement int
|
||||||
log.Printf("Initial Message: %+v\n", strings.Replace(msg, "\r", "\\r", -1))
|
common.DebugLogf("Initial Message: %+v\n", strings.Replace(msg, "\r", "\\r", -1))
|
||||||
|
|
||||||
for index := 0; index < len(msg); index++ {
|
for index := 0; index < len(msg); index++ {
|
||||||
//log.Print("--OUTER MARKDOWN LOOP START--")
|
//log.Print("--OUTER MARKDOWN LOOP START--")
|
||||||
|
@ -229,7 +229,6 @@ func _markdownParse(msg string, n int) string {
|
||||||
|
|
||||||
//log.Print("sIndex: ", sIndex)
|
//log.Print("sIndex: ", sIndex)
|
||||||
//log.Print("lIndex: ", lIndex)
|
//log.Print("lIndex: ", lIndex)
|
||||||
|
|
||||||
if lIndex <= sIndex {
|
if lIndex <= sIndex {
|
||||||
//log.Print("unclosed markdown element @ lIndex <= sIndex")
|
//log.Print("unclosed markdown element @ lIndex <= sIndex")
|
||||||
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
||||||
|
|
|
@ -1088,9 +1088,10 @@ func (adapter *MssqlAdapter) Write() error {
|
||||||
if stmt.Type != "create-table" {
|
if stmt.Type != "create-table" {
|
||||||
stmts += "\t" + name + " *sql.Stmt\n"
|
stmts += "\t" + name + " *sql.Stmt\n"
|
||||||
body += `
|
body += `
|
||||||
log.Print("Preparing ` + name + ` statement.")
|
common.DebugLog("Preparing ` + name + ` statement.")
|
||||||
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in ` + name + ` statement.")
|
||||||
log.Print("Bad Query: ","` + stmt.Contents + `")
|
log.Print("Bad Query: ","` + stmt.Contents + `")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -639,18 +639,20 @@ func (adapter *MysqlAdapter) Write() error {
|
||||||
if stmt.Type == "upsert" {
|
if stmt.Type == "upsert" {
|
||||||
stmts += "\t" + name + " *qgen.MySQLUpsertCallback\n"
|
stmts += "\t" + name + " *qgen.MySQLUpsertCallback\n"
|
||||||
body += `
|
body += `
|
||||||
log.Print("Preparing ` + name + ` statement.")
|
common.DebugLog("Preparing ` + name + ` statement.")
|
||||||
stmts.` + name + `, err = qgen.PrepareMySQLUpsertCallback(db, "` + stmt.Contents + `")
|
stmts.` + name + `, err = qgen.PrepareMySQLUpsertCallback(db, "` + stmt.Contents + `")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in ` + name + ` statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
} else if stmt.Type != "create-table" {
|
} else if stmt.Type != "create-table" {
|
||||||
stmts += "\t" + name + " *sql.Stmt\n"
|
stmts += "\t" + name + " *sql.Stmt\n"
|
||||||
body += `
|
body += `
|
||||||
log.Print("Preparing ` + name + ` statement.")
|
common.DebugLog("Preparing ` + name + ` statement.")
|
||||||
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in ` + name + ` statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -347,9 +347,10 @@ func (adapter *PgsqlAdapter) Write() error {
|
||||||
if stmt.Type != "create-table" {
|
if stmt.Type != "create-table" {
|
||||||
stmts += "\t" + name + " *sql.Stmt\n"
|
stmts += "\t" + name + " *sql.Stmt\n"
|
||||||
body += `
|
body += `
|
||||||
log.Print("Preparing ` + name + ` statement.")
|
common.DebugLog("Preparing ` + name + ` statement.")
|
||||||
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print("Error in ` + name + ` statement.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -255,8 +255,6 @@ func writeSelects(adapter qgen.Adapter) error {
|
||||||
func writeLeftJoins(adapter qgen.Adapter) error {
|
func writeLeftJoins(adapter qgen.Adapter) error {
|
||||||
adapter.SimpleLeftJoin("getForumTopics", "topics", "users", "topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, users.name, users.avatar", "topics.createdBy = users.uid", "topics.parentID = ?", "topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy desc", "")
|
adapter.SimpleLeftJoin("getForumTopics", "topics", "users", "topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, users.name, users.avatar", "topics.createdBy = users.uid", "topics.parentID = ?", "topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy desc", "")
|
||||||
|
|
||||||
adapter.SimpleLeftJoin("getProfileReplies", "users_replies", "users", "users_replies.rid, users_replies.content, users_replies.createdBy, users_replies.createdAt, users_replies.lastEdit, users_replies.lastEditBy, users.avatar, users.name, users.group", "users_replies.createdBy = users.uid", "users_replies.uid = ?", "", "")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -343,19 +343,26 @@ func (router *GenRouter) RemoveFunc(pattern string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (router *GenRouter) StripNewlines(data string) string {
|
||||||
|
// TODO: Strip out all sub-32s?
|
||||||
|
return strings.Replace(strings.Replace(data,"\n","",-1),"\r","",-1)
|
||||||
|
}
|
||||||
|
|
||||||
func (router *GenRouter) DumpRequest(req *http.Request) {
|
func (router *GenRouter) DumpRequest(req *http.Request) {
|
||||||
log.Print("UA: ", req.UserAgent())
|
var heads string
|
||||||
log.Print("Method: ", req.Method)
|
|
||||||
for key, value := range req.Header {
|
for key, value := range req.Header {
|
||||||
for _, vvalue := range value {
|
for _, vvalue := range value {
|
||||||
log.Print("Header '" + key + "': " + vvalue + "!!")
|
heads += "Header '" + router.StripNewlines(key) + "': " + router.StripNewlines(vvalue) + "!!\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Print("req.Host: ", req.Host)
|
|
||||||
log.Print("req.URL.Path: ", req.URL.Path)
|
log.Print("\nUA: " + router.StripNewlines(req.UserAgent()) + "\n" +
|
||||||
log.Print("req.URL.RawQuery: ", req.URL.RawQuery)
|
"Method: " + router.StripNewlines(req.Method) + "\n" + heads +
|
||||||
log.Print("req.Referer(): ", req.Referer())
|
"req.Host: " + router.StripNewlines(req.Host) + "\n" +
|
||||||
log.Print("req.RemoteAddr: ", req.RemoteAddr)
|
"req.URL.Path: " + router.StripNewlines(req.URL.Path) + "\n" +
|
||||||
|
"req.URL.RawQuery: " + router.StripNewlines(req.URL.RawQuery) + "\n" +
|
||||||
|
"req.Referer(): " + router.StripNewlines(req.Referer()) + "\n" +
|
||||||
|
"req.RemoteAddr: " + req.RemoteAddr + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (router *GenRouter) SuspiciousRequest(req *http.Request) {
|
func (router *GenRouter) SuspiciousRequest(req *http.Request) {
|
||||||
|
@ -385,11 +392,6 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
// Deflect malformed requests
|
// Deflect malformed requests
|
||||||
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
|
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
|
||||||
//log.Print("len(req.URL.Path): ",len(req.URL.Path))
|
|
||||||
//log.Print("req.URL.Path[0]: ",req.URL.Path[0])
|
|
||||||
//log.Print("req.Host: ",req.Host)
|
|
||||||
//log.Print("common.Site.Host: ",common.Site.Host)
|
|
||||||
|
|
||||||
w.WriteHeader(200) // 400
|
w.WriteHeader(200) // 400
|
||||||
w.Write([]byte(""))
|
w.Write([]byte(""))
|
||||||
log.Print("Malformed Request")
|
log.Print("Malformed Request")
|
||||||
|
@ -398,8 +400,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if common.Dev.DebugMode {
|
// TODO: Cover more suspicious strings and at a lower layer than this
|
||||||
// TODO: Cover more suspicious strings and at a lower layer than this
|
|
||||||
for _, char := range req.URL.Path {
|
for _, char := range req.URL.Path {
|
||||||
if char != '&' && !(char > 44 && char < 58) && char != '=' && char != '?' && !(char > 64 && char < 91) && char != '\\' && char != '_' && !(char > 96 && char < 123) {
|
if char != '&' && !(char > 44 && char < 58) && char != '=' && char != '?' && !(char > 64 && char < 91) && char != '\\' && char != '_' && !(char > 96 && char < 123) {
|
||||||
router.SuspiciousRequest(req)
|
router.SuspiciousRequest(req)
|
||||||
|
@ -411,7 +412,6 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") || strings.Contains(lowerPath,".php") || strings.Contains(lowerPath,".asp") || strings.Contains(lowerPath,".cgi") || strings.Contains(lowerPath,".py") || strings.Contains(lowerPath,".sql") {
|
if strings.Contains(req.URL.Path,"..") || strings.Contains(req.URL.Path,"--") || strings.Contains(lowerPath,".php") || strings.Contains(lowerPath,".asp") || strings.Contains(lowerPath,".cgi") || strings.Contains(lowerPath,".py") || strings.Contains(lowerPath,".sql") {
|
||||||
router.SuspiciousRequest(req)
|
router.SuspiciousRequest(req)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var prefix, extraData string
|
var prefix, extraData string
|
||||||
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||||
|
|
|
@ -39,7 +39,7 @@ func routes() {
|
||||||
func buildUserRoutes() {
|
func buildUserRoutes() {
|
||||||
userGroup := newRouteGroup("/user/")
|
userGroup := newRouteGroup("/user/")
|
||||||
userGroup.Routes(
|
userGroup.Routes(
|
||||||
View("routeProfile", "/user/").LitBefore("req.URL.Path += extraData"),
|
View("routes.ViewProfile", "/user/").LitBefore("req.URL.Path += extraData"),
|
||||||
MemberView("routes.AccountEditCritical", "/user/edit/critical/"),
|
MemberView("routes.AccountEditCritical", "/user/edit/critical/"),
|
||||||
Action("routeAccountEditCriticalSubmit", "/user/edit/critical/submit/"), // TODO: Full test this
|
Action("routeAccountEditCriticalSubmit", "/user/edit/critical/submit/"), // TODO: Full test this
|
||||||
MemberView("routeAccountEditAvatar", "/user/edit/avatar/"),
|
MemberView("routeAccountEditAvatar", "/user/edit/avatar/"),
|
||||||
|
|
101
routes.go
101
routes.go
|
@ -11,8 +11,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"./common"
|
"./common"
|
||||||
)
|
)
|
||||||
|
@ -98,105 +96,6 @@ func routeForums(w http.ResponseWriter, r *http.Request, user common.User) commo
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func routeProfile(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
|
||||||
headerVars, ferr := common.UserCheck(w, r, &user)
|
|
||||||
if ferr != nil {
|
|
||||||
return ferr
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
var replyCreatedAt time.Time
|
|
||||||
var replyContent, replyCreatedByName, replyRelativeCreatedAt, replyAvatar, replyTag, replyClassName string
|
|
||||||
var rid, replyCreatedBy, replyLastEdit, replyLastEditBy, replyLines, replyGroup int
|
|
||||||
var replyList []common.ReplyUser
|
|
||||||
|
|
||||||
// SEO URLs...
|
|
||||||
// TODO: Do a 301 if it's the wrong username? Do a canonical too?
|
|
||||||
halves := strings.Split(r.URL.Path[len("/user/"):], ".")
|
|
||||||
if len(halves) < 2 {
|
|
||||||
halves = append(halves, halves[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
pid, err := strconv.Atoi(halves[1])
|
|
||||||
if err != nil {
|
|
||||||
return common.LocalError("The provided UserID is not a valid number.", w, r, user)
|
|
||||||
}
|
|
||||||
|
|
||||||
var puser *common.User
|
|
||||||
if pid == user.ID {
|
|
||||||
user.IsMod = true
|
|
||||||
puser = &user
|
|
||||||
} else {
|
|
||||||
// Fetch the user data
|
|
||||||
// TODO: Add a shared function for checking for ErrNoRows and internal erroring if it's not that case?
|
|
||||||
puser, err = common.Users.Get(pid)
|
|
||||||
if err == ErrNoRows {
|
|
||||||
return common.NotFound(w, r, headerVars)
|
|
||||||
} else if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the replies..
|
|
||||||
rows, err := stmts.getProfileReplies.Query(puser.ID)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
err := rows.Scan(&rid, &replyContent, &replyCreatedBy, &replyCreatedAt, &replyLastEdit, &replyLastEditBy, &replyAvatar, &replyCreatedByName, &replyGroup)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
group, err := common.Groups.Get(replyGroup)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
replyLines = strings.Count(replyContent, "\n")
|
|
||||||
if group.IsMod || group.IsAdmin {
|
|
||||||
replyClassName = common.Config.StaffCSS
|
|
||||||
} else {
|
|
||||||
replyClassName = ""
|
|
||||||
}
|
|
||||||
replyAvatar = common.BuildAvatar(replyCreatedBy, replyAvatar)
|
|
||||||
|
|
||||||
if group.Tag != "" {
|
|
||||||
replyTag = group.Tag
|
|
||||||
} else if puser.ID == replyCreatedBy {
|
|
||||||
replyTag = "Profile Owner"
|
|
||||||
} else {
|
|
||||||
replyTag = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
replyLiked := false
|
|
||||||
replyLikeCount := 0
|
|
||||||
replyRelativeCreatedAt = common.RelativeTime(replyCreatedAt)
|
|
||||||
|
|
||||||
// TODO: Add a hook here
|
|
||||||
|
|
||||||
replyList = append(replyList, common.ReplyUser{rid, puser.ID, replyContent, common.ParseMessage(replyContent, 0, ""), replyCreatedBy, common.BuildProfileURL(common.NameToSlug(replyCreatedByName), replyCreatedBy), replyCreatedByName, replyGroup, replyCreatedAt, replyRelativeCreatedAt, replyLastEdit, replyLastEditBy, replyAvatar, replyClassName, replyLines, replyTag, "", "", "", 0, "", replyLiked, replyLikeCount, "", ""})
|
|
||||||
}
|
|
||||||
err = rows.Err()
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Add a phrase for this title
|
|
||||||
ppage := common.ProfilePage{puser.Name + "'s Profile", user, headerVars, replyList, *puser}
|
|
||||||
if common.RunPreRenderHook("pre_render_profile", w, r, &user, &ppage) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err = common.RunThemeTemplate(headerVars.Theme.Name, "profile", ppage, w)
|
|
||||||
if err != nil {
|
|
||||||
return common.InternalError(err, w, r)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Set the cookie domain
|
// TODO: Set the cookie domain
|
||||||
func routeChangeTheme(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
func routeChangeTheme(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||||
//headerLite, _ := SimpleUserCheck(w, r, &user)
|
//headerLite, _ := SimpleUserCheck(w, r, &user)
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"../common"
|
||||||
|
"../query_gen/lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfileStmts struct {
|
||||||
|
getReplies *sql.Stmt
|
||||||
|
}
|
||||||
|
|
||||||
|
var profileStmts ProfileStmts
|
||||||
|
|
||||||
|
// TODO: Move these DbInits into some sort of abstraction
|
||||||
|
func init() {
|
||||||
|
common.DbInits.Add(func(acc *qgen.Accumulator) error {
|
||||||
|
profileStmts = ProfileStmts{
|
||||||
|
getReplies: acc.SimpleLeftJoin("users_replies", "users", "users_replies.rid, users_replies.content, users_replies.createdBy, users_replies.createdAt, users_replies.lastEdit, users_replies.lastEditBy, users.avatar, users.name, users.group", "users_replies.createdBy = users.uid", "users_replies.uid = ?", "", ""),
|
||||||
|
}
|
||||||
|
return acc.FirstError()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func ViewProfile(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||||
|
headerVars, ferr := common.UserCheck(w, r, &user)
|
||||||
|
if ferr != nil {
|
||||||
|
return ferr
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
var replyCreatedAt time.Time
|
||||||
|
var replyContent, replyCreatedByName, replyRelativeCreatedAt, replyAvatar, replyTag, replyClassName string
|
||||||
|
var rid, replyCreatedBy, replyLastEdit, replyLastEditBy, replyLines, replyGroup int
|
||||||
|
var replyList []common.ReplyUser
|
||||||
|
|
||||||
|
// SEO URLs...
|
||||||
|
// TODO: Do a 301 if it's the wrong username? Do a canonical too?
|
||||||
|
halves := strings.Split(r.URL.Path[len("/user/"):], ".")
|
||||||
|
if len(halves) < 2 {
|
||||||
|
halves = append(halves, halves[0])
|
||||||
|
}
|
||||||
|
pid, err := strconv.Atoi(halves[1])
|
||||||
|
if err != nil {
|
||||||
|
return common.LocalError("The provided UserID is not a valid number.", w, r, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
var puser *common.User
|
||||||
|
if pid == user.ID {
|
||||||
|
user.IsMod = true
|
||||||
|
puser = &user
|
||||||
|
} else {
|
||||||
|
// Fetch the user data
|
||||||
|
// TODO: Add a shared function for checking for ErrNoRows and internal erroring if it's not that case?
|
||||||
|
puser, err = common.Users.Get(pid)
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return common.NotFound(w, r, headerVars)
|
||||||
|
} else if err != nil {
|
||||||
|
return common.InternalError(err, w, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the replies..
|
||||||
|
rows, err := profileStmts.getReplies.Query(puser.ID)
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalError(err, w, r)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
err := rows.Scan(&rid, &replyContent, &replyCreatedBy, &replyCreatedAt, &replyLastEdit, &replyLastEditBy, &replyAvatar, &replyCreatedByName, &replyGroup)
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalError(err, w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
group, err := common.Groups.Get(replyGroup)
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalError(err, w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
replyLines = strings.Count(replyContent, "\n")
|
||||||
|
if group.IsMod || group.IsAdmin {
|
||||||
|
replyClassName = common.Config.StaffCSS
|
||||||
|
} else {
|
||||||
|
replyClassName = ""
|
||||||
|
}
|
||||||
|
replyAvatar = common.BuildAvatar(replyCreatedBy, replyAvatar)
|
||||||
|
|
||||||
|
if group.Tag != "" {
|
||||||
|
replyTag = group.Tag
|
||||||
|
} else if puser.ID == replyCreatedBy {
|
||||||
|
replyTag = "Profile Owner"
|
||||||
|
} else {
|
||||||
|
replyTag = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
replyLiked := false
|
||||||
|
replyLikeCount := 0
|
||||||
|
replyRelativeCreatedAt = common.RelativeTime(replyCreatedAt)
|
||||||
|
|
||||||
|
// TODO: Add a hook here
|
||||||
|
|
||||||
|
replyList = append(replyList, common.ReplyUser{rid, puser.ID, replyContent, common.ParseMessage(replyContent, 0, ""), replyCreatedBy, common.BuildProfileURL(common.NameToSlug(replyCreatedByName), replyCreatedBy), replyCreatedByName, replyGroup, replyCreatedAt, replyRelativeCreatedAt, replyLastEdit, replyLastEditBy, replyAvatar, replyClassName, replyLines, replyTag, "", "", "", 0, "", replyLiked, replyLikeCount, "", ""})
|
||||||
|
}
|
||||||
|
err = rows.Err()
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalError(err, w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add a phrase for this title
|
||||||
|
ppage := common.ProfilePage{puser.Name + "'s Profile", user, headerVars, replyList, *puser}
|
||||||
|
if common.RunPreRenderHook("pre_render_profile", w, r, &user, &ppage) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = common.RunThemeTemplate(headerVars.Theme.Name, "profile", ppage, w)
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalError(err, w, r)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -318,10 +318,8 @@ func CreateTopicSubmit(w http.ResponseWriter, r *http.Request, user common.User)
|
||||||
var maxPollOptions = 10
|
var maxPollOptions = 10
|
||||||
var pollInputItems = make(map[int]string)
|
var pollInputItems = make(map[int]string)
|
||||||
for key, values := range r.Form {
|
for key, values := range r.Form {
|
||||||
//if common.Dev.SuperDebug {
|
common.DebugDetail("key: ", key)
|
||||||
log.Print("key: ", key)
|
common.DebugDetailf("values: %+v\n", values)
|
||||||
log.Printf("values: %+v\n", values)
|
|
||||||
//}
|
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
if strings.HasPrefix(key, "pollinputitem[") {
|
if strings.HasPrefix(key, "pollinputitem[") {
|
||||||
halves := strings.Split(key, "[")
|
halves := strings.Split(key, "[")
|
||||||
|
@ -548,7 +546,7 @@ func DeleteTopicSubmit(w http.ResponseWriter, r *http.Request, user common.User)
|
||||||
return common.InternalErrorJSQ(err,w,r,isJs)
|
return common.InternalErrorJSQ(err,w,r,isJs)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
log.Printf("Topic #%d was deleted by common.User #%d", tid, user.ID)
|
log.Printf("Topic #%d was deleted by UserID #%d", tid, user.ID)
|
||||||
}
|
}
|
||||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -683,41 +683,48 @@ var profile_7 = []byte(`
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="passiveBlock">
|
<div class="passiveBlock">
|
||||||
<div class="rowitem passive">
|
|
||||||
<a class="profile_menu_item">Add Friend</a>
|
|
||||||
</div>
|
|
||||||
`)
|
`)
|
||||||
var profile_8 = []byte(`<div class="rowitem passive">
|
var profile_8 = []byte(`<div class="rowitem passive">
|
||||||
`)
|
<a class="profile_menu_item">Login for options</a>
|
||||||
var profile_9 = []byte(`<a href="/users/unban/`)
|
|
||||||
var profile_10 = []byte(`?session=`)
|
|
||||||
var profile_11 = []byte(`" class="profile_menu_item">Unban</a>
|
|
||||||
`)
|
|
||||||
var profile_12 = []byte(`<a href="#ban_user" class="profile_menu_item">Ban</a>`)
|
|
||||||
var profile_13 = []byte(`
|
|
||||||
</div>`)
|
</div>`)
|
||||||
var profile_14 = []byte(`
|
var profile_9 = []byte(`
|
||||||
|
<!--<div class="rowitem passive">
|
||||||
|
<a class="profile_menu_item">Add Friend</a>
|
||||||
|
</div>-->
|
||||||
|
`)
|
||||||
|
var profile_10 = []byte(`<div class="rowitem passive">
|
||||||
|
`)
|
||||||
|
var profile_11 = []byte(`<a href="/users/unban/`)
|
||||||
|
var profile_12 = []byte(`?session=`)
|
||||||
|
var profile_13 = []byte(`" class="profile_menu_item">Unban</a>
|
||||||
|
`)
|
||||||
|
var profile_14 = []byte(`<a href="#ban_user" class="profile_menu_item">Ban</a>`)
|
||||||
|
var profile_15 = []byte(`
|
||||||
|
</div>`)
|
||||||
|
var profile_16 = []byte(`
|
||||||
<div class="rowitem passive">
|
<div class="rowitem passive">
|
||||||
<a href="/report/submit/`)
|
<a href="/report/submit/`)
|
||||||
var profile_15 = []byte(`?session=`)
|
var profile_17 = []byte(`?session=`)
|
||||||
var profile_16 = []byte(`&type=user" class="profile_menu_item report_item" aria-label="Report User" title="Report User"></a>
|
var profile_18 = []byte(`&type=user" class="profile_menu_item report_item" aria-label="Report User" title="Report User"></a>
|
||||||
</div>
|
</div>
|
||||||
|
`)
|
||||||
|
var profile_19 = []byte(`
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="profile_right_lane" class="colstack_right">
|
<div id="profile_right_lane" class="colstack_right">
|
||||||
`)
|
`)
|
||||||
var profile_17 = []byte(`
|
var profile_20 = []byte(`
|
||||||
<!-- TODO: Inline the display: none; CSS -->
|
<!-- TODO: Inline the display: none; CSS -->
|
||||||
<div id="ban_user_head" class="colstack_item colstack_head hash_hide ban_user_hash" style="display: none;">
|
<div id="ban_user_head" class="colstack_item colstack_head hash_hide ban_user_hash" style="display: none;">
|
||||||
<div class="rowitem"><h1><a>Ban User</a></h1></div>
|
<div class="rowitem"><h1><a>Ban User</a></h1></div>
|
||||||
</div>
|
</div>
|
||||||
<form id="ban_user_form" class="hash_hide ban_user_hash" action="/users/ban/submit/`)
|
<form id="ban_user_form" class="hash_hide ban_user_hash" action="/users/ban/submit/`)
|
||||||
var profile_18 = []byte(`?session=`)
|
var profile_21 = []byte(`?session=`)
|
||||||
var profile_19 = []byte(`" method="post" style="display: none;">
|
var profile_22 = []byte(`" method="post" style="display: none;">
|
||||||
`)
|
`)
|
||||||
var profile_20 = []byte(`
|
var profile_23 = []byte(`
|
||||||
<div class="colline">If all the fields are left blank, the ban will be permanent.</div>
|
<div class="colline">If all the fields are left blank, the ban will be permanent.</div>
|
||||||
<div class="colstack_item">
|
<div class="colstack_item">
|
||||||
<div class="formrow real_first_child">
|
<div class="formrow real_first_child">
|
||||||
|
@ -748,7 +755,7 @@ var profile_20 = []byte(`
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
`)
|
`)
|
||||||
var profile_21 = []byte(`
|
var profile_24 = []byte(`
|
||||||
|
|
||||||
<div id="profile_comments_head" class="colstack_item colstack_head hash_hide">
|
<div id="profile_comments_head" class="colstack_item colstack_head hash_hide">
|
||||||
<div class="rowitem"><h1><a>Comments</a></h1></div>
|
<div class="rowitem"><h1><a>Comments</a></h1></div>
|
||||||
|
@ -828,15 +835,16 @@ var profile_comments_row_36 = []byte(`&type=user-reply"><button class="username
|
||||||
var profile_comments_row_37 = []byte(`</span>
|
var profile_comments_row_37 = []byte(`</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="after_comment"></div>
|
||||||
`)
|
`)
|
||||||
var profile_22 = []byte(`</div>
|
var profile_25 = []byte(`</div>
|
||||||
|
|
||||||
`)
|
`)
|
||||||
var profile_23 = []byte(`
|
var profile_26 = []byte(`
|
||||||
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session=`)
|
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session=`)
|
||||||
var profile_24 = []byte(`" method="post">
|
var profile_27 = []byte(`" method="post">
|
||||||
<input name="uid" value='`)
|
<input name="uid" value='`)
|
||||||
var profile_25 = []byte(`' type="hidden" />
|
var profile_28 = []byte(`' type="hidden" />
|
||||||
<div class="colstack_item topic_reply_form" style="border-top: none;">
|
<div class="colstack_item topic_reply_form" style="border-top: none;">
|
||||||
<div class="formrow">
|
<div class="formrow">
|
||||||
<div class="formitem"><textarea class="input_content" name="reply-content" placeholder="Insert comment here"></textarea></div>
|
<div class="formitem"><textarea class="input_content" name="reply-content" placeholder="Insert comment here"></textarea></div>
|
||||||
|
@ -847,13 +855,13 @@ var profile_25 = []byte(`' type="hidden" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
`)
|
`)
|
||||||
var profile_26 = []byte(`
|
var profile_29 = []byte(`
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
`)
|
`)
|
||||||
var profile_27 = []byte(`
|
var profile_30 = []byte(`
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function handle_profile_hashbit() {
|
function handle_profile_hashbit() {
|
||||||
var hash_class = ""
|
var hash_class = ""
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
// Code generated by Gosora. More below:
|
// Code generated by Gosora. More below:
|
||||||
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
|
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
|
||||||
package main
|
package main
|
||||||
|
import "net/http"
|
||||||
import "./common"
|
import "./common"
|
||||||
import "strconv"
|
import "strconv"
|
||||||
import "net/http"
|
|
||||||
|
|
||||||
// nolint
|
// nolint
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -95,33 +95,39 @@ w.Write([]byte(tmpl_profile_vars.ProfileOwner.Tag))
|
||||||
w.Write(profile_6)
|
w.Write(profile_6)
|
||||||
}
|
}
|
||||||
w.Write(profile_7)
|
w.Write(profile_7)
|
||||||
if tmpl_profile_vars.CurrentUser.IsSuperMod && !tmpl_profile_vars.ProfileOwner.IsSuperMod {
|
if !tmpl_profile_vars.CurrentUser.Loggedin {
|
||||||
w.Write(profile_8)
|
w.Write(profile_8)
|
||||||
if tmpl_profile_vars.ProfileOwner.IsBanned {
|
|
||||||
w.Write(profile_9)
|
|
||||||
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
|
||||||
w.Write(profile_10)
|
|
||||||
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
|
||||||
w.Write(profile_11)
|
|
||||||
} else {
|
} else {
|
||||||
|
w.Write(profile_9)
|
||||||
|
if tmpl_profile_vars.CurrentUser.IsSuperMod && !tmpl_profile_vars.ProfileOwner.IsSuperMod {
|
||||||
|
w.Write(profile_10)
|
||||||
|
if tmpl_profile_vars.ProfileOwner.IsBanned {
|
||||||
|
w.Write(profile_11)
|
||||||
|
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
||||||
w.Write(profile_12)
|
w.Write(profile_12)
|
||||||
}
|
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
||||||
w.Write(profile_13)
|
w.Write(profile_13)
|
||||||
}
|
} else {
|
||||||
w.Write(profile_14)
|
w.Write(profile_14)
|
||||||
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
|
||||||
w.Write(profile_15)
|
|
||||||
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
|
||||||
w.Write(profile_16)
|
|
||||||
if tmpl_profile_vars.CurrentUser.Perms.BanUsers {
|
|
||||||
w.Write(profile_17)
|
|
||||||
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
|
||||||
w.Write(profile_18)
|
|
||||||
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
|
||||||
w.Write(profile_19)
|
|
||||||
w.Write(profile_20)
|
|
||||||
}
|
}
|
||||||
|
w.Write(profile_15)
|
||||||
|
}
|
||||||
|
w.Write(profile_16)
|
||||||
|
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
||||||
|
w.Write(profile_17)
|
||||||
|
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
||||||
|
w.Write(profile_18)
|
||||||
|
}
|
||||||
|
w.Write(profile_19)
|
||||||
|
if tmpl_profile_vars.CurrentUser.Perms.BanUsers {
|
||||||
|
w.Write(profile_20)
|
||||||
|
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
||||||
w.Write(profile_21)
|
w.Write(profile_21)
|
||||||
|
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
||||||
|
w.Write(profile_22)
|
||||||
|
w.Write(profile_23)
|
||||||
|
}
|
||||||
|
w.Write(profile_24)
|
||||||
if tmpl_profile_vars.Header.Theme.BgAvatars {
|
if tmpl_profile_vars.Header.Theme.BgAvatars {
|
||||||
if len(tmpl_profile_vars.ItemList) != 0 {
|
if len(tmpl_profile_vars.ItemList) != 0 {
|
||||||
for _, item := range tmpl_profile_vars.ItemList {
|
for _, item := range tmpl_profile_vars.ItemList {
|
||||||
|
@ -207,16 +213,16 @@ w.Write(profile_comments_row_37)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.Write(profile_22)
|
|
||||||
if !tmpl_profile_vars.CurrentUser.IsBanned {
|
|
||||||
w.Write(profile_23)
|
|
||||||
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
|
||||||
w.Write(profile_24)
|
|
||||||
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
|
||||||
w.Write(profile_25)
|
w.Write(profile_25)
|
||||||
}
|
if !tmpl_profile_vars.CurrentUser.IsBanned {
|
||||||
w.Write(profile_26)
|
w.Write(profile_26)
|
||||||
|
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
|
||||||
w.Write(profile_27)
|
w.Write(profile_27)
|
||||||
|
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
|
||||||
|
w.Write(profile_28)
|
||||||
|
}
|
||||||
|
w.Write(profile_29)
|
||||||
|
w.Write(profile_30)
|
||||||
w.Write(footer_0)
|
w.Write(footer_0)
|
||||||
w.Write([]byte(common.BuildWidget("footer",tmpl_profile_vars.Header)))
|
w.Write([]byte(common.BuildWidget("footer",tmpl_profile_vars.Header)))
|
||||||
w.Write(footer_1)
|
w.Write(footer_1)
|
||||||
|
|
|
@ -11,7 +11,5 @@
|
||||||
<div class="rowitem passive"><a href="/user/edit/email/">Email</a></div>
|
<div class="rowitem passive"><a href="/user/edit/email/">Email</a></div>
|
||||||
<div class="rowitem passive"><a href="/user/edit/notifications">Notifications</a></div>
|
<div class="rowitem passive"><a href="/user/edit/notifications">Notifications</a></div>
|
||||||
{{/** TODO: Add an alerts page with pagination to go through alerts which either don't fit in the alerts drop-down or which have already been dismissed. Bear in mind though that dismissed alerts older than two weeks might be purged to save space and to speed up the database **/}}
|
{{/** TODO: Add an alerts page with pagination to go through alerts which either don't fit in the alerts drop-down or which have already been dismissed. Bear in mind though that dismissed alerts older than two weeks might be purged to save space and to speed up the database **/}}
|
||||||
<div class="rowitem passive"><a>Coming Soon</a></div>
|
|
||||||
<div class="rowitem passive"><a>Coming Soon</a></div>
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="rowblock">
|
<div class="rowblock">
|
||||||
<form action="/accounts/login/submit/" method="post">
|
<form action="/accounts/login/submit/" method="post">
|
||||||
<div class="formrow">
|
<div class="formrow login_name_row">
|
||||||
<div class="formitem formlabel"><a>Account Name</a></div>
|
<div class="formitem formlabel"><a>Account Name</a></div>
|
||||||
<div class="formitem"><input name="username" type="text" placeholder="Account Name" required /></div>
|
<div class="formitem"><input name="username" type="text" placeholder="Account Name" required /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow">
|
<div class="formrow login_password_row">
|
||||||
<div class="formitem formlabel"><a>Password</a></div>
|
<div class="formitem formlabel"><a>Password</a></div>
|
||||||
<div class="formitem"><input name="password" type="password" autocomplete="current-password" placeholder="*****" required /></div>
|
<div class="formitem"><input name="password" type="password" autocomplete="current-password" placeholder="*****" required /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="formrow">
|
<div class="formrow login_button_row">
|
||||||
<div class="formitem"><button name="login-button" class="formbutton">Login</button></div>
|
<div class="formitem"><button name="login-button" class="formbutton">Login</button></div>
|
||||||
<div class="formitem" style="color: #505050; font-size: 12px; font-weight: normal; float: right;">Don't have an account?</div>
|
<div class="formitem dont_have_account">Don't have an account?</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,9 +13,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="passiveBlock">
|
<div class="passiveBlock">
|
||||||
<div class="rowitem passive">
|
{{if not .CurrentUser.Loggedin}}<div class="rowitem passive">
|
||||||
|
<a class="profile_menu_item">Login for options</a>
|
||||||
|
</div>{{else}}
|
||||||
|
<!--<div class="rowitem passive">
|
||||||
<a class="profile_menu_item">Add Friend</a>
|
<a class="profile_menu_item">Add Friend</a>
|
||||||
</div>
|
</div>-->
|
||||||
{{if (.CurrentUser.IsSuperMod) and not (.ProfileOwner.IsSuperMod) }}<div class="rowitem passive">
|
{{if (.CurrentUser.IsSuperMod) and not (.ProfileOwner.IsSuperMod) }}<div class="rowitem passive">
|
||||||
{{if .ProfileOwner.IsBanned }}<a href="/users/unban/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}" class="profile_menu_item">Unban</a>
|
{{if .ProfileOwner.IsBanned }}<a href="/users/unban/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}" class="profile_menu_item">Unban</a>
|
||||||
{{else}}<a href="#ban_user" class="profile_menu_item">Ban</a>{{end}}
|
{{else}}<a href="#ban_user" class="profile_menu_item">Ban</a>{{end}}
|
||||||
|
@ -23,6 +26,7 @@
|
||||||
<div class="rowitem passive">
|
<div class="rowitem passive">
|
||||||
<a href="/report/submit/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}&type=user" class="profile_menu_item report_item" aria-label="Report User" title="Report User"></a>
|
<a href="/report/submit/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}&type=user" class="profile_menu_item report_item" aria-label="Report User" title="Report User"></a>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -39,5 +39,6 @@
|
||||||
<span class="editable_block user_content">{{.ContentHtml}}</span>
|
<span class="editable_block user_content">{{.ContentHtml}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="after_comment"></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
|
@ -1131,12 +1131,13 @@ textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
}
|
}
|
||||||
#profile_right_lane .colstack_item, .colstack_right .colstack_item:not(.rowlist) {
|
.colstack_right .colstack_item:not(.rowlist):not(#profile_comments),
|
||||||
|
#profile_comments .comment {
|
||||||
border: 1px solid var(--element-border-color);
|
border: 1px solid var(--element-border-color);
|
||||||
border-bottom: 2px solid var(--element-border-color);
|
border-bottom: 2px solid var(--element-border-color);
|
||||||
background-color: var(--element-background-color);
|
background-color: var(--element-background-color);
|
||||||
}
|
}
|
||||||
#profile_right_lane .colstack_item, .colstack_right .colstack_item, .colstack_right .colstack_grid {
|
.colstack_right .colstack_item, .colstack_right .colstack_grid {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
#profile_right_lane .topic_reply_form {
|
#profile_right_lane .topic_reply_form {
|
||||||
|
@ -1162,16 +1163,18 @@ textarea {
|
||||||
#profile_comments button:hover {
|
#profile_comments button:hover {
|
||||||
color: var(--light-text-color);
|
color: var(--light-text-color);
|
||||||
}
|
}
|
||||||
#profile_comments button.edit_item:after {
|
#profile_comments button.edit_item:after,
|
||||||
|
#profile_comments button.delete_item:after,
|
||||||
|
#profile_comments button.report_item:after {
|
||||||
font: normal normal normal 14px/1 FontAwesome;
|
font: normal normal normal 14px/1 FontAwesome;
|
||||||
|
}
|
||||||
|
#profile_comments button.edit_item:after {
|
||||||
content: "\f040";
|
content: "\f040";
|
||||||
}
|
}
|
||||||
#profile_comments button.delete_item:after {
|
#profile_comments button.delete_item:after {
|
||||||
font: normal normal normal 14px/1 FontAwesome;
|
|
||||||
content: "\f1f8";
|
content: "\f1f8";
|
||||||
}
|
}
|
||||||
#profile_comments button.report_item:after {
|
#profile_comments button.report_item:after {
|
||||||
font: normal normal normal 14px/1 FontAwesome;
|
|
||||||
content: "\f024";
|
content: "\f024";
|
||||||
}
|
}
|
||||||
#profile_comments_head {
|
#profile_comments_head {
|
||||||
|
@ -1186,6 +1189,9 @@ textarea {
|
||||||
#profile_comments .rowitem {
|
#profile_comments .rowitem {
|
||||||
background-image: none !important;
|
background-image: none !important;
|
||||||
}
|
}
|
||||||
|
#profile_comments .comment:not(:last-child) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
#profile_comments .comment .userbit {
|
#profile_comments .comment .userbit {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-left: 14px;
|
margin-left: 14px;
|
||||||
|
@ -1278,6 +1284,17 @@ textarea {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Add a generic button_row class and add this to them all? */
|
||||||
|
.login_button_row {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.dont_have_account {
|
||||||
|
color: var(--primary-link-color);
|
||||||
|
font-size: 12px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-top: 23px;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Highlight the one we're currently on? */
|
/* TODO: Highlight the one we're currently on? */
|
||||||
.pageset {
|
.pageset {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -1705,7 +1722,10 @@ textarea {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media(max-width: 520px) {
|
@media(max-width: 520px) {
|
||||||
main > .rowhead, #main > .rowhead {
|
#main {
|
||||||
|
padding-top: 0px;
|
||||||
|
}
|
||||||
|
main > .rowhead, #main > .rowhead, main > .opthead, #main > .opthead {
|
||||||
margin-left: -3px;
|
margin-left: -3px;
|
||||||
margin-right: -3px;
|
margin-right: -3px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,6 +366,13 @@ a {
|
||||||
padding-bottom: 12px;
|
padding-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dont_have_account {
|
||||||
|
color: #505050;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: normal;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
background-color: var(--input-background-color);
|
background-color: var(--input-background-color);
|
||||||
border-color: var(--input-border-color);
|
border-color: var(--input-border-color);
|
||||||
|
@ -694,6 +701,14 @@ input[type=checkbox]:checked + label.poll_option_label .sel {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.topic_left.topic_sticky .topic_inner_left {
|
||||||
|
border-top: 4px solid hsl(51, 100%, 50%);
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-top: 8px;
|
||||||
|
margin-top: 0px;
|
||||||
|
margin-left: 0px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.topic_list .topic_right {
|
.topic_list .topic_right {
|
||||||
height: 59px;
|
height: 59px;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
|
|
|
@ -357,7 +357,6 @@ li a {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clearfix */
|
/* Clearfix */
|
||||||
.formrow:before, .formrow:after {
|
.formrow:before, .formrow:after {
|
||||||
content: " ";
|
content: " ";
|
||||||
|
@ -383,7 +382,6 @@ li a {
|
||||||
.formitem.invisible_border {
|
.formitem.invisible_border {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mostly for textareas */
|
/* Mostly for textareas */
|
||||||
.formitem:only-child { width: 100%; }
|
.formitem:only-child { width: 100%; }
|
||||||
.formitem textarea {
|
.formitem textarea {
|
||||||
|
@ -404,7 +402,14 @@ li a {
|
||||||
/*padding-left: 15px;*/
|
/*padding-left: 15px;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.formbutton, button {
|
.dont_have_account {
|
||||||
|
color: #505050;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: normal;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formbutton, button, input[type="submit"] {
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #8e8e8e;
|
border: 1px solid #8e8e8e;
|
||||||
}
|
}
|
||||||
|
@ -414,9 +419,24 @@ li a {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
.formbutton .ip_search_search {
|
||||||
border-color: var(--main-border-color);
|
border-color: var(--main-border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ip_search_block {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.ip_search_block .rowitem {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.ip_search_input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.ip_search_search {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Add the avatars to the forum list */
|
/* TODO: Add the avatars to the forum list */
|
||||||
.extra_little_row_avatar {
|
.extra_little_row_avatar {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -328,7 +328,14 @@ li a {
|
||||||
border-color: #ccc;
|
border-color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
.dont_have_account {
|
||||||
|
color: #505050;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: normal;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
button, input[type="submit"] {
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #8e8e8e;
|
border: 1px solid #8e8e8e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,7 +398,7 @@ input, select {
|
||||||
padding-bottom: 12px;
|
padding-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.formbutton, button {
|
.formbutton, button, input[type="submit"] {
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #8e8e8e;
|
border: 1px solid #8e8e8e;
|
||||||
}
|
}
|
||||||
|
@ -408,9 +408,31 @@ input, select {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
.formbutton, ip_search_search {
|
||||||
border-color: hsl(0, 0%, 80%);
|
border-color: hsl(0, 0%, 80%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dont_have_account {
|
||||||
|
color: #505050;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: normal;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ip_search_block {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.ip_search_block .rowitem {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.ip_search_input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.ip_search_search {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Add the avatars to the forum list */
|
/* TODO: Add the avatars to the forum list */
|
||||||
.extra_little_row_avatar {
|
.extra_little_row_avatar {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
Loading…
Reference in New Issue