github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/gen_router.go (about) 1 // Code generated by Gosora's Router Generator. DO NOT EDIT. 2 /* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */ 3 package main 4 5 import ( 6 "strings" 7 //"bytes" 8 "strconv" 9 "compress/gzip" 10 "sync/atomic" 11 "errors" 12 "net/http" 13 14 c "github.com/Azareal/Gosora/common" 15 co "github.com/Azareal/Gosora/common/counters" 16 "github.com/Azareal/Gosora/uutils" 17 "github.com/Azareal/Gosora/routes" 18 "github.com/Azareal/Gosora/routes/panel" 19 20 //"github.com/andybalholm/brotli" 21 ) 22 23 var ErrNoRoute = errors.New("That route doesn't exist.") 24 // TODO: What about the /uploads/ route? x.x 25 var RouteMap = map[string]interface{}{ 26 "routes.Error": routes.Error, 27 "routes.Overview": routes.Overview, 28 "routes.CustomPage": routes.CustomPage, 29 "routes.ForumList": routes.ForumList, 30 "routes.ViewForum": routes.ViewForum, 31 "routes.ChangeTheme": routes.ChangeTheme, 32 "routes.ShowAttachment": routes.ShowAttachment, 33 "common.RouteWebsockets": c.RouteWebsockets, 34 "routeAPIPhrases": routeAPIPhrases, 35 "routes.APIMe": routes.APIMe, 36 "routeJSAntispam": routeJSAntispam, 37 "routeAPI": routeAPI, 38 "routes.ReportSubmit": routes.ReportSubmit, 39 "routes.TopicListMostViewed": routes.TopicListMostViewed, 40 "routes.TopicListWeekViews": routes.TopicListWeekViews, 41 "routes.CreateTopic": routes.CreateTopic, 42 "routes.TopicList": routes.TopicList, 43 "panel.Forums": panel.Forums, 44 "panel.ForumsCreateSubmit": panel.ForumsCreateSubmit, 45 "panel.ForumsDelete": panel.ForumsDelete, 46 "panel.ForumsDeleteSubmit": panel.ForumsDeleteSubmit, 47 "panel.ForumsOrderSubmit": panel.ForumsOrderSubmit, 48 "panel.ForumsEdit": panel.ForumsEdit, 49 "panel.ForumsEditSubmit": panel.ForumsEditSubmit, 50 "panel.ForumsEditPermsSubmit": panel.ForumsEditPermsSubmit, 51 "panel.ForumsEditPermsAdvance": panel.ForumsEditPermsAdvance, 52 "panel.ForumsEditPermsAdvanceSubmit": panel.ForumsEditPermsAdvanceSubmit, 53 "panel.ForumsEditActionCreateSubmit": panel.ForumsEditActionCreateSubmit, 54 "panel.ForumsEditActionDeleteSubmit": panel.ForumsEditActionDeleteSubmit, 55 "panel.Settings": panel.Settings, 56 "panel.SettingEdit": panel.SettingEdit, 57 "panel.SettingEditSubmit": panel.SettingEditSubmit, 58 "panel.WordFilters": panel.WordFilters, 59 "panel.WordFiltersCreateSubmit": panel.WordFiltersCreateSubmit, 60 "panel.WordFiltersEdit": panel.WordFiltersEdit, 61 "panel.WordFiltersEditSubmit": panel.WordFiltersEditSubmit, 62 "panel.WordFiltersDeleteSubmit": panel.WordFiltersDeleteSubmit, 63 "panel.Pages": panel.Pages, 64 "panel.PagesCreateSubmit": panel.PagesCreateSubmit, 65 "panel.PagesEdit": panel.PagesEdit, 66 "panel.PagesEditSubmit": panel.PagesEditSubmit, 67 "panel.PagesDeleteSubmit": panel.PagesDeleteSubmit, 68 "panel.Themes": panel.Themes, 69 "panel.ThemesSetDefault": panel.ThemesSetDefault, 70 "panel.ThemesMenus": panel.ThemesMenus, 71 "panel.ThemesMenusEdit": panel.ThemesMenusEdit, 72 "panel.ThemesMenuItemEdit": panel.ThemesMenuItemEdit, 73 "panel.ThemesMenuItemEditSubmit": panel.ThemesMenuItemEditSubmit, 74 "panel.ThemesMenuItemCreateSubmit": panel.ThemesMenuItemCreateSubmit, 75 "panel.ThemesMenuItemDeleteSubmit": panel.ThemesMenuItemDeleteSubmit, 76 "panel.ThemesMenuItemOrderSubmit": panel.ThemesMenuItemOrderSubmit, 77 "panel.ThemesWidgets": panel.ThemesWidgets, 78 "panel.ThemesWidgetsEditSubmit": panel.ThemesWidgetsEditSubmit, 79 "panel.ThemesWidgetsCreateSubmit": panel.ThemesWidgetsCreateSubmit, 80 "panel.ThemesWidgetsDeleteSubmit": panel.ThemesWidgetsDeleteSubmit, 81 "panel.Plugins": panel.Plugins, 82 "panel.PluginsActivate": panel.PluginsActivate, 83 "panel.PluginsDeactivate": panel.PluginsDeactivate, 84 "panel.PluginsInstall": panel.PluginsInstall, 85 "panel.Users": panel.Users, 86 "panel.UsersEdit": panel.UsersEdit, 87 "panel.UsersEditSubmit": panel.UsersEditSubmit, 88 "panel.UsersAvatarSubmit": panel.UsersAvatarSubmit, 89 "panel.UsersAvatarRemoveSubmit": panel.UsersAvatarRemoveSubmit, 90 "panel.AnalyticsViews": panel.AnalyticsViews, 91 "panel.AnalyticsRoutes": panel.AnalyticsRoutes, 92 "panel.AnalyticsRoutesPerf": panel.AnalyticsRoutesPerf, 93 "panel.AnalyticsAgents": panel.AnalyticsAgents, 94 "panel.AnalyticsSystems": panel.AnalyticsSystems, 95 "panel.AnalyticsLanguages": panel.AnalyticsLanguages, 96 "panel.AnalyticsReferrers": panel.AnalyticsReferrers, 97 "panel.AnalyticsRouteViews": panel.AnalyticsRouteViews, 98 "panel.AnalyticsAgentViews": panel.AnalyticsAgentViews, 99 "panel.AnalyticsForumViews": panel.AnalyticsForumViews, 100 "panel.AnalyticsSystemViews": panel.AnalyticsSystemViews, 101 "panel.AnalyticsLanguageViews": panel.AnalyticsLanguageViews, 102 "panel.AnalyticsReferrerViews": panel.AnalyticsReferrerViews, 103 "panel.AnalyticsPosts": panel.AnalyticsPosts, 104 "panel.AnalyticsMemory": panel.AnalyticsMemory, 105 "panel.AnalyticsActiveMemory": panel.AnalyticsActiveMemory, 106 "panel.AnalyticsTopics": panel.AnalyticsTopics, 107 "panel.AnalyticsForums": panel.AnalyticsForums, 108 "panel.AnalyticsPerf": panel.AnalyticsPerf, 109 "panel.Groups": panel.Groups, 110 "panel.GroupsEdit": panel.GroupsEdit, 111 "panel.GroupsEditPromotions": panel.GroupsEditPromotions, 112 "panel.GroupsPromotionsCreateSubmit": panel.GroupsPromotionsCreateSubmit, 113 "panel.GroupsPromotionsDeleteSubmit": panel.GroupsPromotionsDeleteSubmit, 114 "panel.GroupsEditPerms": panel.GroupsEditPerms, 115 "panel.GroupsEditSubmit": panel.GroupsEditSubmit, 116 "panel.GroupsEditPermsSubmit": panel.GroupsEditPermsSubmit, 117 "panel.GroupsCreateSubmit": panel.GroupsCreateSubmit, 118 "panel.Backups": panel.Backups, 119 "panel.LogsRegs": panel.LogsRegs, 120 "panel.LogsMod": panel.LogsMod, 121 "panel.LogsAdmin": panel.LogsAdmin, 122 "panel.Debug": panel.Debug, 123 "panel.DebugTasks": panel.DebugTasks, 124 "panel.Dashboard": panel.Dashboard, 125 "routes.AccountEdit": routes.AccountEdit, 126 "routes.AccountEditPassword": routes.AccountEditPassword, 127 "routes.AccountEditPasswordSubmit": routes.AccountEditPasswordSubmit, 128 "routes.AccountEditAvatarSubmit": routes.AccountEditAvatarSubmit, 129 "routes.AccountEditRevokeAvatarSubmit": routes.AccountEditRevokeAvatarSubmit, 130 "routes.AccountEditUsernameSubmit": routes.AccountEditUsernameSubmit, 131 "routes.AccountEditPrivacy": routes.AccountEditPrivacy, 132 "routes.AccountEditPrivacySubmit": routes.AccountEditPrivacySubmit, 133 "routes.AccountEditMFA": routes.AccountEditMFA, 134 "routes.AccountEditMFASetup": routes.AccountEditMFASetup, 135 "routes.AccountEditMFASetupSubmit": routes.AccountEditMFASetupSubmit, 136 "routes.AccountEditMFADisableSubmit": routes.AccountEditMFADisableSubmit, 137 "routes.AccountEditEmail": routes.AccountEditEmail, 138 "routes.AccountEditEmailTokenSubmit": routes.AccountEditEmailTokenSubmit, 139 "routes.AccountLogins": routes.AccountLogins, 140 "routes.AccountBlocked": routes.AccountBlocked, 141 "routes.LevelList": routes.LevelList, 142 "routes.Convos": routes.Convos, 143 "routes.ConvosCreate": routes.ConvosCreate, 144 "routes.Convo": routes.Convo, 145 "routes.ConvosCreateSubmit": routes.ConvosCreateSubmit, 146 "routes.ConvosCreateReplySubmit": routes.ConvosCreateReplySubmit, 147 "routes.ConvosDeleteReplySubmit": routes.ConvosDeleteReplySubmit, 148 "routes.ConvosEditReplySubmit": routes.ConvosEditReplySubmit, 149 "routes.RelationsBlockCreate": routes.RelationsBlockCreate, 150 "routes.RelationsBlockCreateSubmit": routes.RelationsBlockCreateSubmit, 151 "routes.RelationsBlockRemove": routes.RelationsBlockRemove, 152 "routes.RelationsBlockRemoveSubmit": routes.RelationsBlockRemoveSubmit, 153 "routes.ViewProfile": routes.ViewProfile, 154 "routes.BanUserSubmit": routes.BanUserSubmit, 155 "routes.UnbanUser": routes.UnbanUser, 156 "routes.ActivateUser": routes.ActivateUser, 157 "routes.IPSearch": routes.IPSearch, 158 "routes.DeletePostsSubmit": routes.DeletePostsSubmit, 159 "routes.CreateTopicSubmit": routes.CreateTopicSubmit, 160 "routes.EditTopicSubmit": routes.EditTopicSubmit, 161 "routes.DeleteTopicSubmit": routes.DeleteTopicSubmit, 162 "routes.StickTopicSubmit": routes.StickTopicSubmit, 163 "routes.UnstickTopicSubmit": routes.UnstickTopicSubmit, 164 "routes.LockTopicSubmit": routes.LockTopicSubmit, 165 "routes.UnlockTopicSubmit": routes.UnlockTopicSubmit, 166 "routes.MoveTopicSubmit": routes.MoveTopicSubmit, 167 "routes.LikeTopicSubmit": routes.LikeTopicSubmit, 168 "routes.UnlikeTopicSubmit": routes.UnlikeTopicSubmit, 169 "routes.AddAttachToTopicSubmit": routes.AddAttachToTopicSubmit, 170 "routes.RemoveAttachFromTopicSubmit": routes.RemoveAttachFromTopicSubmit, 171 "routes.ViewTopic": routes.ViewTopic, 172 "routes.CreateReplySubmit": routes.CreateReplySubmit, 173 "routes.ReplyEditSubmit": routes.ReplyEditSubmit, 174 "routes.ReplyDeleteSubmit": routes.ReplyDeleteSubmit, 175 "routes.ReplyLikeSubmit": routes.ReplyLikeSubmit, 176 "routes.ReplyUnlikeSubmit": routes.ReplyUnlikeSubmit, 177 "routes.AddAttachToReplySubmit": routes.AddAttachToReplySubmit, 178 "routes.RemoveAttachFromReplySubmit": routes.RemoveAttachFromReplySubmit, 179 "routes.ProfileReplyCreateSubmit": routes.ProfileReplyCreateSubmit, 180 "routes.ProfileReplyEditSubmit": routes.ProfileReplyEditSubmit, 181 "routes.ProfileReplyDeleteSubmit": routes.ProfileReplyDeleteSubmit, 182 "routes.PollVote": routes.PollVote, 183 "routes.PollResults": routes.PollResults, 184 "routes.AccountLogin": routes.AccountLogin, 185 "routes.AccountRegister": routes.AccountRegister, 186 "routes.AccountLogout": routes.AccountLogout, 187 "routes.AccountLoginSubmit": routes.AccountLoginSubmit, 188 "routes.AccountLoginMFAVerify": routes.AccountLoginMFAVerify, 189 "routes.AccountLoginMFAVerifySubmit": routes.AccountLoginMFAVerifySubmit, 190 "routes.AccountRegisterSubmit": routes.AccountRegisterSubmit, 191 "routes.AccountPasswordReset": routes.AccountPasswordReset, 192 "routes.AccountPasswordResetSubmit": routes.AccountPasswordResetSubmit, 193 "routes.AccountPasswordResetToken": routes.AccountPasswordResetToken, 194 "routes.AccountPasswordResetTokenSubmit": routes.AccountPasswordResetTokenSubmit, 195 "routes.DynamicRoute": routes.DynamicRoute, 196 "routes.UploadedFile": routes.UploadedFile, 197 "routes.StaticFile": routes.StaticFile, 198 "routes.RobotsTxt": routes.RobotsTxt, 199 "routes.SitemapXml": routes.SitemapXml, 200 "routes.OpenSearchXml": routes.OpenSearchXml, 201 "routes.Favicon": routes.Favicon, 202 "routes.BadRoute": routes.BadRoute, 203 "routes.HTTPSRedirect": routes.HTTPSRedirect, 204 } 205 206 // ! NEVER RELY ON THESE REMAINING THE SAME BETWEEN COMMITS 207 var routeMapEnum = map[string]int{ 208 "routes.Error": 0, 209 "routes.Overview": 1, 210 "routes.CustomPage": 2, 211 "routes.ForumList": 3, 212 "routes.ViewForum": 4, 213 "routes.ChangeTheme": 5, 214 "routes.ShowAttachment": 6, 215 "common.RouteWebsockets": 7, 216 "routeAPIPhrases": 8, 217 "routes.APIMe": 9, 218 "routeJSAntispam": 10, 219 "routeAPI": 11, 220 "routes.ReportSubmit": 12, 221 "routes.TopicListMostViewed": 13, 222 "routes.TopicListWeekViews": 14, 223 "routes.CreateTopic": 15, 224 "routes.TopicList": 16, 225 "panel.Forums": 17, 226 "panel.ForumsCreateSubmit": 18, 227 "panel.ForumsDelete": 19, 228 "panel.ForumsDeleteSubmit": 20, 229 "panel.ForumsOrderSubmit": 21, 230 "panel.ForumsEdit": 22, 231 "panel.ForumsEditSubmit": 23, 232 "panel.ForumsEditPermsSubmit": 24, 233 "panel.ForumsEditPermsAdvance": 25, 234 "panel.ForumsEditPermsAdvanceSubmit": 26, 235 "panel.ForumsEditActionCreateSubmit": 27, 236 "panel.ForumsEditActionDeleteSubmit": 28, 237 "panel.Settings": 29, 238 "panel.SettingEdit": 30, 239 "panel.SettingEditSubmit": 31, 240 "panel.WordFilters": 32, 241 "panel.WordFiltersCreateSubmit": 33, 242 "panel.WordFiltersEdit": 34, 243 "panel.WordFiltersEditSubmit": 35, 244 "panel.WordFiltersDeleteSubmit": 36, 245 "panel.Pages": 37, 246 "panel.PagesCreateSubmit": 38, 247 "panel.PagesEdit": 39, 248 "panel.PagesEditSubmit": 40, 249 "panel.PagesDeleteSubmit": 41, 250 "panel.Themes": 42, 251 "panel.ThemesSetDefault": 43, 252 "panel.ThemesMenus": 44, 253 "panel.ThemesMenusEdit": 45, 254 "panel.ThemesMenuItemEdit": 46, 255 "panel.ThemesMenuItemEditSubmit": 47, 256 "panel.ThemesMenuItemCreateSubmit": 48, 257 "panel.ThemesMenuItemDeleteSubmit": 49, 258 "panel.ThemesMenuItemOrderSubmit": 50, 259 "panel.ThemesWidgets": 51, 260 "panel.ThemesWidgetsEditSubmit": 52, 261 "panel.ThemesWidgetsCreateSubmit": 53, 262 "panel.ThemesWidgetsDeleteSubmit": 54, 263 "panel.Plugins": 55, 264 "panel.PluginsActivate": 56, 265 "panel.PluginsDeactivate": 57, 266 "panel.PluginsInstall": 58, 267 "panel.Users": 59, 268 "panel.UsersEdit": 60, 269 "panel.UsersEditSubmit": 61, 270 "panel.UsersAvatarSubmit": 62, 271 "panel.UsersAvatarRemoveSubmit": 63, 272 "panel.AnalyticsViews": 64, 273 "panel.AnalyticsRoutes": 65, 274 "panel.AnalyticsRoutesPerf": 66, 275 "panel.AnalyticsAgents": 67, 276 "panel.AnalyticsSystems": 68, 277 "panel.AnalyticsLanguages": 69, 278 "panel.AnalyticsReferrers": 70, 279 "panel.AnalyticsRouteViews": 71, 280 "panel.AnalyticsAgentViews": 72, 281 "panel.AnalyticsForumViews": 73, 282 "panel.AnalyticsSystemViews": 74, 283 "panel.AnalyticsLanguageViews": 75, 284 "panel.AnalyticsReferrerViews": 76, 285 "panel.AnalyticsPosts": 77, 286 "panel.AnalyticsMemory": 78, 287 "panel.AnalyticsActiveMemory": 79, 288 "panel.AnalyticsTopics": 80, 289 "panel.AnalyticsForums": 81, 290 "panel.AnalyticsPerf": 82, 291 "panel.Groups": 83, 292 "panel.GroupsEdit": 84, 293 "panel.GroupsEditPromotions": 85, 294 "panel.GroupsPromotionsCreateSubmit": 86, 295 "panel.GroupsPromotionsDeleteSubmit": 87, 296 "panel.GroupsEditPerms": 88, 297 "panel.GroupsEditSubmit": 89, 298 "panel.GroupsEditPermsSubmit": 90, 299 "panel.GroupsCreateSubmit": 91, 300 "panel.Backups": 92, 301 "panel.LogsRegs": 93, 302 "panel.LogsMod": 94, 303 "panel.LogsAdmin": 95, 304 "panel.Debug": 96, 305 "panel.DebugTasks": 97, 306 "panel.Dashboard": 98, 307 "routes.AccountEdit": 99, 308 "routes.AccountEditPassword": 100, 309 "routes.AccountEditPasswordSubmit": 101, 310 "routes.AccountEditAvatarSubmit": 102, 311 "routes.AccountEditRevokeAvatarSubmit": 103, 312 "routes.AccountEditUsernameSubmit": 104, 313 "routes.AccountEditPrivacy": 105, 314 "routes.AccountEditPrivacySubmit": 106, 315 "routes.AccountEditMFA": 107, 316 "routes.AccountEditMFASetup": 108, 317 "routes.AccountEditMFASetupSubmit": 109, 318 "routes.AccountEditMFADisableSubmit": 110, 319 "routes.AccountEditEmail": 111, 320 "routes.AccountEditEmailTokenSubmit": 112, 321 "routes.AccountLogins": 113, 322 "routes.AccountBlocked": 114, 323 "routes.LevelList": 115, 324 "routes.Convos": 116, 325 "routes.ConvosCreate": 117, 326 "routes.Convo": 118, 327 "routes.ConvosCreateSubmit": 119, 328 "routes.ConvosCreateReplySubmit": 120, 329 "routes.ConvosDeleteReplySubmit": 121, 330 "routes.ConvosEditReplySubmit": 122, 331 "routes.RelationsBlockCreate": 123, 332 "routes.RelationsBlockCreateSubmit": 124, 333 "routes.RelationsBlockRemove": 125, 334 "routes.RelationsBlockRemoveSubmit": 126, 335 "routes.ViewProfile": 127, 336 "routes.BanUserSubmit": 128, 337 "routes.UnbanUser": 129, 338 "routes.ActivateUser": 130, 339 "routes.IPSearch": 131, 340 "routes.DeletePostsSubmit": 132, 341 "routes.CreateTopicSubmit": 133, 342 "routes.EditTopicSubmit": 134, 343 "routes.DeleteTopicSubmit": 135, 344 "routes.StickTopicSubmit": 136, 345 "routes.UnstickTopicSubmit": 137, 346 "routes.LockTopicSubmit": 138, 347 "routes.UnlockTopicSubmit": 139, 348 "routes.MoveTopicSubmit": 140, 349 "routes.LikeTopicSubmit": 141, 350 "routes.UnlikeTopicSubmit": 142, 351 "routes.AddAttachToTopicSubmit": 143, 352 "routes.RemoveAttachFromTopicSubmit": 144, 353 "routes.ViewTopic": 145, 354 "routes.CreateReplySubmit": 146, 355 "routes.ReplyEditSubmit": 147, 356 "routes.ReplyDeleteSubmit": 148, 357 "routes.ReplyLikeSubmit": 149, 358 "routes.ReplyUnlikeSubmit": 150, 359 "routes.AddAttachToReplySubmit": 151, 360 "routes.RemoveAttachFromReplySubmit": 152, 361 "routes.ProfileReplyCreateSubmit": 153, 362 "routes.ProfileReplyEditSubmit": 154, 363 "routes.ProfileReplyDeleteSubmit": 155, 364 "routes.PollVote": 156, 365 "routes.PollResults": 157, 366 "routes.AccountLogin": 158, 367 "routes.AccountRegister": 159, 368 "routes.AccountLogout": 160, 369 "routes.AccountLoginSubmit": 161, 370 "routes.AccountLoginMFAVerify": 162, 371 "routes.AccountLoginMFAVerifySubmit": 163, 372 "routes.AccountRegisterSubmit": 164, 373 "routes.AccountPasswordReset": 165, 374 "routes.AccountPasswordResetSubmit": 166, 375 "routes.AccountPasswordResetToken": 167, 376 "routes.AccountPasswordResetTokenSubmit": 168, 377 "routes.DynamicRoute": 169, 378 "routes.UploadedFile": 170, 379 "routes.StaticFile": 171, 380 "routes.RobotsTxt": 172, 381 "routes.SitemapXml": 173, 382 "routes.OpenSearchXml": 174, 383 "routes.Favicon": 175, 384 "routes.BadRoute": 176, 385 "routes.HTTPSRedirect": 177, 386 } 387 var reverseRouteMapEnum = map[int]string{ 388 0: "routes.Error", 389 1: "routes.Overview", 390 2: "routes.CustomPage", 391 3: "routes.ForumList", 392 4: "routes.ViewForum", 393 5: "routes.ChangeTheme", 394 6: "routes.ShowAttachment", 395 7: "common.RouteWebsockets", 396 8: "routeAPIPhrases", 397 9: "routes.APIMe", 398 10: "routeJSAntispam", 399 11: "routeAPI", 400 12: "routes.ReportSubmit", 401 13: "routes.TopicListMostViewed", 402 14: "routes.TopicListWeekViews", 403 15: "routes.CreateTopic", 404 16: "routes.TopicList", 405 17: "panel.Forums", 406 18: "panel.ForumsCreateSubmit", 407 19: "panel.ForumsDelete", 408 20: "panel.ForumsDeleteSubmit", 409 21: "panel.ForumsOrderSubmit", 410 22: "panel.ForumsEdit", 411 23: "panel.ForumsEditSubmit", 412 24: "panel.ForumsEditPermsSubmit", 413 25: "panel.ForumsEditPermsAdvance", 414 26: "panel.ForumsEditPermsAdvanceSubmit", 415 27: "panel.ForumsEditActionCreateSubmit", 416 28: "panel.ForumsEditActionDeleteSubmit", 417 29: "panel.Settings", 418 30: "panel.SettingEdit", 419 31: "panel.SettingEditSubmit", 420 32: "panel.WordFilters", 421 33: "panel.WordFiltersCreateSubmit", 422 34: "panel.WordFiltersEdit", 423 35: "panel.WordFiltersEditSubmit", 424 36: "panel.WordFiltersDeleteSubmit", 425 37: "panel.Pages", 426 38: "panel.PagesCreateSubmit", 427 39: "panel.PagesEdit", 428 40: "panel.PagesEditSubmit", 429 41: "panel.PagesDeleteSubmit", 430 42: "panel.Themes", 431 43: "panel.ThemesSetDefault", 432 44: "panel.ThemesMenus", 433 45: "panel.ThemesMenusEdit", 434 46: "panel.ThemesMenuItemEdit", 435 47: "panel.ThemesMenuItemEditSubmit", 436 48: "panel.ThemesMenuItemCreateSubmit", 437 49: "panel.ThemesMenuItemDeleteSubmit", 438 50: "panel.ThemesMenuItemOrderSubmit", 439 51: "panel.ThemesWidgets", 440 52: "panel.ThemesWidgetsEditSubmit", 441 53: "panel.ThemesWidgetsCreateSubmit", 442 54: "panel.ThemesWidgetsDeleteSubmit", 443 55: "panel.Plugins", 444 56: "panel.PluginsActivate", 445 57: "panel.PluginsDeactivate", 446 58: "panel.PluginsInstall", 447 59: "panel.Users", 448 60: "panel.UsersEdit", 449 61: "panel.UsersEditSubmit", 450 62: "panel.UsersAvatarSubmit", 451 63: "panel.UsersAvatarRemoveSubmit", 452 64: "panel.AnalyticsViews", 453 65: "panel.AnalyticsRoutes", 454 66: "panel.AnalyticsRoutesPerf", 455 67: "panel.AnalyticsAgents", 456 68: "panel.AnalyticsSystems", 457 69: "panel.AnalyticsLanguages", 458 70: "panel.AnalyticsReferrers", 459 71: "panel.AnalyticsRouteViews", 460 72: "panel.AnalyticsAgentViews", 461 73: "panel.AnalyticsForumViews", 462 74: "panel.AnalyticsSystemViews", 463 75: "panel.AnalyticsLanguageViews", 464 76: "panel.AnalyticsReferrerViews", 465 77: "panel.AnalyticsPosts", 466 78: "panel.AnalyticsMemory", 467 79: "panel.AnalyticsActiveMemory", 468 80: "panel.AnalyticsTopics", 469 81: "panel.AnalyticsForums", 470 82: "panel.AnalyticsPerf", 471 83: "panel.Groups", 472 84: "panel.GroupsEdit", 473 85: "panel.GroupsEditPromotions", 474 86: "panel.GroupsPromotionsCreateSubmit", 475 87: "panel.GroupsPromotionsDeleteSubmit", 476 88: "panel.GroupsEditPerms", 477 89: "panel.GroupsEditSubmit", 478 90: "panel.GroupsEditPermsSubmit", 479 91: "panel.GroupsCreateSubmit", 480 92: "panel.Backups", 481 93: "panel.LogsRegs", 482 94: "panel.LogsMod", 483 95: "panel.LogsAdmin", 484 96: "panel.Debug", 485 97: "panel.DebugTasks", 486 98: "panel.Dashboard", 487 99: "routes.AccountEdit", 488 100: "routes.AccountEditPassword", 489 101: "routes.AccountEditPasswordSubmit", 490 102: "routes.AccountEditAvatarSubmit", 491 103: "routes.AccountEditRevokeAvatarSubmit", 492 104: "routes.AccountEditUsernameSubmit", 493 105: "routes.AccountEditPrivacy", 494 106: "routes.AccountEditPrivacySubmit", 495 107: "routes.AccountEditMFA", 496 108: "routes.AccountEditMFASetup", 497 109: "routes.AccountEditMFASetupSubmit", 498 110: "routes.AccountEditMFADisableSubmit", 499 111: "routes.AccountEditEmail", 500 112: "routes.AccountEditEmailTokenSubmit", 501 113: "routes.AccountLogins", 502 114: "routes.AccountBlocked", 503 115: "routes.LevelList", 504 116: "routes.Convos", 505 117: "routes.ConvosCreate", 506 118: "routes.Convo", 507 119: "routes.ConvosCreateSubmit", 508 120: "routes.ConvosCreateReplySubmit", 509 121: "routes.ConvosDeleteReplySubmit", 510 122: "routes.ConvosEditReplySubmit", 511 123: "routes.RelationsBlockCreate", 512 124: "routes.RelationsBlockCreateSubmit", 513 125: "routes.RelationsBlockRemove", 514 126: "routes.RelationsBlockRemoveSubmit", 515 127: "routes.ViewProfile", 516 128: "routes.BanUserSubmit", 517 129: "routes.UnbanUser", 518 130: "routes.ActivateUser", 519 131: "routes.IPSearch", 520 132: "routes.DeletePostsSubmit", 521 133: "routes.CreateTopicSubmit", 522 134: "routes.EditTopicSubmit", 523 135: "routes.DeleteTopicSubmit", 524 136: "routes.StickTopicSubmit", 525 137: "routes.UnstickTopicSubmit", 526 138: "routes.LockTopicSubmit", 527 139: "routes.UnlockTopicSubmit", 528 140: "routes.MoveTopicSubmit", 529 141: "routes.LikeTopicSubmit", 530 142: "routes.UnlikeTopicSubmit", 531 143: "routes.AddAttachToTopicSubmit", 532 144: "routes.RemoveAttachFromTopicSubmit", 533 145: "routes.ViewTopic", 534 146: "routes.CreateReplySubmit", 535 147: "routes.ReplyEditSubmit", 536 148: "routes.ReplyDeleteSubmit", 537 149: "routes.ReplyLikeSubmit", 538 150: "routes.ReplyUnlikeSubmit", 539 151: "routes.AddAttachToReplySubmit", 540 152: "routes.RemoveAttachFromReplySubmit", 541 153: "routes.ProfileReplyCreateSubmit", 542 154: "routes.ProfileReplyEditSubmit", 543 155: "routes.ProfileReplyDeleteSubmit", 544 156: "routes.PollVote", 545 157: "routes.PollResults", 546 158: "routes.AccountLogin", 547 159: "routes.AccountRegister", 548 160: "routes.AccountLogout", 549 161: "routes.AccountLoginSubmit", 550 162: "routes.AccountLoginMFAVerify", 551 163: "routes.AccountLoginMFAVerifySubmit", 552 164: "routes.AccountRegisterSubmit", 553 165: "routes.AccountPasswordReset", 554 166: "routes.AccountPasswordResetSubmit", 555 167: "routes.AccountPasswordResetToken", 556 168: "routes.AccountPasswordResetTokenSubmit", 557 169: "routes.DynamicRoute", 558 170: "routes.UploadedFile", 559 171: "routes.StaticFile", 560 172: "routes.RobotsTxt", 561 173: "routes.SitemapXml", 562 174: "routes.OpenSearchXml", 563 175: "routes.Favicon", 564 176: "routes.BadRoute", 565 177: "routes.HTTPSRedirect", 566 } 567 var osMapEnum = map[string]int{ 568 "unknown": 0, 569 "windows": 1, 570 "linux": 2, 571 "mac": 3, 572 "android": 4, 573 "iphone": 5, 574 } 575 var reverseOSMapEnum = map[int]string{ 576 0: "unknown", 577 1: "windows", 578 2: "linux", 579 3: "mac", 580 4: "android", 581 5: "iphone", 582 } 583 var agentMapEnum = map[string]int{ 584 "unknown": 0, 585 "opera": 1, 586 "chrome": 2, 587 "firefox": 3, 588 "safari": 4, 589 "edge": 5, 590 "internetexplorer": 6, 591 "trident": 7, 592 "androidchrome": 8, 593 "mobilesafari": 9, 594 "samsung": 10, 595 "ucbrowser": 11, 596 "googlebot": 12, 597 "yandex": 13, 598 "bing": 14, 599 "slurp": 15, 600 "exabot": 16, 601 "mojeek": 17, 602 "cliqz": 18, 603 "qwant": 19, 604 "datenbank": 20, 605 "baidu": 21, 606 "sogou": 22, 607 "toutiao": 23, 608 "haosou": 24, 609 "duckduckgo": 25, 610 "seznambot": 26, 611 "discord": 27, 612 "telegram": 28, 613 "twitter": 29, 614 "facebook": 30, 615 "cloudflare": 31, 616 "archive_org": 32, 617 "uptimebot": 33, 618 "slackbot": 34, 619 "apple": 35, 620 "discourse": 36, 621 "xenforo": 37, 622 "mattermost": 38, 623 "alexa": 39, 624 "lynx": 40, 625 "blank": 41, 626 "malformed": 42, 627 "suspicious": 43, 628 "semrush": 44, 629 "dotbot": 45, 630 "ahrefs": 46, 631 "proximic": 47, 632 "megaindex": 48, 633 "majestic": 49, 634 "cocolyze": 50, 635 "babbar": 51, 636 "surdotly": 52, 637 "domcop": 53, 638 "netcraft": 54, 639 "seostar": 55, 640 "pandalytics": 56, 641 "blexbot": 57, 642 "wappalyzer": 58, 643 "twingly": 59, 644 "linkfluence": 60, 645 "pagething": 61, 646 "burf": 62, 647 "aspiegel": 63, 648 "mail_ru": 64, 649 "ccbot": 65, 650 "yacy": 66, 651 "zgrab": 67, 652 "cloudsystemnetworks": 68, 653 "maui": 69, 654 "curl": 70, 655 "python": 71, 656 "headlesschrome": 72, 657 "awesome_bot": 73, 658 } 659 var reverseAgentMapEnum = map[int]string{ 660 0: "unknown", 661 1: "opera", 662 2: "chrome", 663 3: "firefox", 664 4: "safari", 665 5: "edge", 666 6: "internetexplorer", 667 7: "trident", 668 8: "androidchrome", 669 9: "mobilesafari", 670 10: "samsung", 671 11: "ucbrowser", 672 12: "googlebot", 673 13: "yandex", 674 14: "bing", 675 15: "slurp", 676 16: "exabot", 677 17: "mojeek", 678 18: "cliqz", 679 19: "qwant", 680 20: "datenbank", 681 21: "baidu", 682 22: "sogou", 683 23: "toutiao", 684 24: "haosou", 685 25: "duckduckgo", 686 26: "seznambot", 687 27: "discord", 688 28: "telegram", 689 29: "twitter", 690 30: "facebook", 691 31: "cloudflare", 692 32: "archive_org", 693 33: "uptimebot", 694 34: "slackbot", 695 35: "apple", 696 36: "discourse", 697 37: "xenforo", 698 38: "mattermost", 699 39: "alexa", 700 40: "lynx", 701 41: "blank", 702 42: "malformed", 703 43: "suspicious", 704 44: "semrush", 705 45: "dotbot", 706 46: "ahrefs", 707 47: "proximic", 708 48: "megaindex", 709 49: "majestic", 710 50: "cocolyze", 711 51: "babbar", 712 52: "surdotly", 713 53: "domcop", 714 54: "netcraft", 715 55: "seostar", 716 56: "pandalytics", 717 57: "blexbot", 718 58: "wappalyzer", 719 59: "twingly", 720 60: "linkfluence", 721 61: "pagething", 722 62: "burf", 723 63: "aspiegel", 724 64: "mail_ru", 725 65: "ccbot", 726 66: "yacy", 727 67: "zgrab", 728 68: "cloudsystemnetworks", 729 69: "maui", 730 70: "curl", 731 71: "python", 732 72: "headlesschrome", 733 73: "awesome_bot", 734 } 735 var markToAgent = map[string]string{ 736 "OPR": "opera", 737 "Chrome": "chrome", 738 "Firefox": "firefox", 739 "Safari": "safari", 740 "MSIE": "internetexplorer", 741 "Trident": "trident", 742 "Edge": "edge", 743 "Lynx": "lynx", 744 "SamsungBrowser": "samsung", 745 "UCBrowser": "ucbrowser", 746 "Google": "googlebot", 747 "Googlebot": "googlebot", 748 "yandex": "yandex", 749 "DuckDuckBot": "duckduckgo", 750 "DuckDuckGo": "duckduckgo", 751 "Baiduspider": "baidu", 752 "Sogou": "sogou", 753 "ToutiaoSpider": "toutiao", 754 "Bytespider": "toutiao", 755 "360Spider": "haosou", 756 "bingbot": "bing", 757 "BingPreview": "bing", 758 "msnbot": "bing", 759 "Slurp": "slurp", 760 "Exabot": "exabot", 761 "MojeekBot": "mojeek", 762 "Cliqzbot": "cliqz", 763 "Qwantify": "qwant", 764 "netEstate": "datenbank", 765 "SeznamBot": "seznambot", 766 "CloudFlare": "cloudflare", 767 "archive": "archive_org", 768 "Uptimebot": "uptimebot", 769 "Slackbot": "slackbot", 770 "Slack": "slackbot", 771 "Discordbot": "discord", 772 "TelegramBot": "telegram", 773 "Twitterbot": "twitter", 774 "facebookexternalhit": "facebook", 775 "Facebot": "facebook", 776 "Applebot": "apple", 777 "Discourse": "discourse", 778 "XenForo": "xenforo", 779 "mattermost": "mattermost", 780 "ia_archiver": "alexa", 781 "SemrushBot": "semrush", 782 "DotBot": "dotbot", 783 "AhrefsBot": "ahrefs", 784 "proximic": "proximic", 785 "MegaIndex": "megaindex", 786 "MJ12bot": "majestic", 787 "mj12bot": "majestic", 788 "Cocolyzebot": "cocolyze", 789 "Barkrowler": "babbar", 790 "SurdotlyBot": "surdotly", 791 "DomCopBot": "domcop", 792 "NetcraftSurveyAgent": "netcraft", 793 "seostar": "seostar", 794 "Pandalytics": "pandalytics", 795 "BLEXBot": "blexbot", 796 "Wappalyzer": "wappalyzer", 797 "Twingly": "twingly", 798 "linkfluence": "linkfluence", 799 "PageThing": "pagething", 800 "Burf": "burf", 801 "AspiegelBot": "aspiegel", 802 "PetalBot": "aspiegel", 803 "RU_Bot": "mail_ru", 804 "CCBot": "ccbot", 805 "yacybot": "yacy", 806 "zgrab": "zgrab", 807 "Nimbostratus": "cloudsystemnetworks", 808 "MauiBot": "maui", 809 "curl": "curl", 810 "python": "python", 811 "HeadlessChrome": "headlesschrome", 812 "awesome_bot": "awesome_bot", 813 } 814 var markToID = map[string]int{ 815 "OPR": 1, 816 "Chrome": 2, 817 "Firefox": 3, 818 "Safari": 4, 819 "MSIE": 6, 820 "Trident": 7, 821 "Edge": 5, 822 "Lynx": 40, 823 "SamsungBrowser": 10, 824 "UCBrowser": 11, 825 "Google": 12, 826 "Googlebot": 12, 827 "yandex": 13, 828 "DuckDuckBot": 25, 829 "DuckDuckGo": 25, 830 "Baiduspider": 21, 831 "Sogou": 22, 832 "ToutiaoSpider": 23, 833 "Bytespider": 23, 834 "360Spider": 24, 835 "bingbot": 14, 836 "BingPreview": 14, 837 "msnbot": 14, 838 "Slurp": 15, 839 "Exabot": 16, 840 "MojeekBot": 17, 841 "Cliqzbot": 18, 842 "Qwantify": 19, 843 "netEstate": 20, 844 "SeznamBot": 26, 845 "CloudFlare": 31, 846 "archive": 32, 847 "Uptimebot": 33, 848 "Slackbot": 34, 849 "Slack": 34, 850 "Discordbot": 27, 851 "TelegramBot": 28, 852 "Twitterbot": 29, 853 "facebookexternalhit": 30, 854 "Facebot": 30, 855 "Applebot": 35, 856 "Discourse": 36, 857 "XenForo": 37, 858 "mattermost": 38, 859 "ia_archiver": 39, 860 "SemrushBot": 44, 861 "DotBot": 45, 862 "AhrefsBot": 46, 863 "proximic": 47, 864 "MegaIndex": 48, 865 "MJ12bot": 49, 866 "mj12bot": 49, 867 "Cocolyzebot": 50, 868 "Barkrowler": 51, 869 "SurdotlyBot": 52, 870 "DomCopBot": 53, 871 "NetcraftSurveyAgent": 54, 872 "seostar": 55, 873 "Pandalytics": 56, 874 "BLEXBot": 57, 875 "Wappalyzer": 58, 876 "Twingly": 59, 877 "linkfluence": 60, 878 "PageThing": 61, 879 "Burf": 62, 880 "AspiegelBot": 63, 881 "PetalBot": 63, 882 "RU_Bot": 64, 883 "CCBot": 65, 884 "yacybot": 66, 885 "zgrab": 67, 886 "Nimbostratus": 68, 887 "MauiBot": 69, 888 "curl": 70, 889 "python": 71, 890 "HeadlessChrome": 72, 891 "awesome_bot": 73, 892 } 893 /*var agentRank = map[string]int{ 894 "opera":9, 895 "chrome":8, 896 "safari":1, 897 }*/ 898 899 // HTTPSRedirect is a connection handler which redirects all HTTP requests to HTTPS 900 type HTTPSRedirect struct {} 901 902 func (red *HTTPSRedirect) ServeHTTP(w http.ResponseWriter, req *http.Request) { 903 w.Header().Set("Connection", "close") 904 co.RouteViewCounter.Bump(177) 905 dest := "https://" + req.Host + req.URL.String() 906 http.Redirect(w, req, dest, http.StatusTemporaryRedirect) 907 } 908 909 func (r *GenRouter) SuspiciousRequest(req *http.Request, pre string) { 910 if c.Config.DisableSuspLog { 911 return 912 } 913 var sb strings.Builder 914 if pre != "" { 915 sb.WriteString("Suspicious Request\n") 916 } else { 917 pre = "Suspicious Request" 918 } 919 r.ddumpRequest(req,pre,r.suspLog,&sb) 920 co.AgentViewCounter.Bump(43) 921 } 922 923 // TODO: Pass the default path or config struct to the router rather than accessing it via a package global 924 // TODO: SetDefaultPath 925 // TODO: GetDefaultPath 926 func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { 927 malformedRequest := func(typ int) { 928 w.WriteHeader(200) // 400 929 w.Write([]byte("")) 930 r.DumpRequest(req,"Malformed Request T"+strconv.Itoa(typ)) 931 co.AgentViewCounter.Bump(42) 932 } 933 934 // Split the Host and Port string 935 var shost, sport string 936 if req.Host[0]=='[' { 937 spl := strings.Split(req.Host,"]") 938 if len(spl) > 2 { 939 malformedRequest(0) 940 return 941 } 942 shost = strings.TrimPrefix(spl[0],"[") 943 sport = strings.TrimPrefix(spl[1],":") 944 } else if strings.Contains(req.Host,":") { 945 spl := strings.Split(req.Host,":") 946 if len(spl) > 2 { 947 malformedRequest(1) 948 return 949 } 950 shost = spl[0] 951 //if len(spl)==2 { 952 sport = spl[1] 953 //} 954 } else { 955 shost = req.Host 956 } 957 // TODO: Reject requests from non-local IPs, if the site host is set to localhost or a localhost IP 958 if !c.Config.LoosePort && c.Site.PortInt != 80 && c.Site.PortInt != 443 && sport != c.Site.Port { 959 malformedRequest(2) 960 return 961 } 962 963 // Redirect www. and local IP requests to the right place 964 if strings.HasPrefix(shost, "www.") || c.Site.LocalHost { 965 if shost == "www." + c.Site.Host || (c.Site.LocalHost && shost != c.Site.Host && isLocalHost(shost)) { 966 // TODO: Abstract the redirect logic? 967 w.Header().Set("Connection", "close") 968 var s, p string 969 if c.Config.SslSchema { 970 s = "s" 971 } 972 if c.Site.PortInt != 80 && c.Site.PortInt != 443 { 973 p = ":"+c.Site.Port 974 } 975 dest := "http"+s+"://" + c.Site.Host+p + req.URL.Path 976 if len(req.URL.RawQuery) > 0 { 977 dest += "?" + req.URL.RawQuery 978 } 979 http.Redirect(w, req, dest, http.StatusMovedPermanently) 980 return 981 } 982 } 983 984 // Deflect malformed requests 985 if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || (!c.Config.LooseHost && shost != c.Site.Host) { 986 malformedRequest(3) 987 return 988 } 989 r.suspScan(req) 990 991 // Indirect the default route onto a different one 992 if req.URL.Path == "/" { 993 req.URL.Path = c.Config.DefaultPath 994 } 995 //log.Print("URL.Path: ", req.URL.Path) 996 prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1] 997 998 // TODO: Use the same hook table as downstream 999 hTbl := c.GetHookTable() 1000 skip, ferr := c.H_router_after_filters_hook(hTbl, w, req, prefix) 1001 if skip || ferr != nil { 1002 return 1003 } 1004 1005 if prefix != "/ws" { 1006 h := w.Header() 1007 h.Set("X-Frame-Options", "deny") 1008 h.Set("X-XSS-Protection", "1; mode=block") // TODO: Remove when we add a CSP? CSP's are horrendously glitchy things, tread with caution before removing 1009 h.Set("X-Content-Type-Options", "nosniff") 1010 if c.Config.RefNoRef || !c.Config.SslSchema { 1011 h.Set("Referrer-Policy","no-referrer") 1012 } else { 1013 h.Set("Referrer-Policy","strict-origin") 1014 } 1015 h.Set("Permissions-Policy","interest-cohort=()") 1016 } 1017 1018 if c.Dev.SuperDebug { 1019 r.DumpRequest(req,"before routes.StaticFile") 1020 } 1021 // Increment the request counter 1022 if !c.Config.DisableAnalytics { 1023 co.GlobalViewCounter.Bump() 1024 } 1025 1026 if prefix == "/s" { //old prefix: /static 1027 if !c.Config.DisableAnalytics { 1028 co.RouteViewCounter.Bump(171) 1029 } 1030 routes.StaticFile(w, req) 1031 return 1032 } 1033 // TODO: Handle JS routes 1034 if atomic.LoadInt32(&c.IsDBDown) == 1 { 1035 c.DatabaseError(w, req) 1036 return 1037 } 1038 if c.Dev.SuperDebug { 1039 r.reqLogger.Print("before PreRoute") 1040 } 1041 1042 /*if c.Dev.QuicPort != 0 { 1043 sQuicPort := strconv.Itoa(c.Dev.QuicPort) 1044 w.Header().Set("Alt-Svc", "quic=\":"+sQuicPort+"\"; ma=2592000; v=\"44,43,39\", h3-23=\":"+sQuicPort+"\"; ma=3600, h3-24=\":"+sQuicPort+"\"; ma=3600, h2=\":443\"; ma=3600") 1045 }*/ 1046 1047 // Track the user agents. Unfortunately, everyone pretends to be Mozilla, so this'll be a little less efficient than I would like. 1048 // TODO: Add a setting to disable this? 1049 // TODO: Use a more efficient detector instead of smashing every possible combination in 1050 // TODO: Make this testable 1051 var agent int 1052 if !c.Config.DisableAnalytics { 1053 1054 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 1055 if ua == "" { 1056 co.AgentViewCounter.Bump(41) 1057 r.unknownUA(req) 1058 } else { 1059 // WIP UA Parser 1060 //var ii = uaBufPool.Get() 1061 var buf []byte 1062 //if ii != nil { 1063 // buf = ii.([]byte) 1064 //} 1065 var items []string 1066 var os int 1067 for _, it := range uutils.StringToBytes(ua) { 1068 if (it > 64 && it < 91) || (it > 96 && it < 123) || (it > 47 && it < 58) || it == '_' { 1069 // TODO: Store an index and slice that instead? 1070 buf = append(buf, it) 1071 } else if it == ' ' || it == '(' || it == ')' || it == '-' || it == ';' || it == ':' || it == '.' || it == '+' || it == '~' || it == '@' /*|| (it == ':' && bytes.Equal(buf,[]byte("http")))*/ || it == ',' || it == '/' { 1072 //log.Print("buf: ",string(buf)) 1073 //log.Print("it: ",string(it)) 1074 if len(buf) != 0 { 1075 if len(buf) > 2 { 1076 // Use an unsafe zero copy conversion here just to use the switch, it's not safe for this string to escape from here, as it will get mutated, so do a regular string conversion in append 1077 switch(uutils.BytesToString(buf)) { 1078 case "Windows": 1079 os = 1 1080 case "Linux": 1081 os = 2 1082 case "Mac": 1083 os = 3 1084 case "iPhone": 1085 os = 5 1086 case "Android": 1087 os = 4 1088 case "like","compatible","NT","X","com","KHTML": 1089 // Skip these words 1090 default: 1091 //log.Print("append buf") 1092 items = append(items, string(buf)) 1093 } 1094 } 1095 //log.Print("reset buf") 1096 buf = buf[:0] 1097 } 1098 } else { 1099 // TODO: Test this 1100 items = items[:0] 1101 if c.Config.DisableSuspLog { 1102 r.reqLogger.Print("Illegal char "+strconv.Itoa(int(it))+" in UA\nUA Buf: ", buf,"\nUA Buf String: ", string(buf)) 1103 } else { 1104 r.SuspiciousRequest(req,"Illegal char "+strconv.Itoa(int(it))+" in UA") 1105 r.reqLogger.Print("UA Buf: ", buf,"\nUA Buf String: ", string(buf)) 1106 } 1107 break 1108 } 1109 } 1110 //uaBufPool.Put(buf) 1111 1112 // Iterate over this in reverse as the real UA tends to be on the right side 1113 for i := len(items) - 1; i >= 0; i-- { 1114 //fAgent, ok := markToAgent[items[i]] 1115 fAgent, ok := markToID[items[i]] 1116 if ok { 1117 agent = fAgent 1118 if agent != 4 { 1119 break 1120 } 1121 } 1122 } 1123 if c.Dev.SuperDebug { 1124 r.reqLogger.Print("parsed agent: ", agent,"\nos: ", os) 1125 r.reqLogger.Printf("items: %+v\n",items) 1126 /*for _, it := range items { 1127 r.reqLogger.Printf("it: %+v\n",string(it)) 1128 }*/ 1129 } 1130 1131 // Special handling 1132 switch(agent) { 1133 case 2: 1134 if os == 4 { 1135 agent = 8 1136 } 1137 case 4: 1138 if os == 5 { 1139 agent = 9 1140 } 1141 case 7: 1142 // Hack to support IE11, change this after we start logging versions 1143 if strings.Contains(ua,"rv:11") { 1144 agent = 6 1145 } 1146 case 67: 1147 w.WriteHeader(200) // 400 1148 w.Write([]byte("")) 1149 r.DumpRequest(req,"Blocked Scanner") 1150 co.AgentViewCounter.Bump(67) 1151 return 1152 } 1153 1154 if agent == 0 { 1155 //co.AgentViewCounter.Bump(0) 1156 r.unknownUA(req) 1157 }// else { 1158 //co.AgentViewCounter.Bump(agentMapEnum[agent]) 1159 co.AgentViewCounter.Bump(agent) 1160 //} 1161 co.OSViewCounter.Bump(os) 1162 } 1163 1164 // TODO: Do we want to track missing language headers too? Maybe as it's own type, e.g. "noheader"? 1165 // TODO: Default to anything other than en, if anything else is present, to avoid over-representing it for multi-linguals? 1166 lang := req.Header.Get("Accept-Language") 1167 if lang != "" { 1168 // TODO: Reduce allocs here 1169 lLang := strings.Split(strings.TrimSpace(lang),"-") 1170 tLang := strings.Split(strings.Split(lLang[0],";")[0],",") 1171 c.DebugDetail("tLang:", tLang) 1172 var llLang string 1173 for _, seg := range tLang { 1174 if seg == "*" { 1175 continue 1176 } 1177 llLang = seg 1178 break 1179 } 1180 c.DebugDetail("llLang:", llLang) 1181 if !co.LangViewCounter.Bump(llLang) { 1182 r.DumpRequest(req,"Invalid ISO Code") 1183 } 1184 } else { 1185 co.LangViewCounter.Bump2(0) 1186 } 1187 1188 if !c.Config.RefNoTrack { 1189 ae := req.Header.Get("Accept-Encoding") 1190 likelyBot := ae == "gzip" || ae == "" 1191 if !likelyBot { 1192 ref := req.Header.Get("Referer") // Check the 'referrer' header too? :P 1193 // TODO: Extend the effects of DNT elsewhere? 1194 if ref != "" && req.Header.Get("DNT") != "1" { 1195 // ? Optimise this a little? 1196 ref = strings.TrimPrefix(strings.TrimPrefix(ref,"http://"),"https://") 1197 ref = strings.Split(ref,"/")[0] 1198 portless := strings.Split(ref,":")[0] 1199 // TODO: Handle c.Site.Host in uppercase too? 1200 if portless != "localhost" && portless != "127.0.0.1" && portless != c.Site.Host { 1201 r.DumpRequest(req,"Ref Route") 1202 co.ReferrerTracker.Bump(ref) 1203 } 1204 } 1205 } 1206 } 1207 1208 } 1209 1210 // Deal with the session stuff, etc. 1211 ucpy, ok := c.PreRoute(w, req) 1212 if !ok { 1213 return 1214 } 1215 user := &ucpy 1216 user.LastAgent = agent 1217 if c.Dev.SuperDebug { 1218 r.reqLogger.Print( 1219 "after PreRoute\n" + 1220 "routeMapEnum: ", routeMapEnum) 1221 } 1222 //log.Println("req: ", req) 1223 1224 // Disable Gzip when SSL is disabled for security reasons? 1225 if prefix != "/ws" { 1226 ae := req.Header.Get("Accept-Encoding") 1227 /*if strings.Contains(ae, "br") { 1228 h := w.Header() 1229 h.Set("Content-Encoding", "br") 1230 var ii = brPool.Get() 1231 var igzw *brotli.Writer 1232 if ii == nil { 1233 igzw = brotli.NewWriter(w) 1234 } else { 1235 igzw = ii.(*brotli.Writer) 1236 igzw.Reset(w) 1237 } 1238 gzw := c.BrResponseWriter{Writer: igzw, ResponseWriter: w} 1239 defer func() { 1240 //h := w.Header() 1241 if h.Get("Content-Encoding") == "br" && h.Get("X-I") == "" { 1242 //log.Print("push br close") 1243 igzw := gzw.Writer.(*brotli.Writer) 1244 igzw.Close() 1245 brPool.Put(igzw) 1246 } 1247 }() 1248 w = gzw 1249 } else */if strings.Contains(ae, "gzip") { 1250 h := w.Header() 1251 h.Set("Content-Encoding", "gzip") 1252 var ii = gzipPool.Get() 1253 var igzw *gzip.Writer 1254 if ii == nil { 1255 igzw = gzip.NewWriter(w) 1256 } else { 1257 igzw = ii.(*gzip.Writer) 1258 igzw.Reset(w) 1259 } 1260 gzw := c.GzipResponseWriter{Writer: igzw, ResponseWriter: w} 1261 defer func() { 1262 //h := w.Header() 1263 if h.Get("Content-Encoding") == "gzip" && h.Get("X-I") == "" { 1264 //log.Print("push gzip close") 1265 igzw := gzw.Writer.(*gzip.Writer) 1266 igzw.Close() 1267 gzipPool.Put(igzw) 1268 } 1269 }() 1270 w = gzw 1271 } 1272 } 1273 1274 skip, ferr = c.H_router_pre_route_hook(hTbl, w, req, user, prefix) 1275 if skip || ferr != nil { 1276 r.handleError(ferr,w,req,user) 1277 return 1278 } 1279 var extraData string 1280 if req.URL.Path[len(req.URL.Path) - 1] != '/' { 1281 extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] 1282 req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] 1283 } 1284 ferr = r.routeSwitch(w, req, user, prefix, extraData) 1285 if ferr != nil { 1286 r.handleError(ferr,w,req,user) 1287 return 1288 } 1289 /*if !c.Config.DisableAnalytics { 1290 co.RouteViewCounter.Bump(id) 1291 }*/ 1292 1293 hTbl.VhookNoRet("router_end", w, req, user, prefix, extraData) 1294 //c.StoppedServer("Profile end") 1295 } 1296 1297 func (r *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, user *c.User, prefix, extraData string) /*(id int, orerr */c.RouteError/*)*/ { 1298 var err c.RouteError 1299 cn := uutils.Nanotime() 1300 switch(prefix) { 1301 case "/overview": 1302 h, err := c.UserCheckNano(w,req,user,cn) 1303 if err != nil { 1304 return err 1305 } 1306 err = routes.Overview(w,req,user,h) 1307 co.RouteViewCounter.Bump3(1, cn) 1308 case "/pages": 1309 h, err := c.UserCheckNano(w,req,user,cn) 1310 if err != nil { 1311 return err 1312 } 1313 err = routes.CustomPage(w,req,user,h,extraData) 1314 co.RouteViewCounter.Bump3(2, cn) 1315 case "/forums": 1316 h, err := c.UserCheckNano(w,req,user,cn) 1317 if err != nil { 1318 return err 1319 } 1320 err = routes.ForumList(w,req,user,h) 1321 co.RouteViewCounter.Bump3(3, cn) 1322 case "/forum": 1323 h, err := c.UserCheckNano(w,req,user,cn) 1324 if err != nil { 1325 return err 1326 } 1327 err = routes.ViewForum(w,req,user,h,extraData) 1328 co.RouteViewCounter.Bump3(4, cn) 1329 case "/theme": 1330 err = c.ParseForm(w,req,user) 1331 if err != nil { 1332 return err 1333 } 1334 1335 err = routes.ChangeTheme(w,req,user) 1336 co.RouteViewCounter.Bump3(5, cn) 1337 case "/attachs": 1338 err = c.ParseForm(w,req,user) 1339 if err != nil { 1340 return err 1341 } 1342 1343 w = r.responseWriter(w) 1344 err = routes.ShowAttachment(w,req,user,extraData) 1345 co.RouteViewCounter.Bump3(6, cn) 1346 case "/ws": 1347 req.URL.Path += extraData 1348 err = c.RouteWebsockets(w,req,user) 1349 case "/api": 1350 switch(req.URL.Path) { 1351 case "/api/phrases/": 1352 err = routeAPIPhrases(w,req,user) 1353 co.RouteViewCounter.Bump3(8, cn) 1354 case "/api/me/": 1355 err = routes.APIMe(w,req,user) 1356 co.RouteViewCounter.Bump3(9, cn) 1357 case "/api/watches/": 1358 err = routeJSAntispam(w,req,user) 1359 co.RouteViewCounter.Bump3(10, cn) 1360 default: 1361 err = routeAPI(w,req,user) 1362 co.RouteViewCounter.Bump3(11, cn) 1363 } 1364 case "/report": 1365 err = c.NoBanned(w,req,user) 1366 if err != nil { 1367 return err 1368 } 1369 1370 err = c.NoSessionMismatch(w,req,user) 1371 if err != nil { 1372 return err 1373 } 1374 1375 err = c.MemberOnly(w,req,user) 1376 if err != nil { 1377 return err 1378 } 1379 1380 switch(req.URL.Path) { 1381 case "/report/submit/": 1382 err = routes.ReportSubmit(w,req,user,extraData) 1383 co.RouteViewCounter.Bump3(12, cn) 1384 } 1385 case "/topics": 1386 switch(req.URL.Path) { 1387 case "/topics/most-viewed/": 1388 h, err := c.UserCheckNano(w,req,user,cn) 1389 if err != nil { 1390 return err 1391 } 1392 err = routes.TopicListMostViewed(w,req,user,h) 1393 co.RouteViewCounter.Bump3(13, cn) 1394 case "/topics/week-views/": 1395 h, err := c.UserCheckNano(w,req,user,cn) 1396 if err != nil { 1397 return err 1398 } 1399 err = routes.TopicListWeekViews(w,req,user,h) 1400 co.RouteViewCounter.Bump3(14, cn) 1401 case "/topics/create/": 1402 err = c.MemberOnly(w,req,user) 1403 if err != nil { 1404 return err 1405 } 1406 1407 h, err := c.UserCheckNano(w,req,user,cn) 1408 if err != nil { 1409 return err 1410 } 1411 err = routes.CreateTopic(w,req,user,h,extraData) 1412 co.RouteViewCounter.Bump3(15, cn) 1413 default: 1414 h, err := c.UserCheckNano(w,req,user,cn) 1415 if err != nil { 1416 return err 1417 } 1418 err = routes.TopicList(w,req,user,h) 1419 co.RouteViewCounter.Bump3(16, cn) 1420 } 1421 case "/panel": 1422 err = c.SuperModOnly(w,req,user) 1423 if err != nil { 1424 return err 1425 } 1426 1427 switch(req.URL.Path) { 1428 case "/panel/forums/": 1429 err = panel.Forums(w,req,user) 1430 co.RouteViewCounter.Bump3(17, cn) 1431 case "/panel/forums/create/": 1432 err = c.NoSessionMismatch(w,req,user) 1433 if err != nil { 1434 return err 1435 } 1436 1437 err = panel.ForumsCreateSubmit(w,req,user) 1438 co.RouteViewCounter.Bump3(18, cn) 1439 case "/panel/forums/delete/": 1440 err = c.NoSessionMismatch(w,req,user) 1441 if err != nil { 1442 return err 1443 } 1444 1445 err = panel.ForumsDelete(w,req,user,extraData) 1446 co.RouteViewCounter.Bump3(19, cn) 1447 case "/panel/forums/delete/submit/": 1448 err = c.NoSessionMismatch(w,req,user) 1449 if err != nil { 1450 return err 1451 } 1452 1453 err = panel.ForumsDeleteSubmit(w,req,user,extraData) 1454 co.RouteViewCounter.Bump3(20, cn) 1455 case "/panel/forums/order/edit/submit/": 1456 err = c.NoSessionMismatch(w,req,user) 1457 if err != nil { 1458 return err 1459 } 1460 1461 err = panel.ForumsOrderSubmit(w,req,user) 1462 co.RouteViewCounter.Bump3(21, cn) 1463 case "/panel/forums/edit/": 1464 err = panel.ForumsEdit(w,req,user,extraData) 1465 co.RouteViewCounter.Bump3(22, cn) 1466 case "/panel/forums/edit/submit/": 1467 err = c.NoSessionMismatch(w,req,user) 1468 if err != nil { 1469 return err 1470 } 1471 1472 err = panel.ForumsEditSubmit(w,req,user,extraData) 1473 co.RouteViewCounter.Bump3(23, cn) 1474 case "/panel/forums/edit/perms/submit/": 1475 err = c.NoSessionMismatch(w,req,user) 1476 if err != nil { 1477 return err 1478 } 1479 1480 err = panel.ForumsEditPermsSubmit(w,req,user,extraData) 1481 co.RouteViewCounter.Bump3(24, cn) 1482 case "/panel/forums/edit/perms/": 1483 err = panel.ForumsEditPermsAdvance(w,req,user,extraData) 1484 co.RouteViewCounter.Bump3(25, cn) 1485 case "/panel/forums/edit/perms/adv/submit/": 1486 err = c.NoSessionMismatch(w,req,user) 1487 if err != nil { 1488 return err 1489 } 1490 1491 err = panel.ForumsEditPermsAdvanceSubmit(w,req,user,extraData) 1492 co.RouteViewCounter.Bump3(26, cn) 1493 case "/panel/forums/action/create/submit/": 1494 err = c.NoSessionMismatch(w,req,user) 1495 if err != nil { 1496 return err 1497 } 1498 1499 err = panel.ForumsEditActionCreateSubmit(w,req,user,extraData) 1500 co.RouteViewCounter.Bump3(27, cn) 1501 case "/panel/forums/action/delete/submit/": 1502 err = c.NoSessionMismatch(w,req,user) 1503 if err != nil { 1504 return err 1505 } 1506 1507 err = panel.ForumsEditActionDeleteSubmit(w,req,user,extraData) 1508 co.RouteViewCounter.Bump3(28, cn) 1509 case "/panel/settings/": 1510 err = panel.Settings(w,req,user) 1511 co.RouteViewCounter.Bump3(29, cn) 1512 case "/panel/settings/edit/": 1513 err = panel.SettingEdit(w,req,user,extraData) 1514 co.RouteViewCounter.Bump3(30, cn) 1515 case "/panel/settings/edit/submit/": 1516 err = c.NoSessionMismatch(w,req,user) 1517 if err != nil { 1518 return err 1519 } 1520 1521 err = panel.SettingEditSubmit(w,req,user,extraData) 1522 co.RouteViewCounter.Bump3(31, cn) 1523 case "/panel/settings/word-filters/": 1524 err = panel.WordFilters(w,req,user) 1525 co.RouteViewCounter.Bump3(32, cn) 1526 case "/panel/settings/word-filters/create/": 1527 err = c.NoSessionMismatch(w,req,user) 1528 if err != nil { 1529 return err 1530 } 1531 1532 err = panel.WordFiltersCreateSubmit(w,req,user) 1533 co.RouteViewCounter.Bump3(33, cn) 1534 case "/panel/settings/word-filters/edit/": 1535 err = panel.WordFiltersEdit(w,req,user,extraData) 1536 co.RouteViewCounter.Bump3(34, cn) 1537 case "/panel/settings/word-filters/edit/submit/": 1538 err = c.NoSessionMismatch(w,req,user) 1539 if err != nil { 1540 return err 1541 } 1542 1543 err = panel.WordFiltersEditSubmit(w,req,user,extraData) 1544 co.RouteViewCounter.Bump3(35, cn) 1545 case "/panel/settings/word-filters/delete/submit/": 1546 err = c.NoSessionMismatch(w,req,user) 1547 if err != nil { 1548 return err 1549 } 1550 1551 err = panel.WordFiltersDeleteSubmit(w,req,user,extraData) 1552 co.RouteViewCounter.Bump3(36, cn) 1553 case "/panel/pages/": 1554 err = c.AdminOnly(w,req,user) 1555 if err != nil { 1556 return err 1557 } 1558 1559 err = panel.Pages(w,req,user) 1560 co.RouteViewCounter.Bump3(37, cn) 1561 case "/panel/pages/create/submit/": 1562 err = c.NoSessionMismatch(w,req,user) 1563 if err != nil { 1564 return err 1565 } 1566 1567 err = c.AdminOnly(w,req,user) 1568 if err != nil { 1569 return err 1570 } 1571 1572 err = panel.PagesCreateSubmit(w,req,user) 1573 co.RouteViewCounter.Bump3(38, cn) 1574 case "/panel/pages/edit/": 1575 err = c.AdminOnly(w,req,user) 1576 if err != nil { 1577 return err 1578 } 1579 1580 err = panel.PagesEdit(w,req,user,extraData) 1581 co.RouteViewCounter.Bump3(39, cn) 1582 case "/panel/pages/edit/submit/": 1583 err = c.NoSessionMismatch(w,req,user) 1584 if err != nil { 1585 return err 1586 } 1587 1588 err = c.AdminOnly(w,req,user) 1589 if err != nil { 1590 return err 1591 } 1592 1593 err = panel.PagesEditSubmit(w,req,user,extraData) 1594 co.RouteViewCounter.Bump3(40, cn) 1595 case "/panel/pages/delete/submit/": 1596 err = c.NoSessionMismatch(w,req,user) 1597 if err != nil { 1598 return err 1599 } 1600 1601 err = c.AdminOnly(w,req,user) 1602 if err != nil { 1603 return err 1604 } 1605 1606 err = panel.PagesDeleteSubmit(w,req,user,extraData) 1607 co.RouteViewCounter.Bump3(41, cn) 1608 case "/panel/themes/": 1609 err = panel.Themes(w,req,user) 1610 co.RouteViewCounter.Bump3(42, cn) 1611 case "/panel/themes/default/": 1612 err = c.NoSessionMismatch(w,req,user) 1613 if err != nil { 1614 return err 1615 } 1616 1617 err = panel.ThemesSetDefault(w,req,user,extraData) 1618 co.RouteViewCounter.Bump3(43, cn) 1619 case "/panel/themes/menus/": 1620 err = panel.ThemesMenus(w,req,user) 1621 co.RouteViewCounter.Bump3(44, cn) 1622 case "/panel/themes/menus/edit/": 1623 err = panel.ThemesMenusEdit(w,req,user,extraData) 1624 co.RouteViewCounter.Bump3(45, cn) 1625 case "/panel/themes/menus/item/edit/": 1626 err = panel.ThemesMenuItemEdit(w,req,user,extraData) 1627 co.RouteViewCounter.Bump3(46, cn) 1628 case "/panel/themes/menus/item/edit/submit/": 1629 err = c.NoSessionMismatch(w,req,user) 1630 if err != nil { 1631 return err 1632 } 1633 1634 err = panel.ThemesMenuItemEditSubmit(w,req,user,extraData) 1635 co.RouteViewCounter.Bump3(47, cn) 1636 case "/panel/themes/menus/item/create/submit/": 1637 err = c.NoSessionMismatch(w,req,user) 1638 if err != nil { 1639 return err 1640 } 1641 1642 err = panel.ThemesMenuItemCreateSubmit(w,req,user) 1643 co.RouteViewCounter.Bump3(48, cn) 1644 case "/panel/themes/menus/item/delete/submit/": 1645 err = c.NoSessionMismatch(w,req,user) 1646 if err != nil { 1647 return err 1648 } 1649 1650 err = panel.ThemesMenuItemDeleteSubmit(w,req,user,extraData) 1651 co.RouteViewCounter.Bump3(49, cn) 1652 case "/panel/themes/menus/item/order/edit/submit/": 1653 err = c.NoSessionMismatch(w,req,user) 1654 if err != nil { 1655 return err 1656 } 1657 1658 err = panel.ThemesMenuItemOrderSubmit(w,req,user,extraData) 1659 co.RouteViewCounter.Bump3(50, cn) 1660 case "/panel/themes/widgets/": 1661 err = panel.ThemesWidgets(w,req,user) 1662 co.RouteViewCounter.Bump3(51, cn) 1663 case "/panel/themes/widgets/edit/submit/": 1664 err = c.NoSessionMismatch(w,req,user) 1665 if err != nil { 1666 return err 1667 } 1668 1669 err = panel.ThemesWidgetsEditSubmit(w,req,user,extraData) 1670 co.RouteViewCounter.Bump3(52, cn) 1671 case "/panel/themes/widgets/create/submit/": 1672 err = c.NoSessionMismatch(w,req,user) 1673 if err != nil { 1674 return err 1675 } 1676 1677 err = panel.ThemesWidgetsCreateSubmit(w,req,user) 1678 co.RouteViewCounter.Bump3(53, cn) 1679 case "/panel/themes/widgets/delete/submit/": 1680 err = c.NoSessionMismatch(w,req,user) 1681 if err != nil { 1682 return err 1683 } 1684 1685 err = panel.ThemesWidgetsDeleteSubmit(w,req,user,extraData) 1686 co.RouteViewCounter.Bump3(54, cn) 1687 case "/panel/plugins/": 1688 err = panel.Plugins(w,req,user) 1689 co.RouteViewCounter.Bump3(55, cn) 1690 case "/panel/plugins/activate/": 1691 err = c.NoSessionMismatch(w,req,user) 1692 if err != nil { 1693 return err 1694 } 1695 1696 err = panel.PluginsActivate(w,req,user,extraData) 1697 co.RouteViewCounter.Bump3(56, cn) 1698 case "/panel/plugins/deactivate/": 1699 err = c.NoSessionMismatch(w,req,user) 1700 if err != nil { 1701 return err 1702 } 1703 1704 err = panel.PluginsDeactivate(w,req,user,extraData) 1705 co.RouteViewCounter.Bump3(57, cn) 1706 case "/panel/plugins/install/": 1707 err = c.NoSessionMismatch(w,req,user) 1708 if err != nil { 1709 return err 1710 } 1711 1712 err = panel.PluginsInstall(w,req,user,extraData) 1713 co.RouteViewCounter.Bump3(58, cn) 1714 case "/panel/users/": 1715 err = panel.Users(w,req,user) 1716 co.RouteViewCounter.Bump3(59, cn) 1717 case "/panel/users/edit/": 1718 err = panel.UsersEdit(w,req,user,extraData) 1719 co.RouteViewCounter.Bump3(60, cn) 1720 case "/panel/users/edit/submit/": 1721 err = c.NoSessionMismatch(w,req,user) 1722 if err != nil { 1723 return err 1724 } 1725 1726 err = panel.UsersEditSubmit(w,req,user,extraData) 1727 co.RouteViewCounter.Bump3(61, cn) 1728 case "/panel/users/avatar/submit/": 1729 err = c.HandleUploadRoute(w,req,user,int(c.Config.MaxRequestSize)) 1730 if err != nil { 1731 return err 1732 } 1733 err = c.NoUploadSessionMismatch(w,req,user) 1734 if err != nil { 1735 return err 1736 } 1737 1738 err = panel.UsersAvatarSubmit(w,req,user,extraData) 1739 co.RouteViewCounter.Bump3(62, cn) 1740 case "/panel/users/avatar/remove/submit/": 1741 err = c.NoSessionMismatch(w,req,user) 1742 if err != nil { 1743 return err 1744 } 1745 1746 err = panel.UsersAvatarRemoveSubmit(w,req,user,extraData) 1747 co.RouteViewCounter.Bump3(63, cn) 1748 case "/panel/analytics/views/": 1749 err = c.ParseForm(w,req,user) 1750 if err != nil { 1751 return err 1752 } 1753 1754 err = panel.AnalyticsViews(w,req,user) 1755 co.RouteViewCounter.Bump3(64, cn) 1756 case "/panel/analytics/routes/": 1757 err = c.ParseForm(w,req,user) 1758 if err != nil { 1759 return err 1760 } 1761 1762 err = panel.AnalyticsRoutes(w,req,user) 1763 co.RouteViewCounter.Bump3(65, cn) 1764 case "/panel/analytics/routes-perf/": 1765 err = c.ParseForm(w,req,user) 1766 if err != nil { 1767 return err 1768 } 1769 1770 err = panel.AnalyticsRoutesPerf(w,req,user) 1771 co.RouteViewCounter.Bump3(66, cn) 1772 case "/panel/analytics/agents/": 1773 err = c.ParseForm(w,req,user) 1774 if err != nil { 1775 return err 1776 } 1777 1778 err = panel.AnalyticsAgents(w,req,user) 1779 co.RouteViewCounter.Bump3(67, cn) 1780 case "/panel/analytics/systems/": 1781 err = c.ParseForm(w,req,user) 1782 if err != nil { 1783 return err 1784 } 1785 1786 err = panel.AnalyticsSystems(w,req,user) 1787 co.RouteViewCounter.Bump3(68, cn) 1788 case "/panel/analytics/langs/": 1789 err = c.ParseForm(w,req,user) 1790 if err != nil { 1791 return err 1792 } 1793 1794 err = panel.AnalyticsLanguages(w,req,user) 1795 co.RouteViewCounter.Bump3(69, cn) 1796 case "/panel/analytics/referrers/": 1797 err = c.ParseForm(w,req,user) 1798 if err != nil { 1799 return err 1800 } 1801 1802 err = panel.AnalyticsReferrers(w,req,user) 1803 co.RouteViewCounter.Bump3(70, cn) 1804 case "/panel/analytics/route/": 1805 err = panel.AnalyticsRouteViews(w,req,user,extraData) 1806 co.RouteViewCounter.Bump3(71, cn) 1807 case "/panel/analytics/agent/": 1808 err = panel.AnalyticsAgentViews(w,req,user,extraData) 1809 co.RouteViewCounter.Bump3(72, cn) 1810 case "/panel/analytics/forum/": 1811 err = panel.AnalyticsForumViews(w,req,user,extraData) 1812 co.RouteViewCounter.Bump3(73, cn) 1813 case "/panel/analytics/system/": 1814 err = panel.AnalyticsSystemViews(w,req,user,extraData) 1815 co.RouteViewCounter.Bump3(74, cn) 1816 case "/panel/analytics/lang/": 1817 err = panel.AnalyticsLanguageViews(w,req,user,extraData) 1818 co.RouteViewCounter.Bump3(75, cn) 1819 case "/panel/analytics/referrer/": 1820 err = panel.AnalyticsReferrerViews(w,req,user,extraData) 1821 co.RouteViewCounter.Bump3(76, cn) 1822 case "/panel/analytics/posts/": 1823 err = c.ParseForm(w,req,user) 1824 if err != nil { 1825 return err 1826 } 1827 1828 err = panel.AnalyticsPosts(w,req,user) 1829 co.RouteViewCounter.Bump3(77, cn) 1830 case "/panel/analytics/memory/": 1831 err = c.ParseForm(w,req,user) 1832 if err != nil { 1833 return err 1834 } 1835 1836 err = panel.AnalyticsMemory(w,req,user) 1837 co.RouteViewCounter.Bump3(78, cn) 1838 case "/panel/analytics/active-memory/": 1839 err = c.ParseForm(w,req,user) 1840 if err != nil { 1841 return err 1842 } 1843 1844 err = panel.AnalyticsActiveMemory(w,req,user) 1845 co.RouteViewCounter.Bump3(79, cn) 1846 case "/panel/analytics/topics/": 1847 err = c.ParseForm(w,req,user) 1848 if err != nil { 1849 return err 1850 } 1851 1852 err = panel.AnalyticsTopics(w,req,user) 1853 co.RouteViewCounter.Bump3(80, cn) 1854 case "/panel/analytics/forums/": 1855 err = c.ParseForm(w,req,user) 1856 if err != nil { 1857 return err 1858 } 1859 1860 err = panel.AnalyticsForums(w,req,user) 1861 co.RouteViewCounter.Bump3(81, cn) 1862 case "/panel/analytics/perf/": 1863 err = c.ParseForm(w,req,user) 1864 if err != nil { 1865 return err 1866 } 1867 1868 err = panel.AnalyticsPerf(w,req,user) 1869 co.RouteViewCounter.Bump3(82, cn) 1870 case "/panel/groups/": 1871 err = panel.Groups(w,req,user) 1872 co.RouteViewCounter.Bump3(83, cn) 1873 case "/panel/groups/edit/": 1874 err = panel.GroupsEdit(w,req,user,extraData) 1875 co.RouteViewCounter.Bump3(84, cn) 1876 case "/panel/groups/edit/promotions/": 1877 err = panel.GroupsEditPromotions(w,req,user,extraData) 1878 co.RouteViewCounter.Bump3(85, cn) 1879 case "/panel/groups/promotions/create/submit/": 1880 err = c.NoSessionMismatch(w,req,user) 1881 if err != nil { 1882 return err 1883 } 1884 1885 err = panel.GroupsPromotionsCreateSubmit(w,req,user,extraData) 1886 co.RouteViewCounter.Bump3(86, cn) 1887 case "/panel/groups/promotions/delete/submit/": 1888 err = c.NoSessionMismatch(w,req,user) 1889 if err != nil { 1890 return err 1891 } 1892 1893 err = panel.GroupsPromotionsDeleteSubmit(w,req,user,extraData) 1894 co.RouteViewCounter.Bump3(87, cn) 1895 case "/panel/groups/edit/perms/": 1896 err = panel.GroupsEditPerms(w,req,user,extraData) 1897 co.RouteViewCounter.Bump3(88, cn) 1898 case "/panel/groups/edit/submit/": 1899 err = c.NoSessionMismatch(w,req,user) 1900 if err != nil { 1901 return err 1902 } 1903 1904 err = panel.GroupsEditSubmit(w,req,user,extraData) 1905 co.RouteViewCounter.Bump3(89, cn) 1906 case "/panel/groups/edit/perms/submit/": 1907 err = c.NoSessionMismatch(w,req,user) 1908 if err != nil { 1909 return err 1910 } 1911 1912 err = panel.GroupsEditPermsSubmit(w,req,user,extraData) 1913 co.RouteViewCounter.Bump3(90, cn) 1914 case "/panel/groups/create/": 1915 err = c.NoSessionMismatch(w,req,user) 1916 if err != nil { 1917 return err 1918 } 1919 1920 err = panel.GroupsCreateSubmit(w,req,user) 1921 co.RouteViewCounter.Bump3(91, cn) 1922 case "/panel/backups/": 1923 err = c.SuperAdminOnly(w,req,user) 1924 if err != nil { 1925 return err 1926 } 1927 1928 w = r.responseWriter(w) 1929 err = panel.Backups(w,req,user,extraData) 1930 co.RouteViewCounter.Bump3(92, cn) 1931 case "/panel/logs/regs/": 1932 err = panel.LogsRegs(w,req,user) 1933 co.RouteViewCounter.Bump3(93, cn) 1934 case "/panel/logs/mod/": 1935 err = panel.LogsMod(w,req,user) 1936 co.RouteViewCounter.Bump3(94, cn) 1937 case "/panel/logs/admin/": 1938 err = panel.LogsAdmin(w,req,user) 1939 co.RouteViewCounter.Bump3(95, cn) 1940 case "/panel/debug/": 1941 err = c.AdminOnly(w,req,user) 1942 if err != nil { 1943 return err 1944 } 1945 1946 err = panel.Debug(w,req,user) 1947 co.RouteViewCounter.Bump3(96, cn) 1948 case "/panel/debug/tasks/": 1949 err = c.AdminOnly(w,req,user) 1950 if err != nil { 1951 return err 1952 } 1953 1954 err = panel.DebugTasks(w,req,user) 1955 co.RouteViewCounter.Bump3(97, cn) 1956 default: 1957 err = panel.Dashboard(w,req,user) 1958 co.RouteViewCounter.Bump3(98, cn) 1959 } 1960 case "/user": 1961 switch(req.URL.Path) { 1962 case "/user/edit/": 1963 err = c.MemberOnly(w,req,user) 1964 if err != nil { 1965 return err 1966 } 1967 1968 h, err := c.UserCheckNano(w,req,user,cn) 1969 if err != nil { 1970 return err 1971 } 1972 err = routes.AccountEdit(w,req,user,h) 1973 co.RouteViewCounter.Bump3(99, cn) 1974 case "/user/edit/password/": 1975 err = c.MemberOnly(w,req,user) 1976 if err != nil { 1977 return err 1978 } 1979 1980 h, err := c.UserCheckNano(w,req,user,cn) 1981 if err != nil { 1982 return err 1983 } 1984 err = routes.AccountEditPassword(w,req,user,h) 1985 co.RouteViewCounter.Bump3(100, cn) 1986 case "/user/edit/password/submit/": 1987 err = c.NoSessionMismatch(w,req,user) 1988 if err != nil { 1989 return err 1990 } 1991 1992 err = c.MemberOnly(w,req,user) 1993 if err != nil { 1994 return err 1995 } 1996 1997 err = routes.AccountEditPasswordSubmit(w,req,user) 1998 co.RouteViewCounter.Bump3(101, cn) 1999 case "/user/edit/avatar/submit/": 2000 err = c.MemberOnly(w,req,user) 2001 if err != nil { 2002 return err 2003 } 2004 2005 err = c.HandleUploadRoute(w,req,user,int(c.Config.MaxRequestSize)) 2006 if err != nil { 2007 return err 2008 } 2009 err = c.NoUploadSessionMismatch(w,req,user) 2010 if err != nil { 2011 return err 2012 } 2013 2014 err = routes.AccountEditAvatarSubmit(w,req,user) 2015 co.RouteViewCounter.Bump3(102, cn) 2016 case "/user/edit/avatar/revoke/submit/": 2017 err = c.NoSessionMismatch(w,req,user) 2018 if err != nil { 2019 return err 2020 } 2021 2022 err = c.MemberOnly(w,req,user) 2023 if err != nil { 2024 return err 2025 } 2026 2027 err = routes.AccountEditRevokeAvatarSubmit(w,req,user) 2028 co.RouteViewCounter.Bump3(103, cn) 2029 case "/user/edit/username/submit/": 2030 err = c.NoSessionMismatch(w,req,user) 2031 if err != nil { 2032 return err 2033 } 2034 2035 err = c.MemberOnly(w,req,user) 2036 if err != nil { 2037 return err 2038 } 2039 2040 err = routes.AccountEditUsernameSubmit(w,req,user) 2041 co.RouteViewCounter.Bump3(104, cn) 2042 case "/user/edit/privacy/": 2043 err = c.MemberOnly(w,req,user) 2044 if err != nil { 2045 return err 2046 } 2047 2048 h, err := c.UserCheckNano(w,req,user,cn) 2049 if err != nil { 2050 return err 2051 } 2052 err = routes.AccountEditPrivacy(w,req,user,h) 2053 co.RouteViewCounter.Bump3(105, cn) 2054 case "/user/edit/privacy/submit/": 2055 err = c.NoSessionMismatch(w,req,user) 2056 if err != nil { 2057 return err 2058 } 2059 2060 err = c.MemberOnly(w,req,user) 2061 if err != nil { 2062 return err 2063 } 2064 2065 err = routes.AccountEditPrivacySubmit(w,req,user) 2066 co.RouteViewCounter.Bump3(106, cn) 2067 case "/user/edit/mfa/": 2068 err = c.MemberOnly(w,req,user) 2069 if err != nil { 2070 return err 2071 } 2072 2073 h, err := c.UserCheckNano(w,req,user,cn) 2074 if err != nil { 2075 return err 2076 } 2077 err = routes.AccountEditMFA(w,req,user,h) 2078 co.RouteViewCounter.Bump3(107, cn) 2079 case "/user/edit/mfa/setup/": 2080 err = c.MemberOnly(w,req,user) 2081 if err != nil { 2082 return err 2083 } 2084 2085 h, err := c.UserCheckNano(w,req,user,cn) 2086 if err != nil { 2087 return err 2088 } 2089 err = routes.AccountEditMFASetup(w,req,user,h) 2090 co.RouteViewCounter.Bump3(108, cn) 2091 case "/user/edit/mfa/setup/submit/": 2092 err = c.NoSessionMismatch(w,req,user) 2093 if err != nil { 2094 return err 2095 } 2096 2097 err = c.MemberOnly(w,req,user) 2098 if err != nil { 2099 return err 2100 } 2101 2102 err = routes.AccountEditMFASetupSubmit(w,req,user) 2103 co.RouteViewCounter.Bump3(109, cn) 2104 case "/user/edit/mfa/disable/submit/": 2105 err = c.NoSessionMismatch(w,req,user) 2106 if err != nil { 2107 return err 2108 } 2109 2110 err = c.MemberOnly(w,req,user) 2111 if err != nil { 2112 return err 2113 } 2114 2115 err = routes.AccountEditMFADisableSubmit(w,req,user) 2116 co.RouteViewCounter.Bump3(110, cn) 2117 case "/user/edit/email/": 2118 err = c.MemberOnly(w,req,user) 2119 if err != nil { 2120 return err 2121 } 2122 2123 h, err := c.UserCheckNano(w,req,user,cn) 2124 if err != nil { 2125 return err 2126 } 2127 err = routes.AccountEditEmail(w,req,user,h) 2128 co.RouteViewCounter.Bump3(111, cn) 2129 case "/user/edit/token/": 2130 err = routes.AccountEditEmailTokenSubmit(w,req,user,extraData) 2131 co.RouteViewCounter.Bump3(112, cn) 2132 case "/user/edit/logins/": 2133 err = c.MemberOnly(w,req,user) 2134 if err != nil { 2135 return err 2136 } 2137 2138 h, err := c.UserCheckNano(w,req,user,cn) 2139 if err != nil { 2140 return err 2141 } 2142 err = routes.AccountLogins(w,req,user,h) 2143 co.RouteViewCounter.Bump3(113, cn) 2144 case "/user/edit/blocked/": 2145 err = c.MemberOnly(w,req,user) 2146 if err != nil { 2147 return err 2148 } 2149 2150 h, err := c.UserCheckNano(w,req,user,cn) 2151 if err != nil { 2152 return err 2153 } 2154 err = routes.AccountBlocked(w,req,user,h) 2155 co.RouteViewCounter.Bump3(114, cn) 2156 case "/user/levels/": 2157 err = c.MemberOnly(w,req,user) 2158 if err != nil { 2159 return err 2160 } 2161 2162 h, err := c.UserCheckNano(w,req,user,cn) 2163 if err != nil { 2164 return err 2165 } 2166 err = routes.LevelList(w,req,user,h) 2167 co.RouteViewCounter.Bump3(115, cn) 2168 case "/user/convos/": 2169 err = c.MemberOnly(w,req,user) 2170 if err != nil { 2171 return err 2172 } 2173 2174 h, err := c.UserCheckNano(w,req,user,cn) 2175 if err != nil { 2176 return err 2177 } 2178 err = routes.Convos(w,req,user,h) 2179 co.RouteViewCounter.Bump3(116, cn) 2180 case "/user/convos/create/": 2181 err = c.MemberOnly(w,req,user) 2182 if err != nil { 2183 return err 2184 } 2185 2186 h, err := c.UserCheckNano(w,req,user,cn) 2187 if err != nil { 2188 return err 2189 } 2190 err = routes.ConvosCreate(w,req,user,h) 2191 co.RouteViewCounter.Bump3(117, cn) 2192 case "/user/convo/": 2193 err = c.MemberOnly(w,req,user) 2194 if err != nil { 2195 return err 2196 } 2197 2198 h, err := c.UserCheckNano(w,req,user,cn) 2199 if err != nil { 2200 return err 2201 } 2202 err = routes.Convo(w,req,user,h,extraData) 2203 co.RouteViewCounter.Bump3(118, cn) 2204 case "/user/convos/create/submit/": 2205 err = c.NoSessionMismatch(w,req,user) 2206 if err != nil { 2207 return err 2208 } 2209 2210 err = c.MemberOnly(w,req,user) 2211 if err != nil { 2212 return err 2213 } 2214 2215 err = routes.ConvosCreateSubmit(w,req,user) 2216 co.RouteViewCounter.Bump3(119, cn) 2217 case "/user/convo/create/submit/": 2218 err = c.NoSessionMismatch(w,req,user) 2219 if err != nil { 2220 return err 2221 } 2222 2223 err = c.MemberOnly(w,req,user) 2224 if err != nil { 2225 return err 2226 } 2227 2228 err = routes.ConvosCreateReplySubmit(w,req,user,extraData) 2229 co.RouteViewCounter.Bump3(120, cn) 2230 case "/user/convo/delete/submit/": 2231 err = c.NoSessionMismatch(w,req,user) 2232 if err != nil { 2233 return err 2234 } 2235 2236 err = c.MemberOnly(w,req,user) 2237 if err != nil { 2238 return err 2239 } 2240 2241 err = routes.ConvosDeleteReplySubmit(w,req,user,extraData) 2242 co.RouteViewCounter.Bump3(121, cn) 2243 case "/user/convo/edit/submit/": 2244 err = c.NoSessionMismatch(w,req,user) 2245 if err != nil { 2246 return err 2247 } 2248 2249 err = c.MemberOnly(w,req,user) 2250 if err != nil { 2251 return err 2252 } 2253 2254 err = routes.ConvosEditReplySubmit(w,req,user,extraData) 2255 co.RouteViewCounter.Bump3(122, cn) 2256 case "/user/block/create/": 2257 err = c.MemberOnly(w,req,user) 2258 if err != nil { 2259 return err 2260 } 2261 2262 h, err := c.UserCheckNano(w,req,user,cn) 2263 if err != nil { 2264 return err 2265 } 2266 err = routes.RelationsBlockCreate(w,req,user,h,extraData) 2267 co.RouteViewCounter.Bump3(123, cn) 2268 case "/user/block/create/submit/": 2269 err = c.NoSessionMismatch(w,req,user) 2270 if err != nil { 2271 return err 2272 } 2273 2274 err = c.MemberOnly(w,req,user) 2275 if err != nil { 2276 return err 2277 } 2278 2279 err = routes.RelationsBlockCreateSubmit(w,req,user,extraData) 2280 co.RouteViewCounter.Bump3(124, cn) 2281 case "/user/block/remove/": 2282 err = c.MemberOnly(w,req,user) 2283 if err != nil { 2284 return err 2285 } 2286 2287 h, err := c.UserCheckNano(w,req,user,cn) 2288 if err != nil { 2289 return err 2290 } 2291 err = routes.RelationsBlockRemove(w,req,user,h,extraData) 2292 co.RouteViewCounter.Bump3(125, cn) 2293 case "/user/block/remove/submit/": 2294 err = c.NoSessionMismatch(w,req,user) 2295 if err != nil { 2296 return err 2297 } 2298 2299 err = c.MemberOnly(w,req,user) 2300 if err != nil { 2301 return err 2302 } 2303 2304 err = routes.RelationsBlockRemoveSubmit(w,req,user,extraData) 2305 co.RouteViewCounter.Bump3(126, cn) 2306 default: 2307 req.URL.Path += extraData 2308 h, err := c.UserCheckNano(w,req,user,cn) 2309 if err != nil { 2310 return err 2311 } 2312 err = routes.ViewProfile(w,req,user,h) 2313 co.RouteViewCounter.Bump3(127, cn) 2314 } 2315 case "/users": 2316 err = c.MemberOnly(w,req,user) 2317 if err != nil { 2318 return err 2319 } 2320 2321 switch(req.URL.Path) { 2322 case "/users/ban/submit/": 2323 err = c.NoSessionMismatch(w,req,user) 2324 if err != nil { 2325 return err 2326 } 2327 2328 err = routes.BanUserSubmit(w,req,user,extraData) 2329 co.RouteViewCounter.Bump3(128, cn) 2330 case "/users/unban/": 2331 err = c.NoSessionMismatch(w,req,user) 2332 if err != nil { 2333 return err 2334 } 2335 2336 err = routes.UnbanUser(w,req,user,extraData) 2337 co.RouteViewCounter.Bump3(129, cn) 2338 case "/users/activate/": 2339 err = c.NoSessionMismatch(w,req,user) 2340 if err != nil { 2341 return err 2342 } 2343 2344 err = routes.ActivateUser(w,req,user,extraData) 2345 co.RouteViewCounter.Bump3(130, cn) 2346 case "/users/ips/": 2347 h, err := c.UserCheckNano(w,req,user,cn) 2348 if err != nil { 2349 return err 2350 } 2351 err = routes.IPSearch(w,req,user,h) 2352 co.RouteViewCounter.Bump3(131, cn) 2353 case "/users/delete-posts/submit/": 2354 err = c.NoSessionMismatch(w,req,user) 2355 if err != nil { 2356 return err 2357 } 2358 2359 err = routes.DeletePostsSubmit(w,req,user,extraData) 2360 co.RouteViewCounter.Bump3(132, cn) 2361 } 2362 case "/topic": 2363 switch(req.URL.Path) { 2364 case "/topic/create/submit/": 2365 err = c.MemberOnly(w,req,user) 2366 if err != nil { 2367 return err 2368 } 2369 2370 err = c.HandleUploadRoute(w,req,user,int(c.Config.MaxRequestSize)) 2371 if err != nil { 2372 return err 2373 } 2374 err = c.NoUploadSessionMismatch(w,req,user) 2375 if err != nil { 2376 return err 2377 } 2378 2379 err = routes.CreateTopicSubmit(w,req,user) 2380 co.RouteViewCounter.Bump3(133, cn) 2381 case "/topic/edit/submit/": 2382 err = c.NoSessionMismatch(w,req,user) 2383 if err != nil { 2384 return err 2385 } 2386 2387 err = c.MemberOnly(w,req,user) 2388 if err != nil { 2389 return err 2390 } 2391 2392 err = routes.EditTopicSubmit(w,req,user,extraData) 2393 co.RouteViewCounter.Bump3(134, cn) 2394 case "/topic/delete/submit/": 2395 err = c.NoSessionMismatch(w,req,user) 2396 if err != nil { 2397 return err 2398 } 2399 2400 err = c.MemberOnly(w,req,user) 2401 if err != nil { 2402 return err 2403 } 2404 2405 req.URL.Path += extraData 2406 err = routes.DeleteTopicSubmit(w,req,user) 2407 co.RouteViewCounter.Bump3(135, cn) 2408 case "/topic/stick/submit/": 2409 err = c.NoSessionMismatch(w,req,user) 2410 if err != nil { 2411 return err 2412 } 2413 2414 err = c.MemberOnly(w,req,user) 2415 if err != nil { 2416 return err 2417 } 2418 2419 err = routes.StickTopicSubmit(w,req,user,extraData) 2420 co.RouteViewCounter.Bump3(136, cn) 2421 case "/topic/unstick/submit/": 2422 err = c.NoSessionMismatch(w,req,user) 2423 if err != nil { 2424 return err 2425 } 2426 2427 err = c.MemberOnly(w,req,user) 2428 if err != nil { 2429 return err 2430 } 2431 2432 err = routes.UnstickTopicSubmit(w,req,user,extraData) 2433 co.RouteViewCounter.Bump3(137, cn) 2434 case "/topic/lock/submit/": 2435 err = c.NoSessionMismatch(w,req,user) 2436 if err != nil { 2437 return err 2438 } 2439 2440 err = c.MemberOnly(w,req,user) 2441 if err != nil { 2442 return err 2443 } 2444 2445 req.URL.Path += extraData 2446 err = routes.LockTopicSubmit(w,req,user) 2447 co.RouteViewCounter.Bump3(138, cn) 2448 case "/topic/unlock/submit/": 2449 err = c.NoSessionMismatch(w,req,user) 2450 if err != nil { 2451 return err 2452 } 2453 2454 err = c.MemberOnly(w,req,user) 2455 if err != nil { 2456 return err 2457 } 2458 2459 err = routes.UnlockTopicSubmit(w,req,user,extraData) 2460 co.RouteViewCounter.Bump3(139, cn) 2461 case "/topic/move/submit/": 2462 err = c.NoSessionMismatch(w,req,user) 2463 if err != nil { 2464 return err 2465 } 2466 2467 err = c.MemberOnly(w,req,user) 2468 if err != nil { 2469 return err 2470 } 2471 2472 err = routes.MoveTopicSubmit(w,req,user,extraData) 2473 co.RouteViewCounter.Bump3(140, cn) 2474 case "/topic/like/submit/": 2475 err = c.NoSessionMismatch(w,req,user) 2476 if err != nil { 2477 return err 2478 } 2479 2480 err = c.MemberOnly(w,req,user) 2481 if err != nil { 2482 return err 2483 } 2484 2485 err = routes.LikeTopicSubmit(w,req,user,extraData) 2486 co.RouteViewCounter.Bump3(141, cn) 2487 case "/topic/unlike/submit/": 2488 err = c.NoSessionMismatch(w,req,user) 2489 if err != nil { 2490 return err 2491 } 2492 2493 err = c.MemberOnly(w,req,user) 2494 if err != nil { 2495 return err 2496 } 2497 2498 err = routes.UnlikeTopicSubmit(w,req,user,extraData) 2499 co.RouteViewCounter.Bump3(142, cn) 2500 case "/topic/attach/add/submit/": 2501 err = c.MemberOnly(w,req,user) 2502 if err != nil { 2503 return err 2504 } 2505 2506 err = c.HandleUploadRoute(w,req,user,int(c.Config.MaxRequestSize)) 2507 if err != nil { 2508 return err 2509 } 2510 err = c.NoUploadSessionMismatch(w,req,user) 2511 if err != nil { 2512 return err 2513 } 2514 2515 err = routes.AddAttachToTopicSubmit(w,req,user,extraData) 2516 co.RouteViewCounter.Bump3(143, cn) 2517 case "/topic/attach/remove/submit/": 2518 err = c.NoSessionMismatch(w,req,user) 2519 if err != nil { 2520 return err 2521 } 2522 2523 err = c.MemberOnly(w,req,user) 2524 if err != nil { 2525 return err 2526 } 2527 2528 err = routes.RemoveAttachFromTopicSubmit(w,req,user,extraData) 2529 co.RouteViewCounter.Bump3(144, cn) 2530 default: 2531 h, err := c.UserCheckNano(w,req,user,cn) 2532 if err != nil { 2533 return err 2534 } 2535 err = routes.ViewTopic(w,req,user,h,extraData) 2536 co.RouteViewCounter.Bump3(145, cn) 2537 } 2538 case "/reply": 2539 err = c.MemberOnly(w,req,user) 2540 if err != nil { 2541 return err 2542 } 2543 2544 switch(req.URL.Path) { 2545 case "/reply/create/": 2546 err = c.HandleUploadRoute(w,req,user,int(c.Config.MaxRequestSize)) 2547 if err != nil { 2548 return err 2549 } 2550 err = c.NoUploadSessionMismatch(w,req,user) 2551 if err != nil { 2552 return err 2553 } 2554 2555 err = routes.CreateReplySubmit(w,req,user) 2556 co.RouteViewCounter.Bump3(146, cn) 2557 case "/reply/edit/submit/": 2558 err = c.NoSessionMismatch(w,req,user) 2559 if err != nil { 2560 return err 2561 } 2562 2563 err = routes.ReplyEditSubmit(w,req,user,extraData) 2564 co.RouteViewCounter.Bump3(147, cn) 2565 case "/reply/delete/submit/": 2566 err = c.NoSessionMismatch(w,req,user) 2567 if err != nil { 2568 return err 2569 } 2570 2571 err = routes.ReplyDeleteSubmit(w,req,user,extraData) 2572 co.RouteViewCounter.Bump3(148, cn) 2573 case "/reply/like/submit/": 2574 err = c.NoSessionMismatch(w,req,user) 2575 if err != nil { 2576 return err 2577 } 2578 2579 err = routes.ReplyLikeSubmit(w,req,user,extraData) 2580 co.RouteViewCounter.Bump3(149, cn) 2581 case "/reply/unlike/submit/": 2582 err = c.NoSessionMismatch(w,req,user) 2583 if err != nil { 2584 return err 2585 } 2586 2587 err = routes.ReplyUnlikeSubmit(w,req,user,extraData) 2588 co.RouteViewCounter.Bump3(150, cn) 2589 case "/reply/attach/add/submit/": 2590 err = c.HandleUploadRoute(w,req,user,int(c.Config.MaxRequestSize)) 2591 if err != nil { 2592 return err 2593 } 2594 err = c.NoUploadSessionMismatch(w,req,user) 2595 if err != nil { 2596 return err 2597 } 2598 2599 err = routes.AddAttachToReplySubmit(w,req,user,extraData) 2600 co.RouteViewCounter.Bump3(151, cn) 2601 case "/reply/attach/remove/submit/": 2602 err = c.NoSessionMismatch(w,req,user) 2603 if err != nil { 2604 return err 2605 } 2606 2607 err = routes.RemoveAttachFromReplySubmit(w,req,user,extraData) 2608 co.RouteViewCounter.Bump3(152, cn) 2609 } 2610 case "/profile": 2611 err = c.NoSessionMismatch(w,req,user) 2612 if err != nil { 2613 return err 2614 } 2615 2616 err = c.MemberOnly(w,req,user) 2617 if err != nil { 2618 return err 2619 } 2620 2621 switch(req.URL.Path) { 2622 case "/profile/reply/create/": 2623 err = routes.ProfileReplyCreateSubmit(w,req,user) 2624 co.RouteViewCounter.Bump3(153, cn) 2625 case "/profile/reply/edit/submit/": 2626 err = routes.ProfileReplyEditSubmit(w,req,user,extraData) 2627 co.RouteViewCounter.Bump3(154, cn) 2628 case "/profile/reply/delete/submit/": 2629 err = routes.ProfileReplyDeleteSubmit(w,req,user,extraData) 2630 co.RouteViewCounter.Bump3(155, cn) 2631 } 2632 case "/poll": 2633 switch(req.URL.Path) { 2634 case "/poll/vote/": 2635 err = c.NoSessionMismatch(w,req,user) 2636 if err != nil { 2637 return err 2638 } 2639 2640 err = c.MemberOnly(w,req,user) 2641 if err != nil { 2642 return err 2643 } 2644 2645 err = routes.PollVote(w,req,user,extraData) 2646 co.RouteViewCounter.Bump3(156, cn) 2647 case "/poll/results/": 2648 err = routes.PollResults(w,req,user,extraData) 2649 co.RouteViewCounter.Bump3(157, cn) 2650 } 2651 case "/accounts": 2652 switch(req.URL.Path) { 2653 case "/accounts/login/": 2654 h, err := c.UserCheckNano(w,req,user,cn) 2655 if err != nil { 2656 return err 2657 } 2658 err = routes.AccountLogin(w,req,user,h) 2659 co.RouteViewCounter.Bump3(158, cn) 2660 case "/accounts/create/": 2661 h, err := c.UserCheckNano(w,req,user,cn) 2662 if err != nil { 2663 return err 2664 } 2665 err = routes.AccountRegister(w,req,user,h) 2666 co.RouteViewCounter.Bump3(159, cn) 2667 case "/accounts/logout/": 2668 err = c.NoSessionMismatch(w,req,user) 2669 if err != nil { 2670 return err 2671 } 2672 2673 err = c.MemberOnly(w,req,user) 2674 if err != nil { 2675 return err 2676 } 2677 2678 err = routes.AccountLogout(w,req,user) 2679 co.RouteViewCounter.Bump3(160, cn) 2680 case "/accounts/login/submit/": 2681 err = c.ParseForm(w,req,user) 2682 if err != nil { 2683 return err 2684 } 2685 2686 err = routes.AccountLoginSubmit(w,req,user) 2687 co.RouteViewCounter.Bump3(161, cn) 2688 case "/accounts/mfa_verify/": 2689 h, err := c.UserCheckNano(w,req,user,cn) 2690 if err != nil { 2691 return err 2692 } 2693 err = routes.AccountLoginMFAVerify(w,req,user,h) 2694 co.RouteViewCounter.Bump3(162, cn) 2695 case "/accounts/mfa_verify/submit/": 2696 err = c.ParseForm(w,req,user) 2697 if err != nil { 2698 return err 2699 } 2700 2701 err = routes.AccountLoginMFAVerifySubmit(w,req,user) 2702 co.RouteViewCounter.Bump3(163, cn) 2703 case "/accounts/create/submit/": 2704 err = c.ParseForm(w,req,user) 2705 if err != nil { 2706 return err 2707 } 2708 2709 err = routes.AccountRegisterSubmit(w,req,user) 2710 co.RouteViewCounter.Bump3(164, cn) 2711 case "/accounts/password-reset/": 2712 h, err := c.UserCheckNano(w,req,user,cn) 2713 if err != nil { 2714 return err 2715 } 2716 err = routes.AccountPasswordReset(w,req,user,h) 2717 co.RouteViewCounter.Bump3(165, cn) 2718 case "/accounts/password-reset/submit/": 2719 err = c.ParseForm(w,req,user) 2720 if err != nil { 2721 return err 2722 } 2723 2724 err = routes.AccountPasswordResetSubmit(w,req,user) 2725 co.RouteViewCounter.Bump3(166, cn) 2726 case "/accounts/password-reset/token/": 2727 h, err := c.UserCheckNano(w,req,user,cn) 2728 if err != nil { 2729 return err 2730 } 2731 err = routes.AccountPasswordResetToken(w,req,user,h) 2732 co.RouteViewCounter.Bump3(167, cn) 2733 case "/accounts/password-reset/token/submit/": 2734 err = c.ParseForm(w,req,user) 2735 if err != nil { 2736 return err 2737 } 2738 2739 err = routes.AccountPasswordResetTokenSubmit(w,req,user) 2740 co.RouteViewCounter.Bump3(168, cn) 2741 } 2742 /*case "/sitemaps": // TODO: Count these views 2743 req.URL.Path += extraData 2744 err = sitemapSwitch(w,req)*/ 2745 // ! Temporary fix for certain bots 2746 case "/static": 2747 w.Header().Set("Connection", "close") 2748 http.Redirect(w, req, "/s/"+extraData, http.StatusTemporaryRedirect) 2749 case "/uploads": 2750 if extraData == "" { 2751 co.RouteViewCounter.Bump3(170, cn) 2752 return c.NotFound(w,req,nil) 2753 } 2754 w = r.responseWriter(w) 2755 req.URL.Path += extraData 2756 // TODO: Find a way to propagate errors up from this? 2757 r.UploadHandler(w,req) // TODO: Count these views 2758 co.RouteViewCounter.Bump3(170, cn) 2759 return nil 2760 case "": 2761 // Stop the favicons, robots.txt file, etc. resolving to the topics list 2762 // TODO: Add support for favicons and robots.txt files 2763 switch(extraData) { 2764 case "robots.txt": 2765 co.RouteViewCounter.Bump3(172, cn) 2766 return routes.RobotsTxt(w,req) 2767 case "favicon.ico": 2768 w = r.responseWriter(w) 2769 req.URL.Path = "/s/favicon.ico" 2770 co.RouteViewCounter.Bump3(175, cn) 2771 routes.StaticFile(w,req) 2772 return nil 2773 case "opensearch.xml": 2774 co.RouteViewCounter.Bump3(174, cn) 2775 return routes.OpenSearchXml(w,req) 2776 /*case "sitemap.xml": 2777 co.RouteViewCounter.Bump3(173, cn) 2778 return routes.SitemapXml(w,req)*/ 2779 } 2780 co.RouteViewCounter.Bump(0) 2781 return c.NotFound(w,req,nil) 2782 default: 2783 // A fallback for dynamic routes, e.g. ones declared by plugins 2784 r.RLock() 2785 h, ok := r.extraRoutes[req.URL.Path] 2786 r.RUnlock() 2787 req.URL.Path += extraData 2788 2789 if ok { 2790 // TODO: Be more specific about *which* dynamic route it is 2791 co.RouteViewCounter.Bump(169) 2792 return h(w,req,user) 2793 } 2794 co.RouteViewCounter.Bump3(176, cn) 2795 2796 if !c.Config.DisableSuspLog { 2797 lp := strings.ToLower(req.URL.Path) 2798 if strings.Contains(lp,"w") { 2799 if strings.Contains(lp,"wp") || strings.Contains(lp,"wordpress") || strings.Contains(lp,"wget") || strings.Contains(lp,"wp-") { 2800 r.SuspiciousRequest(req,"Bad Route") 2801 return c.MicroNotFound(w,req) 2802 } 2803 } 2804 if strings.Contains(lp,"admin") || strings.Contains(lp,"sql") || strings.Contains(lp,"manage") || strings.Contains(lp,"//") || strings.Contains(lp,"\\\\") || strings.Contains(lp,"config") || strings.Contains(lp,"setup") || strings.Contains(lp,"install") || strings.Contains(lp,"update") || strings.Contains(lp,"php") || strings.Contains(lp,"pl") || strings.Contains(lp,"include") || strings.Contains(lp,"vendor") || strings.Contains(lp,"bin") || strings.Contains(lp,"system") || strings.Contains(lp,"eval") || strings.Contains(lp,"config") { 2805 r.SuspiciousRequest(req,"Bad Route") 2806 return c.MicroNotFound(w,req) 2807 } 2808 } 2809 2810 if !c.Config.DisableBadRouteLog { 2811 r.DumpRequest(req,"Bad Route") 2812 } 2813 ae := req.Header.Get("Accept-Encoding") 2814 likelyBot := ae == "gzip" || ae == "" 2815 if likelyBot { 2816 return c.MicroNotFound(w,req) 2817 } 2818 return c.NotFound(w,req,nil) 2819 } 2820 return err 2821 }