The route handlers now use camelCase.

Updated the default config.go
This commit is contained in:
Azareal 2017-09-11 11:24:03 +01:00
parent ab0776c52b
commit 01bef7a320
15 changed files with 281 additions and 271 deletions

View File

@ -1,52 +1,53 @@
package main package main
func init() { func init() {
// Site Info // Site Info
site.Name = "TS" // Should be a setting in the database site.Name = "TS" // Should be a setting in the database
site.Email = "" // Should be a setting in the database site.Email = "" // Should be a setting in the database
site.Url = "localhost" site.Url = "localhost"
site.Port = "8080" site.Port = "8080" // 8080
site.EnableSsl = false site.EnableSsl = false
site.EnableEmails = false site.EnableEmails = false
config.SslPrivkey = "" site.HasProxy = false // Cloudflare counts as this, if it's sitting in the middle
config.SslFullchain = "" config.SslPrivkey = ""
config.SslFullchain = ""
// Database details // Database details
db_config.Host = "localhost" db_config.Host = "localhost"
db_config.Username = "root" db_config.Username = "root"
db_config.Password = "password" db_config.Password = "password"
db_config.Dbname = "gosora" db_config.Dbname = "gosora"
db_config.Port = "3306" // You probably won't need to change this db_config.Port = "3306" // You probably won't need to change this
// Limiters // Limiters
config.MaxRequestSize = 5 * megabyte config.MaxRequestSize = 5 * megabyte
// Caching // Caching
config.CacheTopicUser = CACHE_STATIC config.CacheTopicUser = CACHE_STATIC
config.UserCacheCapacity = 100 // The max number of users held in memory config.UserCacheCapacity = 120 // The max number of users held in memory
config.TopicCacheCapacity = 100 // The max number of topics held in memory config.TopicCacheCapacity = 200 // The max number of topics held in memory
// Email // Email
config.SmtpServer = "" config.SmtpServer = ""
config.SmtpUsername = "" config.SmtpUsername = ""
config.SmtpPassword = "" config.SmtpPassword = ""
config.SmtpPort = "25" config.SmtpPort = "25"
// Misc // Misc
config.DefaultRoute = route_topics config.DefaultRoute = routeTopics
config.DefaultGroup = 3 // Should be a setting in the database config.DefaultGroup = 3 // Should be a setting in the database
config.ActivationGroup = 5 // Should be a setting in the database config.ActivationGroup = 5 // Should be a setting in the database
config.StaffCss = "staff_post" config.StaffCss = "staff_post"
config.UncategorisedForumVisible = true config.UncategorisedForumVisible = true
config.MinifyTemplates = false config.MinifyTemplates = false
config.MultiServer = false // Experimental: Enable Cross-Server Synchronisation and several other features config.MultiServer = false // Experimental: Enable Cross-Server Synchronisation and several other features
//config.Noavatar = "https://api.adorable.io/avatars/{width}/{id}@{site_url}.png" //config.Noavatar = "https://api.adorable.io/avatars/{width}/{id}@{site_url}.png"
config.Noavatar = "https://api.adorable.io/avatars/285/{id}@{site_url}.png" config.Noavatar = "https://api.adorable.io/avatars/285/{id}@{site_url}.png"
config.ItemsPerPage = 25 config.ItemsPerPage = 25
// Developer flag // Developer flag
dev.DebugMode = true dev.DebugMode = true
//dev.SuperDebug = true //dev.SuperDebug = true
//dev.Profiling = true //dev.Profiling = true
} }

View File

@ -64,7 +64,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
if dev.SuperDebug { if dev.SuperDebug {
log.Print("before route_static") log.Print("before routeStatic")
log.Print("prefix: ", prefix) log.Print("prefix: ", prefix)
log.Print("req.URL.Path: ", req.URL.Path) log.Print("req.URL.Path: ", req.URL.Path)
log.Print("extra_data: ", extra_data) log.Print("extra_data: ", extra_data)
@ -73,7 +73,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if prefix == "/static" { if prefix == "/static" {
req.URL.Path += extra_data req.URL.Path += extra_data
route_static(w,req) routeStatic(w,req)
return return
} }
@ -93,135 +93,135 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
switch(prefix) { switch(prefix) {
case "/api": case "/api":
route_api(w,req,user) routeAPI(w,req,user)
return return
case "/overview": case "/overview":
route_overview(w,req,user) routeOverview(w,req,user)
return return
case "/forums": case "/forums":
route_forums(w,req,user) routeForums(w,req,user)
return return
case "/forum": case "/forum":
route_forum(w,req,user,extra_data) routeForum(w,req,user,extra_data)
return return
case "/theme": case "/theme":
route_change_theme(w,req,user) routeChangeTheme(w,req,user)
return return
case "/report": case "/report":
switch(req.URL.Path) { switch(req.URL.Path) {
case "/report/submit/": case "/report/submit/":
route_report_submit(w,req,user,extra_data) routeReportSubmit(w,req,user,extra_data)
return return
} }
case "/topics": case "/topics":
switch(req.URL.Path) { switch(req.URL.Path) {
case "/topics/create/": case "/topics/create/":
route_topic_create(w,req,user,extra_data) routeTopicCreate(w,req,user,extra_data)
return return
default: default:
route_topics(w,req,user) routeTopics(w,req,user)
return return
} }
case "/panel": case "/panel":
switch(req.URL.Path) { switch(req.URL.Path) {
case "/panel/forums/": case "/panel/forums/":
route_panel_forums(w,req,user) routePanelForums(w,req,user)
return return
case "/panel/forums/create/": case "/panel/forums/create/":
route_panel_forums_create_submit(w,req,user) routePanelForumsCreateSubmit(w,req,user)
return return
case "/panel/forums/delete/": case "/panel/forums/delete/":
route_panel_forums_delete(w,req,user,extra_data) routePanelForumsDelete(w,req,user,extra_data)
return return
case "/panel/forums/delete/submit/": case "/panel/forums/delete/submit/":
route_panel_forums_delete_submit(w,req,user,extra_data) routePanelForumsDeleteSubmit(w,req,user,extra_data)
return return
case "/panel/forums/edit/": case "/panel/forums/edit/":
route_panel_forums_edit(w,req,user,extra_data) routePanelForumsEdit(w,req,user,extra_data)
return return
case "/panel/forums/edit/submit/": case "/panel/forums/edit/submit/":
route_panel_forums_edit_submit(w,req,user,extra_data) routePanelForumsEditSubmit(w,req,user,extra_data)
return return
case "/panel/forums/edit/perms/submit/": case "/panel/forums/edit/perms/submit/":
route_panel_forums_edit_perms_submit(w,req,user,extra_data) routePanelForumsEditPermsSubmit(w,req,user,extra_data)
return return
case "/panel/settings/": case "/panel/settings/":
route_panel_settings(w,req,user) routePanelSettings(w,req,user)
return return
case "/panel/settings/edit/": case "/panel/settings/edit/":
route_panel_setting(w,req,user,extra_data) routePanelSetting(w,req,user,extra_data)
return return
case "/panel/settings/edit/submit/": case "/panel/settings/edit/submit/":
route_panel_setting_edit(w,req,user,extra_data) routePanelSettingEdit(w,req,user,extra_data)
return return
case "/panel/settings/word-filters/": case "/panel/settings/word-filters/":
route_panel_word_filters(w,req,user) routePanelWordFilters(w,req,user)
return return
case "/panel/settings/word-filters/create/": case "/panel/settings/word-filters/create/":
route_panel_word_filters_create(w,req,user) routePanelWordFiltersCreate(w,req,user)
return return
case "/panel/settings/word-filters/edit/": case "/panel/settings/word-filters/edit/":
route_panel_word_filters_edit(w,req,user,extra_data) routePanelWordFiltersEdit(w,req,user,extra_data)
return return
case "/panel/settings/word-filters/edit/submit/": case "/panel/settings/word-filters/edit/submit/":
route_panel_word_filters_edit_submit(w,req,user,extra_data) routePanelWordFiltersEditSubmit(w,req,user,extra_data)
return return
case "/panel/settings/word-filters/delete/submit/": case "/panel/settings/word-filters/delete/submit/":
route_panel_word_filters_delete_submit(w,req,user,extra_data) routePanelWordFiltersDeleteSubmit(w,req,user,extra_data)
return return
case "/panel/themes/": case "/panel/themes/":
route_panel_themes(w,req,user) routePanelThemes(w,req,user)
return return
case "/panel/themes/default/": case "/panel/themes/default/":
route_panel_themes_set_default(w,req,user,extra_data) routePanelThemesSetDefault(w,req,user,extra_data)
return return
case "/panel/plugins/": case "/panel/plugins/":
route_panel_plugins(w,req,user) routePanelPlugins(w,req,user)
return return
case "/panel/plugins/activate/": case "/panel/plugins/activate/":
route_panel_plugins_activate(w,req,user,extra_data) routePanelPluginsActivate(w,req,user,extra_data)
return return
case "/panel/plugins/deactivate/": case "/panel/plugins/deactivate/":
route_panel_plugins_deactivate(w,req,user,extra_data) routePanelPluginsDeactivate(w,req,user,extra_data)
return return
case "/panel/plugins/install/": case "/panel/plugins/install/":
route_panel_plugins_install(w,req,user,extra_data) routePanelPluginsInstall(w,req,user,extra_data)
return return
case "/panel/users/": case "/panel/users/":
route_panel_users(w,req,user) routePanelUsers(w,req,user)
return return
case "/panel/users/edit/": case "/panel/users/edit/":
route_panel_users_edit(w,req,user,extra_data) routePanelUsersEdit(w,req,user,extra_data)
return return
case "/panel/users/edit/submit/": case "/panel/users/edit/submit/":
route_panel_users_edit_submit(w,req,user,extra_data) routePanelUsersEditSubmit(w,req,user,extra_data)
return return
case "/panel/groups/": case "/panel/groups/":
route_panel_groups(w,req,user) routePanelGroups(w,req,user)
return return
case "/panel/groups/edit/": case "/panel/groups/edit/":
route_panel_groups_edit(w,req,user,extra_data) routePanelGroupsEdit(w,req,user,extra_data)
return return
case "/panel/groups/edit/perms/": case "/panel/groups/edit/perms/":
route_panel_groups_edit_perms(w,req,user,extra_data) routePanelGroupsEditPerms(w,req,user,extra_data)
return return
case "/panel/groups/edit/submit/": case "/panel/groups/edit/submit/":
route_panel_groups_edit_submit(w,req,user,extra_data) routePanelGroupsEditSubmit(w,req,user,extra_data)
return return
case "/panel/groups/edit/perms/submit/": case "/panel/groups/edit/perms/submit/":
route_panel_groups_edit_perms_submit(w,req,user,extra_data) routePanelGroupsEditPermsSubmit(w,req,user,extra_data)
return return
case "/panel/groups/create/": case "/panel/groups/create/":
route_panel_groups_create_submit(w,req,user) routePanelGroupsCreateSubmit(w,req,user)
return return
case "/panel/logs/mod/": case "/panel/logs/mod/":
route_panel_logs_mod(w,req,user) routePanelLogsMod(w,req,user)
return return
case "/panel/debug/": case "/panel/debug/":
route_panel_debug(w,req,user) routePanelDebug(w,req,user)
return return
default: default:
route_panel(w,req,user) routePanel(w,req,user)
return return
} }
case "/uploads": case "/uploads":
@ -237,7 +237,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// TODO: Add support for favicons and robots.txt files // TODO: Add support for favicons and robots.txt files
switch(extra_data) { switch(extra_data) {
case "robots.txt": case "robots.txt":
route_robots_txt(w,req) routeRobotsTxt(w,req)
return return
} }

View File

@ -178,7 +178,7 @@ config.SmtpPassword = ""
config.SmtpPort = "25" config.SmtpPort = "25"
// Misc // Misc
config.DefaultRoute = route_topics config.DefaultRoute = routeTopics
config.DefaultGroup = 3 // Should be a setting in the database config.DefaultGroup = 3 // Should be a setting in the database
config.ActivationGroup = 5 // Should be a setting in the database config.ActivationGroup = 5 // Should be a setting in the database
config.StaffCss = "staff_post" config.StaffCss = "staff_post"

View File

@ -1,7 +1,7 @@
{ {
"Name": "english", "Name": "english",
"Levels": { "Levels": {
"Level": "Level {0}", "Level": "Level {0}",
"LevelMax": "" "LevelMax": ""
}, },
"GlobalPerms": { "GlobalPerms": {

95
main.go
View File

@ -204,60 +204,61 @@ func main() {
log.Print("Initialising the router") log.Print("Initialising the router")
router = NewGenRouter(http.FileServer(http.Dir("./uploads"))) router = NewGenRouter(http.FileServer(http.Dir("./uploads")))
///router.HandleFunc("/static/", route_static) ////router.HandleFunc("/static/", routeStatic)
///router.HandleFunc("/overview/", route_overview) ////router.HandleFunc("/overview/", routeOverview)
///router.HandleFunc("/topics/create/", route_topic_create) ////router.HandleFunc("/topics/create/", routeTopicCreate)
///router.HandleFunc("/topics/", route_topics) ////router.HandleFunc("/topics/", routeTopics)
///router.HandleFunc("/forums/", route_forums) ////router.HandleFunc("/forums/", routeForums)
///router.HandleFunc("/forum/", route_forum) ////router.HandleFunc("/forum/", routeForum)
router.HandleFunc("/topic/create/submit/", route_topic_create_submit) router.HandleFunc("/topic/create/submit/", routeTopicCreateSubmit)
router.HandleFunc("/topic/", route_topic_id) router.HandleFunc("/topic/", routeTopicID)
router.HandleFunc("/reply/create/", route_create_reply) router.HandleFunc("/reply/create/", routeCreateReply)
//router.HandleFunc("/reply/edit/", route_reply_edit) //router.HandleFunc("/reply/edit/", routeReplyEdit)
//router.HandleFunc("/reply/delete/", route_reply_delete) //router.HandleFunc("/reply/delete/", routeReplyDelete)
router.HandleFunc("/reply/edit/submit/", route_reply_edit_submit) router.HandleFunc("/reply/edit/submit/", routeReplyEditSubmit)
router.HandleFunc("/reply/delete/submit/", route_reply_delete_submit) router.HandleFunc("/reply/delete/submit/", routeReplyDeleteSubmit)
router.HandleFunc("/reply/like/submit/", route_reply_like_submit) router.HandleFunc("/reply/like/submit/", routeReplyLikeSubmit)
///router.HandleFunc("/report/submit/", route_report_submit) ///router.HandleFunc("/report/submit/", route_report_submit)
router.HandleFunc("/topic/edit/submit/", route_edit_topic) router.HandleFunc("/topic/edit/submit/", routeEditTopic)
router.HandleFunc("/topic/delete/submit/", route_delete_topic) router.HandleFunc("/topic/delete/submit/", routeDeleteTopic)
router.HandleFunc("/topic/stick/submit/", route_stick_topic) router.HandleFunc("/topic/stick/submit/", routeStickTopic)
router.HandleFunc("/topic/unstick/submit/", route_unstick_topic) router.HandleFunc("/topic/unstick/submit/", routeUnstickTopic)
router.HandleFunc("/topic/like/submit/", route_like_topic) router.HandleFunc("/topic/like/submit/", routeLikeTopic)
// Custom Pages // Custom Pages
router.HandleFunc("/pages/", route_custom_page) router.HandleFunc("/pages/", routeCustomPage)
// Accounts // Accounts
router.HandleFunc("/accounts/login/", route_login) router.HandleFunc("/accounts/login/", routeLogin)
router.HandleFunc("/accounts/create/", route_register) router.HandleFunc("/accounts/create/", routeRegister)
router.HandleFunc("/accounts/logout/", route_logout) router.HandleFunc("/accounts/logout/", routeLogout)
router.HandleFunc("/accounts/login/submit/", route_login_submit) router.HandleFunc("/accounts/login/submit/", routeLoginSubmit)
router.HandleFunc("/accounts/create/submit/", route_register_submit) router.HandleFunc("/accounts/create/submit/", routeRegisterSubmit)
//router.HandleFunc("/accounts/list/", route_login) // Redirect /accounts/ and /user/ to here.. // Get a list of all of the accounts on the forum //router.HandleFunc("/accounts/list/", routeLogin) // Redirect /accounts/ and /user/ to here.. // Get a list of all of the accounts on the forum
//router.HandleFunc("/accounts/create/full/", route_logout) // Advanced account creator for admins? //router.HandleFunc("/accounts/create/full/", routeLogout) // Advanced account creator for admins?
//router.HandleFunc("/user/edit/", route_logout) //router.HandleFunc("/user/edit/", routeLogout)
router.HandleFunc("/user/edit/critical/", route_account_own_edit_critical) // Password & Email router.HandleFunc("/user/edit/critical/", routeAccountOwnEditCritical) // Password & Email
router.HandleFunc("/user/edit/critical/submit/", route_account_own_edit_critical_submit) router.HandleFunc("/user/edit/critical/submit/", routeAccountOwnEditCriticalSubmit)
router.HandleFunc("/user/edit/avatar/", route_account_own_edit_avatar) router.HandleFunc("/user/edit/avatar/", routeAccountOwnEditAvatar)
router.HandleFunc("/user/edit/avatar/submit/", route_account_own_edit_avatar_submit) router.HandleFunc("/user/edit/avatar/submit/", routeAccountOwnEditAvatarSubmit)
router.HandleFunc("/user/edit/username/", route_account_own_edit_username) router.HandleFunc("/user/edit/username/", routeAccountOwnEditUsername)
router.HandleFunc("/user/edit/username/submit/", route_account_own_edit_username_submit) router.HandleFunc("/user/edit/username/submit/", routeAccountOwnEditUsernameSubmit)
router.HandleFunc("/user/edit/email/", route_account_own_edit_email) router.HandleFunc("/user/edit/email/", routeAccountOwnEditEmail)
router.HandleFunc("/user/edit/token/", route_account_own_edit_email_token_submit) router.HandleFunc("/user/edit/token/", routeAccountOwnEditEmailTokenSubmit)
router.HandleFunc("/user/", route_profile) router.HandleFunc("/user/", routeProfile)
router.HandleFunc("/profile/reply/create/", route_profile_reply_create) router.HandleFunc("/profile/reply/create/", routeProfileReplyCreate)
router.HandleFunc("/profile/reply/edit/submit/", route_profile_reply_edit_submit) router.HandleFunc("/profile/reply/edit/submit/", routeProfileReplyEditSubmit)
router.HandleFunc("/profile/reply/delete/submit/", route_profile_reply_delete_submit) router.HandleFunc("/profile/reply/delete/submit/", routeProfileReplyDeleteSubmit)
//router.HandleFunc("/user/edit/submit/", route_logout) // route_logout? what on earth? o.o //router.HandleFunc("/user/edit/submit/", routeLogout) // routeLogout? what on earth? o.o
//router.HandleFunc("/users/ban/", route_ban) //router.HandleFunc("/users/ban/", routeBan)
router.HandleFunc("/users/ban/submit/", route_ban_submit) router.HandleFunc("/users/ban/submit/", routeBanSubmit)
router.HandleFunc("/users/unban/", route_unban) router.HandleFunc("/users/unban/", routeUnban)
router.HandleFunc("/users/activate/", route_activate) router.HandleFunc("/users/activate/", routeActivate)
router.HandleFunc("/users/ips/", route_ips) router.HandleFunc("/users/ips/", routeIps)
// The Control Panel // The Control Panel
// TODO: Rename the commented route handlers to the new camelCase format :'(
///router.HandleFunc("/panel/", route_panel) ///router.HandleFunc("/panel/", route_panel)
///router.HandleFunc("/panel/forums/", route_panel_forums) ///router.HandleFunc("/panel/forums/", route_panel_forums)
///router.HandleFunc("/panel/forums/create/", route_panel_forums_create_submit) ///router.HandleFunc("/panel/forums/create/", route_panel_forums_create_submit)
@ -289,7 +290,7 @@ func main() {
///router.HandleFunc("/api/", route_api) ///router.HandleFunc("/api/", route_api)
//router.HandleFunc("/exit/", route_exit) //router.HandleFunc("/exit/", route_exit)
///router.HandleFunc("/", default_route) ///router.HandleFunc("/", default_route)
router.HandleFunc("/ws/", route_websockets) router.HandleFunc("/ws/", routeWebsockets)
log.Print("Initialising the plugins") log.Print("Initialising the plugins")
initPlugins() initPlugins()

View File

@ -12,8 +12,8 @@ import (
// TODO: Update the stats after edits so that we don't under or over decrement stats during deletes // TODO: Update the stats after edits so that we don't under or over decrement stats during deletes
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_socialgroups
func route_edit_topic(w http.ResponseWriter, r *http.Request, user User) { func routeEditTopic(w http.ResponseWriter, r *http.Request, user User) {
//log.Print("in route_edit_topic") //log.Print("in routeEditTopic")
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -111,7 +111,7 @@ func route_edit_topic(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_socialgroups
func route_delete_topic(w http.ResponseWriter, r *http.Request, user User) { func routeDeleteTopic(w http.ResponseWriter, r *http.Request, user User) {
tid, err := strconv.Atoi(r.URL.Path[len("/topic/delete/submit/"):]) tid, err := strconv.Atoi(r.URL.Path[len("/topic/delete/submit/"):])
if err != nil { if err != nil {
PreError("The provided TopicID is not a valid number.", w, r) PreError("The provided TopicID is not a valid number.", w, r)
@ -185,7 +185,7 @@ func route_delete_topic(w http.ResponseWriter, r *http.Request, user User) {
topics.Remove(tid) topics.Remove(tid)
} }
func route_stick_topic(w http.ResponseWriter, r *http.Request, user User) { func routeStickTopic(w http.ResponseWriter, r *http.Request, user User) {
tid, err := strconv.Atoi(r.URL.Path[len("/topic/stick/submit/"):]) tid, err := strconv.Atoi(r.URL.Path[len("/topic/stick/submit/"):])
if err != nil { if err != nil {
PreError("The provided TopicID is not a valid number.", w, r) PreError("The provided TopicID is not a valid number.", w, r)
@ -241,7 +241,7 @@ func route_stick_topic(w http.ResponseWriter, r *http.Request, user User) {
http.Redirect(w, r, "/topic/"+strconv.Itoa(tid), http.StatusSeeOther) http.Redirect(w, r, "/topic/"+strconv.Itoa(tid), http.StatusSeeOther)
} }
func route_unstick_topic(w http.ResponseWriter, r *http.Request, user User) { func routeUnstickTopic(w http.ResponseWriter, r *http.Request, user User) {
tid, err := strconv.Atoi(r.URL.Path[len("/topic/unstick/submit/"):]) tid, err := strconv.Atoi(r.URL.Path[len("/topic/unstick/submit/"):])
if err != nil { if err != nil {
PreError("The provided TopicID is not a valid number.", w, r) PreError("The provided TopicID is not a valid number.", w, r)
@ -299,7 +299,7 @@ func route_unstick_topic(w http.ResponseWriter, r *http.Request, user User) {
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_socialgroups
// TODO: Update the stats after edits so that we don't under or over decrement stats during deletes // TODO: Update the stats after edits so that we don't under or over decrement stats during deletes
func route_reply_edit_submit(w http.ResponseWriter, r *http.Request, user User) { func routeReplyEditSubmit(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -356,7 +356,7 @@ func route_reply_edit_submit(w http.ResponseWriter, r *http.Request, user User)
} }
// TODO: Disable stat updates in posts handled by plugin_socialgroups // TODO: Disable stat updates in posts handled by plugin_socialgroups
func route_reply_delete_submit(w http.ResponseWriter, r *http.Request, user User) { func routeReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -446,7 +446,7 @@ func route_reply_delete_submit(w http.ResponseWriter, r *http.Request, user User
} }
} }
func route_profile_reply_edit_submit(w http.ResponseWriter, r *http.Request, user User) { func routeProfileReplyEditSubmit(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
LocalError("Bad Form", w, r, user) LocalError("Bad Form", w, r, user)
@ -487,7 +487,7 @@ func route_profile_reply_edit_submit(w http.ResponseWriter, r *http.Request, use
} }
} }
func route_profile_reply_delete_submit(w http.ResponseWriter, r *http.Request, user User) { func routeProfileReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
LocalError("Bad Form", w, r, user) LocalError("Bad Form", w, r, user)
@ -530,7 +530,7 @@ func route_profile_reply_delete_submit(w http.ResponseWriter, r *http.Request, u
} }
} }
func route_ips(w http.ResponseWriter, r *http.Request, user User) { func routeIps(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -635,7 +635,7 @@ func route_ips(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: This is being replaced with the new ban route system // TODO: This is being replaced with the new ban route system
/*func route_ban(w http.ResponseWriter, r *http.Request, user User) { /*func routeBan(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w,r,&user) headerVars, ok := UserCheck(w,r,&user)
if !ok { if !ok {
return return
@ -673,7 +673,7 @@ func route_ips(w http.ResponseWriter, r *http.Request, user User) {
templates.ExecuteTemplate(w,"areyousure.html",pi) templates.ExecuteTemplate(w,"areyousure.html",pi)
}*/ }*/
func route_ban_submit(w http.ResponseWriter, r *http.Request, user User) { func routeBanSubmit(w http.ResponseWriter, r *http.Request, user User) {
if !user.Perms.BanUsers { if !user.Perms.BanUsers {
NoPermissions(w, r, user) NoPermissions(w, r, user)
return return
@ -768,7 +768,7 @@ func route_ban_submit(w http.ResponseWriter, r *http.Request, user User) {
http.Redirect(w, r, "/user/"+strconv.Itoa(uid), http.StatusSeeOther) http.Redirect(w, r, "/user/"+strconv.Itoa(uid), http.StatusSeeOther)
} }
func route_unban(w http.ResponseWriter, r *http.Request, user User) { func routeUnban(w http.ResponseWriter, r *http.Request, user User) {
if !user.Perms.BanUsers { if !user.Perms.BanUsers {
NoPermissions(w, r, user) NoPermissions(w, r, user)
return return
@ -821,7 +821,7 @@ func route_unban(w http.ResponseWriter, r *http.Request, user User) {
http.Redirect(w, r, "/user/"+strconv.Itoa(uid), http.StatusSeeOther) http.Redirect(w, r, "/user/"+strconv.Itoa(uid), http.StatusSeeOther)
} }
func route_activate(w http.ResponseWriter, r *http.Request, user User) { func routeActivate(w http.ResponseWriter, r *http.Request, user User) {
if !user.Perms.ActivateUsers { if !user.Perms.ActivateUsers {
NoPermissions(w, r, user) NoPermissions(w, r, user)
return return

View File

@ -35,5 +35,5 @@ func (hub *WS_Hub) pushAlerts(_ []int, _ int, _ string, _ string, _ int, _ int,
return errWsNouser return errWsNouser
} }
func route_websockets(_ http.ResponseWriter, _ *http.Request, _ User) { func routeWebsockets(_ http.ResponseWriter, _ *http.Request, _ User) {
} }

View File

@ -14,7 +14,7 @@ import (
"github.com/Azareal/gopsutil/mem" "github.com/Azareal/gopsutil/mem"
) )
func route_panel(w http.ResponseWriter, r *http.Request, user User) { func routePanel(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -180,7 +180,7 @@ func route_panel(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_forums(w http.ResponseWriter, r *http.Request, user User) { func routePanelForums(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -218,7 +218,7 @@ func route_panel_forums(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request, user User) { func routePanelForumsCreateSubmit(w http.ResponseWriter, r *http.Request, user User) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -254,7 +254,7 @@ func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request, us
} }
// TODO: Revamp this // TODO: Revamp this
func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routePanelForumsDelete(w http.ResponseWriter, r *http.Request, user User, sfid string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -298,7 +298,7 @@ func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, user User
} }
} }
func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routePanelForumsDeleteSubmit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -330,7 +330,7 @@ func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, us
http.Redirect(w, r, "/panel/forums/", http.StatusSeeOther) http.Redirect(w, r, "/panel/forums/", http.StatusSeeOther)
} }
func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routePanelForumsEdit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -380,7 +380,7 @@ func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, user User,
} }
} }
func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routePanelForumsEditSubmit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -463,7 +463,7 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user
} }
} }
func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routePanelForumsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -542,7 +542,7 @@ func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request
} }
} }
func route_panel_settings(w http.ResponseWriter, r *http.Request, user User) { func routePanelSettings(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -607,7 +607,7 @@ func route_panel_settings(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_setting(w http.ResponseWriter, r *http.Request, user User, sname string) { func routePanelSetting(w http.ResponseWriter, r *http.Request, user User, sname string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -658,7 +658,7 @@ func route_panel_setting(w http.ResponseWriter, r *http.Request, user User, snam
} }
} }
func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User, sname string) { func routePanelSettingEdit(w http.ResponseWriter, r *http.Request, user User, sname string) {
headerLite, ok := SimplePanelUserCheck(w, r, &user) headerLite, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -714,7 +714,7 @@ func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User,
http.Redirect(w, r, "/panel/settings/", http.StatusSeeOther) http.Redirect(w, r, "/panel/settings/", http.StatusSeeOther)
} }
func route_panel_word_filters(w http.ResponseWriter, r *http.Request, user User) { func routePanelWordFilters(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -737,7 +737,7 @@ func route_panel_word_filters(w http.ResponseWriter, r *http.Request, user User)
} }
} }
func route_panel_word_filters_create(w http.ResponseWriter, r *http.Request, user User) { func routePanelWordFiltersCreate(w http.ResponseWriter, r *http.Request, user User) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -778,7 +778,7 @@ func route_panel_word_filters_create(w http.ResponseWriter, r *http.Request, use
http.Redirect(w, r, "/panel/settings/word-filters/", http.StatusSeeOther) // TODO: Return json for JS? http.Redirect(w, r, "/panel/settings/word-filters/", http.StatusSeeOther) // TODO: Return json for JS?
} }
func route_panel_word_filters_edit(w http.ResponseWriter, r *http.Request, user User, wfid string) { func routePanelWordFiltersEdit(w http.ResponseWriter, r *http.Request, user User, wfid string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -802,7 +802,7 @@ func route_panel_word_filters_edit(w http.ResponseWriter, r *http.Request, user
} }
} }
func route_panel_word_filters_edit_submit(w http.ResponseWriter, r *http.Request, user User, wfid string) { func routePanelWordFiltersEditSubmit(w http.ResponseWriter, r *http.Request, user User, wfid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -848,7 +848,7 @@ func route_panel_word_filters_edit_submit(w http.ResponseWriter, r *http.Request
http.Redirect(w, r, "/panel/settings/word-filters/", http.StatusSeeOther) http.Redirect(w, r, "/panel/settings/word-filters/", http.StatusSeeOther)
} }
func route_panel_word_filters_delete_submit(w http.ResponseWriter, r *http.Request, user User, wfid string) { func routePanelWordFiltersDeleteSubmit(w http.ResponseWriter, r *http.Request, user User, wfid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -884,7 +884,7 @@ func route_panel_word_filters_delete_submit(w http.ResponseWriter, r *http.Reque
http.Redirect(w, r, "/panel/settings/word-filters/", http.StatusSeeOther) http.Redirect(w, r, "/panel/settings/word-filters/", http.StatusSeeOther)
} }
func route_panel_plugins(w http.ResponseWriter, r *http.Request, user User) { func routePanelPlugins(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -913,7 +913,7 @@ func route_panel_plugins(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user User, uname string) { func routePanelPluginsActivate(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -989,7 +989,7 @@ func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user U
http.Redirect(w, r, "/panel/plugins/", http.StatusSeeOther) http.Redirect(w, r, "/panel/plugins/", http.StatusSeeOther)
} }
func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user User, uname string) { func routePanelPluginsDeactivate(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1037,7 +1037,7 @@ func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user
http.Redirect(w, r, "/panel/plugins/", http.StatusSeeOther) http.Redirect(w, r, "/panel/plugins/", http.StatusSeeOther)
} }
func route_panel_plugins_install(w http.ResponseWriter, r *http.Request, user User, uname string) { func routePanelPluginsInstall(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1123,7 +1123,7 @@ func route_panel_plugins_install(w http.ResponseWriter, r *http.Request, user Us
http.Redirect(w, r, "/panel/plugins/", http.StatusSeeOther) http.Redirect(w, r, "/panel/plugins/", http.StatusSeeOther)
} }
func route_panel_users(w http.ResponseWriter, r *http.Request, user User) { func routePanelUsers(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1185,7 +1185,7 @@ func route_panel_users(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_users_edit(w http.ResponseWriter, r *http.Request, user User, suid string) { func routePanelUsersEdit(w http.ResponseWriter, r *http.Request, user User, suid string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1239,7 +1239,7 @@ func route_panel_users_edit(w http.ResponseWriter, r *http.Request, user User, s
} }
} }
func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, user User, suid string) { func routePanelUsersEditSubmit(w http.ResponseWriter, r *http.Request, user User, suid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1334,7 +1334,7 @@ func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, user
http.Redirect(w, r, "/panel/users/edit/"+strconv.Itoa(targetUser.ID), http.StatusSeeOther) http.Redirect(w, r, "/panel/users/edit/"+strconv.Itoa(targetUser.ID), http.StatusSeeOther)
} }
func route_panel_groups(w http.ResponseWriter, r *http.Request, user User) { func routePanelGroups(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1396,7 +1396,7 @@ func route_panel_groups(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, user User, sgid string) { func routePanelGroupsEdit(w http.ResponseWriter, r *http.Request, user User, sgid string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1455,7 +1455,7 @@ func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, user User,
} }
} }
func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, user User, sgid string) { func routePanelGroupsEditPerms(w http.ResponseWriter, r *http.Request, user User, sgid string) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1534,7 +1534,7 @@ func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, user
} }
} }
func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user User, sgid string) { func routePanelGroupsEditSubmit(w http.ResponseWriter, r *http.Request, user User, sgid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1666,7 +1666,7 @@ func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user
http.Redirect(w, r, "/panel/groups/edit/"+strconv.Itoa(gid), http.StatusSeeOther) http.Redirect(w, r, "/panel/groups/edit/"+strconv.Itoa(gid), http.StatusSeeOther)
} }
func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sgid string) { func routePanelGroupsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user User, sgid string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1702,7 +1702,7 @@ func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request
return return
} }
//var lpmap map[string]bool = make(map[string]bool) ////var lpmap map[string]bool = make(map[string]bool)
var pmap = make(map[string]bool) var pmap = make(map[string]bool)
if user.Perms.EditGroupLocalPerms { if user.Perms.EditGroupLocalPerms {
pplist := LocalPermList pplist := LocalPermList
@ -1712,7 +1712,7 @@ func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request
} }
} }
//var gpmap map[string]bool = make(map[string]bool) ////var gpmap map[string]bool = make(map[string]bool)
if user.Perms.EditGroupGlobalPerms { if user.Perms.EditGroupGlobalPerms {
gplist := GlobalPermList gplist := GlobalPermList
for _, perm := range gplist { for _, perm := range gplist {
@ -1742,7 +1742,7 @@ func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request
http.Redirect(w, r, "/panel/groups/edit/perms/"+strconv.Itoa(gid), http.StatusSeeOther) http.Redirect(w, r, "/panel/groups/edit/perms/"+strconv.Itoa(gid), http.StatusSeeOther)
} }
func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request, user User) { func routePanelGroupsCreateSubmit(w http.ResponseWriter, r *http.Request, user User) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1792,7 +1792,7 @@ func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request, us
http.Redirect(w, r, "/panel/groups/edit/"+strconv.Itoa(gid), http.StatusSeeOther) http.Redirect(w, r, "/panel/groups/edit/"+strconv.Itoa(gid), http.StatusSeeOther)
} }
func route_panel_themes(w http.ResponseWriter, r *http.Request, user User) { func routePanelThemes(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1827,7 +1827,7 @@ func route_panel_themes(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_themes_set_default(w http.ResponseWriter, r *http.Request, user User, uname string) { func routePanelThemesSetDefault(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelUserCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1908,7 +1908,7 @@ func route_panel_themes_set_default(w http.ResponseWriter, r *http.Request, user
http.Redirect(w, r, "/panel/themes/", http.StatusSeeOther) http.Redirect(w, r, "/panel/themes/", http.StatusSeeOther)
} }
func route_panel_logs_mod(w http.ResponseWriter, r *http.Request, user User) { func routePanelLogsMod(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -2024,7 +2024,7 @@ func route_panel_logs_mod(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_panel_debug(w http.ResponseWriter, r *http.Request, user User) { func routePanelDebug(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelUserCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return

View File

@ -23,7 +23,7 @@ var currentLanguage = "english"
var currentLangPack atomic.Value var currentLangPack atomic.Value
var langpackCount int // TODO: Use atomics for this var langpackCount int // TODO: Use atomics for this
// We'll be implementing the level phrases in the software proper very very soon! // TODO: We'll be implementing the level phrases in the software proper very very soon!
type LevelPhrases struct { type LevelPhrases struct {
Level string Level string
LevelMax string // ? Add a max level setting? LevelMax string // ? Add a max level setting?
@ -32,6 +32,7 @@ type LevelPhrases struct {
Levels []string // index = level Levels []string // index = level
} }
// ! For the sake of thread safety, you must never modify a *LanguagePack directly, but to create a copy of it and overwrite the entry in the sync.Map
type LanguagePack struct { type LanguagePack struct {
Name string Name string
Phrases map[string]string // Should we use a sync map or a struct for these? It would be nice, if we could keep all the phrases consistent. Phrases map[string]string // Should we use a sync map or a struct for these? It would be nice, if we could keep all the phrases consistent.
@ -42,7 +43,6 @@ type LanguagePack struct {
} }
// TODO: Add the ability to edit language JSON files from the Control Panel and automatically scan the files for changes // TODO: Add the ability to edit language JSON files from the Control Panel and automatically scan the files for changes
// TODO: Move the english language pack into a JSON file and load that on start-up
////var langpacks = map[string]*LanguagePack ////var langpacks = map[string]*LanguagePack
var langpacks sync.Map // nolint it is used var langpacks sync.Map // nolint it is used
@ -94,12 +94,18 @@ func initPhrases() error {
return nil return nil
} }
// TODO: Implement this
func LoadLangPack(name string) error { func LoadLangPack(name string) error {
_ = name _ = name
return nil return nil
} }
// We might not need to use a mutex for this, we shouldn't need to change the phrases after start-up, and when we do we could overwrite the entire map // TODO: Implement this
func SaveLangPack(langPack *LanguagePack) error {
_ = langPack
return nil
}
func GetPhrase(name string) (string, bool) { func GetPhrase(name string) (string, bool) {
res, ok := currentLangPack.Load().(*LanguagePack).Phrases[name] res, ok := currentLangPack.Load().(*LanguagePack).Phrases[name]
return res, ok return res, ok
@ -129,12 +135,12 @@ func GetSettingLabel(name string) string {
return res return res
} }
// Is this a copy of the map or a pointer to it? We don't want to accidentally create a race condition
func GetAllSettingLabels() map[string]string { func GetAllSettingLabels() map[string]string {
return currentLangPack.Load().(*LanguagePack).SettingLabels return currentLangPack.Load().(*LanguagePack).SettingLabels
} }
// Use runtime reflection for updating phrases? // ? - Use runtime reflection for updating phrases?
// TODO: Implement these
func AddPhrase() { func AddPhrase() {
} }

View File

@ -346,9 +346,9 @@ func socialgroupsViewGroup(w http.ResponseWriter, r *http.Request, user User) {
NotFound(w, r) NotFound(w, r)
} }
// Re-route the request to route_forums // Re-route the request to routeForums
var ctx = context.WithValue(r.Context(), "socialgroups_current_group", sgItem) var ctx = context.WithValue(r.Context(), "socialgroups_current_group", sgItem)
route_forum(w, r.WithContext(ctx), user, strconv.Itoa(sgItem.MainForumID)) routeForum(w, r.WithContext(ctx), user, strconv.Itoa(sgItem.MainForumID))
} }
func socialgroupsCreateGroup(w http.ResponseWriter, r *http.Request, user User) { func socialgroupsCreateGroup(w http.ResponseWriter, r *http.Request, user User) {

View File

@ -142,7 +142,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
if dev.SuperDebug { if dev.SuperDebug {
log.Print("before route_static") log.Print("before routeStatic")
log.Print("prefix: ", prefix) log.Print("prefix: ", prefix)
log.Print("req.URL.Path: ", req.URL.Path) log.Print("req.URL.Path: ", req.URL.Path)
log.Print("extra_data: ", extra_data) log.Print("extra_data: ", extra_data)
@ -151,7 +151,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if prefix == "/static" { if prefix == "/static" {
req.URL.Path += extra_data req.URL.Path += extra_data
route_static(w,req) routeStatic(w,req)
return return
} }
@ -183,7 +183,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// TODO: Add support for favicons and robots.txt files // TODO: Add support for favicons and robots.txt files
switch(extra_data) { switch(extra_data) {
case "robots.txt": case "robots.txt":
route_robots_txt(w,req) routeRobotsTxt(w,req)
return return
} }

View File

@ -22,66 +22,66 @@ func addRouteGroup(path string, routes ...Route) {
func routes() { func routes() {
//addRoute("default_route","","") //addRoute("default_route","","")
addRoute("route_api", "/api/", "") addRoute("routeAPI", "/api/", "")
///addRoute("route_static","/static/","req.URL.Path += extra_data") ///addRoute("routeStatic","/static/","req.URL.Path += extra_data")
addRoute("route_overview", "/overview/", "") addRoute("routeOverview", "/overview/", "")
//addRoute("route_custom_page","/pages/",""/*,"&extra_data"*/) //addRoute("routeCustomPage","/pages/",""/*,"&extra_data"*/)
addRoute("route_forums", "/forums/", "" /*,"&forums"*/) addRoute("routeForums", "/forums/", "" /*,"&forums"*/)
addRoute("route_forum", "/forum/", "", "extra_data") addRoute("routeForum", "/forum/", "", "extra_data")
//addRoute("route_topic_create","/topics/create/","","extra_data") //addRoute("routeTopicCreate","/topics/create/","","extra_data")
//addRoute("route_topics","/topics/",""/*,"&groups","&forums"*/) //addRoute("routeTopics","/topics/",""/*,"&groups","&forums"*/)
addRoute("route_change_theme", "/theme/", "") addRoute("routeChangeTheme", "/theme/", "")
addRouteGroup("/report/", addRouteGroup("/report/",
Route{"route_report_submit", "/report/submit/", "", []string{"extra_data"}}, Route{"routeReportSubmit", "/report/submit/", "", []string{"extra_data"}},
) )
addRouteGroup("/topics/", addRouteGroup("/topics/",
Route{"route_topics", "/topics/", "", []string{}}, Route{"routeTopics", "/topics/", "", []string{}},
Route{"route_topic_create", "/topics/create/", "", []string{"extra_data"}}, Route{"routeTopicCreate", "/topics/create/", "", []string{"extra_data"}},
) )
// The Control Panel // The Control Panel
addRouteGroup("/panel/", addRouteGroup("/panel/",
Route{"route_panel", "/panel/", "", []string{}}, Route{"routePanel", "/panel/", "", []string{}},
Route{"route_panel_forums", "/panel/forums/", "", []string{}}, Route{"routePanelForums", "/panel/forums/", "", []string{}},
Route{"route_panel_forums_create_submit", "/panel/forums/create/", "", []string{}}, Route{"routePanelForumsCreateSubmit", "/panel/forums/create/", "", []string{}},
Route{"route_panel_forums_delete", "/panel/forums/delete/", "", []string{"extra_data"}}, Route{"routePanelForumsDelete", "/panel/forums/delete/", "", []string{"extra_data"}},
Route{"route_panel_forums_delete_submit", "/panel/forums/delete/submit/", "", []string{"extra_data"}}, Route{"routePanelForumsDeleteSubmit", "/panel/forums/delete/submit/", "", []string{"extra_data"}},
Route{"route_panel_forums_edit", "/panel/forums/edit/", "", []string{"extra_data"}}, Route{"routePanelForumsEdit", "/panel/forums/edit/", "", []string{"extra_data"}},
Route{"route_panel_forums_edit_submit", "/panel/forums/edit/submit/", "", []string{"extra_data"}}, Route{"routePanelForumsEditSubmit", "/panel/forums/edit/submit/", "", []string{"extra_data"}},
Route{"route_panel_forums_edit_perms_submit", "/panel/forums/edit/perms/submit/", "", []string{"extra_data"}}, Route{"routePanelForumsEditPermsSubmit", "/panel/forums/edit/perms/submit/", "", []string{"extra_data"}},
Route{"route_panel_settings", "/panel/settings/", "", []string{}}, Route{"routePanelSettings", "/panel/settings/", "", []string{}},
Route{"route_panel_setting", "/panel/settings/edit/", "", []string{"extra_data"}}, Route{"routePanelSetting", "/panel/settings/edit/", "", []string{"extra_data"}},
Route{"route_panel_setting_edit", "/panel/settings/edit/submit/", "", []string{"extra_data"}}, Route{"routePanelSettingEdit", "/panel/settings/edit/submit/", "", []string{"extra_data"}},
Route{"route_panel_word_filters", "/panel/settings/word-filters/", "", []string{}}, Route{"routePanelWordFilters", "/panel/settings/word-filters/", "", []string{}},
Route{"route_panel_word_filters_create", "/panel/settings/word-filters/create/", "", []string{}}, Route{"routePanelWordFiltersCreate", "/panel/settings/word-filters/create/", "", []string{}},
Route{"route_panel_word_filters_edit", "/panel/settings/word-filters/edit/", "", []string{"extra_data"}}, Route{"routePanelWordFiltersEdit", "/panel/settings/word-filters/edit/", "", []string{"extra_data"}},
Route{"route_panel_word_filters_edit_submit", "/panel/settings/word-filters/edit/submit/", "", []string{"extra_data"}}, Route{"routePanelWordFiltersEditSubmit", "/panel/settings/word-filters/edit/submit/", "", []string{"extra_data"}},
Route{"route_panel_word_filters_delete_submit", "/panel/settings/word-filters/delete/submit/", "", []string{"extra_data"}}, Route{"routePanelWordFiltersDeleteSubmit", "/panel/settings/word-filters/delete/submit/", "", []string{"extra_data"}},
Route{"route_panel_themes", "/panel/themes/", "", []string{}}, Route{"routePanelThemes", "/panel/themes/", "", []string{}},
Route{"route_panel_themes_set_default", "/panel/themes/default/", "", []string{"extra_data"}}, Route{"routePanelThemesSetDefault", "/panel/themes/default/", "", []string{"extra_data"}},
Route{"route_panel_plugins", "/panel/plugins/", "", []string{}}, Route{"routePanelPlugins", "/panel/plugins/", "", []string{}},
Route{"route_panel_plugins_activate", "/panel/plugins/activate/", "", []string{"extra_data"}}, Route{"routePanelPluginsActivate", "/panel/plugins/activate/", "", []string{"extra_data"}},
Route{"route_panel_plugins_deactivate", "/panel/plugins/deactivate/", "", []string{"extra_data"}}, Route{"routePanelPluginsDeactivate", "/panel/plugins/deactivate/", "", []string{"extra_data"}},
Route{"route_panel_plugins_install", "/panel/plugins/install/", "", []string{"extra_data"}}, Route{"routePanelPluginsInstall", "/panel/plugins/install/", "", []string{"extra_data"}},
Route{"route_panel_users", "/panel/users/", "", []string{}}, Route{"routePanelUsers", "/panel/users/", "", []string{}},
Route{"route_panel_users_edit", "/panel/users/edit/", "", []string{"extra_data"}}, Route{"routePanelUsersEdit", "/panel/users/edit/", "", []string{"extra_data"}},
Route{"route_panel_users_edit_submit", "/panel/users/edit/submit/", "", []string{"extra_data"}}, Route{"routePanelUsersEditSubmit", "/panel/users/edit/submit/", "", []string{"extra_data"}},
Route{"route_panel_groups", "/panel/groups/", "", []string{}}, Route{"routePanelGroups", "/panel/groups/", "", []string{}},
Route{"route_panel_groups_edit", "/panel/groups/edit/", "", []string{"extra_data"}}, Route{"routePanelGroupsEdit", "/panel/groups/edit/", "", []string{"extra_data"}},
Route{"route_panel_groups_edit_perms", "/panel/groups/edit/perms/", "", []string{"extra_data"}}, Route{"routePanelGroupsEditPerms", "/panel/groups/edit/perms/", "", []string{"extra_data"}},
Route{"route_panel_groups_edit_submit", "/panel/groups/edit/submit/", "", []string{"extra_data"}}, Route{"routePanelGroupsEditSubmit", "/panel/groups/edit/submit/", "", []string{"extra_data"}},
Route{"route_panel_groups_edit_perms_submit", "/panel/groups/edit/perms/submit/", "", []string{"extra_data"}}, Route{"routePanelGroupsEditPermsSubmit", "/panel/groups/edit/perms/submit/", "", []string{"extra_data"}},
Route{"route_panel_groups_create_submit", "/panel/groups/create/", "", []string{}}, Route{"routePanelGroupsCreateSubmit", "/panel/groups/create/", "", []string{}},
Route{"route_panel_logs_mod", "/panel/logs/mod/", "", []string{}}, Route{"routePanelLogsMod", "/panel/logs/mod/", "", []string{}},
Route{"route_panel_debug", "/panel/debug/", "", []string{}}, Route{"routePanelDebug", "/panel/debug/", "", []string{}},
) )
} }

View File

@ -47,7 +47,7 @@ func (red *HTTPSRedirect) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
// GET functions // GET functions
func route_static(w http.ResponseWriter, r *http.Request) { func routeStatic(w http.ResponseWriter, r *http.Request) {
//log.Print("Outputting static file '" + r.URL.Path + "'") //log.Print("Outputting static file '" + r.URL.Path + "'")
file, ok := staticFiles[r.URL.Path] file, ok := staticFiles[r.URL.Path]
if !ok { if !ok {
@ -94,7 +94,7 @@ func route_fstatic(w http.ResponseWriter, r *http.Request){
// TODO: Make this a static file somehow? Is it possible for us to put this file somewhere else? // TODO: Make this a static file somehow? Is it possible for us to put this file somewhere else?
// TODO: Add a sitemap // TODO: Add a sitemap
// TODO: Add an API so that plugins can register disallowed areas. E.g. /groups/join for plugin_socialgroups // TODO: Add an API so that plugins can register disallowed areas. E.g. /groups/join for plugin_socialgroups
func route_robots_txt(w http.ResponseWriter, r *http.Request) { func routeRobotsTxt(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(`User-agent: * _, _ = w.Write([]byte(`User-agent: *
Disallow: /panel/ Disallow: /panel/
Disallow: /topics/create/ Disallow: /topics/create/
@ -103,7 +103,7 @@ Disallow: /accounts/
`)) `))
} }
func route_overview(w http.ResponseWriter, r *http.Request, user User) { func routeOverview(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -123,7 +123,7 @@ func route_overview(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_custom_page(w http.ResponseWriter, r *http.Request, user User) { func routeCustomPage(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -150,7 +150,7 @@ func route_custom_page(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Paginate this // TODO: Paginate this
func route_topics(w http.ResponseWriter, r *http.Request, user User) { func routeTopics(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -256,7 +256,7 @@ func route_topics(w http.ResponseWriter, r *http.Request, user User) {
RunThemeTemplate(headerVars.ThemeName, "topics", pi, w) RunThemeTemplate(headerVars.ThemeName, "topics", pi, w)
} }
func route_forum(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routeForum(w http.ResponseWriter, r *http.Request, user User, sfid string) {
page, _ := strconv.Atoi(r.FormValue("page")) page, _ := strconv.Atoi(r.FormValue("page"))
// SEO URLs... // SEO URLs...
@ -371,7 +371,7 @@ func route_forum(w http.ResponseWriter, r *http.Request, user User, sfid string)
RunThemeTemplate(headerVars.ThemeName, "forum", pi, w) RunThemeTemplate(headerVars.ThemeName, "forum", pi, w)
} }
func route_forums(w http.ResponseWriter, r *http.Request, user User) { func routeForums(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -423,7 +423,7 @@ func route_forums(w http.ResponseWriter, r *http.Request, user User) {
RunThemeTemplate(headerVars.ThemeName, "forums", pi, w) RunThemeTemplate(headerVars.ThemeName, "forums", pi, w)
} }
func route_topic_id(w http.ResponseWriter, r *http.Request, user User) { func routeTopicID(w http.ResponseWriter, r *http.Request, user User) {
var err error var err error
var page, offset int var page, offset int
var replyList []Reply var replyList []Reply
@ -604,7 +604,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request, user User) {
RunThemeTemplate(headerVars.ThemeName, "topic", tpage, w) RunThemeTemplate(headerVars.ThemeName, "topic", tpage, w)
} }
func route_profile(w http.ResponseWriter, r *http.Request, user User) { func routeProfile(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -703,7 +703,7 @@ func route_profile(w http.ResponseWriter, r *http.Request, user User) {
template_profile_handle(ppage, w) template_profile_handle(ppage, w)
} }
func route_topic_create(w http.ResponseWriter, r *http.Request, user User, sfid string) { func routeTopicCreate(w http.ResponseWriter, r *http.Request, user User, sfid string) {
var fid int var fid int
var err error var err error
if sfid != "" { if sfid != "" {
@ -776,7 +776,7 @@ func route_topic_create(w http.ResponseWriter, r *http.Request, user User, sfid
} }
// POST functions. Authorised users only. // POST functions. Authorised users only.
func route_topic_create_submit(w http.ResponseWriter, r *http.Request, user User) { func routeTopicCreateSubmit(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -844,7 +844,7 @@ func route_topic_create_submit(w http.ResponseWriter, r *http.Request, user User
} }
} }
func route_create_reply(w http.ResponseWriter, r *http.Request, user User) { func routeCreateReply(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -940,7 +940,7 @@ func route_create_reply(w http.ResponseWriter, r *http.Request, user User) {
} }
} }
func route_like_topic(w http.ResponseWriter, r *http.Request, user User) { func routeLikeTopic(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -1041,7 +1041,7 @@ func route_like_topic(w http.ResponseWriter, r *http.Request, user User) {
http.Redirect(w, r, "/topic/"+strconv.Itoa(tid), http.StatusSeeOther) http.Redirect(w, r, "/topic/"+strconv.Itoa(tid), http.StatusSeeOther)
} }
func route_reply_like_submit(w http.ResponseWriter, r *http.Request, user User) { func routeReplyLikeSubmit(w http.ResponseWriter, r *http.Request, user User) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)
@ -1142,7 +1142,7 @@ func route_reply_like_submit(w http.ResponseWriter, r *http.Request, user User)
http.Redirect(w, r, "/topic/"+strconv.Itoa(reply.ParentID), http.StatusSeeOther) http.Redirect(w, r, "/topic/"+strconv.Itoa(reply.ParentID), http.StatusSeeOther)
} }
func route_profile_reply_create(w http.ResponseWriter, r *http.Request, user User) { func routeProfileReplyCreate(w http.ResponseWriter, r *http.Request, user User) {
if !user.Loggedin || !user.Perms.CreateReply { if !user.Loggedin || !user.Perms.CreateReply {
NoPermissions(w, r, user) NoPermissions(w, r, user)
return return
@ -1184,7 +1184,7 @@ func route_profile_reply_create(w http.ResponseWriter, r *http.Request, user Use
http.Redirect(w, r, "/user/"+strconv.Itoa(uid), http.StatusSeeOther) http.Redirect(w, r, "/user/"+strconv.Itoa(uid), http.StatusSeeOther)
} }
func route_report_submit(w http.ResponseWriter, r *http.Request, user User, sitemID string) { func routeReportSubmit(w http.ResponseWriter, r *http.Request, user User, sitemID string) {
if !user.Loggedin { if !user.Loggedin {
LoginRequired(w, r, user) LoginRequired(w, r, user)
return return
@ -1321,7 +1321,7 @@ func route_report_submit(w http.ResponseWriter, r *http.Request, user User, site
http.Redirect(w, r, "/topic/"+strconv.FormatInt(lastID, 10), http.StatusSeeOther) http.Redirect(w, r, "/topic/"+strconv.FormatInt(lastID, 10), http.StatusSeeOther)
} }
func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditCritical(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1340,7 +1340,7 @@ func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request, use
templates.ExecuteTemplate(w, "account-own-edit.html", pi) templates.ExecuteTemplate(w, "account-own-edit.html", pi)
} }
func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditCriticalSubmit(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1397,7 +1397,7 @@ func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Reque
templates.ExecuteTemplate(w, "account-own-edit.html", pi) templates.ExecuteTemplate(w, "account-own-edit.html", pi)
} }
func route_account_own_edit_avatar(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditAvatar(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1415,7 +1415,7 @@ func route_account_own_edit_avatar(w http.ResponseWriter, r *http.Request, user
templates.ExecuteTemplate(w, "account-own-edit-avatar.html", pi) templates.ExecuteTemplate(w, "account-own-edit-avatar.html", pi)
} }
func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditAvatarSubmit(w http.ResponseWriter, r *http.Request, user User) {
if r.ContentLength > int64(config.MaxRequestSize) { if r.ContentLength > int64(config.MaxRequestSize) {
http.Error(w, "Request too large", http.StatusExpectationFailed) http.Error(w, "Request too large", http.StatusExpectationFailed)
return return
@ -1513,7 +1513,7 @@ func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request
templates.ExecuteTemplate(w, "account-own-edit-avatar.html", pi) templates.ExecuteTemplate(w, "account-own-edit-avatar.html", pi)
} }
func route_account_own_edit_username(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditUsername(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1531,7 +1531,7 @@ func route_account_own_edit_username(w http.ResponseWriter, r *http.Request, use
templates.ExecuteTemplate(w, "account-own-edit-username.html", pi) templates.ExecuteTemplate(w, "account-own-edit-username.html", pi)
} }
func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditUsernameSubmit(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1571,7 +1571,7 @@ func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Reque
templates.ExecuteTemplate(w, "account-own-edit-username.html", pi) templates.ExecuteTemplate(w, "account-own-edit-username.html", pi)
} }
func route_account_own_edit_email(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditEmail(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1626,7 +1626,7 @@ func route_account_own_edit_email(w http.ResponseWriter, r *http.Request, user U
templates.ExecuteTemplate(w, "account-own-edit-email.html", pi) templates.ExecuteTemplate(w, "account-own-edit-email.html", pi)
} }
func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Request, user User) { func routeAccountOwnEditEmailTokenSubmit(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1706,7 +1706,7 @@ func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Re
} }
// TODO: Move this into member_routes.go // TODO: Move this into member_routes.go
func route_logout(w http.ResponseWriter, r *http.Request, user User) { func routeLogout(w http.ResponseWriter, r *http.Request, user User) {
if !user.Loggedin { if !user.Loggedin {
LocalError("You can't logout without logging in first.", w, r, user) LocalError("You can't logout without logging in first.", w, r, user)
return return
@ -1715,7 +1715,7 @@ func route_logout(w http.ResponseWriter, r *http.Request, user User) {
http.Redirect(w, r, "/", http.StatusSeeOther) http.Redirect(w, r, "/", http.StatusSeeOther)
} }
func route_login(w http.ResponseWriter, r *http.Request, user User) { func routeLogin(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1736,7 +1736,7 @@ func route_login(w http.ResponseWriter, r *http.Request, user User) {
// TODO: Log failed attempted logins? // TODO: Log failed attempted logins?
// TODO: Lock IPS out if they have too many failed attempts? // TODO: Lock IPS out if they have too many failed attempts?
// TODO: Log unusual countries in comparison to the country a user usually logs in from? Alert the user about this? // TODO: Log unusual countries in comparison to the country a user usually logs in from? Alert the user about this?
func route_login_submit(w http.ResponseWriter, r *http.Request, user User) { func routeLoginSubmit(w http.ResponseWriter, r *http.Request, user User) {
if user.Loggedin { if user.Loggedin {
LocalError("You're already logged in.", w, r, user) LocalError("You're already logged in.", w, r, user)
return return
@ -1784,7 +1784,7 @@ func route_login_submit(w http.ResponseWriter, r *http.Request, user User) {
http.Redirect(w, r, "/", http.StatusSeeOther) http.Redirect(w, r, "/", http.StatusSeeOther)
} }
func route_register(w http.ResponseWriter, r *http.Request, user User) { func routeRegister(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := UserCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
@ -1802,7 +1802,7 @@ func route_register(w http.ResponseWriter, r *http.Request, user User) {
templates.ExecuteTemplate(w, "register.html", pi) templates.ExecuteTemplate(w, "register.html", pi)
} }
func route_register_submit(w http.ResponseWriter, r *http.Request, user User) { func routeRegisterSubmit(w http.ResponseWriter, r *http.Request, user User) {
headerLite, _ := SimpleUserCheck(w, r, &user) headerLite, _ := SimpleUserCheck(w, r, &user)
err := r.ParseForm() err := r.ParseForm()
@ -1901,7 +1901,7 @@ func route_register_submit(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Set the cookie domain // TODO: Set the cookie domain
func route_change_theme(w http.ResponseWriter, r *http.Request, user User) { func routeChangeTheme(w http.ResponseWriter, r *http.Request, user User) {
//headerLite, _ := SimpleUserCheck(w, r, &user) //headerLite, _ := SimpleUserCheck(w, r, &user)
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
@ -1943,7 +1943,7 @@ func route_change_theme(w http.ResponseWriter, r *http.Request, user User) {
// TODO: We don't need support XML here to support sitemaps, we could handle those elsewhere // TODO: We don't need support XML here to support sitemaps, we could handle those elsewhere
var phraseLoginAlerts = []byte(`{"msgs":[{"msg":"Login to see your alerts","path":"/accounts/login"}]}`) var phraseLoginAlerts = []byte(`{"msgs":[{"msg":"Login to see your alerts","path":"/accounts/login"}]}`)
func route_api(w http.ResponseWriter, r *http.Request, user User) { func routeAPI(w http.ResponseWriter, r *http.Request, user User) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {

View File

@ -2,6 +2,8 @@ package main
import "net/http" import "net/http"
// TODO: Add a langPack configuration item or setting
var site = &Site{Name: "Magical Fairy Land"} var site = &Site{Name: "Magical Fairy Land"}
var db_config = DB_Config{Host: "localhost"} var db_config = DB_Config{Host: "localhost"}
var config Config var config Config

View File

@ -155,7 +155,7 @@ func (hub *WS_Hub) pushAlerts(users []int, asid int, event string, elementType s
return nil return nil
} }
func route_websockets(w http.ResponseWriter, r *http.Request, user User) { func routeWebsockets(w http.ResponseWriter, r *http.Request, user User) {
conn, err := wsUpgrader.Upgrade(w, r, nil) conn, err := wsUpgrader.Upgrade(w, r, nil)
if err != nil { if err != nil {
return return