2017-04-12 13:39:03 +00:00
// Code generated by. DO NOT EDIT.
/* 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-03-08 03:59:47 +00:00
"strconv"
2017-11-11 04:06:16 +00:00
"sync"
"errors"
2018-04-03 04:34:07 +00:00
"os"
2017-11-11 04:06:16 +00:00
"net/http"
"./common"
2018-02-19 04:26:01 +00:00
"./common/counters"
2018-01-18 12:31:25 +00:00
"./routes"
2018-05-27 09:36:35 +00:00
"./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 ,
2018-03-08 03:59:47 +00:00
"common.RouteWebsockets" : common . RouteWebsockets ,
2018-06-24 13:49:29 +00:00
"routeAPIPhrases" : routeAPIPhrases ,
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-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 ,
"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 ,
2017-12-10 03:43:30 +00:00
"routePanelWordFilters" : routePanelWordFilters ,
2018-01-18 12:31:25 +00:00
"routePanelWordFiltersCreateSubmit" : routePanelWordFiltersCreateSubmit ,
2017-12-10 03:43:30 +00:00
"routePanelWordFiltersEdit" : routePanelWordFiltersEdit ,
"routePanelWordFiltersEditSubmit" : routePanelWordFiltersEditSubmit ,
"routePanelWordFiltersDeleteSubmit" : routePanelWordFiltersDeleteSubmit ,
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 ,
2017-12-10 03:43:30 +00:00
"routePanelThemes" : routePanelThemes ,
"routePanelThemesSetDefault" : routePanelThemesSetDefault ,
2018-05-11 05:41:51 +00:00
"routePanelThemesMenus" : routePanelThemesMenus ,
"routePanelThemesMenusEdit" : routePanelThemesMenusEdit ,
"routePanelThemesMenuItemEdit" : routePanelThemesMenuItemEdit ,
"routePanelThemesMenuItemEditSubmit" : routePanelThemesMenuItemEditSubmit ,
2018-05-13 06:56:59 +00:00
"routePanelThemesMenuItemCreateSubmit" : routePanelThemesMenuItemCreateSubmit ,
"routePanelThemesMenuItemDeleteSubmit" : routePanelThemesMenuItemDeleteSubmit ,
"routePanelThemesMenuItemOrderSubmit" : routePanelThemesMenuItemOrderSubmit ,
2017-12-10 03:43:30 +00:00
"routePanelPlugins" : routePanelPlugins ,
"routePanelPluginsActivate" : routePanelPluginsActivate ,
"routePanelPluginsDeactivate" : routePanelPluginsDeactivate ,
"routePanelPluginsInstall" : routePanelPluginsInstall ,
2018-06-17 07:28:18 +00:00
"panel.Users" : panel . Users ,
"panel.UsersEdit" : panel . UsersEdit ,
"panel.UsersEditSubmit" : panel . UsersEditSubmit ,
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 ,
"panel.AnalyticsTopics" : panel . AnalyticsTopics ,
"panel.AnalyticsForums" : panel . AnalyticsForums ,
2017-12-10 03:43:30 +00:00
"routePanelGroups" : routePanelGroups ,
"routePanelGroupsEdit" : routePanelGroupsEdit ,
"routePanelGroupsEditPerms" : routePanelGroupsEditPerms ,
"routePanelGroupsEditSubmit" : routePanelGroupsEditSubmit ,
"routePanelGroupsEditPermsSubmit" : routePanelGroupsEditPermsSubmit ,
"routePanelGroupsCreateSubmit" : routePanelGroupsCreateSubmit ,
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-01-22 08:15:45 +00:00
"routePanelDashboard" : routePanelDashboard ,
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 ,
"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-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-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 ,
"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 ,
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 ,
2018-05-15 05:59:52 +00:00
"routes.BadRoute" : routes . BadRoute ,
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-07-05 09:54:01 +00:00
"routeJSAntispam" : 8 ,
"routeAPI" : 9 ,
"routes.ReportSubmit" : 10 ,
"routes.CreateTopic" : 11 ,
"routes.TopicList" : 12 ,
"panel.Forums" : 13 ,
"panel.ForumsCreateSubmit" : 14 ,
"panel.ForumsDelete" : 15 ,
"panel.ForumsDeleteSubmit" : 16 ,
"panel.ForumsEdit" : 17 ,
"panel.ForumsEditSubmit" : 18 ,
"panel.ForumsEditPermsSubmit" : 19 ,
"panel.ForumsEditPermsAdvance" : 20 ,
"panel.ForumsEditPermsAdvanceSubmit" : 21 ,
"panel.Settings" : 22 ,
"panel.SettingEdit" : 23 ,
"panel.SettingEditSubmit" : 24 ,
"routePanelWordFilters" : 25 ,
"routePanelWordFiltersCreateSubmit" : 26 ,
"routePanelWordFiltersEdit" : 27 ,
"routePanelWordFiltersEditSubmit" : 28 ,
"routePanelWordFiltersDeleteSubmit" : 29 ,
"panel.Pages" : 30 ,
"panel.PagesCreateSubmit" : 31 ,
"panel.PagesEdit" : 32 ,
"panel.PagesEditSubmit" : 33 ,
"panel.PagesDeleteSubmit" : 34 ,
"routePanelThemes" : 35 ,
"routePanelThemesSetDefault" : 36 ,
"routePanelThemesMenus" : 37 ,
"routePanelThemesMenusEdit" : 38 ,
"routePanelThemesMenuItemEdit" : 39 ,
"routePanelThemesMenuItemEditSubmit" : 40 ,
"routePanelThemesMenuItemCreateSubmit" : 41 ,
"routePanelThemesMenuItemDeleteSubmit" : 42 ,
"routePanelThemesMenuItemOrderSubmit" : 43 ,
"routePanelPlugins" : 44 ,
"routePanelPluginsActivate" : 45 ,
"routePanelPluginsDeactivate" : 46 ,
"routePanelPluginsInstall" : 47 ,
"panel.Users" : 48 ,
"panel.UsersEdit" : 49 ,
"panel.UsersEditSubmit" : 50 ,
"panel.AnalyticsViews" : 51 ,
"panel.AnalyticsRoutes" : 52 ,
"panel.AnalyticsAgents" : 53 ,
"panel.AnalyticsSystems" : 54 ,
"panel.AnalyticsLanguages" : 55 ,
"panel.AnalyticsReferrers" : 56 ,
"panel.AnalyticsRouteViews" : 57 ,
"panel.AnalyticsAgentViews" : 58 ,
"panel.AnalyticsForumViews" : 59 ,
"panel.AnalyticsSystemViews" : 60 ,
"panel.AnalyticsLanguageViews" : 61 ,
"panel.AnalyticsReferrerViews" : 62 ,
"panel.AnalyticsPosts" : 63 ,
"panel.AnalyticsTopics" : 64 ,
"panel.AnalyticsForums" : 65 ,
"routePanelGroups" : 66 ,
"routePanelGroupsEdit" : 67 ,
"routePanelGroupsEditPerms" : 68 ,
"routePanelGroupsEditSubmit" : 69 ,
"routePanelGroupsEditPermsSubmit" : 70 ,
"routePanelGroupsCreateSubmit" : 71 ,
"panel.Backups" : 72 ,
"panel.LogsRegs" : 73 ,
"panel.LogsMod" : 74 ,
"panel.Debug" : 75 ,
"routePanelDashboard" : 76 ,
"routes.AccountEdit" : 77 ,
"routes.AccountEditPassword" : 78 ,
"routes.AccountEditPasswordSubmit" : 79 ,
"routes.AccountEditAvatarSubmit" : 80 ,
"routes.AccountEditUsernameSubmit" : 81 ,
"routes.AccountEditMFA" : 82 ,
"routes.AccountEditMFASetup" : 83 ,
"routes.AccountEditMFASetupSubmit" : 84 ,
"routes.AccountEditMFADisableSubmit" : 85 ,
"routes.AccountEditEmail" : 86 ,
"routes.AccountEditEmailTokenSubmit" : 87 ,
"routes.ViewProfile" : 88 ,
"routes.BanUserSubmit" : 89 ,
"routes.UnbanUser" : 90 ,
"routes.ActivateUser" : 91 ,
"routes.IPSearch" : 92 ,
"routes.CreateTopicSubmit" : 93 ,
"routes.EditTopicSubmit" : 94 ,
"routes.DeleteTopicSubmit" : 95 ,
"routes.StickTopicSubmit" : 96 ,
"routes.UnstickTopicSubmit" : 97 ,
"routes.LockTopicSubmit" : 98 ,
"routes.UnlockTopicSubmit" : 99 ,
"routes.MoveTopicSubmit" : 100 ,
"routes.LikeTopicSubmit" : 101 ,
"routes.ViewTopic" : 102 ,
"routes.CreateReplySubmit" : 103 ,
"routes.ReplyEditSubmit" : 104 ,
"routes.ReplyDeleteSubmit" : 105 ,
"routes.ReplyLikeSubmit" : 106 ,
"routes.ProfileReplyCreateSubmit" : 107 ,
"routes.ProfileReplyEditSubmit" : 108 ,
"routes.ProfileReplyDeleteSubmit" : 109 ,
"routes.PollVote" : 110 ,
"routes.PollResults" : 111 ,
"routes.AccountLogin" : 112 ,
"routes.AccountRegister" : 113 ,
"routes.AccountLogout" : 114 ,
"routes.AccountLoginSubmit" : 115 ,
"routes.AccountLoginMFAVerify" : 116 ,
"routes.AccountLoginMFAVerifySubmit" : 117 ,
"routes.AccountRegisterSubmit" : 118 ,
"routes.DynamicRoute" : 119 ,
"routes.UploadedFile" : 120 ,
"routes.StaticFile" : 121 ,
"routes.RobotsTxt" : 122 ,
"routes.SitemapXml" : 123 ,
"routes.BadRoute" : 124 ,
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-07-05 09:54:01 +00:00
8 : "routeJSAntispam" ,
9 : "routeAPI" ,
10 : "routes.ReportSubmit" ,
11 : "routes.CreateTopic" ,
12 : "routes.TopicList" ,
13 : "panel.Forums" ,
14 : "panel.ForumsCreateSubmit" ,
15 : "panel.ForumsDelete" ,
16 : "panel.ForumsDeleteSubmit" ,
17 : "panel.ForumsEdit" ,
18 : "panel.ForumsEditSubmit" ,
19 : "panel.ForumsEditPermsSubmit" ,
20 : "panel.ForumsEditPermsAdvance" ,
21 : "panel.ForumsEditPermsAdvanceSubmit" ,
22 : "panel.Settings" ,
23 : "panel.SettingEdit" ,
24 : "panel.SettingEditSubmit" ,
25 : "routePanelWordFilters" ,
26 : "routePanelWordFiltersCreateSubmit" ,
27 : "routePanelWordFiltersEdit" ,
28 : "routePanelWordFiltersEditSubmit" ,
29 : "routePanelWordFiltersDeleteSubmit" ,
30 : "panel.Pages" ,
31 : "panel.PagesCreateSubmit" ,
32 : "panel.PagesEdit" ,
33 : "panel.PagesEditSubmit" ,
34 : "panel.PagesDeleteSubmit" ,
35 : "routePanelThemes" ,
36 : "routePanelThemesSetDefault" ,
37 : "routePanelThemesMenus" ,
38 : "routePanelThemesMenusEdit" ,
39 : "routePanelThemesMenuItemEdit" ,
40 : "routePanelThemesMenuItemEditSubmit" ,
41 : "routePanelThemesMenuItemCreateSubmit" ,
42 : "routePanelThemesMenuItemDeleteSubmit" ,
43 : "routePanelThemesMenuItemOrderSubmit" ,
44 : "routePanelPlugins" ,
45 : "routePanelPluginsActivate" ,
46 : "routePanelPluginsDeactivate" ,
47 : "routePanelPluginsInstall" ,
48 : "panel.Users" ,
49 : "panel.UsersEdit" ,
50 : "panel.UsersEditSubmit" ,
51 : "panel.AnalyticsViews" ,
52 : "panel.AnalyticsRoutes" ,
53 : "panel.AnalyticsAgents" ,
54 : "panel.AnalyticsSystems" ,
55 : "panel.AnalyticsLanguages" ,
56 : "panel.AnalyticsReferrers" ,
57 : "panel.AnalyticsRouteViews" ,
58 : "panel.AnalyticsAgentViews" ,
59 : "panel.AnalyticsForumViews" ,
60 : "panel.AnalyticsSystemViews" ,
61 : "panel.AnalyticsLanguageViews" ,
62 : "panel.AnalyticsReferrerViews" ,
63 : "panel.AnalyticsPosts" ,
64 : "panel.AnalyticsTopics" ,
65 : "panel.AnalyticsForums" ,
66 : "routePanelGroups" ,
67 : "routePanelGroupsEdit" ,
68 : "routePanelGroupsEditPerms" ,
69 : "routePanelGroupsEditSubmit" ,
70 : "routePanelGroupsEditPermsSubmit" ,
71 : "routePanelGroupsCreateSubmit" ,
72 : "panel.Backups" ,
73 : "panel.LogsRegs" ,
74 : "panel.LogsMod" ,
75 : "panel.Debug" ,
76 : "routePanelDashboard" ,
77 : "routes.AccountEdit" ,
78 : "routes.AccountEditPassword" ,
79 : "routes.AccountEditPasswordSubmit" ,
80 : "routes.AccountEditAvatarSubmit" ,
81 : "routes.AccountEditUsernameSubmit" ,
82 : "routes.AccountEditMFA" ,
83 : "routes.AccountEditMFASetup" ,
84 : "routes.AccountEditMFASetupSubmit" ,
85 : "routes.AccountEditMFADisableSubmit" ,
86 : "routes.AccountEditEmail" ,
87 : "routes.AccountEditEmailTokenSubmit" ,
88 : "routes.ViewProfile" ,
89 : "routes.BanUserSubmit" ,
90 : "routes.UnbanUser" ,
91 : "routes.ActivateUser" ,
92 : "routes.IPSearch" ,
93 : "routes.CreateTopicSubmit" ,
94 : "routes.EditTopicSubmit" ,
95 : "routes.DeleteTopicSubmit" ,
96 : "routes.StickTopicSubmit" ,
97 : "routes.UnstickTopicSubmit" ,
98 : "routes.LockTopicSubmit" ,
99 : "routes.UnlockTopicSubmit" ,
100 : "routes.MoveTopicSubmit" ,
101 : "routes.LikeTopicSubmit" ,
102 : "routes.ViewTopic" ,
103 : "routes.CreateReplySubmit" ,
104 : "routes.ReplyEditSubmit" ,
105 : "routes.ReplyDeleteSubmit" ,
106 : "routes.ReplyLikeSubmit" ,
107 : "routes.ProfileReplyCreateSubmit" ,
108 : "routes.ProfileReplyEditSubmit" ,
109 : "routes.ProfileReplyDeleteSubmit" ,
110 : "routes.PollVote" ,
111 : "routes.PollResults" ,
112 : "routes.AccountLogin" ,
113 : "routes.AccountRegister" ,
114 : "routes.AccountLogout" ,
115 : "routes.AccountLoginSubmit" ,
116 : "routes.AccountLoginMFAVerify" ,
117 : "routes.AccountLoginMFAVerifySubmit" ,
118 : "routes.AccountRegisterSubmit" ,
119 : "routes.DynamicRoute" ,
120 : "routes.UploadedFile" ,
121 : "routes.StaticFile" ,
122 : "routes.RobotsTxt" ,
123 : "routes.SitemapXml" ,
124 : "routes.BadRoute" ,
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 ,
"cloudflare" : 20 ,
"uptimebot" : 21 ,
2018-03-08 03:59:47 +00:00
"slackbot" : 22 ,
"discourse" : 23 ,
"lynx" : 24 ,
"blank" : 25 ,
"malformed" : 26 ,
"suspicious" : 27 ,
"zgrab" : 28 ,
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" ,
20 : "cloudflare" ,
21 : "uptimebot" ,
2018-03-08 03:59:47 +00:00
22 : "slackbot" ,
23 : "discourse" ,
24 : "lynx" ,
25 : "blank" ,
26 : "malformed" ,
27 : "suspicious" ,
28 : "zgrab" ,
2017-12-19 03:53:13 +00:00
}
2018-02-03 05:47:14 +00:00
var markToAgent = map [ string ] string {
"OPR" : "opera" ,
"Chrome" : "chrome" ,
"Firefox" : "firefox" ,
"MSIE" : "internetexplorer" ,
2018-02-04 08:15:20 +00:00
"Trident" : "trident" , // Hack to support IE11
2018-02-03 05:47:14 +00:00
"Edge" : "edge" ,
"Lynx" : "lynx" , // There's a rare android variant of lynx which isn't covered by this
2018-02-04 08:15:20 +00:00
"SamsungBrowser" : "samsung" ,
2018-02-03 05:47:14 +00:00
"UCBrowser" : "ucbrowser" ,
"Google" : "googlebot" ,
"Googlebot" : "googlebot" ,
"yandex" : "yandex" , // from the URL
"DuckDuckBot" : "duckduckgo" ,
"Baiduspider" : "baidu" ,
"bingbot" : "bing" ,
"BingPreview" : "bing" ,
2018-02-04 08:15:20 +00:00
"SeznamBot" : "seznambot" ,
2018-02-03 05:47:14 +00:00
"CloudFlare" : "cloudflare" , // Track alwayson specifically in case there are other bots?
"Uptimebot" : "uptimebot" ,
2018-03-08 03:59:47 +00:00
"Slackbot" : "slackbot" ,
2018-02-03 05:47:14 +00:00
"Discordbot" : "discord" ,
2018-02-04 08:15:20 +00:00
"Twitterbot" : "twitter" ,
"Discourse" : "discourse" ,
2018-02-03 05:47:14 +00:00
"zgrab" : "zgrab" ,
}
/ * 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 ( ) {
2018-02-19 04:26:01 +00:00
counters . SetRouteMapEnum ( routeMapEnum )
counters . SetReverseRouteMapEnum ( reverseRouteMapEnum )
counters . SetAgentMapEnum ( agentMapEnum )
counters . SetReverseAgentMapEnum ( reverseAgentMapEnum )
counters . SetOSMapEnum ( osMapEnum )
counters . SetReverseOSMapEnum ( reverseOSMapEnum )
2017-12-19 03:53:13 +00:00
}
2018-03-31 05:25:27 +00:00
type WriterIntercept struct {
w http . ResponseWriter
code int
}
func NewWriterIntercept ( w http . ResponseWriter ) * WriterIntercept {
return & WriterIntercept { w : w , code : 200 }
}
func ( writ * WriterIntercept ) Header ( ) http . Header {
return writ . w . Header ( )
}
func ( writ * WriterIntercept ) Write ( pieces [ ] byte ) ( int , error ) {
return writ . w . Write ( pieces )
}
func ( writ * WriterIntercept ) WriteHeader ( code int ) {
writ . w . WriteHeader ( code )
writ . code = code
}
func ( writ * WriterIntercept ) GetCode ( ) int {
return writ . code
}
2017-04-12 13:39:03 +00:00
type GenRouter struct {
UploadHandler func ( http . ResponseWriter , * http . Request )
2017-12-19 03:53:13 +00:00
extraRoutes map [ string ] func ( http . ResponseWriter , * http . Request , common . User ) common . 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 ) {
f , err := os . OpenFile ( "./logs/requests.log" , os . O_WRONLY | os . O_APPEND | os . O_CREATE , 0755 )
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 ) {
writ := NewWriterIntercept ( w )
http . StripPrefix ( "/uploads/" , uploads ) . ServeHTTP ( writ , req )
if writ . GetCode ( ) == 200 {
2018-05-14 08:56:56 +00:00
w . Header ( ) . Set ( "Cache-Control" , "max-age=" + strconv . Itoa ( int ( common . Day ) ) )
2018-03-31 05:25:27 +00:00
w . Header ( ) . Set ( "Vary" , "Accept-Encoding" )
}
} ,
2017-12-19 03:53:13 +00:00
extraRoutes : make ( map [ string ] func ( http . ResponseWriter , * http . Request , common . User ) common . RouteError ) ,
2018-04-03 04:34:07 +00:00
requestLogger : log . New ( f , "" , log . LstdFlags ) ,
} , nil
2017-04-12 13:39:03 +00:00
}
2017-11-11 04:06:16 +00:00
func ( router * GenRouter ) handleError ( err common . RouteError , w http . ResponseWriter , r * http . Request , user common . User ) {
2017-10-30 09:57:08 +00:00
if err . Handled ( ) {
return
}
if err . Type ( ) == "system" {
2017-11-11 04:06:16 +00:00
common . InternalErrorJSQ ( err , w , r , err . JSON ( ) )
2017-10-30 09:57:08 +00:00
return
}
2017-11-11 04:06:16 +00:00
common . LocalErrorJSQ ( err . Error ( ) , w , r , user , err . JSON ( ) )
2017-10-30 09:57:08 +00:00
}
2017-04-13 09:26:40 +00:00
func ( router * GenRouter ) Handle ( _ string , _ http . Handler ) {
2017-04-12 13:39:03 +00:00
}
2017-11-11 04:06:16 +00:00
func ( router * GenRouter ) HandleFunc ( pattern string , handle func ( http . ResponseWriter , * http . Request , common . User ) common . RouteError ) {
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
router . Lock ( )
2017-12-10 03:43:30 +00:00
defer router . Unlock ( )
2017-12-19 03:53:13 +00:00
router . 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
}
func ( router * GenRouter ) RemoveFunc ( pattern string ) error {
2017-04-12 13:39:03 +00:00
router . Lock ( )
2017-12-10 03:43:30 +00:00
defer router . Unlock ( )
2017-12-19 03:53:13 +00:00
_ , ok := router . 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
}
2017-12-19 03:53:13 +00:00
delete ( router . 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-03-08 03:59:47 +00:00
func ( router * 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 {
2018-05-31 06:51:31 +00:00
heads += "Header '" + common . SanitiseSingleLine ( key ) + "': " + common . SanitiseSingleLine ( vvalue ) + "!!\n"
2018-01-27 07:30:44 +00:00
}
}
2018-02-26 09:07:00 +00:00
2018-04-03 04:34:07 +00:00
router . requestLogger . Print ( prepend +
2018-05-31 06:51:31 +00:00
"\nUA: " + common . SanitiseSingleLine ( req . UserAgent ( ) ) + "\n" +
"Method: " + common . SanitiseSingleLine ( req . Method ) + "\n" + heads +
"req.Host: " + common . SanitiseSingleLine ( req . Host ) + "\n" +
"req.URL.Path: " + common . SanitiseSingleLine ( req . URL . Path ) + "\n" +
"req.URL.RawQuery: " + common . SanitiseSingleLine ( req . URL . RawQuery ) + "\n" +
"req.Referer(): " + common . 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-04-03 04:34:07 +00:00
func ( router * GenRouter ) SuspiciousRequest ( req * http . Request , prepend string ) {
if prepend != "" {
prepend += "\n"
}
router . DumpRequest ( req , prepend + "Suspicious Request" )
2018-03-08 03:59:47 +00:00
counters . AgentViewCounter . Bump ( 27 )
2018-01-27 07:30:44 +00:00
}
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
2017-04-12 13:39:03 +00:00
func ( router * GenRouter ) ServeHTTP ( w http . ResponseWriter , req * http . Request ) {
2018-01-28 14:30:24 +00:00
// Redirect www. requests to the right place
if req . Host == "www." + common . Site . Host {
w . Header ( ) . Set ( "Connection" , "close" )
var s string
if common . Site . EnableSsl {
s = "s"
}
dest := "http" + s + "://" + req . Host + req . URL . Path
if len ( req . URL . RawQuery ) > 0 {
dest += "?" + req . URL . RawQuery
}
http . Redirect ( w , req , dest , http . StatusMovedPermanently )
return
}
// Deflect malformed requests
2018-01-25 04:57:33 +00:00
if len ( req . URL . Path ) == 0 || req . URL . Path [ 0 ] != '/' || req . Host != common . Site . Host {
2018-01-27 07:30:44 +00:00
w . WriteHeader ( 200 ) // 400
2017-04-12 13:39:03 +00:00
w . Write ( [ ] byte ( "" ) )
2018-03-08 03:59:47 +00:00
router . DumpRequest ( req , "Malformed Request" )
counters . AgentViewCounter . Bump ( 26 )
2017-04-12 13:39:03 +00:00
return
}
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
2018-03-08 03:59:47 +00:00
for _ , char := range req . URL . Path {
if char != '&' && ! ( char > 44 && char < 58 ) && char != '=' && char != '?' && ! ( char > 64 && char < 91 ) && char != '\\' && char != '_' && ! ( char > 96 && char < 123 ) {
2018-06-24 13:49:29 +00:00
router . 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-06-24 13:49:29 +00:00
router . 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 == "/" {
req . URL . Path = common . Config . DefaultPath
}
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
}
2017-08-06 15:22:18 +00:00
2017-11-11 04:06:16 +00:00
if common . Dev . SuperDebug {
2018-03-08 03:59:47 +00:00
router . 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
counters . 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
if prefix == "/static" {
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 121 )
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
}
2017-11-11 04:06:16 +00:00
if common . Dev . SuperDebug {
2018-04-03 04:34:07 +00:00
router . 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
if ua == "" {
2018-03-08 03:59:47 +00:00
counters . AgentViewCounter . Bump ( 25 )
2018-01-11 09:29:25 +00:00
if common . Dev . DebugMode {
2018-03-08 03:59:47 +00:00
var prepend string
for _ , char := range req . UserAgent ( ) {
prepend += strconv . Itoa ( int ( char ) ) + " "
}
router . DumpRequest ( req , "Blank UA: " + prepend )
2018-01-11 09:29:25 +00:00
}
2018-02-03 05:47:14 +00:00
} else {
2018-02-04 08:15:20 +00:00
var runeEquals = func ( a [ ] rune , b [ ] rune ) bool {
if len ( a ) != len ( b ) {
return false
}
for i , item := range a {
if item != b [ i ] {
return false
}
}
return true
}
2018-02-03 05:47:14 +00:00
// WIP UA Parser
var indices [ ] int
var items [ ] string
var buffer [ ] rune
for index , item := range ua {
if ( item > 64 && item < 91 ) || ( item > 96 && item < 123 ) {
buffer = append ( buffer , item )
2018-02-04 09:33:04 +00:00
} else if item == ' ' || item == '(' || item == ')' || item == '-' || ( item > 47 && item < 58 ) || item == '_' || item == ';' || item == '.' || item == '+' || ( item == ':' && ( runeEquals ( buffer , [ ] rune ( "http" ) ) || runeEquals ( buffer , [ ] rune ( "rv" ) ) ) ) || item == ',' || item == '/' {
2018-02-04 08:15:20 +00:00
if len ( buffer ) != 0 {
items = append ( items , string ( buffer ) )
indices = append ( indices , index - 1 )
buffer = buffer [ : 0 ]
}
} else {
// TODO: Test this
items = items [ : 0 ]
indices = indices [ : 0 ]
2018-06-24 13:49:29 +00:00
router . SuspiciousRequest ( req , "Illegal char in UA" )
2018-04-03 04:34:07 +00:00
router . requestLogger . Print ( "UA Buffer: " , buffer )
router . requestLogger . Print ( "UA Buffer String: " , string ( buffer ) )
2018-02-04 08:15:20 +00:00
break
2018-02-03 05:47:14 +00:00
}
}
// Iterate over this in reverse as the real UA tends to be on the right side
var agent string
for i := len ( items ) - 1 ; i >= 0 ; i -- {
fAgent , ok := markToAgent [ items [ i ] ]
if ok {
agent = fAgent
if agent != "safari" {
break
}
}
}
2018-02-04 08:15:20 +00:00
if common . Dev . SuperDebug {
2018-04-03 04:34:07 +00:00
router . requestLogger . Print ( "parsed agent: " , agent )
2018-02-04 08:15:20 +00:00
}
2018-02-03 05:47:14 +00:00
2018-02-04 08:15:20 +00:00
var os string
for _ , mark := range items {
switch ( mark ) {
case "Windows" :
os = "windows"
case "Linux" :
os = "linux"
case "Mac" :
os = "mac"
case "iPhone" :
os = "iphone"
case "Android" :
os = "android"
}
}
if os == "" {
os = "unknown"
}
if common . Dev . SuperDebug {
2018-04-03 04:34:07 +00:00
router . requestLogger . Print ( "os: " , os )
router . 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-04-03 04:34:07 +00:00
router . SuspiciousRequest ( req , "Vulnerability Scanner" )
2018-02-03 05:47:14 +00:00
}
if agent == "" {
2018-02-19 04:26:01 +00:00
counters . AgentViewCounter . Bump ( 0 )
2018-02-03 05:47:14 +00:00
if common . Dev . DebugMode {
2018-03-08 03:59:47 +00:00
var prepend string
for _ , char := range req . UserAgent ( ) {
prepend += strconv . Itoa ( int ( char ) ) + " "
}
router . DumpRequest ( req , "Blank UA: " + prepend )
2018-02-03 05:47:14 +00:00
}
} else {
2018-02-19 04:26:01 +00:00
counters . AgentViewCounter . Bump ( agentMapEnum [ agent ] )
2018-01-10 03:32:48 +00:00
}
2018-02-19 04:26:01 +00:00
counters . 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 , "-" )
common . DebugDetail ( "lLang:" , lLang )
counters . LangViewCounter . Bump ( lLang [ 0 ] )
2018-03-17 08:16:43 +00:00
} else {
counters . LangViewCounter . Bump ( "none" )
2018-03-08 03:59:47 +00:00
}
2018-02-10 15:07:21 +00:00
referrer := req . Header . Get ( "Referer" ) // Check the 'referrer' header too? :P
2018-02-05 10:29:13 +00:00
if referrer != "" {
// ? Optimise this a little?
referrer = strings . TrimPrefix ( strings . TrimPrefix ( referrer , "http://" ) , "https://" )
referrer = strings . Split ( referrer , "/" ) [ 0 ]
portless := strings . Split ( referrer , ":" ) [ 0 ]
2018-02-10 15:07:21 +00:00
if portless != "localhost" && portless != "127.0.0.1" && portless != common . Site . Host {
2018-02-19 04:26:01 +00:00
counters . ReferrerTracker . Bump ( referrer )
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.
2017-11-11 04:06:16 +00:00
user , ok := common . 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
}
2017-11-11 04:06:16 +00:00
if common . Dev . SuperDebug {
2018-04-03 04:34:07 +00:00
router . requestLogger . Print (
"after PreRoute\n" +
"routeMapEnum: " , routeMapEnum )
2017-07-17 10:23:42 +00:00
}
2017-11-11 04:06:16 +00:00
var err common . RouteError
2017-04-13 09:26:40 +00:00
switch ( prefix ) {
case "/overview" :
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 0 )
2018-02-03 05:47:14 +00:00
err = routes . Overview ( w , req , user )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
2017-12-22 03:32:23 +00:00
case "/pages" :
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 1 )
2018-02-03 05:47:14 +00:00
err = routes . CustomPage ( w , req , user , extraData )
2017-12-22 03:32:23 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
case "/forums" :
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 2 )
2018-03-17 08:16:43 +00:00
err = routes . ForumList ( w , req , user )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
2017-04-13 15:01:30 +00:00
case "/forum" :
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 3 )
2018-02-22 02:27:17 +00:00
err = routes . ViewForum ( w , req , user , extraData )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
2017-09-10 16:57:22 +00:00
case "/theme" :
2017-11-12 07:18:25 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 4 )
2018-05-15 05:59:52 +00:00
err = routes . ChangeTheme ( w , req , user )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , 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" :
2017-11-12 07:18:25 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 5 )
2018-05-15 05:59:52 +00:00
err = routes . ShowAttachment ( w , req , user , extraData )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
2018-01-18 12:31:25 +00:00
case "/ws" :
req . URL . Path += extraData
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 6 )
2018-03-08 03:59:47 +00:00
err = common . RouteWebsockets ( w , req , user )
2018-01-18 12:31:25 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
2018-06-24 13:49:29 +00:00
case "/api" :
switch ( req . URL . Path ) {
case "/api/phrases/" :
counters . RouteViewCounter . Bump ( 7 )
err = routeAPIPhrases ( w , req , user )
2018-07-05 09:54:01 +00:00
case "/api/watches/" :
2018-06-24 13:49:29 +00:00
counters . RouteViewCounter . Bump ( 8 )
2018-07-05 09:54:01 +00:00
err = routeJSAntispam ( w , req , user )
default :
counters . RouteViewCounter . Bump ( 9 )
2018-06-24 13:49:29 +00:00
err = routeAPI ( w , req , user )
}
if err != nil {
router . handleError ( err , w , req , user )
}
2017-05-02 17:24:33 +00:00
case "/report" :
2017-11-11 04:06:16 +00:00
err = common . NoBanned ( w , req , user )
2017-11-08 07:28:33 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-05-02 17:24:33 +00:00
switch ( req . URL . Path ) {
case "/report/submit/" :
2017-11-12 07:18:25 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 10 )
2018-05-27 09:36:35 +00:00
err = routes . ReportSubmit ( w , req , user , extraData )
2017-10-30 09:57:08 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
2017-05-02 17:24:33 +00:00
}
2017-04-13 09:26:40 +00:00
case "/topics" :
switch ( req . URL . Path ) {
case "/topics/create/" :
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 11 )
2018-01-21 11:17:43 +00:00
err = routes . CreateTopic ( w , req , user , extraData )
2017-04-13 10:55:51 +00:00
default :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 12 )
2018-02-10 15:07:21 +00:00
err = routes . TopicList ( w , req , user )
2017-10-30 09:57:08 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
2017-04-13 10:55:51 +00:00
}
case "/panel" :
2017-11-11 04:06:16 +00:00
err = common . SuperModOnly ( w , req , user )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-04-13 10:55:51 +00:00
switch ( req . URL . Path ) {
case "/panel/forums/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 13 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 14 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 15 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 16 )
2018-05-27 09:36:35 +00:00
err = panel . ForumsDeleteSubmit ( w , req , user , extraData )
2017-04-13 10:55:51 +00:00
case "/panel/forums/edit/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 17 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 18 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 19 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 20 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 21 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 22 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 23 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 24 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 25 )
2017-10-30 09:57:08 +00:00
err = routePanelWordFilters ( w , req , user )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/create/" :
2017-11-12 07:18:25 +00:00
err = common . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 26 )
2018-01-18 12:31:25 +00:00
err = routePanelWordFiltersCreateSubmit ( w , req , user )
case "/panel/settings/word-filters/edit/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 27 )
2017-12-19 03:53:13 +00:00
err = routePanelWordFiltersEdit ( w , req , user , extraData )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/edit/submit/" :
2017-11-12 07:18:25 +00:00
err = common . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 28 )
2017-12-19 03:53:13 +00:00
err = routePanelWordFiltersEditSubmit ( w , req , user , extraData )
2017-08-27 09:33:45 +00:00
case "/panel/settings/word-filters/delete/submit/" :
2017-11-12 07:18:25 +00:00
err = common . NoSessionMismatch ( w , req , user )
2017-11-11 23:34:27 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 29 )
2017-12-19 03:53:13 +00:00
err = routePanelWordFiltersDeleteSubmit ( w , req , user , extraData )
2018-06-06 00:21:22 +00:00
case "/panel/pages/" :
err = common . AdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 30 )
2018-06-06 00:21:22 +00:00
err = panel . Pages ( w , req , user )
case "/panel/pages/create/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . AdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 31 )
2018-06-06 00:21:22 +00:00
err = panel . PagesCreateSubmit ( w , req , user )
case "/panel/pages/edit/" :
err = common . AdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 32 )
2018-06-06 00:21:22 +00:00
err = panel . PagesEdit ( w , req , user , extraData )
case "/panel/pages/edit/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . AdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 33 )
2018-06-06 00:21:22 +00:00
err = panel . PagesEditSubmit ( w , req , user , extraData )
case "/panel/pages/delete/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . AdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 34 )
2018-06-06 00:21:22 +00:00
err = panel . PagesDeleteSubmit ( w , req , user , extraData )
case "/panel/themes/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 35 )
2017-10-30 09:57:08 +00:00
err = routePanelThemes ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/themes/default/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 36 )
2017-12-19 03:53:13 +00:00
err = routePanelThemesSetDefault ( w , req , user , extraData )
2018-05-11 05:41:51 +00:00
case "/panel/themes/menus/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 37 )
2018-05-11 05:41:51 +00:00
err = routePanelThemesMenus ( w , req , user )
case "/panel/themes/menus/edit/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 38 )
2018-05-11 05:41:51 +00:00
err = routePanelThemesMenusEdit ( w , req , user , extraData )
case "/panel/themes/menus/item/edit/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 39 )
2018-05-11 05:41:51 +00:00
err = routePanelThemesMenuItemEdit ( w , req , user , extraData )
case "/panel/themes/menus/item/edit/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 40 )
2018-05-11 05:41:51 +00:00
err = routePanelThemesMenuItemEditSubmit ( w , req , user , extraData )
2018-05-13 06:56:59 +00:00
case "/panel/themes/menus/item/create/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 41 )
2018-05-13 06:56:59 +00:00
err = routePanelThemesMenuItemCreateSubmit ( w , req , user )
case "/panel/themes/menus/item/delete/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 42 )
2018-05-13 06:56:59 +00:00
err = routePanelThemesMenuItemDeleteSubmit ( w , req , user , extraData )
case "/panel/themes/menus/item/order/edit/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 43 )
2018-05-13 06:56:59 +00:00
err = routePanelThemesMenuItemOrderSubmit ( w , req , user , extraData )
case "/panel/plugins/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 44 )
2017-10-30 09:57:08 +00:00
err = routePanelPlugins ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/plugins/activate/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 45 )
2017-12-19 03:53:13 +00:00
err = routePanelPluginsActivate ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/plugins/deactivate/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 46 )
2017-12-19 03:53:13 +00:00
err = routePanelPluginsDeactivate ( 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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 47 )
2017-12-19 03:53:13 +00:00
err = routePanelPluginsInstall ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/users/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 48 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 49 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 50 )
2018-06-17 07:28:18 +00:00
err = panel . UsersEditSubmit ( w , req , user , extraData )
2017-12-30 05:47:46 +00:00
case "/panel/analytics/views/" :
2018-01-08 08:53:51 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 51 )
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/" :
2018-01-17 11:13:08 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 52 )
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/" :
2018-01-17 11:13:08 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 53 )
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/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 54 )
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/" :
2018-02-05 10:29:13 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 55 )
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/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 56 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 57 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 58 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 59 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 60 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 61 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 62 )
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/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 63 )
2018-05-27 09:36:35 +00:00
err = panel . AnalyticsPosts ( w , req , user )
2018-01-18 12:31:25 +00:00
case "/panel/analytics/topics/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 64 )
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/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 65 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 66 )
2017-10-30 09:57:08 +00:00
err = routePanelGroups ( w , req , user )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 67 )
2017-12-19 03:53:13 +00:00
err = routePanelGroupsEdit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/perms/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 68 )
2017-12-19 03:53:13 +00:00
err = routePanelGroupsEditPerms ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/submit/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 69 )
2017-12-19 03:53:13 +00:00
err = routePanelGroupsEditSubmit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/edit/perms/submit/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 70 )
2017-12-19 03:53:13 +00:00
err = routePanelGroupsEditPermsSubmit ( w , req , user , extraData )
2017-04-13 15:01:30 +00:00
case "/panel/groups/create/" :
2017-11-11 23:34:27 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 71 )
2017-10-30 09:57:08 +00:00
err = routePanelGroupsCreateSubmit ( w , req , user )
2017-09-23 19:57:13 +00:00
case "/panel/backups/" :
2017-12-19 03:53:13 +00:00
err = common . SuperAdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 72 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 73 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 74 )
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/" :
2017-11-11 23:34:27 +00:00
err = common . AdminOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 75 )
2018-05-27 09:36:35 +00:00
err = panel . Debug ( w , req , user )
2017-04-13 10:55:51 +00:00
default :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 76 )
2018-01-22 08:15:45 +00:00
err = routePanelDashboard ( w , req , user )
2017-10-30 09:57:08 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
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/" :
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 77 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEdit ( w , req , user )
case "/user/edit/password/" :
err = common . MemberOnly ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 78 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditPassword ( w , req , user )
case "/user/edit/password/submit/" :
err = common . NoSessionMismatch ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 79 )
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/" :
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-05-14 08:56:56 +00:00
err = common . HandleUploadRoute ( w , req , user , int ( common . Config . MaxRequestSize ) )
2018-01-14 12:03:20 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . NoUploadSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 80 )
2018-05-14 08:56:56 +00:00
err = routes . AccountEditAvatarSubmit ( w , req , user )
2018-06-17 07:28:18 +00:00
case "/user/edit/username/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 81 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditUsernameSubmit ( w , req , user )
case "/user/edit/mfa/" :
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 82 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditMFA ( w , req , user )
case "/user/edit/mfa/setup/" :
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 83 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditMFASetup ( w , req , user )
case "/user/edit/mfa/setup/submit/" :
2017-11-12 07:18:25 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 84 )
2018-06-17 07:28:18 +00:00
err = routes . AccountEditMFASetupSubmit ( w , req , user )
case "/user/edit/mfa/disable/submit/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 85 )
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/" :
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 86 )
2018-05-27 09:36:35 +00:00
err = routes . AccountEditEmail ( w , req , user )
2017-11-05 09:55:34 +00:00
case "/user/edit/token/" :
2017-11-12 07:18:25 +00:00
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-11 04:06:16 +00:00
err = common . MemberOnly ( w , req , user )
2017-11-05 09:55:34 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 87 )
2018-05-27 09:36:35 +00:00
err = routes . AccountEditEmailTokenSubmit ( 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
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 88 )
2018-02-26 09:07:00 +00:00
err = routes . ViewProfile ( w , req , user )
2017-11-05 09:55:34 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
2017-11-10 03:33:11 +00:00
}
case "/users" :
switch ( req . URL . Path ) {
case "/users/ban/submit/" :
2017-11-11 04:06:16 +00:00
err = common . NoSessionMismatch ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-12 07:18:25 +00:00
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 89 )
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/" :
2017-11-11 04:06:16 +00:00
err = common . NoSessionMismatch ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-12 07:18:25 +00:00
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 90 )
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/" :
2017-11-11 04:06:16 +00:00
err = common . NoSessionMismatch ( w , req , user )
2017-11-10 03:33:11 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2017-11-12 07:18:25 +00:00
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 91 )
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/" :
2017-11-12 07:18:25 +00:00
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 92 )
2018-01-21 11:17:43 +00:00
err = routes . IPSearch ( w , req , user )
2017-11-10 03:33:11 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
2017-04-13 09:26:40 +00:00
}
2018-01-14 12:03:20 +00:00
case "/topic" :
switch ( req . URL . Path ) {
case "/topic/create/submit/" :
2018-01-22 08:15:45 +00:00
err = common . MemberOnly ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-05-14 08:56:56 +00:00
err = common . HandleUploadRoute ( w , req , user , int ( common . Config . MaxRequestSize ) )
2018-01-22 08:15:45 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . NoUploadSessionMismatch ( w , req , user )
2018-01-14 12:03:20 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 93 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 94 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
req . URL . Path += extraData
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 95 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 96 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 97 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
req . URL . Path += extraData
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 98 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 99 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 100 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-03-31 05:25:27 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 101 )
2018-05-15 05:59:52 +00:00
err = routes . LikeTopicSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
default :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 102 )
2018-02-03 05:47:14 +00:00
err = routes . ViewTopic ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
}
case "/reply" :
switch ( req . URL . Path ) {
case "/reply/create/" :
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-05-14 08:56:56 +00:00
err = common . HandleUploadRoute ( w , req , user , int ( common . Config . MaxRequestSize ) )
2018-01-14 12:03:20 +00:00
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . NoUploadSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 103 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 104 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 105 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-03-31 05:25:27 +00:00
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 106 )
2018-05-15 05:59:52 +00:00
err = routes . ReplyLikeSubmit ( w , req , user , extraData )
2018-01-14 12:03:20 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
}
2018-01-14 14:27:10 +00:00
case "/profile" :
switch ( req . URL . Path ) {
case "/profile/reply/create/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 107 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 108 )
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/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 109 )
2018-01-20 06:50:29 +00:00
err = routes . ProfileReplyDeleteSubmit ( w , req , user , extraData )
2018-01-14 14:27:10 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
}
2018-01-27 07:30:44 +00:00
case "/poll" :
switch ( req . URL . Path ) {
case "/poll/vote/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 110 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 111 )
2018-01-28 14:30:24 +00:00
err = routes . PollResults ( w , req , user , extraData )
2018-01-27 07:30:44 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
}
2018-01-17 11:13:08 +00:00
case "/accounts" :
switch ( req . URL . Path ) {
case "/accounts/login/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 112 )
2018-02-03 05:47:14 +00:00
err = routes . AccountLogin ( w , req , user )
2018-01-17 11:13:08 +00:00
case "/accounts/create/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 113 )
2018-02-03 05:47:14 +00:00
err = routes . AccountRegister ( w , req , user )
2018-01-17 11:13:08 +00:00
case "/accounts/logout/" :
err = common . NoSessionMismatch ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
err = common . MemberOnly ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 114 )
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/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 115 )
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/" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 116 )
2018-06-17 07:28:18 +00:00
err = routes . AccountLoginMFAVerify ( w , req , user )
case "/accounts/mfa_verify/submit/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 117 )
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/" :
err = common . ParseForm ( w , req , user )
if err != nil {
router . handleError ( err , w , req , user )
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 118 )
2018-02-03 05:47:14 +00:00
err = routes . AccountRegisterSubmit ( w , req , user )
2018-01-17 11:13:08 +00:00
}
if err != nil {
router . handleError ( err , w , req , user )
}
2017-12-24 07:38:46 +00:00
/ * case "/sitemaps" : // TODO: Count these views
req . URL . Path += extraData
err = sitemapSwitch ( w , req )
if err != nil {
router . handleError ( err , w , req , user )
} * /
2017-04-13 09:26:40 +00:00
case "/uploads" :
2017-12-19 03:53:13 +00:00
if extraData == "" {
2018-02-19 04:26:01 +00:00
common . NotFound ( w , req , nil )
2017-04-13 09:26:40 +00:00
return
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 120 )
2017-12-19 03:53:13 +00:00
req . URL . Path += extraData
2017-10-30 09:57:08 +00:00
// TODO: Find a way to propagate errors up from this?
2017-12-19 03:53:13 +00:00
router . UploadHandler ( w , req ) // TODO: Count these views
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" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 122 )
2018-03-17 08:16:43 +00:00
err = routes . RobotsTxt ( w , req )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
2017-08-06 15:22:18 +00:00
return
2017-12-24 07:38:46 +00:00
/ * case "sitemap.xml" :
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 123 )
2018-03-17 08:16:43 +00:00
err = routes . SitemapXml ( w , req )
2017-12-24 07:38:46 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
return * /
2017-08-06 15:22:18 +00:00
}
2018-06-17 07:28:18 +00:00
common . NotFound ( w , req , nil )
return
2017-10-30 09:57:08 +00:00
default :
// A fallback for the routes which haven't been converted to the new router yet or plugins
router . RLock ( )
2017-12-19 03:53:13 +00:00
handle , ok := router . extraRoutes [ req . URL . Path ]
2017-10-30 09:57:08 +00:00
router . RUnlock ( )
if ok {
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 119 ) // TODO: Be more specific about *which* dynamic route it is
2017-12-19 03:53:13 +00:00
req . URL . Path += extraData
2017-12-24 22:08:35 +00:00
err = handle ( w , req , user )
2017-10-30 09:57:08 +00:00
if err != nil {
router . handleError ( err , w , req , user )
}
return
}
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-04-03 04:34:07 +00:00
router . SuspiciousRequest ( req , "Bad Route" )
} else {
router . DumpRequest ( req , "Bad Route" )
2018-01-27 07:30:44 +00:00
}
2018-07-05 09:54:01 +00:00
counters . RouteViewCounter . Bump ( 124 )
2018-02-19 04:26:01 +00:00
common . NotFound ( w , req , nil )
2017-04-12 13:39:03 +00:00
}
}