2018-07-13 11:27:58 +00:00
// Code generated by Gosora's Router Generator. DO NOT EDIT.
2017-04-12 13:39:03 +00:00
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main
2017-11-11 04:06:16 +00:00
import (
"log"
"strings"
2018-12-31 09:03:49 +00:00
"bytes"
2018-03-08 03:59:47 +00:00
"strconv"
2018-08-21 08:00:35 +00:00
"compress/gzip"
2017-11-11 04:06:16 +00:00
"sync"
2018-07-15 10:29:31 +00:00
"sync/atomic"
2017-11-11 04:06:16 +00:00
"errors"
2018-04-03 04:34:07 +00:00
"os"
2017-11-11 04:06:16 +00:00
"net/http"
2019-04-19 07:16:09 +00:00
c "github.com/Azareal/Gosora/common"
2019-10-29 07:13:04 +00:00
co "github.com/Azareal/Gosora/common/counters"
2018-10-27 03:21:02 +00:00
"github.com/Azareal/Gosora/routes"
"github.com/Azareal/Gosora/routes/panel"
2017-11-11 04:06:16 +00:00
)
2017-04-12 13:39:03 +00:00
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
var ErrNoRoute = errors . New ( "That route doesn't exist." )
2017-12-19 03:53:13 +00:00
// TODO: What about the /uploads/ route? x.x
var RouteMap = map [ string ] interface { } {
2018-02-03 05:47:14 +00:00
"routes.Overview" : routes . Overview ,
"routes.CustomPage" : routes . CustomPage ,
2018-03-17 08:16:43 +00:00
"routes.ForumList" : routes . ForumList ,
2018-02-22 02:27:17 +00:00
"routes.ViewForum" : routes . ViewForum ,
2018-05-15 05:59:52 +00:00
"routes.ChangeTheme" : routes . ChangeTheme ,
"routes.ShowAttachment" : routes . ShowAttachment ,
2019-04-19 07:16:09 +00:00
"common.RouteWebsockets" : c . RouteWebsockets ,
2018-06-24 13:49:29 +00:00
"routeAPIPhrases" : routeAPIPhrases ,
2018-08-11 15:53:42 +00:00
"routes.APIMe" : routes . APIMe ,
2018-07-05 09:54:01 +00:00
"routeJSAntispam" : routeJSAntispam ,
2018-06-24 13:49:29 +00:00
"routeAPI" : routeAPI ,
2018-05-27 09:36:35 +00:00
"routes.ReportSubmit" : routes . ReportSubmit ,
2018-09-26 07:46:30 +00:00
"routes.TopicListMostViewed" : routes . TopicListMostViewed ,
2018-01-21 11:17:43 +00:00
"routes.CreateTopic" : routes . CreateTopic ,
2018-02-10 15:07:21 +00:00
"routes.TopicList" : routes . TopicList ,
2018-05-27 09:36:35 +00:00
"panel.Forums" : panel . Forums ,
"panel.ForumsCreateSubmit" : panel . ForumsCreateSubmit ,
"panel.ForumsDelete" : panel . ForumsDelete ,
"panel.ForumsDeleteSubmit" : panel . ForumsDeleteSubmit ,
2019-04-27 06:32:26 +00:00
"panel.ForumsOrderSubmit" : panel . ForumsOrderSubmit ,
2018-05-27 09:36:35 +00:00
"panel.ForumsEdit" : panel . ForumsEdit ,
"panel.ForumsEditSubmit" : panel . ForumsEditSubmit ,
"panel.ForumsEditPermsSubmit" : panel . ForumsEditPermsSubmit ,
"panel.ForumsEditPermsAdvance" : panel . ForumsEditPermsAdvance ,
"panel.ForumsEditPermsAdvanceSubmit" : panel . ForumsEditPermsAdvanceSubmit ,
"panel.Settings" : panel . Settings ,
"panel.SettingEdit" : panel . SettingEdit ,
"panel.SettingEditSubmit" : panel . SettingEditSubmit ,
2018-08-04 11:46:36 +00:00
"panel.WordFilters" : panel . WordFilters ,
"panel.WordFiltersCreateSubmit" : panel . WordFiltersCreateSubmit ,
"panel.WordFiltersEdit" : panel . WordFiltersEdit ,
"panel.WordFiltersEditSubmit" : panel . WordFiltersEditSubmit ,
"panel.WordFiltersDeleteSubmit" : panel . WordFiltersDeleteSubmit ,
2018-06-06 00:21:22 +00:00
"panel.Pages" : panel . Pages ,
"panel.PagesCreateSubmit" : panel . PagesCreateSubmit ,
"panel.PagesEdit" : panel . PagesEdit ,
"panel.PagesEditSubmit" : panel . PagesEditSubmit ,
"panel.PagesDeleteSubmit" : panel . PagesDeleteSubmit ,
2018-09-30 14:43:46 +00:00
"panel.Themes" : panel . Themes ,
2018-10-02 04:09:17 +00:00
"panel.ThemesSetDefault" : panel . ThemesSetDefault ,
2018-09-30 14:43:46 +00:00
"panel.ThemesMenus" : panel . ThemesMenus ,
"panel.ThemesMenusEdit" : panel . ThemesMenusEdit ,
"panel.ThemesMenuItemEdit" : panel . ThemesMenuItemEdit ,
"panel.ThemesMenuItemEditSubmit" : panel . ThemesMenuItemEditSubmit ,
"panel.ThemesMenuItemCreateSubmit" : panel . ThemesMenuItemCreateSubmit ,
"panel.ThemesMenuItemDeleteSubmit" : panel . ThemesMenuItemDeleteSubmit ,
"panel.ThemesMenuItemOrderSubmit" : panel . ThemesMenuItemOrderSubmit ,
2019-01-21 12:27:59 +00:00
"panel.ThemesWidgets" : panel . ThemesWidgets ,
"panel.ThemesWidgetsEditSubmit" : panel . ThemesWidgetsEditSubmit ,
"panel.ThemesWidgetsCreateSubmit" : panel . ThemesWidgetsCreateSubmit ,
"panel.ThemesWidgetsDeleteSubmit" : panel . ThemesWidgetsDeleteSubmit ,
2018-07-29 10:54:12 +00:00
"panel.Plugins" : panel . Plugins ,
"panel.PluginsActivate" : panel . PluginsActivate ,
"panel.PluginsDeactivate" : panel . PluginsDeactivate ,
"panel.PluginsInstall" : panel . PluginsInstall ,
2018-06-17 07:28:18 +00:00
"panel.Users" : panel . Users ,
"panel.UsersEdit" : panel . UsersEdit ,
"panel.UsersEditSubmit" : panel . UsersEditSubmit ,
2019-06-10 22:00:57 +00:00
"panel.UsersAvatarSubmit" : panel . UsersAvatarSubmit ,
"panel.UsersAvatarRemoveSubmit" : panel . UsersAvatarRemoveSubmit ,
2018-05-27 09:36:35 +00:00
"panel.AnalyticsViews" : panel . AnalyticsViews ,
"panel.AnalyticsRoutes" : panel . AnalyticsRoutes ,
"panel.AnalyticsAgents" : panel . AnalyticsAgents ,
"panel.AnalyticsSystems" : panel . AnalyticsSystems ,
"panel.AnalyticsLanguages" : panel . AnalyticsLanguages ,
"panel.AnalyticsReferrers" : panel . AnalyticsReferrers ,
"panel.AnalyticsRouteViews" : panel . AnalyticsRouteViews ,
"panel.AnalyticsAgentViews" : panel . AnalyticsAgentViews ,
"panel.AnalyticsForumViews" : panel . AnalyticsForumViews ,
"panel.AnalyticsSystemViews" : panel . AnalyticsSystemViews ,
"panel.AnalyticsLanguageViews" : panel . AnalyticsLanguageViews ,
"panel.AnalyticsReferrerViews" : panel . AnalyticsReferrerViews ,
"panel.AnalyticsPosts" : panel . AnalyticsPosts ,
2019-05-01 06:59:51 +00:00
"panel.AnalyticsMemory" : panel . AnalyticsMemory ,
2019-05-09 06:58:55 +00:00
"panel.AnalyticsActiveMemory" : panel . AnalyticsActiveMemory ,
2018-05-27 09:36:35 +00:00
"panel.AnalyticsTopics" : panel . AnalyticsTopics ,
"panel.AnalyticsForums" : panel . AnalyticsForums ,
2018-09-30 00:08:27 +00:00
"panel.Groups" : panel . Groups ,
"panel.GroupsEdit" : panel . GroupsEdit ,
2019-09-29 04:56:39 +00:00
"panel.GroupsEditPromotions" : panel . GroupsEditPromotions ,
"panel.GroupsPromotionsCreateSubmit" : panel . GroupsPromotionsCreateSubmit ,
"panel.GroupsPromotionsDeleteSubmit" : panel . GroupsPromotionsDeleteSubmit ,
2018-09-30 00:08:27 +00:00
"panel.GroupsEditPerms" : panel . GroupsEditPerms ,
"panel.GroupsEditSubmit" : panel . GroupsEditSubmit ,
"panel.GroupsEditPermsSubmit" : panel . GroupsEditPermsSubmit ,
"panel.GroupsCreateSubmit" : panel . GroupsCreateSubmit ,
2018-05-27 09:36:35 +00:00
"panel.Backups" : panel . Backups ,
"panel.LogsRegs" : panel . LogsRegs ,
"panel.LogsMod" : panel . LogsMod ,
"panel.Debug" : panel . Debug ,
2018-10-02 05:03:20 +00:00
"panel.Dashboard" : panel . Dashboard ,
2018-06-17 07:28:18 +00:00
"routes.AccountEdit" : routes . AccountEdit ,
"routes.AccountEditPassword" : routes . AccountEditPassword ,
"routes.AccountEditPasswordSubmit" : routes . AccountEditPasswordSubmit ,
2018-05-14 08:56:56 +00:00
"routes.AccountEditAvatarSubmit" : routes . AccountEditAvatarSubmit ,
2019-06-09 03:21:48 +00:00
"routes.AccountEditRevokeAvatarSubmit" : routes . AccountEditRevokeAvatarSubmit ,
2018-05-14 08:56:56 +00:00
"routes.AccountEditUsernameSubmit" : routes . AccountEditUsernameSubmit ,
2018-06-17 07:28:18 +00:00
"routes.AccountEditMFA" : routes . AccountEditMFA ,
"routes.AccountEditMFASetup" : routes . AccountEditMFASetup ,
"routes.AccountEditMFASetupSubmit" : routes . AccountEditMFASetupSubmit ,
"routes.AccountEditMFADisableSubmit" : routes . AccountEditMFADisableSubmit ,
2018-05-27 09:36:35 +00:00
"routes.AccountEditEmail" : routes . AccountEditEmail ,
"routes.AccountEditEmailTokenSubmit" : routes . AccountEditEmailTokenSubmit ,
2018-12-17 04:58:55 +00:00
"routes.AccountLogins" : routes . AccountLogins ,
2018-10-10 07:33:51 +00:00
"routes.LevelList" : routes . LevelList ,
2019-08-14 10:39:04 +00:00
"routes.Convos" : routes . Convos ,
"routes.ConvosCreate" : routes . ConvosCreate ,
"routes.Convo" : routes . Convo ,
"routes.ConvosCreateSubmit" : routes . ConvosCreateSubmit ,
"routes.ConvosCreateReplySubmit" : routes . ConvosCreateReplySubmit ,
"routes.ConvosDeleteReplySubmit" : routes . ConvosDeleteReplySubmit ,
"routes.ConvosEditReplySubmit" : routes . ConvosEditReplySubmit ,
2019-10-18 00:35:13 +00:00
"routes.RelationsBlockCreate" : routes . RelationsBlockCreate ,
"routes.RelationsBlockCreateSubmit" : routes . RelationsBlockCreateSubmit ,
"routes.RelationsBlockRemove" : routes . RelationsBlockRemove ,
"routes.RelationsBlockRemoveSubmit" : routes . RelationsBlockRemoveSubmit ,
2018-02-26 09:07:00 +00:00
"routes.ViewProfile" : routes . ViewProfile ,
2018-01-21 11:17:43 +00:00
"routes.BanUserSubmit" : routes . BanUserSubmit ,
"routes.UnbanUser" : routes . UnbanUser ,
"routes.ActivateUser" : routes . ActivateUser ,
"routes.IPSearch" : routes . IPSearch ,
2018-01-22 08:15:45 +00:00
"routes.CreateTopicSubmit" : routes . CreateTopicSubmit ,
2018-01-18 12:31:25 +00:00
"routes.EditTopicSubmit" : routes . EditTopicSubmit ,
2018-01-20 06:50:29 +00:00
"routes.DeleteTopicSubmit" : routes . DeleteTopicSubmit ,
"routes.StickTopicSubmit" : routes . StickTopicSubmit ,
"routes.UnstickTopicSubmit" : routes . UnstickTopicSubmit ,
"routes.LockTopicSubmit" : routes . LockTopicSubmit ,
"routes.UnlockTopicSubmit" : routes . UnlockTopicSubmit ,
"routes.MoveTopicSubmit" : routes . MoveTopicSubmit ,
2018-05-15 05:59:52 +00:00
"routes.LikeTopicSubmit" : routes . LikeTopicSubmit ,
2018-12-27 05:42:41 +00:00
"routes.AddAttachToTopicSubmit" : routes . AddAttachToTopicSubmit ,
"routes.RemoveAttachFromTopicSubmit" : routes . RemoveAttachFromTopicSubmit ,
2018-02-03 05:47:14 +00:00
"routes.ViewTopic" : routes . ViewTopic ,
2018-03-08 03:59:47 +00:00
"routes.CreateReplySubmit" : routes . CreateReplySubmit ,
2018-01-20 06:50:29 +00:00
"routes.ReplyEditSubmit" : routes . ReplyEditSubmit ,
"routes.ReplyDeleteSubmit" : routes . ReplyDeleteSubmit ,
2018-05-15 05:59:52 +00:00
"routes.ReplyLikeSubmit" : routes . ReplyLikeSubmit ,
2018-12-31 09:03:49 +00:00
"routes.AddAttachToReplySubmit" : routes . AddAttachToReplySubmit ,
"routes.RemoveAttachFromReplySubmit" : routes . RemoveAttachFromReplySubmit ,
2018-05-15 05:59:52 +00:00
"routes.ProfileReplyCreateSubmit" : routes . ProfileReplyCreateSubmit ,
2018-01-20 06:50:29 +00:00
"routes.ProfileReplyEditSubmit" : routes . ProfileReplyEditSubmit ,
"routes.ProfileReplyDeleteSubmit" : routes . ProfileReplyDeleteSubmit ,
2018-01-27 07:30:44 +00:00
"routes.PollVote" : routes . PollVote ,
2018-01-28 14:30:24 +00:00
"routes.PollResults" : routes . PollResults ,
2018-02-03 05:47:14 +00:00
"routes.AccountLogin" : routes . AccountLogin ,
"routes.AccountRegister" : routes . AccountRegister ,
2018-05-15 05:59:52 +00:00
"routes.AccountLogout" : routes . AccountLogout ,
2018-02-03 05:47:14 +00:00
"routes.AccountLoginSubmit" : routes . AccountLoginSubmit ,
2018-06-17 07:28:18 +00:00
"routes.AccountLoginMFAVerify" : routes . AccountLoginMFAVerify ,
"routes.AccountLoginMFAVerifySubmit" : routes . AccountLoginMFAVerifySubmit ,
2018-02-03 05:47:14 +00:00
"routes.AccountRegisterSubmit" : routes . AccountRegisterSubmit ,
2019-03-11 08:47:45 +00:00
"routes.AccountPasswordReset" : routes . AccountPasswordReset ,
"routes.AccountPasswordResetSubmit" : routes . AccountPasswordResetSubmit ,
"routes.AccountPasswordResetToken" : routes . AccountPasswordResetToken ,
"routes.AccountPasswordResetTokenSubmit" : routes . AccountPasswordResetTokenSubmit ,
2018-05-15 05:59:52 +00:00
"routes.DynamicRoute" : routes . DynamicRoute ,
"routes.UploadedFile" : routes . UploadedFile ,
2018-02-19 04:26:01 +00:00
"routes.StaticFile" : routes . StaticFile ,
2018-03-17 08:16:43 +00:00
"routes.RobotsTxt" : routes . RobotsTxt ,
"routes.SitemapXml" : routes . SitemapXml ,
2019-05-08 05:26:38 +00:00
"routes.OpenSearchXml" : routes . OpenSearchXml ,
2018-05-15 05:59:52 +00:00
"routes.BadRoute" : routes . BadRoute ,
2019-03-21 22:59:41 +00:00
"routes.HTTPSRedirect" : routes . HTTPSRedirect ,
2017-12-10 03:43:30 +00:00
}
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
2017-12-19 03:53:13 +00:00
// ! NEVER RELY ON THESE REMAINING THE SAME BETWEEN COMMITS
var routeMapEnum = map [ string ] int {
2018-06-24 13:49:29 +00:00
"routes.Overview" : 0 ,
"routes.CustomPage" : 1 ,
"routes.ForumList" : 2 ,
"routes.ViewForum" : 3 ,
"routes.ChangeTheme" : 4 ,
"routes.ShowAttachment" : 5 ,
"common.RouteWebsockets" : 6 ,
"routeAPIPhrases" : 7 ,
2018-08-11 15:53:42 +00:00
"routes.APIMe" : 8 ,
"routeJSAntispam" : 9 ,
"routeAPI" : 10 ,
"routes.ReportSubmit" : 11 ,
2018-09-26 07:46:30 +00:00
"routes.TopicListMostViewed" : 12 ,
"routes.CreateTopic" : 13 ,
"routes.TopicList" : 14 ,
"panel.Forums" : 15 ,
"panel.ForumsCreateSubmit" : 16 ,
"panel.ForumsDelete" : 17 ,
"panel.ForumsDeleteSubmit" : 18 ,
2019-04-27 06:32:26 +00:00
"panel.ForumsOrderSubmit" : 19 ,
"panel.ForumsEdit" : 20 ,
"panel.ForumsEditSubmit" : 21 ,
"panel.ForumsEditPermsSubmit" : 22 ,
"panel.ForumsEditPermsAdvance" : 23 ,
"panel.ForumsEditPermsAdvanceSubmit" : 24 ,
"panel.Settings" : 25 ,
"panel.SettingEdit" : 26 ,
"panel.SettingEditSubmit" : 27 ,
"panel.WordFilters" : 28 ,
"panel.WordFiltersCreateSubmit" : 29 ,
"panel.WordFiltersEdit" : 30 ,
"panel.WordFiltersEditSubmit" : 31 ,
"panel.WordFiltersDeleteSubmit" : 32 ,
"panel.Pages" : 33 ,
"panel.PagesCreateSubmit" : 34 ,
"panel.PagesEdit" : 35 ,
"panel.PagesEditSubmit" : 36 ,
"panel.PagesDeleteSubmit" : 37 ,
"panel.Themes" : 38 ,
"panel.ThemesSetDefault" : 39 ,
"panel.ThemesMenus" : 40 ,
"panel.ThemesMenusEdit" : 41 ,
"panel.ThemesMenuItemEdit" : 42 ,
"panel.ThemesMenuItemEditSubmit" : 43 ,
"panel.ThemesMenuItemCreateSubmit" : 44 ,
"panel.ThemesMenuItemDeleteSubmit" : 45 ,
"panel.ThemesMenuItemOrderSubmit" : 46 ,
"panel.ThemesWidgets" : 47 ,
"panel.ThemesWidgetsEditSubmit" : 48 ,
"panel.ThemesWidgetsCreateSubmit" : 49 ,
"panel.ThemesWidgetsDeleteSubmit" : 50 ,
"panel.Plugins" : 51 ,
"panel.PluginsActivate" : 52 ,
"panel.PluginsDeactivate" : 53 ,
"panel.PluginsInstall" : 54 ,
"panel.Users" : 55 ,
"panel.UsersEdit" : 56 ,
"panel.UsersEditSubmit" : 57 ,
2019-06-10 22:00:57 +00:00
"panel.UsersAvatarSubmit" : 58 ,
"panel.UsersAvatarRemoveSubmit" : 59 ,
"panel.AnalyticsViews" : 60 ,
"panel.AnalyticsRoutes" : 61 ,
"panel.AnalyticsAgents" : 62 ,
"panel.AnalyticsSystems" : 63 ,
"panel.AnalyticsLanguages" : 64 ,
"panel.AnalyticsReferrers" : 65 ,
"panel.AnalyticsRouteViews" : 66 ,
"panel.AnalyticsAgentViews" : 67 ,
"panel.AnalyticsForumViews" : 68 ,
"panel.AnalyticsSystemViews" : 69 ,
"panel.AnalyticsLanguageViews" : 70 ,
"panel.AnalyticsReferrerViews" : 71 ,
"panel.AnalyticsPosts" : 72 ,
"panel.AnalyticsMemory" : 73 ,
"panel.AnalyticsActiveMemory" : 74 ,
"panel.AnalyticsTopics" : 75 ,
"panel.AnalyticsForums" : 76 ,
"panel.Groups" : 77 ,
"panel.GroupsEdit" : 78 ,
2019-09-29 04:56:39 +00:00
"panel.GroupsEditPromotions" : 79 ,
"panel.GroupsPromotionsCreateSubmit" : 80 ,
"panel.GroupsPromotionsDeleteSubmit" : 81 ,
"panel.GroupsEditPerms" : 82 ,
"panel.GroupsEditSubmit" : 83 ,
"panel.GroupsEditPermsSubmit" : 84 ,
"panel.GroupsCreateSubmit" : 85 ,
"panel.Backups" : 86 ,
"panel.LogsRegs" : 87 ,
"panel.LogsMod" : 88 ,
"panel.Debug" : 89 ,
"panel.Dashboard" : 90 ,
"routes.AccountEdit" : 91 ,
"routes.AccountEditPassword" : 92 ,
"routes.AccountEditPasswordSubmit" : 93 ,
"routes.AccountEditAvatarSubmit" : 94 ,
"routes.AccountEditRevokeAvatarSubmit" : 95 ,
"routes.AccountEditUsernameSubmit" : 96 ,
"routes.AccountEditMFA" : 97 ,
"routes.AccountEditMFASetup" : 98 ,
"routes.AccountEditMFASetupSubmit" : 99 ,
"routes.AccountEditMFADisableSubmit" : 100 ,
"routes.AccountEditEmail" : 101 ,
"routes.AccountEditEmailTokenSubmit" : 102 ,
"routes.AccountLogins" : 103 ,
"routes.LevelList" : 104 ,
"routes.Convos" : 105 ,
"routes.ConvosCreate" : 106 ,
"routes.Convo" : 107 ,
"routes.ConvosCreateSubmit" : 108 ,
"routes.ConvosCreateReplySubmit" : 109 ,
"routes.ConvosDeleteReplySubmit" : 110 ,
"routes.ConvosEditReplySubmit" : 111 ,
2019-10-18 00:35:13 +00:00
"routes.RelationsBlockCreate" : 112 ,
"routes.RelationsBlockCreateSubmit" : 113 ,
"routes.RelationsBlockRemove" : 114 ,
"routes.RelationsBlockRemoveSubmit" : 115 ,
"routes.ViewProfile" : 116 ,
"routes.BanUserSubmit" : 117 ,
"routes.UnbanUser" : 118 ,
"routes.ActivateUser" : 119 ,
"routes.IPSearch" : 120 ,
"routes.CreateTopicSubmit" : 121 ,
"routes.EditTopicSubmit" : 122 ,
"routes.DeleteTopicSubmit" : 123 ,
"routes.StickTopicSubmit" : 124 ,
"routes.UnstickTopicSubmit" : 125 ,
"routes.LockTopicSubmit" : 126 ,
"routes.UnlockTopicSubmit" : 127 ,
"routes.MoveTopicSubmit" : 128 ,
"routes.LikeTopicSubmit" : 129 ,
"routes.AddAttachToTopicSubmit" : 130 ,
"routes.RemoveAttachFromTopicSubmit" : 131 ,
"routes.ViewTopic" : 132 ,
"routes.CreateReplySubmit" : 133 ,
"routes.ReplyEditSubmit" : 134 ,
"routes.ReplyDeleteSubmit" : 135 ,
"routes.ReplyLikeSubmit" : 136 ,
"routes.AddAttachToReplySubmit" : 137 ,
"routes.RemoveAttachFromReplySubmit" : 138 ,
"routes.ProfileReplyCreateSubmit" : 139 ,
"routes.ProfileReplyEditSubmit" : 140 ,
"routes.ProfileReplyDeleteSubmit" : 141 ,
"routes.PollVote" : 142 ,
"routes.PollResults" : 143 ,
"routes.AccountLogin" : 144 ,
"routes.AccountRegister" : 145 ,
"routes.AccountLogout" : 146 ,
"routes.AccountLoginSubmit" : 147 ,
"routes.AccountLoginMFAVerify" : 148 ,
"routes.AccountLoginMFAVerifySubmit" : 149 ,
"routes.AccountRegisterSubmit" : 150 ,
"routes.AccountPasswordReset" : 151 ,
"routes.AccountPasswordResetSubmit" : 152 ,
"routes.AccountPasswordResetToken" : 153 ,
"routes.AccountPasswordResetTokenSubmit" : 154 ,
"routes.DynamicRoute" : 155 ,
"routes.UploadedFile" : 156 ,
"routes.StaticFile" : 157 ,
"routes.RobotsTxt" : 158 ,
"routes.SitemapXml" : 159 ,
"routes.OpenSearchXml" : 160 ,
"routes.BadRoute" : 161 ,
"routes.HTTPSRedirect" : 162 ,
2017-12-19 03:53:13 +00:00
}
var reverseRouteMapEnum = map [ int ] string {
2018-06-24 13:49:29 +00:00
0 : "routes.Overview" ,
1 : "routes.CustomPage" ,
2 : "routes.ForumList" ,
3 : "routes.ViewForum" ,
4 : "routes.ChangeTheme" ,
5 : "routes.ShowAttachment" ,
6 : "common.RouteWebsockets" ,
7 : "routeAPIPhrases" ,
2018-08-11 15:53:42 +00:00
8 : "routes.APIMe" ,
9 : "routeJSAntispam" ,
10 : "routeAPI" ,
11 : "routes.ReportSubmit" ,
2018-09-26 07:46:30 +00:00
12 : "routes.TopicListMostViewed" ,
13 : "routes.CreateTopic" ,
14 : "routes.TopicList" ,
15 : "panel.Forums" ,
16 : "panel.ForumsCreateSubmit" ,
17 : "panel.ForumsDelete" ,
18 : "panel.ForumsDeleteSubmit" ,
2019-04-27 06:32:26 +00:00
19 : "panel.ForumsOrderSubmit" ,
20 : "panel.ForumsEdit" ,
21 : "panel.ForumsEditSubmit" ,
22 : "panel.ForumsEditPermsSubmit" ,
23 : "panel.ForumsEditPermsAdvance" ,
24 : "panel.ForumsEditPermsAdvanceSubmit" ,
25 : "panel.Settings" ,
26 : "panel.SettingEdit" ,
27 : "panel.SettingEditSubmit" ,
28 : "panel.WordFilters" ,
29 : "panel.WordFiltersCreateSubmit" ,
30 : "panel.WordFiltersEdit" ,
31 : "panel.WordFiltersEditSubmit" ,
32 : "panel.WordFiltersDeleteSubmit" ,
33 : "panel.Pages" ,
34 : "panel.PagesCreateSubmit" ,
35 : "panel.PagesEdit" ,
36 : "panel.PagesEditSubmit" ,
37 : "panel.PagesDeleteSubmit" ,
38 : "panel.Themes" ,
39 : "panel.ThemesSetDefault" ,
40 : "panel.ThemesMenus" ,
41 : "panel.ThemesMenusEdit" ,
42 : "panel.ThemesMenuItemEdit" ,
43 : "panel.ThemesMenuItemEditSubmit" ,
44 : "panel.ThemesMenuItemCreateSubmit" ,
45 : "panel.ThemesMenuItemDeleteSubmit" ,
46 : "panel.ThemesMenuItemOrderSubmit" ,
47 : "panel.ThemesWidgets" ,
48 : "panel.ThemesWidgetsEditSubmit" ,
49 : "panel.ThemesWidgetsCreateSubmit" ,
50 : "panel.ThemesWidgetsDeleteSubmit" ,
51 : "panel.Plugins" ,
52 : "panel.PluginsActivate" ,
53 : "panel.PluginsDeactivate" ,
54 : "panel.PluginsInstall" ,
55 : "panel.Users" ,
56 : "panel.UsersEdit" ,
57 : "panel.UsersEditSubmit" ,
2019-06-10 22:00:57 +00:00
58 : "panel.UsersAvatarSubmit" ,
59 : "panel.UsersAvatarRemoveSubmit" ,
60 : "panel.AnalyticsViews" ,
61 : "panel.AnalyticsRoutes" ,
62 : "panel.AnalyticsAgents" ,
63 : "panel.AnalyticsSystems" ,
64 : "panel.AnalyticsLanguages" ,
65 : "panel.AnalyticsReferrers" ,
66 : "panel.AnalyticsRouteViews" ,
67 : "panel.AnalyticsAgentViews" ,
68 : "panel.AnalyticsForumViews" ,
69 : "panel.AnalyticsSystemViews" ,
70 : "panel.AnalyticsLanguageViews" ,
71 : "panel.AnalyticsReferrerViews" ,
72 : "panel.AnalyticsPosts" ,
73 : "panel.AnalyticsMemory" ,
74 : "panel.AnalyticsActiveMemory" ,
75 : "panel.AnalyticsTopics" ,
76 : "panel.AnalyticsForums" ,
77 : "panel.Groups" ,
78 : "panel.GroupsEdit" ,
2019-09-29 04:56:39 +00:00
79 : "panel.GroupsEditPromotions" ,
80 : "panel.GroupsPromotionsCreateSubmit" ,
81 : "panel.GroupsPromotionsDeleteSubmit" ,
82 : "panel.GroupsEditPerms" ,
83 : "panel.GroupsEditSubmit" ,
84 : "panel.GroupsEditPermsSubmit" ,
85 : "panel.GroupsCreateSubmit" ,
86 : "panel.Backups" ,
87 : "panel.LogsRegs" ,
88 : "panel.LogsMod" ,
89 : "panel.Debug" ,
90 : "panel.Dashboard" ,
91 : "routes.AccountEdit" ,
92 : "routes.AccountEditPassword" ,
93 : "routes.AccountEditPasswordSubmit" ,
94 : "routes.AccountEditAvatarSubmit" ,
95 : "routes.AccountEditRevokeAvatarSubmit" ,
96 : "routes.AccountEditUsernameSubmit" ,
97 : "routes.AccountEditMFA" ,
98 : "routes.AccountEditMFASetup" ,
99 : "routes.AccountEditMFASetupSubmit" ,
100 : "routes.AccountEditMFADisableSubmit" ,
101 : "routes.AccountEditEmail" ,
102 : "routes.AccountEditEmailTokenSubmit" ,
103 : "routes.AccountLogins" ,
104 : "routes.LevelList" ,
105 : "routes.Convos" ,
106 : "routes.ConvosCreate" ,
107 : "routes.Convo" ,
108 : "routes.ConvosCreateSubmit" ,
109 : "routes.ConvosCreateReplySubmit" ,
110 : "routes.ConvosDeleteReplySubmit" ,
111 : "routes.ConvosEditReplySubmit" ,
2019-10-18 00:35:13 +00:00
112 : "routes.RelationsBlockCreate" ,
113 : "routes.RelationsBlockCreateSubmit" ,
114 : "routes.RelationsBlockRemove" ,
115 : "routes.RelationsBlockRemoveSubmit" ,
116 : "routes.ViewProfile" ,
117 : "routes.BanUserSubmit" ,
118 : "routes.UnbanUser" ,
119 : "routes.ActivateUser" ,
120 : "routes.IPSearch" ,
121 : "routes.CreateTopicSubmit" ,
122 : "routes.EditTopicSubmit" ,
123 : "routes.DeleteTopicSubmit" ,
124 : "routes.StickTopicSubmit" ,
125 : "routes.UnstickTopicSubmit" ,
126 : "routes.LockTopicSubmit" ,
127 : "routes.UnlockTopicSubmit" ,
128 : "routes.MoveTopicSubmit" ,
129 : "routes.LikeTopicSubmit" ,
130 : "routes.AddAttachToTopicSubmit" ,
131 : "routes.RemoveAttachFromTopicSubmit" ,
132 : "routes.ViewTopic" ,
133 : "routes.CreateReplySubmit" ,
134 : "routes.ReplyEditSubmit" ,
135 : "routes.ReplyDeleteSubmit" ,
136 : "routes.ReplyLikeSubmit" ,
137 : "routes.AddAttachToReplySubmit" ,
138 : "routes.RemoveAttachFromReplySubmit" ,
139 : "routes.ProfileReplyCreateSubmit" ,
140 : "routes.ProfileReplyEditSubmit" ,
141 : "routes.ProfileReplyDeleteSubmit" ,
142 : "routes.PollVote" ,
143 : "routes.PollResults" ,
144 : "routes.AccountLogin" ,
145 : "routes.AccountRegister" ,
146 : "routes.AccountLogout" ,
147 : "routes.AccountLoginSubmit" ,
148 : "routes.AccountLoginMFAVerify" ,
149 : "routes.AccountLoginMFAVerifySubmit" ,
150 : "routes.AccountRegisterSubmit" ,
151 : "routes.AccountPasswordReset" ,
152 : "routes.AccountPasswordResetSubmit" ,
153 : "routes.AccountPasswordResetToken" ,
154 : "routes.AccountPasswordResetTokenSubmit" ,
155 : "routes.DynamicRoute" ,
156 : "routes.UploadedFile" ,
157 : "routes.StaticFile" ,
158 : "routes.RobotsTxt" ,
159 : "routes.SitemapXml" ,
160 : "routes.OpenSearchXml" ,
161 : "routes.BadRoute" ,
162 : "routes.HTTPSRedirect" ,
2018-02-04 08:15:20 +00:00
}
var osMapEnum = map [ string ] int {
"unknown" : 0 ,
"windows" : 1 ,
"linux" : 2 ,
"mac" : 3 ,
"android" : 4 ,
"iphone" : 5 ,
}
var reverseOSMapEnum = map [ int ] string {
0 : "unknown" ,
1 : "windows" ,
2 : "linux" ,
3 : "mac" ,
4 : "android" ,
5 : "iphone" ,
2018-01-09 07:39:29 +00:00
}
var agentMapEnum = map [ string ] int {
"unknown" : 0 ,
"firefox" : 1 ,
"chrome" : 2 ,
"opera" : 3 ,
"safari" : 4 ,
"edge" : 5 ,
2018-01-09 08:46:16 +00:00
"internetexplorer" : 6 ,
2018-02-04 08:15:20 +00:00
"trident" : 7 ,
"androidchrome" : 8 ,
"mobilesafari" : 9 ,
"samsung" : 10 ,
"ucbrowser" : 11 ,
"googlebot" : 12 ,
"yandex" : 13 ,
"bing" : 14 ,
"baidu" : 15 ,
"duckduckgo" : 16 ,
"seznambot" : 17 ,
"discord" : 18 ,
"twitter" : 19 ,
2019-03-03 02:28:17 +00:00
"facebook" : 20 ,
"cloudflare" : 21 ,
"uptimebot" : 22 ,
"slackbot" : 23 ,
2019-06-01 02:03:04 +00:00
"apple" : 24 ,
"discourse" : 25 ,
"lynx" : 26 ,
"blank" : 27 ,
"malformed" : 28 ,
"suspicious" : 29 ,
"semrush" : 30 ,
"dotbot" : 31 ,
"zgrab" : 32 ,
2018-01-09 07:39:29 +00:00
}
var reverseAgentMapEnum = map [ int ] string {
0 : "unknown" ,
1 : "firefox" ,
2 : "chrome" ,
3 : "opera" ,
4 : "safari" ,
5 : "edge" ,
2018-01-09 08:46:16 +00:00
6 : "internetexplorer" ,
2018-02-04 08:15:20 +00:00
7 : "trident" ,
8 : "androidchrome" ,
9 : "mobilesafari" ,
10 : "samsung" ,
11 : "ucbrowser" ,
12 : "googlebot" ,
13 : "yandex" ,
14 : "bing" ,
15 : "baidu" ,
16 : "duckduckgo" ,
17 : "seznambot" ,
18 : "discord" ,
19 : "twitter" ,
2019-03-03 02:28:17 +00:00
20 : "facebook" ,
21 : "cloudflare" ,
22 : "uptimebot" ,
23 : "slackbot" ,
2019-06-01 02:03:04 +00:00
24 : "apple" ,
25 : "discourse" ,
26 : "lynx" ,
27 : "blank" ,
28 : "malformed" ,
29 : "suspicious" ,
30 : "semrush" ,
31 : "dotbot" ,
32 : "zgrab" ,
2017-12-19 03:53:13 +00:00
}
2018-12-31 09:03:49 +00:00
var markToAgent = map [ string ] string {
"OPR" : "opera" ,
"Chrome" : "chrome" ,
"Firefox" : "firefox" ,
"MSIE" : "internetexplorer" ,
"Trident" : "trident" ,
"Edge" : "edge" ,
"Lynx" : "lynx" ,
"SamsungBrowser" : "samsung" ,
"UCBrowser" : "ucbrowser" ,
"Google" : "googlebot" ,
"Googlebot" : "googlebot" ,
"yandex" : "yandex" ,
"DuckDuckBot" : "duckduckgo" ,
"Baiduspider" : "baidu" ,
"bingbot" : "bing" ,
"BingPreview" : "bing" ,
"SeznamBot" : "seznambot" ,
"CloudFlare" : "cloudflare" ,
"Uptimebot" : "uptimebot" ,
"Slackbot" : "slackbot" ,
"Discordbot" : "discord" ,
"Twitterbot" : "twitter" ,
2019-03-03 02:28:17 +00:00
"facebookexternalhit" : "facebook" ,
"Facebot" : "facebook" ,
2019-06-01 02:03:04 +00:00
"Applebot" : "apple" ,
2018-12-31 09:03:49 +00:00
"Discourse" : "discourse" ,
2019-02-10 09:32:05 +00:00
"SemrushBot" : "semrush" ,
2019-02-23 06:29:19 +00:00
"DotBot" : "dotbot" ,
2018-12-31 09:03:49 +00:00
"zgrab" : "zgrab" ,
2018-02-03 05:47:14 +00:00
}
/ * var agentRank = map [ string ] int {
"opera" : 9 ,
"chrome" : 8 ,
"safari" : 1 ,
} * /
2017-12-19 03:53:13 +00:00
// TODO: Stop spilling these into the package scope?
func init ( ) {
2019-10-29 07:13:04 +00:00
co . SetRouteMapEnum ( routeMapEnum )
co . SetReverseRouteMapEnum ( reverseRouteMapEnum )
co . SetAgentMapEnum ( agentMapEnum )
co . SetReverseAgentMapEnum ( reverseAgentMapEnum )
co . SetOSMapEnum ( osMapEnum )
co . SetReverseOSMapEnum ( reverseOSMapEnum )
2017-12-19 03:53:13 +00:00
}
2018-08-23 12:18:15 +00:00
type WriterIntercept struct {
2018-08-24 06:24:27 +00:00
http . ResponseWriter
2018-08-23 12:18:15 +00:00
}
func NewWriterIntercept ( w http . ResponseWriter ) * WriterIntercept {
2018-08-24 06:24:27 +00:00
return & WriterIntercept { w }
2018-08-23 12:18:15 +00:00
}
2019-04-19 07:16:09 +00:00
var wiMaxAge = "max-age=" + strconv . Itoa ( int ( c . Day ) )
2018-08-23 12:18:15 +00:00
func ( writ * WriterIntercept ) WriteHeader ( code int ) {
2018-08-24 06:24:27 +00:00
if code == 200 {
2019-07-12 08:33:25 +00:00
h := writ . ResponseWriter . Header ( )
h . Set ( "Cache-Control" , wiMaxAge )
h . Set ( "Vary" , "Accept-Encoding" )
2018-08-24 06:24:27 +00:00
}
writ . ResponseWriter . WriteHeader ( code )
2018-08-23 12:18:15 +00:00
}
2019-03-21 22:59:41 +00:00
// HTTPSRedirect is a connection handler which redirects all HTTP requests to HTTPS
2019-07-12 08:33:25 +00:00
type HTTPSRedirect struct { }
2019-03-21 22:59:41 +00:00
func ( red * HTTPSRedirect ) ServeHTTP ( w http . ResponseWriter , req * http . Request ) {
w . Header ( ) . Set ( "Connection" , "close" )
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 162 )
2019-03-21 22:59:41 +00:00
dest := "https://" + req . Host + req . URL . String ( )
http . Redirect ( w , req , dest , http . StatusTemporaryRedirect )
}
2017-04-12 13:39:03 +00:00
type GenRouter struct {
UploadHandler func ( http . ResponseWriter , * http . Request )
2019-04-19 07:16:09 +00:00
extraRoutes map [ string ] func ( http . ResponseWriter , * http . Request , c . User ) c . RouteError
2018-04-03 04:34:07 +00:00
requestLogger * log . Logger
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
sync . RWMutex
2017-04-12 13:39:03 +00:00
}
2018-04-03 04:34:07 +00:00
func NewGenRouter ( uploads http . Handler ) ( * GenRouter , error ) {
2019-04-19 07:16:09 +00:00
f , err := os . OpenFile ( "./logs/reqs-" + strconv . FormatInt ( c . StartTime . Unix ( ) , 10 ) + ".log" , os . O_WRONLY | os . O_APPEND | os . O_CREATE , 0755 )
2018-04-03 04:34:07 +00:00
if err != nil {
return nil , err
}
2017-04-12 13:39:03 +00:00
return & GenRouter {
2018-03-31 05:25:27 +00:00
UploadHandler : func ( w http . ResponseWriter , req * http . Request ) {
2018-08-23 12:18:15 +00:00
writ := NewWriterIntercept ( w )
http . StripPrefix ( "/uploads/" , uploads ) . ServeHTTP ( writ , req )
2018-03-31 05:25:27 +00:00
} ,
2019-04-19 07:16:09 +00:00
extraRoutes : make ( map [ string ] func ( http . ResponseWriter , * http . Request , c . User ) c . RouteError ) ,
2018-04-03 04:34:07 +00:00
requestLogger : log . New ( f , "" , log . LstdFlags ) ,
} , nil
2017-04-12 13:39:03 +00:00
}
2019-04-19 07:16:09 +00:00
func ( r * GenRouter ) handleError ( err c . RouteError , w http . ResponseWriter , req * http . Request , user c . User ) {
2017-10-30 09:57:08 +00:00
if err . Handled ( ) {
return
}
if err . Type ( ) == "system" {
2019-04-19 07:16:09 +00:00
c . InternalErrorJSQ ( err , w , req , err . JSON ( ) )
2017-10-30 09:57:08 +00:00
return
}
2019-04-19 07:16:09 +00:00
c . LocalErrorJSQ ( err . Error ( ) , w , req , user , err . JSON ( ) )
2017-10-30 09:57:08 +00:00
}
2018-11-13 06:51:34 +00:00
func ( r * GenRouter ) Handle ( _ string , _ http . Handler ) {
2017-04-12 13:39:03 +00:00
}
2019-04-19 07:16:09 +00:00
func ( r * GenRouter ) HandleFunc ( pattern string , handle func ( http . ResponseWriter , * http . Request , c . User ) c . RouteError ) {
2018-11-13 06:51:34 +00:00
r . Lock ( )
defer r . Unlock ( )
r . extraRoutes [ pattern ] = handle
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
2018-11-13 06:51:34 +00:00
func ( r * GenRouter ) RemoveFunc ( pattern string ) error {
r . Lock ( )
defer r . Unlock ( )
_ , ok := r . extraRoutes [ pattern ]
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
if ! ok {
return ErrNoRoute
}
2018-11-13 06:51:34 +00:00
delete ( r . extraRoutes , pattern )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
return nil
2017-04-12 13:39:03 +00:00
}
2018-11-13 06:51:34 +00:00
func ( r * GenRouter ) DumpRequest ( req * http . Request , prepend string ) {
2018-02-26 09:07:00 +00:00
var heads string
2018-01-27 07:30:44 +00:00
for key , value := range req . Header {
for _ , vvalue := range value {
2019-04-19 07:16:09 +00:00
heads += "Header '" + c . SanitiseSingleLine ( key ) + "': " + c . SanitiseSingleLine ( vvalue ) + "!\n"
2018-01-27 07:30:44 +00:00
}
}
2018-02-26 09:07:00 +00:00
2018-11-13 06:51:34 +00:00
r . requestLogger . Print ( prepend +
2019-04-19 07:16:09 +00:00
"\nUA: " + c . SanitiseSingleLine ( req . UserAgent ( ) ) + "\n" +
"Method: " + c . SanitiseSingleLine ( req . Method ) + "\n" + heads +
"req.Host: " + c . SanitiseSingleLine ( req . Host ) + "\n" +
"req.URL.Path: " + c . SanitiseSingleLine ( req . URL . Path ) + "\n" +
"req.URL.RawQuery: " + c . SanitiseSingleLine ( req . URL . RawQuery ) + "\n" +
"req.Referer(): " + c . SanitiseSingleLine ( req . Referer ( ) ) + "\n" +
2018-02-26 09:07:00 +00:00
"req.RemoteAddr: " + req . RemoteAddr + "\n" )
2018-01-27 07:30:44 +00:00
}
2018-11-13 06:51:34 +00:00
func ( r * GenRouter ) SuspiciousRequest ( req * http . Request , prepend string ) {
2018-04-03 04:34:07 +00:00
if prepend != "" {
prepend += "\n"
}
2018-11-13 06:51:34 +00:00
r . DumpRequest ( req , prepend + "Suspicious Request" )
2019-10-29 07:13:04 +00:00
co . AgentViewCounter . Bump ( 29 )
2018-01-27 07:30:44 +00:00
}
2019-04-01 05:44:38 +00:00
func isLocalHost ( host string ) bool {
return host == "localhost" || host == "127.0.0.1" || host == "::1"
}
2018-06-17 07:28:18 +00:00
// TODO: Pass the default path or config struct to the router rather than accessing it via a package global
// TODO: SetDefaultPath
// TODO: GetDefaultPath
2018-11-13 06:51:34 +00:00
func ( r * GenRouter ) ServeHTTP ( w http . ResponseWriter , req * http . Request ) {
2019-10-29 07:13:04 +00:00
malformedRequest := func ( typ int ) {
2019-04-01 05:44:38 +00:00
w . WriteHeader ( 200 ) // 400
w . Write ( [ ] byte ( "" ) )
2019-04-14 00:13:32 +00:00
r . DumpRequest ( req , "Malformed Request T" + strconv . Itoa ( typ ) )
2019-10-29 07:13:04 +00:00
co . AgentViewCounter . Bump ( 28 )
2019-04-01 05:44:38 +00:00
}
// Split the Host and Port string
var shost , sport string
if req . Host [ 0 ] == '[' {
spl := strings . Split ( req . Host , "]" )
if len ( spl ) > 2 {
2019-04-14 00:13:32 +00:00
malformedRequest ( 0 )
2019-04-01 05:44:38 +00:00
return
}
shost = strings . TrimPrefix ( spl [ 0 ] , "[" )
sport = strings . TrimPrefix ( spl [ 1 ] , ":" )
} else {
spl := strings . Split ( req . Host , ":" )
if len ( spl ) > 2 {
2019-04-14 00:13:32 +00:00
malformedRequest ( 1 )
2019-04-01 05:44:38 +00:00
return
}
shost = spl [ 0 ]
2019-04-01 07:04:02 +00:00
if len ( spl ) == 2 {
2019-04-01 05:44:38 +00:00
sport = spl [ 1 ]
}
}
// TODO: Reject requests from non-local IPs, if the site host is set to localhost or a localhost IP
2019-04-19 07:16:09 +00:00
if ! c . Config . LoosePort && c . Site . PortInt != 80 && c . Site . PortInt != 443 && sport != c . Site . Port {
2019-04-14 00:13:32 +00:00
malformedRequest ( 2 )
2019-04-01 05:44:38 +00:00
return
}
// Redirect www. and local IP requests to the right place
2019-04-19 07:16:09 +00:00
if shost == "www." + c . Site . Host || ( c . Site . LocalHost && shost != c . Site . Host && isLocalHost ( shost ) ) {
2019-03-31 01:50:59 +00:00
// TODO: Abstract the redirect logic?
2018-01-28 14:30:24 +00:00
w . Header ( ) . Set ( "Connection" , "close" )
var s string
2019-11-04 11:55:52 +00:00
if c . Config . SslSchema {
2018-01-28 14:30:24 +00:00
s = "s"
}
2019-04-01 05:44:38 +00:00
var p string
2019-04-19 07:16:09 +00:00
if c . Site . PortInt != 80 && c . Site . PortInt != 443 {
p = ":" + c . Site . Port
2019-04-01 05:44:38 +00:00
}
2019-04-19 07:16:09 +00:00
dest := "http" + s + "://" + c . Site . Host + p + req . URL . Path
2018-01-28 14:30:24 +00:00
if len ( req . URL . RawQuery ) > 0 {
dest += "?" + req . URL . RawQuery
}
http . Redirect ( w , req , dest , http . StatusMovedPermanently )
return
}
// Deflect malformed requests
2019-04-19 07:16:09 +00:00
if len ( req . URL . Path ) == 0 || req . URL . Path [ 0 ] != '/' || ( ! c . Config . LooseHost && shost != c . Site . Host ) {
2019-04-14 00:13:32 +00:00
malformedRequest ( 3 )
2017-04-12 13:39:03 +00:00
return
}
2019-04-19 07:16:09 +00:00
if c . Dev . FullReqLog {
2019-03-16 12:50:31 +00:00
r . DumpRequest ( req , "" )
}
2018-01-18 12:51:35 +00:00
2018-02-26 09:07:00 +00:00
// TODO: Cover more suspicious strings and at a lower layer than this
2019-11-04 11:55:52 +00:00
for _ , ch := range req . URL . Path { //char
if ch != '&' && ! ( ch > 44 && ch < 58 ) && ch != '=' && ch != '?' && ! ( ch > 64 && ch < 91 ) && ch != '\\' && ch != '_' && ! ( ch > 96 && ch < 123 ) {
2018-11-13 06:51:34 +00:00
r . SuspiciousRequest ( req , "Bad char in path" )
2018-03-08 03:59:47 +00:00
break
2018-01-17 11:13:08 +00:00
}
2018-03-08 03:59:47 +00:00
}
lowerPath := strings . ToLower ( req . URL . Path )
// TODO: Flag any requests which has a dot with anything but a number after that
if strings . Contains ( req . URL . Path , ".." ) || strings . Contains ( req . URL . Path , "--" ) || strings . Contains ( lowerPath , ".php" ) || strings . Contains ( lowerPath , ".asp" ) || strings . Contains ( lowerPath , ".cgi" ) || strings . Contains ( lowerPath , ".py" ) || strings . Contains ( lowerPath , ".sql" ) || strings . Contains ( lowerPath , ".action" ) {
2018-11-13 06:51:34 +00:00
r . SuspiciousRequest ( req , "Bad snippet in path" )
2018-03-08 03:59:47 +00:00
}
2018-06-17 07:28:18 +00:00
// Indirect the default route onto a different one
if req . URL . Path == "/" {
2019-04-19 07:16:09 +00:00
req . URL . Path = c . Config . DefaultPath
2018-06-17 07:28:18 +00:00
}
2018-01-18 12:51:35 +00:00
var prefix , extraData string
prefix = req . URL . Path [ 0 : strings . IndexByte ( req . URL . Path [ 1 : ] , '/' ) + 1 ]
if req . URL . Path [ len ( req . URL . Path ) - 1 ] != '/' {
2017-12-19 03:53:13 +00:00
extraData = req . URL . Path [ strings . LastIndexByte ( req . URL . Path , '/' ) + 1 : ]
2017-04-12 13:39:03 +00:00
req . URL . Path = req . URL . Path [ : strings . LastIndexByte ( req . URL . Path , '/' ) + 1 ]
2017-04-13 09:26:40 +00:00
}
2018-08-21 08:00:35 +00:00
2019-04-10 07:40:47 +00:00
// TODO: Use the same hook table as downstream
2019-04-19 07:16:09 +00:00
hTbl := c . GetHookTable ( )
2019-04-10 07:40:47 +00:00
skip , ferr := hTbl . VhookSkippable ( "router_after_filters" , w , req , prefix , extraData )
if skip || ferr != nil {
return
}
2018-08-21 08:00:35 +00:00
if prefix != "/ws" {
h := w . Header ( )
h . Set ( "X-Frame-Options" , "deny" )
h . Set ( "X-XSS-Protection" , "1; mode=block" ) // TODO: Remove when we add a CSP? CSP's are horrendously glitchy things, tread with caution before removing
h . Set ( "X-Content-Type-Options" , "nosniff" )
2019-11-04 11:55:52 +00:00
if c . Config . RefNoRef || ! c . Config . SslSchema {
2019-08-14 10:39:04 +00:00
h . Set ( "Referrer-Policy" , "no-referrer" )
} else {
h . Set ( "Referrer-Policy" , "strict-origin" )
}
2018-08-21 08:00:35 +00:00
}
2017-08-06 15:22:18 +00:00
2019-04-19 07:16:09 +00:00
if c . Dev . SuperDebug {
2018-11-13 06:51:34 +00:00
r . DumpRequest ( req , "before routes.StaticFile" )
2017-08-06 15:22:18 +00:00
}
2018-02-19 04:26:01 +00:00
// Increment the request counter
2019-10-29 07:13:04 +00:00
co . GlobalViewCounter . Bump ( )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
2019-08-14 10:39:04 +00:00
if prefix == "/s" { //old prefix: /static
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 157 )
2017-12-19 03:53:13 +00:00
req . URL . Path += extraData
2018-02-03 05:47:14 +00:00
routes . StaticFile ( w , req )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
return
}
2019-04-19 07:16:09 +00:00
if atomic . LoadInt32 ( & c . IsDBDown ) == 1 {
c . DatabaseError ( w , req )
2018-07-15 10:29:31 +00:00
return
}
2019-04-19 07:16:09 +00:00
if c . Dev . SuperDebug {
2018-11-13 06:51:34 +00:00
r . requestLogger . Print ( "before PreRoute" )
2017-07-17 10:23:42 +00:00
}
2017-12-10 03:43:30 +00:00
2018-01-09 07:39:29 +00:00
// Track the user agents. Unfortunately, everyone pretends to be Mozilla, so this'll be a little less efficient than I would like.
// TODO: Add a setting to disable this?
// TODO: Use a more efficient detector instead of smashing every possible combination in
2018-02-03 05:47:14 +00:00
ua := strings . TrimSpace ( strings . Replace ( strings . TrimPrefix ( req . UserAgent ( ) , "Mozilla/5.0 " ) , " Safari/537.36" , "" , - 1 ) ) // Noise, no one's going to be running this and it would require some sort of agent ranking system to determine which identifier should be prioritised over another
2019-04-02 07:43:11 +00:00
var agent string
2018-02-03 05:47:14 +00:00
if ua == "" {
2019-10-29 07:13:04 +00:00
co . AgentViewCounter . Bump ( 27 )
2019-04-19 07:16:09 +00:00
if c . Dev . DebugMode {
2018-03-08 03:59:47 +00:00
var prepend string
for _ , char := range req . UserAgent ( ) {
prepend += strconv . Itoa ( int ( char ) ) + " "
}
2018-11-13 06:51:34 +00:00
r . DumpRequest ( req , "Blank UA: " + prepend )
2018-01-11 09:29:25 +00:00
}
2018-12-31 09:03:49 +00:00
} else {
2018-02-03 05:47:14 +00:00
// WIP UA Parser
var items [ ] string
2018-12-31 09:03:49 +00:00
var buffer [ ] byte
var os string
for _ , item := range StringToBytes ( ua ) {
2018-02-03 05:47:14 +00:00
if ( item > 64 && item < 91 ) || ( item > 96 && item < 123 ) {
buffer = append ( buffer , item )
2019-02-24 08:02:00 +00:00
} else if item == ' ' || item == '(' || item == ')' || item == '-' || ( item > 47 && item < 58 ) || item == '_' || item == ';' || item == ':' || item == '.' || item == '+' || item == '~' || item == '@' || ( item == ':' && bytes . Equal ( buffer , [ ] byte ( "http" ) ) ) || item == ',' || item == '/' {
2018-02-04 08:15:20 +00:00
if len ( buffer ) != 0 {
2018-12-31 09:03:49 +00:00
if len ( buffer ) > 2 {
// Use an unsafe zero copy conversion here just to use the switch, it's not safe for this string to escape from here, as it will get mutated, so do a regular string conversion in append
switch ( BytesToString ( buffer ) ) {
case "Windows" :
os = "windows"
case "Linux" :
os = "linux"
case "Mac" :
os = "mac"
case "iPhone" :
os = "iphone"
case "Android" :
os = "android"
2019-02-10 09:32:05 +00:00
case "like" , "compatible" :
// Skip these words
2018-12-31 09:03:49 +00:00
default :
items = append ( items , string ( buffer ) )
}
}
2018-02-04 08:15:20 +00:00
buffer = buffer [ : 0 ]
}
} else {
// TODO: Test this
items = items [ : 0 ]
2019-02-23 06:29:19 +00:00
r . SuspiciousRequest ( req , "Illegal char " + strconv . Itoa ( int ( item ) ) + " in UA" )
2018-11-13 06:51:34 +00:00
r . requestLogger . Print ( "UA Buffer: " , buffer )
r . requestLogger . Print ( "UA Buffer String: " , string ( buffer ) )
2018-02-04 08:15:20 +00:00
break
2018-02-03 05:47:14 +00:00
}
}
2018-12-31 09:03:49 +00:00
if os == "" {
os = "unknown"
}
2018-02-03 05:47:14 +00:00
// Iterate over this in reverse as the real UA tends to be on the right side
for i := len ( items ) - 1 ; i >= 0 ; i -- {
fAgent , ok := markToAgent [ items [ i ] ]
if ok {
agent = fAgent
if agent != "safari" {
break
}
}
}
2019-04-19 07:16:09 +00:00
if c . Dev . SuperDebug {
2018-11-13 06:51:34 +00:00
r . requestLogger . Print ( "parsed agent: " , agent )
2018-02-04 08:15:20 +00:00
}
2019-04-19 07:16:09 +00:00
if c . Dev . SuperDebug {
2018-11-13 06:51:34 +00:00
r . requestLogger . Print ( "os: " , os )
r . requestLogger . Printf ( "items: %+v\n" , items )
2018-02-03 05:47:14 +00:00
}
// Special handling
switch ( agent ) {
case "chrome" :
2018-02-04 08:15:20 +00:00
if os == "android" {
agent = "androidchrome"
}
case "safari" :
if os == "iphone" {
agent = "mobilesafari"
}
case "trident" :
// Hack to support IE11, change this after we start logging versions
if strings . Contains ( ua , "rv:11" ) {
agent = "internetexplorer"
2018-02-03 05:47:14 +00:00
}
case "zgrab" :
2018-11-13 06:51:34 +00:00
r . SuspiciousRequest ( req , "Vulnerability Scanner" )
2018-02-03 05:47:14 +00:00
}
if agent == "" {
2019-10-29 07:13:04 +00:00
co . AgentViewCounter . Bump ( 0 )
2019-04-19 07:16:09 +00:00
if c . Dev . DebugMode {
2018-03-08 03:59:47 +00:00
var prepend string
for _ , char := range req . UserAgent ( ) {
prepend += strconv . Itoa ( int ( char ) ) + " "
}
2018-11-13 06:51:34 +00:00
r . DumpRequest ( req , "Blank UA: " + prepend )
2018-02-03 05:47:14 +00:00
}
} else {
2019-10-29 07:13:04 +00:00
co . AgentViewCounter . Bump ( agentMapEnum [ agent ] )
2018-01-10 03:32:48 +00:00
}
2019-10-29 07:13:04 +00:00
co . OSViewCounter . Bump ( osMapEnum [ os ] )
2018-01-09 07:39:29 +00:00
}
2018-02-05 10:29:13 +00:00
2018-03-08 03:59:47 +00:00
// TODO: Do we want to track missing language headers too? Maybe as it's own type, e.g. "noheader"?
lang := req . Header . Get ( "Accept-Language" )
if lang != "" {
lang = strings . TrimSpace ( lang )
lLang := strings . Split ( lang , "-" )
2019-02-28 07:28:17 +00:00
tLang := strings . Split ( strings . Split ( lLang [ 0 ] , ";" ) [ 0 ] , "," )
2019-04-19 07:16:09 +00:00
c . DebugDetail ( "tLang:" , tLang )
2019-02-28 07:28:17 +00:00
var llLang string
for _ , seg := range tLang {
if seg == "*" {
continue
}
llLang = seg
2019-03-03 02:28:17 +00:00
break
2019-02-28 07:28:17 +00:00
}
2019-04-19 07:16:09 +00:00
c . DebugDetail ( "llLang:" , llLang )
2019-02-28 07:28:17 +00:00
if llLang == "" {
2019-10-29 07:13:04 +00:00
co . LangViewCounter . Bump ( "none" )
2019-02-28 07:28:17 +00:00
} else {
2019-10-29 07:13:04 +00:00
validCode := co . LangViewCounter . Bump ( llLang )
2019-02-28 07:28:17 +00:00
if ! validCode {
r . DumpRequest ( req , "Invalid ISO Code" )
}
2019-02-23 06:29:19 +00:00
}
2018-03-17 08:16:43 +00:00
} else {
2019-10-29 07:13:04 +00:00
co . LangViewCounter . Bump ( "none" )
2018-03-08 03:59:47 +00:00
}
2019-08-14 10:39:04 +00:00
if ! c . Config . RefNoTrack {
2019-10-29 07:13:04 +00:00
ref := req . Header . Get ( "Referer" ) // Check the 'referrer' header too? :P
if ref != "" {
2019-08-14 10:39:04 +00:00
// ? Optimise this a little?
2019-10-29 07:13:04 +00:00
ref = strings . TrimPrefix ( strings . TrimPrefix ( ref , "http://" ) , "https://" )
ref = strings . Split ( ref , "/" ) [ 0 ]
portless := strings . Split ( ref , ":" ) [ 0 ]
2019-08-14 10:39:04 +00:00
if portless != "localhost" && portless != "127.0.0.1" && portless != c . Site . Host {
2019-10-29 07:13:04 +00:00
co . ReferrerTracker . Bump ( ref )
2019-08-14 10:39:04 +00:00
}
2018-02-05 10:29:13 +00:00
}
}
2017-07-17 10:23:42 +00:00
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
// Deal with the session stuff, etc.
2019-04-19 07:16:09 +00:00
user , ok := c . PreRoute ( w , req )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
if ! ok {
return
}
2019-04-02 07:43:11 +00:00
user . LastAgent = agent
2019-04-19 07:16:09 +00:00
if c . Dev . SuperDebug {
2018-11-13 06:51:34 +00:00
r . requestLogger . Print (
2018-04-03 04:34:07 +00:00
"after PreRoute\n" +
"routeMapEnum: " , routeMapEnum )
2017-07-17 10:23:42 +00:00
}
2018-08-11 15:53:42 +00:00
2018-08-21 08:00:35 +00:00
// Disable Gzip when SSL is disabled for security reasons?
2018-08-22 02:13:17 +00:00
if prefix != "/ws" && strings . Contains ( req . Header . Get ( "Accept-Encoding" ) , "gzip" ) {
2019-04-27 10:22:39 +00:00
h := w . Header ( )
h . Set ( "Content-Encoding" , "gzip" )
h . Set ( "Content-Type" , "text/html; charset=utf-8" )
gzw := c . GzipResponseWriter { Writer : gzip . NewWriter ( w ) , ResponseWriter : w }
2018-08-22 07:10:29 +00:00
defer func ( ) {
2019-04-27 10:22:39 +00:00
if h . Get ( "Content-Encoding" ) == "gzip" && h . Get ( "X-I" ) == "" {
gzw . Writer . ( * gzip . Writer ) . Close ( )
2018-08-22 07:10:29 +00:00
}
} ( )
2019-04-27 10:22:39 +00:00
w = gzw
2018-08-21 08:00:35 +00:00
}
2018-11-12 09:23:36 +00:00
2019-04-10 07:40:47 +00:00
skip , ferr = hTbl . VhookSkippable ( "router_pre_route" , w , req , user , prefix , extraData )
2019-04-06 01:08:49 +00:00
if skip || ferr != nil {
r . handleError ( ferr , w , req , user )
}
ferr = r . routeSwitch ( w , req , user , prefix , extraData )
2018-11-12 09:23:36 +00:00
if ferr != nil {
2018-11-13 06:51:34 +00:00
r . handleError ( ferr , w , req , user )
2018-11-12 09:23:36 +00:00
}
2019-04-06 01:08:49 +00:00
hTbl . VhookNoRet ( "router_end" , w , req , user , prefix , extraData )
2019-04-19 07:16:09 +00:00
//c.StoppedServer("Profile end")
2018-08-11 15:53:42 +00:00
}
2017-07-17 10:23:42 +00:00
2019-04-19 07:16:09 +00:00
func ( r * GenRouter ) routeSwitch ( w http . ResponseWriter , req * http . Request , user c . User , prefix string , extraData string ) c . RouteError {
var err c . RouteError
2017-04-13 09:26:40 +00:00
switch ( prefix ) {
case "/overview" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 0 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . Overview ( w , req , user , head )
2017-12-22 03:32:23 +00:00
case "/pages" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 1 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . CustomPage ( w , req , user , head , extraData )
2017-12-22 03:32:23 +00:00
case "/forums" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 2 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . ForumList ( w , req , user , head )
2017-04-13 15:01:30 +00:00
case "/forum" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 3 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . ViewForum ( w , req , user , head , extraData )
2017-09-10 16:57:22 +00:00
case "/theme" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 4 )
2018-05-15 05:59:52 +00:00
err = routes . ChangeTheme ( w , req , user )
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
case "/attachs" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-04-19 07:16:09 +00:00
gzw , ok := w . ( c . GzipResponseWriter )
2018-08-22 02:13:17 +00:00
if ok {
w = gzw . ResponseWriter
w . Header ( ) . Del ( "Content-Type" )
w . Header ( ) . Del ( "Content-Encoding" )
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 5 )
2018-05-15 05:59:52 +00:00
err = routes . ShowAttachment ( w , req , user , extraData )
2018-01-18 12:31:25 +00:00
case "/ws" :
req . URL . Path += extraData
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 6 )
2019-04-19 07:16:09 +00:00
err = c . RouteWebsockets ( w , req , user )
2018-06-24 13:49:29 +00:00
case "/api" :
switch ( req . URL . Path ) {
case "/api/phrases/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 7 )
2018-06-24 13:49:29 +00:00
err = routeAPIPhrases ( w , req , user )
2018-08-11 15:53:42 +00:00
case "/api/me/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 8 )
2018-08-11 15:53:42 +00:00
err = routes . APIMe ( w , req , user )
case "/api/watches/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 9 )
2018-07-05 09:54:01 +00:00
err = routeJSAntispam ( w , req , user )
default :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 10 )
2018-06-24 13:49:29 +00:00
err = routeAPI ( w , req , user )
}
2017-05-02 17:24:33 +00:00
case "/report" :
2019-04-19 07:16:09 +00:00
err = c . NoBanned ( w , req , user )
2017-11-08 07:28:33 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-08 07:28:33 +00:00
}
2017-05-02 17:24:33 +00:00
switch ( req . URL . Path ) {
case "/report/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 11 )
2018-05-27 09:36:35 +00:00
err = routes . ReportSubmit ( w , req , user , extraData )
2017-10-30 09:57:08 +00:00
}
2017-04-13 09:26:40 +00:00
case "/topics" :
switch ( req . URL . Path ) {
2018-09-26 07:46:30 +00:00
case "/topics/most-viewed/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 12 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . TopicListMostViewed ( w , req , user , head )
2017-04-13 09:26:40 +00:00
case "/topics/create/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 13 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . CreateTopic ( w , req , user , head , extraData )
2017-04-13 10:55:51 +00:00
default :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 14 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . TopicList ( w , req , user , head )
2017-10-30 09:57:08 +00:00
}
2017-04-13 10:55:51 +00:00
case "/panel" :
2019-04-19 07:16:09 +00:00
err = c . SuperModOnly ( w , req , user )
2017-10-30 09:57:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-10-30 09:57:08 +00:00
}
2017-04-13 10:55:51 +00:00
switch ( req . URL . Path ) {
case "/panel/forums/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 15 )
2018-05-27 09:36:35 +00:00
err = panel . Forums ( w , req , user )
2017-04-13 10:55:51 +00:00
case "/panel/forums/create/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 16 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsCreateSubmit ( w , req , user )
2017-04-13 10:55:51 +00:00
case "/panel/forums/delete/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 17 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsDelete ( w , req , user , extraData )
2017-04-13 10:55:51 +00:00
case "/panel/forums/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 18 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsDeleteSubmit ( w , req , user , extraData )
2019-04-27 06:32:26 +00:00
case "/panel/forums/order/edit/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 19 )
2019-04-27 06:32:26 +00:00
err = panel . ForumsOrderSubmit ( w , req , user )
case "/panel/forums/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 20 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsEdit ( w , req , user , extraData )
2017-04-13 10:55:51 +00:00
case "/panel/forums/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 21 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsEditSubmit ( w , req , user , extraData )
2017-06-05 11:57:27 +00:00
case "/panel/forums/edit/perms/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 22 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsEditPermsSubmit ( w , req , user , extraData )
2018-01-08 08:53:51 +00:00
case "/panel/forums/edit/perms/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 23 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsEditPermsAdvance ( w , req , user , extraData )
2018-01-10 03:32:48 +00:00
case "/panel/forums/edit/perms/adv/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-10 03:32:48 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-10 03:32:48 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 24 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsEditPermsAdvanceSubmit ( w , req , user , extraData )
2018-01-10 03:32:48 +00:00
case "/panel/settings/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 25 )
2018-05-27 09:36:35 +00:00
err = panel . Settings ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/settings/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 26 )
2018-05-27 09:36:35 +00:00
err = panel . SettingEdit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/settings/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 27 )
2018-05-27 09:36:35 +00:00
err = panel . SettingEditSubmit ( w , req , user , extraData )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 28 )
2018-08-04 11:46:36 +00:00
err = panel . WordFilters ( w , req , user )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/create/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 29 )
2018-08-04 11:46:36 +00:00
err = panel . WordFiltersCreateSubmit ( w , req , user )
2018-01-18 12:31:25 +00:00
case "/panel/settings/word-filters/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 30 )
2018-08-04 11:46:36 +00:00
err = panel . WordFiltersEdit ( w , req , user , extraData )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 31 )
2018-08-04 11:46:36 +00:00
err = panel . WordFiltersEditSubmit ( w , req , user , extraData )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 32 )
2018-08-04 11:46:36 +00:00
err = panel . WordFiltersDeleteSubmit ( w , req , user , extraData )
2018-06-06 00:21:22 +00:00
case "/panel/pages/" :
2019-04-19 07:16:09 +00:00
err = c . AdminOnly ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 33 )
2018-06-06 00:21:22 +00:00
err = panel . Pages ( w , req , user )
case "/panel/pages/create/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . AdminOnly ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 34 )
2018-06-06 00:21:22 +00:00
err = panel . PagesCreateSubmit ( w , req , user )
case "/panel/pages/edit/" :
2019-04-19 07:16:09 +00:00
err = c . AdminOnly ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 35 )
2018-06-06 00:21:22 +00:00
err = panel . PagesEdit ( w , req , user , extraData )
case "/panel/pages/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . AdminOnly ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 36 )
2018-06-06 00:21:22 +00:00
err = panel . PagesEditSubmit ( w , req , user , extraData )
case "/panel/pages/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . AdminOnly ( w , req , user )
2018-06-06 00:21:22 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-06 00:21:22 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 37 )
2018-06-06 00:21:22 +00:00
err = panel . PagesDeleteSubmit ( w , req , user , extraData )
case "/panel/themes/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 38 )
2018-09-30 14:43:46 +00:00
err = panel . Themes ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/themes/default/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 39 )
2018-10-02 04:09:17 +00:00
err = panel . ThemesSetDefault ( w , req , user , extraData )
2018-05-11 05:41:51 +00:00
case "/panel/themes/menus/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 40 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenus ( w , req , user )
2018-05-11 05:41:51 +00:00
case "/panel/themes/menus/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 41 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenusEdit ( w , req , user , extraData )
2018-05-11 05:41:51 +00:00
case "/panel/themes/menus/item/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 42 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenuItemEdit ( w , req , user , extraData )
2018-05-11 05:41:51 +00:00
case "/panel/themes/menus/item/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-05-11 05:41:51 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-05-11 05:41:51 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 43 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenuItemEditSubmit ( w , req , user , extraData )
2018-05-13 06:56:59 +00:00
case "/panel/themes/menus/item/create/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-05-13 06:56:59 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-05-13 06:56:59 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 44 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenuItemCreateSubmit ( w , req , user )
2018-05-13 06:56:59 +00:00
case "/panel/themes/menus/item/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-05-13 06:56:59 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-05-13 06:56:59 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 45 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenuItemDeleteSubmit ( w , req , user , extraData )
2018-05-13 06:56:59 +00:00
case "/panel/themes/menus/item/order/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-05-13 06:56:59 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-05-13 06:56:59 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 46 )
2018-09-30 14:43:46 +00:00
err = panel . ThemesMenuItemOrderSubmit ( w , req , user , extraData )
2019-01-21 12:27:59 +00:00
case "/panel/themes/widgets/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 47 )
2019-01-21 12:27:59 +00:00
err = panel . ThemesWidgets ( w , req , user )
case "/panel/themes/widgets/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2019-01-21 12:27:59 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 48 )
2019-01-21 12:27:59 +00:00
err = panel . ThemesWidgetsEditSubmit ( w , req , user , extraData )
case "/panel/themes/widgets/create/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2019-01-21 12:27:59 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 49 )
2019-01-21 12:27:59 +00:00
err = panel . ThemesWidgetsCreateSubmit ( w , req , user )
case "/panel/themes/widgets/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2019-01-21 12:27:59 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 50 )
2019-01-21 12:27:59 +00:00
err = panel . ThemesWidgetsDeleteSubmit ( w , req , user , extraData )
case "/panel/plugins/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 51 )
2018-07-29 10:54:12 +00:00
err = panel . Plugins ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/plugins/activate/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 52 )
2018-07-29 10:54:12 +00:00
err = panel . PluginsActivate ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/plugins/deactivate/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 53 )
2018-07-29 10:54:12 +00:00
err = panel . PluginsDeactivate ( w , req , user , extraData )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
case "/panel/plugins/install/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 54 )
2018-07-29 10:54:12 +00:00
err = panel . PluginsInstall ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/users/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 55 )
2018-06-17 07:28:18 +00:00
err = panel . Users ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/users/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 56 )
2018-06-17 07:28:18 +00:00
err = panel . UsersEdit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/users/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 57 )
2018-06-17 07:28:18 +00:00
err = panel . UsersEditSubmit ( w , req , user , extraData )
2019-06-10 22:00:57 +00:00
case "/panel/users/avatar/submit/" :
err = c . HandleUploadRoute ( w , req , user , int ( c . Config . MaxRequestSize ) )
if err != nil {
return err
}
err = c . NoUploadSessionMismatch ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 58 )
2019-06-10 22:00:57 +00:00
err = panel . UsersAvatarSubmit ( w , req , user , extraData )
case "/panel/users/avatar/remove/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 59 )
2019-06-10 22:00:57 +00:00
err = panel . UsersAvatarRemoveSubmit ( w , req , user , extraData )
2017-12-30 05:47:46 +00:00
case "/panel/analytics/views/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-08 08:53:51 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-08 08:53:51 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 60 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsViews ( w , req , user )
2018-01-04 10:23:33 +00:00
case "/panel/analytics/routes/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-17 11:13:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-17 11:13:08 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 61 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsRoutes ( w , req , user )
2018-01-09 07:39:29 +00:00
case "/panel/analytics/agents/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-17 11:13:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-17 11:13:08 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 62 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsAgents ( w , req , user )
2018-02-04 08:15:20 +00:00
case "/panel/analytics/systems/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-02-04 08:15:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-02-04 08:15:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 63 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsSystems ( w , req , user )
2018-03-08 03:59:47 +00:00
case "/panel/analytics/langs/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-02-05 10:29:13 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-02-05 10:29:13 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 64 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsLanguages ( w , req , user )
2018-03-08 03:59:47 +00:00
case "/panel/analytics/referrers/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-03-08 03:59:47 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-03-08 03:59:47 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 65 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsReferrers ( w , req , user )
2018-02-05 10:29:13 +00:00
case "/panel/analytics/route/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 66 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsRouteViews ( w , req , user , extraData )
2018-01-10 03:32:48 +00:00
case "/panel/analytics/agent/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 67 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsAgentViews ( w , req , user , extraData )
2018-02-22 02:27:17 +00:00
case "/panel/analytics/forum/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 68 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsForumViews ( w , req , user , extraData )
2018-02-22 02:27:17 +00:00
case "/panel/analytics/system/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 69 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsSystemViews ( w , req , user , extraData )
2018-03-08 03:59:47 +00:00
case "/panel/analytics/lang/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 70 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsLanguageViews ( w , req , user , extraData )
2018-02-05 10:29:13 +00:00
case "/panel/analytics/referrer/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 71 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsReferrerViews ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/panel/analytics/posts/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 72 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsPosts ( w , req , user )
2019-05-01 06:59:51 +00:00
case "/panel/analytics/memory/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-18 12:31:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-18 12:31:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 73 )
2019-05-01 06:59:51 +00:00
err = panel . AnalyticsMemory ( w , req , user )
2019-05-09 06:58:55 +00:00
case "/panel/analytics/active-memory/" :
2019-05-01 06:59:51 +00:00
err = c . ParseForm ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 74 )
2019-05-09 06:58:55 +00:00
err = panel . AnalyticsActiveMemory ( w , req , user )
case "/panel/analytics/topics/" :
err = c . ParseForm ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 75 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsTopics ( w , req , user )
2018-02-22 02:27:17 +00:00
case "/panel/analytics/forums/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-02-22 02:27:17 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-02-22 02:27:17 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 76 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsForums ( w , req , user )
2018-01-14 12:03:20 +00:00
case "/panel/groups/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 77 )
2018-09-30 00:08:27 +00:00
err = panel . Groups ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 78 )
2018-09-30 00:08:27 +00:00
err = panel . GroupsEdit ( w , req , user , extraData )
2019-09-29 04:56:39 +00:00
case "/panel/groups/edit/promotions/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 79 )
2019-09-29 04:56:39 +00:00
err = panel . GroupsEditPromotions ( w , req , user , extraData )
case "/panel/groups/promotions/create/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 80 )
2019-09-29 04:56:39 +00:00
err = panel . GroupsPromotionsCreateSubmit ( w , req , user , extraData )
case "/panel/groups/promotions/delete/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 81 )
2019-09-29 04:56:39 +00:00
err = panel . GroupsPromotionsDeleteSubmit ( w , req , user , extraData )
case "/panel/groups/edit/perms/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 82 )
2018-09-30 00:08:27 +00:00
err = panel . GroupsEditPerms ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 83 )
2018-09-30 00:08:27 +00:00
err = panel . GroupsEditSubmit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/perms/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 84 )
2018-09-30 00:08:27 +00:00
err = panel . GroupsEditPermsSubmit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/create/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 85 )
2018-09-30 00:08:27 +00:00
err = panel . GroupsCreateSubmit ( w , req , user )
2017-09-23 19:57:13 +00:00
case "/panel/backups/" :
2019-04-19 07:16:09 +00:00
err = c . SuperAdminOnly ( w , req , user )
2017-12-19 03:53:13 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-12-19 03:53:13 +00:00
}
2019-04-19 07:16:09 +00:00
gzw , ok := w . ( c . GzipResponseWriter )
2018-08-22 07:10:29 +00:00
if ok {
w = gzw . ResponseWriter
w . Header ( ) . Del ( "Content-Type" )
w . Header ( ) . Del ( "Content-Encoding" )
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 86 )
2018-05-27 09:36:35 +00:00
err = panel . Backups ( w , req , user , extraData )
2018-05-16 10:46:14 +00:00
case "/panel/logs/regs/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 87 )
2018-05-27 09:36:35 +00:00
err = panel . LogsRegs ( w , req , user )
2018-05-16 10:46:14 +00:00
case "/panel/logs/mod/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 88 )
2018-05-27 09:36:35 +00:00
err = panel . LogsMod ( w , req , user )
2017-08-15 13:47:56 +00:00
case "/panel/debug/" :
2019-04-19 07:16:09 +00:00
err = c . AdminOnly ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-11 23:34:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 89 )
2018-05-27 09:36:35 +00:00
err = panel . Debug ( w , req , user )
2017-04-13 10:55:51 +00:00
default :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 90 )
2018-10-02 05:03:20 +00:00
err = panel . Dashboard ( w , req , user )
2017-10-30 09:57:08 +00:00
}
2017-11-05 09:55:34 +00:00
case "/user" :
switch ( req . URL . Path ) {
2018-06-17 07:28:18 +00:00
case "/user/edit/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 91 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountEdit ( w , req , user , head )
2018-06-17 07:28:18 +00:00
case "/user/edit/password/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-10 03:33:11 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 92 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountEditPassword ( w , req , user , head )
2018-06-17 07:28:18 +00:00
case "/user/edit/password/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 93 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditPasswordSubmit ( w , req , user )
2017-11-05 09:55:34 +00:00
case "/user/edit/avatar/submit/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . HandleUploadRoute ( w , req , user , int ( c . Config . MaxRequestSize ) )
2018-08-22 02:13:17 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-08-22 02:13:17 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . NoUploadSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 94 )
2018-05-14 08:56:56 +00:00
err = routes . AccountEditAvatarSubmit ( w , req , user )
2019-06-09 03:21:48 +00:00
case "/user/edit/avatar/revoke/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-06-17 07:28:18 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-17 07:28:18 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 95 )
2019-06-09 03:21:48 +00:00
err = routes . AccountEditRevokeAvatarSubmit ( w , req , user )
case "/user/edit/username/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 96 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditUsernameSubmit ( w , req , user )
case "/user/edit/mfa/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-06-17 07:28:18 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-17 07:28:18 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 97 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountEditMFA ( w , req , user , head )
2018-06-17 07:28:18 +00:00
case "/user/edit/mfa/setup/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-06-17 07:28:18 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-17 07:28:18 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 98 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountEditMFASetup ( w , req , user , head )
2018-06-17 07:28:18 +00:00
case "/user/edit/mfa/setup/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 99 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditMFASetupSubmit ( w , req , user )
case "/user/edit/mfa/disable/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-06-17 07:28:18 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-17 07:28:18 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-06-17 07:28:18 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-17 07:28:18 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 100 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditMFADisableSubmit ( w , req , user )
2017-11-05 09:55:34 +00:00
case "/user/edit/email/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-05 09:55:34 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 101 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountEditEmail ( w , req , user , head )
2017-11-05 09:55:34 +00:00
case "/user/edit/token/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 102 )
2018-05-27 09:36:35 +00:00
err = routes . AccountEditEmailTokenSubmit ( w , req , user , extraData )
2018-12-17 04:58:55 +00:00
case "/user/edit/logins/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-10-10 07:33:51 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-10-10 07:33:51 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 103 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-12-17 04:58:55 +00:00
if err != nil {
return err
}
err = routes . AccountLogins ( w , req , user , head )
case "/user/levels/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-12-17 04:58:55 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 104 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . LevelList ( w , req , user , head )
2019-08-14 10:39:04 +00:00
case "/user/convos/" :
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 105 )
2019-08-14 10:39:04 +00:00
head , err := c . UserCheck ( w , req , & user )
if err != nil {
return err
}
err = routes . Convos ( w , req , user , head )
case "/user/convos/create/" :
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 106 )
2019-08-14 10:39:04 +00:00
head , err := c . UserCheck ( w , req , & user )
if err != nil {
return err
}
err = routes . ConvosCreate ( w , req , user , head )
case "/user/convo/" :
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 107 )
2019-08-14 10:39:04 +00:00
head , err := c . UserCheck ( w , req , & user )
if err != nil {
return err
}
err = routes . Convo ( w , req , user , head , extraData )
case "/user/convos/create/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 108 )
2019-08-14 10:39:04 +00:00
err = routes . ConvosCreateSubmit ( w , req , user )
case "/user/convo/create/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 109 )
2019-08-20 08:44:37 +00:00
err = routes . ConvosCreateReplySubmit ( w , req , user , extraData )
2019-08-14 10:39:04 +00:00
case "/user/convo/delete/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 110 )
2019-08-14 10:39:04 +00:00
err = routes . ConvosDeleteReplySubmit ( w , req , user , extraData )
case "/user/convo/edit/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 111 )
2019-08-14 10:39:04 +00:00
err = routes . ConvosEditReplySubmit ( w , req , user , extraData )
2019-10-18 00:35:13 +00:00
case "/user/block/create/" :
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 112 )
2019-10-18 00:35:13 +00:00
head , err := c . UserCheck ( w , req , & user )
if err != nil {
return err
}
err = routes . RelationsBlockCreate ( w , req , user , head , extraData )
case "/user/block/create/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 113 )
2019-10-18 00:35:13 +00:00
err = routes . RelationsBlockCreateSubmit ( w , req , user , extraData )
case "/user/block/remove/" :
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 114 )
2019-10-18 00:35:13 +00:00
head , err := c . UserCheck ( w , req , & user )
if err != nil {
return err
}
err = routes . RelationsBlockRemove ( w , req , user , head , extraData )
case "/user/block/remove/submit/" :
err = c . NoSessionMismatch ( w , req , user )
if err != nil {
return err
}
err = c . MemberOnly ( w , req , user )
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 115 )
2019-10-18 00:35:13 +00:00
err = routes . RelationsBlockRemoveSubmit ( w , req , user , extraData )
2017-11-05 09:55:34 +00:00
default :
2017-12-19 03:53:13 +00:00
req . URL . Path += extraData
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 116 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . ViewProfile ( w , req , user , head )
2017-11-05 09:55:34 +00:00
}
2017-11-10 03:33:11 +00:00
case "/users" :
switch ( req . URL . Path ) {
case "/users/ban/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-10 03:33:11 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 117 )
2018-01-21 11:17:43 +00:00
err = routes . BanUserSubmit ( w , req , user , extraData )
2017-11-10 03:33:11 +00:00
case "/users/unban/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-10 03:33:11 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 118 )
2018-01-21 11:17:43 +00:00
err = routes . UnbanUser ( w , req , user , extraData )
2017-11-10 03:33:11 +00:00
case "/users/activate/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-10 03:33:11 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 119 )
2018-01-21 11:17:43 +00:00
err = routes . ActivateUser ( w , req , user , extraData )
2017-11-10 03:33:11 +00:00
case "/users/ips/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2017-11-12 07:18:25 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2017-11-12 07:18:25 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 120 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . IPSearch ( w , req , user , head )
2017-11-10 03:33:11 +00:00
}
2018-01-14 12:03:20 +00:00
case "/topic" :
switch ( req . URL . Path ) {
case "/topic/create/submit/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . HandleUploadRoute ( w , req , user , int ( c . Config . MaxRequestSize ) )
2018-08-22 02:13:17 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-08-22 02:13:17 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . NoUploadSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 121 )
2018-01-22 08:15:45 +00:00
err = routes . CreateTopicSubmit ( w , req , user )
2018-01-14 12:03:20 +00:00
case "/topic/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 122 )
2018-01-18 12:31:25 +00:00
err = routes . EditTopicSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/topic/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
req . URL . Path += extraData
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 123 )
2018-01-20 06:50:29 +00:00
err = routes . DeleteTopicSubmit ( w , req , user )
2018-01-14 12:03:20 +00:00
case "/topic/stick/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 124 )
2018-01-20 06:50:29 +00:00
err = routes . StickTopicSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/topic/unstick/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 125 )
2018-01-20 06:50:29 +00:00
err = routes . UnstickTopicSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/topic/lock/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
req . URL . Path += extraData
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 126 )
2018-01-20 06:50:29 +00:00
err = routes . LockTopicSubmit ( w , req , user )
2018-01-14 12:03:20 +00:00
case "/topic/unlock/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 127 )
2018-01-20 06:50:29 +00:00
err = routes . UnlockTopicSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/topic/move/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 128 )
2018-01-20 06:50:29 +00:00
err = routes . MoveTopicSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/topic/like/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 129 )
2018-12-27 05:42:41 +00:00
err = routes . LikeTopicSubmit ( w , req , user , extraData )
case "/topic/attach/add/submit/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
2019-04-19 07:16:09 +00:00
err = c . HandleUploadRoute ( w , req , user , int ( c . Config . MaxRequestSize ) )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
2019-04-19 07:16:09 +00:00
err = c . NoUploadSessionMismatch ( w , req , user )
2018-03-31 05:25:27 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-03-31 05:25:27 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 130 )
2018-12-27 05:42:41 +00:00
err = routes . AddAttachToTopicSubmit ( w , req , user , extraData )
case "/topic/attach/remove/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 131 )
2018-12-27 05:42:41 +00:00
err = routes . RemoveAttachFromTopicSubmit ( w , req , user , extraData )
default :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 132 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . ViewTopic ( w , req , user , head , extraData )
2018-01-14 12:03:20 +00:00
}
case "/reply" :
switch ( req . URL . Path ) {
case "/reply/create/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . HandleUploadRoute ( w , req , user , int ( c . Config . MaxRequestSize ) )
2018-08-22 02:13:17 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-08-22 02:13:17 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . NoUploadSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 133 )
2018-03-08 03:59:47 +00:00
err = routes . CreateReplySubmit ( w , req , user )
2018-01-14 12:03:20 +00:00
case "/reply/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 134 )
2018-01-20 06:50:29 +00:00
err = routes . ReplyEditSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/reply/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 135 )
2018-01-20 06:50:29 +00:00
err = routes . ReplyDeleteSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
case "/reply/like/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 12:03:20 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 136 )
2018-05-15 05:59:52 +00:00
err = routes . ReplyLikeSubmit ( w , req , user , extraData )
2018-12-31 09:03:49 +00:00
case "/reply/attach/add/submit/" :
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-12-31 09:03:49 +00:00
if err != nil {
return err
}
2019-04-19 07:16:09 +00:00
err = c . HandleUploadRoute ( w , req , user , int ( c . Config . MaxRequestSize ) )
2018-12-31 09:03:49 +00:00
if err != nil {
return err
}
2019-04-19 07:16:09 +00:00
err = c . NoUploadSessionMismatch ( w , req , user )
2018-12-31 09:03:49 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 137 )
2018-12-31 09:03:49 +00:00
err = routes . AddAttachToReplySubmit ( w , req , user , extraData )
case "/reply/attach/remove/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-12-31 09:03:49 +00:00
if err != nil {
return err
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-12-31 09:03:49 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 138 )
2018-12-31 09:03:49 +00:00
err = routes . RemoveAttachFromReplySubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
}
2018-01-14 14:27:10 +00:00
case "/profile" :
switch ( req . URL . Path ) {
case "/profile/reply/create/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 14:27:10 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 14:27:10 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 14:27:10 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 14:27:10 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 139 )
2018-05-15 05:59:52 +00:00
err = routes . ProfileReplyCreateSubmit ( w , req , user )
2018-01-14 14:27:10 +00:00
case "/profile/reply/edit/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 14:27:10 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 14:27:10 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 14:27:10 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 14:27:10 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 140 )
2018-01-20 06:50:29 +00:00
err = routes . ProfileReplyEditSubmit ( w , req , user , extraData )
2018-01-14 14:27:10 +00:00
case "/profile/reply/delete/submit/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-14 14:27:10 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 14:27:10 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-14 14:27:10 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-14 14:27:10 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 141 )
2018-01-20 06:50:29 +00:00
err = routes . ProfileReplyDeleteSubmit ( w , req , user , extraData )
2018-01-14 14:27:10 +00:00
}
2018-01-27 07:30:44 +00:00
case "/poll" :
switch ( req . URL . Path ) {
case "/poll/vote/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-27 07:30:44 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-27 07:30:44 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-27 07:30:44 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-27 07:30:44 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 142 )
2018-01-27 07:30:44 +00:00
err = routes . PollVote ( w , req , user , extraData )
2018-01-28 14:30:24 +00:00
case "/poll/results/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 143 )
2018-11-12 09:38:46 +00:00
err = routes . PollResults ( w , req , user , extraData )
2018-01-27 07:30:44 +00:00
}
2018-01-17 11:13:08 +00:00
case "/accounts" :
switch ( req . URL . Path ) {
case "/accounts/login/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 144 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountLogin ( w , req , user , head )
2018-01-17 11:13:08 +00:00
case "/accounts/create/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 145 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountRegister ( w , req , user , head )
2018-01-17 11:13:08 +00:00
case "/accounts/logout/" :
2019-04-19 07:16:09 +00:00
err = c . NoSessionMismatch ( w , req , user )
2018-01-17 11:13:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-17 11:13:08 +00:00
}
2019-04-19 07:16:09 +00:00
err = c . MemberOnly ( w , req , user )
2018-01-17 11:13:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-17 11:13:08 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 146 )
2018-05-15 05:59:52 +00:00
err = routes . AccountLogout ( w , req , user )
2018-01-17 11:13:08 +00:00
case "/accounts/login/submit/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-17 11:13:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-17 11:13:08 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 147 )
2018-02-03 05:47:14 +00:00
err = routes . AccountLoginSubmit ( w , req , user )
2018-06-17 07:28:18 +00:00
case "/accounts/mfa_verify/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 148 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2018-11-12 09:23:36 +00:00
if err != nil {
return err
}
err = routes . AccountLoginMFAVerify ( w , req , user , head )
2018-06-17 07:28:18 +00:00
case "/accounts/mfa_verify/submit/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-06-17 07:28:18 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-06-17 07:28:18 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 149 )
2018-06-17 07:28:18 +00:00
err = routes . AccountLoginMFAVerifySubmit ( w , req , user )
2018-01-17 11:13:08 +00:00
case "/accounts/create/submit/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2018-01-17 11:13:08 +00:00
if err != nil {
2018-11-12 09:23:36 +00:00
return err
2018-01-17 11:13:08 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 150 )
2018-02-03 05:47:14 +00:00
err = routes . AccountRegisterSubmit ( w , req , user )
2019-03-11 08:47:45 +00:00
case "/accounts/password-reset/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 151 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2019-03-11 08:47:45 +00:00
if err != nil {
return err
}
err = routes . AccountPasswordReset ( w , req , user , head )
case "/accounts/password-reset/submit/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2019-03-11 08:47:45 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 152 )
2019-03-11 08:47:45 +00:00
err = routes . AccountPasswordResetSubmit ( w , req , user )
case "/accounts/password-reset/token/" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 153 )
2019-04-19 07:16:09 +00:00
head , err := c . UserCheck ( w , req , & user )
2019-03-11 08:47:45 +00:00
if err != nil {
return err
}
err = routes . AccountPasswordResetToken ( w , req , user , head )
case "/accounts/password-reset/token/submit/" :
2019-04-19 07:16:09 +00:00
err = c . ParseForm ( w , req , user )
2019-03-11 08:47:45 +00:00
if err != nil {
return err
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 154 )
2019-03-11 08:47:45 +00:00
err = routes . AccountPasswordResetTokenSubmit ( w , req , user )
2018-01-17 11:13:08 +00:00
}
2017-12-24 07:38:46 +00:00
/ * case "/sitemaps" : // TODO: Count these views
req . URL . Path += extraData
2018-08-22 02:29:11 +00:00
err = sitemapSwitch ( w , req ) * /
2018-08-22 02:13:17 +00:00
case "/uploads" :
if extraData == "" {
2019-04-19 07:16:09 +00:00
return c . NotFound ( w , req , nil )
2018-08-22 02:13:17 +00:00
}
2019-04-19 07:16:09 +00:00
gzw , ok := w . ( c . GzipResponseWriter )
2018-08-22 02:13:17 +00:00
if ok {
w = gzw . ResponseWriter
2019-07-23 10:34:44 +00:00
h := w . Header ( )
h . Del ( "Content-Type" )
h . Del ( "Content-Encoding" )
2018-08-22 02:13:17 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 156 )
2018-08-22 02:13:17 +00:00
req . URL . Path += extraData
// TODO: Find a way to propagate errors up from this?
2018-11-13 06:51:34 +00:00
r . UploadHandler ( w , req ) // TODO: Count these views
2018-11-12 09:23:36 +00:00
return nil
2017-04-13 09:26:40 +00:00
case "" :
2017-08-06 15:22:18 +00:00
// Stop the favicons, robots.txt file, etc. resolving to the topics list
2017-09-10 16:57:22 +00:00
// TODO: Add support for favicons and robots.txt files
2017-12-19 03:53:13 +00:00
switch ( extraData ) {
2017-08-06 15:22:18 +00:00
case "robots.txt" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 158 )
2018-11-12 09:23:36 +00:00
return routes . RobotsTxt ( w , req )
2019-02-28 07:28:17 +00:00
case "favicon.ico" :
2019-07-23 10:34:44 +00:00
gzw , ok := w . ( c . GzipResponseWriter )
if ok {
w = gzw . ResponseWriter
h := w . Header ( )
h . Del ( "Content-Type" )
h . Del ( "Content-Encoding" )
}
2019-08-14 10:39:04 +00:00
req . URL . Path = "/s/favicon.ico"
2019-02-28 07:28:17 +00:00
routes . StaticFile ( w , req )
return nil
2019-05-08 05:26:38 +00:00
case "opensearch.xml" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 160 )
2019-05-08 05:26:38 +00:00
return routes . OpenSearchXml ( w , req )
2017-12-24 07:38:46 +00:00
/ * case "sitemap.xml" :
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 159 )
2018-11-12 09:23:36 +00:00
return routes . SitemapXml ( w , req ) * /
2017-08-06 15:22:18 +00:00
}
2019-04-19 07:16:09 +00:00
return c . NotFound ( w , req , nil )
2017-10-30 09:57:08 +00:00
default :
2018-11-13 06:51:34 +00:00
// A fallback for dynamic routes, e.g. ones declared by plugins
r . RLock ( )
handle , ok := r . extraRoutes [ req . URL . Path ]
r . RUnlock ( )
2017-10-30 09:57:08 +00:00
if ok {
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 155 ) // TODO: Be more specific about *which* dynamic route it is
2017-12-19 03:53:13 +00:00
req . URL . Path += extraData
2018-11-12 09:23:36 +00:00
return handle ( w , req , user )
2017-10-30 09:57:08 +00:00
}
2018-01-26 05:53:34 +00:00
2018-01-27 07:30:44 +00:00
lowerPath := strings . ToLower ( req . URL . Path )
2018-02-04 08:15:20 +00:00
if strings . Contains ( lowerPath , "admin" ) || strings . Contains ( lowerPath , "sql" ) || strings . Contains ( lowerPath , "manage" ) || strings . Contains ( lowerPath , "//" ) || strings . Contains ( lowerPath , "\\\\" ) || strings . Contains ( lowerPath , "wp" ) || strings . Contains ( lowerPath , "wordpress" ) || strings . Contains ( lowerPath , "config" ) || strings . Contains ( lowerPath , "setup" ) || strings . Contains ( lowerPath , "install" ) || strings . Contains ( lowerPath , "update" ) || strings . Contains ( lowerPath , "php" ) {
2018-11-13 06:51:34 +00:00
r . SuspiciousRequest ( req , "Bad Route" )
2018-04-03 04:34:07 +00:00
} else {
2018-11-13 06:51:34 +00:00
r . DumpRequest ( req , "Bad Route" )
2018-01-27 07:30:44 +00:00
}
2019-10-29 07:13:04 +00:00
co . RouteViewCounter . Bump ( 161 )
2019-04-19 07:16:09 +00:00
return c . NotFound ( w , req , nil )
2017-04-12 13:39:03 +00:00
}
2018-11-12 09:23:36 +00:00
return err
2017-04-12 13:39:03 +00:00
}