diff --git a/.gitignore b/.gitignore index 2b1307dd..79aecf79 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,6 @@ tmp/* tmp2/* uploads/avatar_* bin/* -gosora.exe -gosora.test.exe -install.exe +*.exe *.prof .DS_Store diff --git a/data.sql b/data.sql index 452b4c89..2dc46cb9 100644 --- a/data.sql +++ b/data.sql @@ -217,6 +217,7 @@ ManageForums EditSettings ManageThemes ManagePlugins +ViewAdminLogs ViewIPs ViewTopic @@ -231,7 +232,7 @@ PinTopic CloseTopic */ -INSERT INTO users_groups(`name`,`permissions`,`is_mod`,`is_admin`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewIPs":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,1,"Admin"); +INSERT INTO users_groups(`name`,`permissions`,`is_mod`,`is_admin`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,1,"Admin"); INSERT INTO users_groups(`name`,`permissions`,`is_mod`,`tag`) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":false,"EditUser":true,"EditUserEmail":false,"EditUserGroup":true,"ViewIPs":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}',1,"Mod"); INSERT INTO users_groups(`name`,`permissions`) VALUES ('Member','{"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}'); INSERT INTO users_groups(`name`,`permissions`,`is_banned`) VALUES ('Banned','{"ViewTopic":true}',1); diff --git a/general_test.go b/general_test.go index 7ec9ec4e..28a6b7dc 100644 --- a/general_test.go +++ b/general_test.go @@ -3,6 +3,7 @@ import "os" import "fmt" import "log" import "bytes" +import "strings" import "strconv" import "math/rand" import "testing" @@ -10,17 +11,17 @@ import "net/http" import "net/http/httptest" import "io/ioutil" import "database/sql" +import "runtime/pprof" + //import _ "github.com/go-sql-driver/mysql" //import "github.com/erikstmartin/go-testdb" //import "github.com/husobee/vestigo" -import "runtime/pprof" var db_test *sql.DB var db_prod *sql.DB var gloinited bool = false func gloinit() { - var err error debug = false nogrouplog = true @@ -29,7 +30,11 @@ func gloinit() { //log.SetOutput(discard) init_themes() - init_database(err) + err := init_database() + if err != nil { + log.Fatal(err) + } + db_prod = db //db_test, err = sql.Open("testdb","") //if err != nil { @@ -73,16 +78,16 @@ func BenchmarkTopicTemplateSerial(b *testing.B) { topic := TopicUser{Title: "Lol",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,CreatedByName:"Admin",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"} var replyList []Reply - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) - replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) + replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""}) tpage := TopicPage{"Topic Blah",user,noticeList,replyList,topic,1,1,false} tpage2 := TopicPage{"Topic Blah",admin,noticeList,replyList,topic,1,1,false} @@ -1409,4 +1414,33 @@ func TestForumGuestRoute(t *testing.T) { /*func TestRoute(t *testing.T) { -}*/ \ No newline at end of file +}*/ + +func TestSplittyThing(t *testing.T) { + fmt.Println("Splitty thing test") + var extra_data string + var path string = "/pages/hohoho" + fmt.Println("Raw Path:",path) + if path[len(path) - 1] != '/' { + extra_data = path[strings.LastIndexByte(path,'/') + 1:] + path = path[:strings.LastIndexByte(path,'/') + 1] + } + fmt.Println("Path:", path) + fmt.Println("Extra Data:", extra_data) + fmt.Println("Path Bytes:", []byte(path)) + fmt.Println("Extra Data Bytes:", []byte(extra_data)) + + + fmt.Println("Splitty thing test") + path = "/topics/" + extra_data = "" + fmt.Println("Raw Path:",path) + if path[len(path) - 1] != '/' { + extra_data = path[strings.LastIndexByte(path,'/') + 1:] + path = path[:strings.LastIndexByte(path,'/') + 1] + } + fmt.Println("Path:", path) + fmt.Println("Extra Data:", extra_data) + fmt.Println("Path Bytes:", []byte(path)) + fmt.Println("Extra Data Bytes:", []byte(extra_data)) +} diff --git a/main.go b/main.go index d8c9ee87..0d5947c6 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ const day int = hour * 24 const month int = day * 30 const year int = day * 365 const kilobyte int = 1024 -const megabyte int = 1024 * 1024 +const megabyte int = kilobyte * 1024 const saltLength int = 32 const sessionLength int = 80 var nogrouplog bool = false // This is mainly for benchmarks, as we don't want a lot of information getting in the way of the results @@ -158,8 +158,11 @@ func main(){ //} init_themes() - var err error - init_database(err) + err := init_database() + if err != nil { + log.Fatal(err) + } + init_templates() db.SetMaxOpenConns(64) @@ -184,13 +187,13 @@ func main(){ init_plugins() router := NewRouter() - router.HandleFunc("/static/", route_static) + router.HandleFunc("/static/", route_static)// fs_u := http.FileServer(http.Dir("./uploads")) - router.Handle("/uploads/", http.StripPrefix("/uploads/",fs_u)) + router.Handle("/uploads/", http.StripPrefix("/uploads/",fs_u))// - router.HandleFunc("/overview/", route_overview) + router.HandleFunc("/overview/", route_overview)// router.HandleFunc("/topics/create/", route_topic_create) - router.HandleFunc("/topics/", route_topics) + router.HandleFunc("/topics/", route_topics)// router.HandleFunc("/forums/", route_forums) router.HandleFunc("/forum/", route_forum) router.HandleFunc("/topic/create/submit/", route_create_topic) diff --git a/mysql.go b/mysql.go index d571e987..64355599 100644 --- a/mysql.go +++ b/mysql.go @@ -10,6 +10,7 @@ import "encoding/json" var db *sql.DB var db_version string +var db_collation string = "utf8mb4_general_ci" var get_user_stmt *sql.Stmt var get_full_user_stmt *sql.Stmt @@ -94,19 +95,19 @@ var update_theme_stmt *sql.Stmt var add_modlog_entry_stmt *sql.Stmt var add_adminlog_entry_stmt *sql.Stmt -func init_database(err error) { +func init_database() (err error) { if(dbpassword != ""){ dbpassword = ":" + dbpassword } - db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname + "?collation=utf8mb4_general_ci") + db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname + "?collation=" + db_collation) if err != nil { - log.Fatal(err) + return err } // Make sure that the connection is alive.. err = db.Ping() if err != nil { - log.Fatal(err) + return err } // Getting the database version.. @@ -115,259 +116,259 @@ func init_database(err error) { /*log.Print("Preparing get_session statement.") get_session_stmt, err = db.Prepare("select `uid`,`name`,`group`,`is_super_admin`,`session`,`email`,`avatar`,`message`,`url_prefix`,`url_name`,`level`,`score`,`last_ip` from `users` where `uid` = ? and `session` = ? AND `session` <> ''") if err != nil { - log.Fatal(err) + return err }*/ log.Print("Preparing get_user statement.") get_user_stmt, err = db.Prepare("select `name`,`group`,`is_super_admin`,`avatar`,`message`,`url_prefix`,`url_name`,`level` from `users` where `uid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_full_user statement.") get_full_user_stmt, err = db.Prepare("select `name`,`group`,`is_super_admin`,`session`,`email`,`avatar`,`message`,`url_prefix`,`url_name`,`level`,`score`,`last_ip` from `users` where `uid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_topic_list statement.") get_topic_list_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.parentID, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_topic_user statement.") get_topic_user_stmt, err = db.Prepare("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level from topics left join users ON topics.createdBy = users.uid where tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_topic statement.") get_topic_stmt, err = db.Prepare("select title, content, createdBy, createdAt, is_closed, sticky, parentID, ipaddress, postCount, likeCount from topics where tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_topic_by_reply statement.") get_topic_by_reply_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount from replies left join topics on replies.tid = topics.tid where rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_topic_replies statement.") get_topic_replies_stmt, err = db.Prepare("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress from replies left join users ON replies.createdBy = users.uid where tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_topic_replies_offset statement.") get_topic_replies_offset_stmt, err = db.Prepare("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress, replies.likeCount, replies.actionType from replies left join users on replies.createdBy = users.uid where tid = ? limit ?, " + strconv.Itoa(items_per_page)) if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_reply statement.") get_reply_stmt, err = db.Prepare("select content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress, likeCount from replies where rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_forum_topics statement.") get_forum_topics_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid where topics.parentID = ? order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy desc") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_forum_topics_offset statement.") get_forum_topics_offset_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, topics.likeCount, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid WHERE topics.parentID = ? order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC limit ?, " + strconv.Itoa(items_per_page)) if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_topic statement.") create_topic_stmt, err = db.Prepare("insert into topics(parentID,title,content,parsed_content,createdAt,lastReplyAt,ipaddress,words,createdBy) VALUES(?,?,?,?,NOW(),NOW(),?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_report statement.") create_report_stmt, err = db.Prepare("INSERT INTO topics(title,content,parsed_content,createdAt,lastReplyAt,createdBy,data,parentID) VALUES(?,?,?,NOW(),NOW(),?,?,1)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_reply statement.") create_reply_stmt, err = db.Prepare("INSERT INTO replies(tid,content,parsed_content,createdAt,ipaddress,words,createdBy) VALUES(?,?,?,NOW(),?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_action_reply statement.") create_action_reply_stmt, err = db.Prepare("INSERT INTO replies(tid,actionType,ipaddress,createdBy) VALUES(?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_replies_to_topic statement.") add_replies_to_topic_stmt, err = db.Prepare("UPDATE topics SET postCount = postCount + ?, lastReplyAt = NOW() WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing remove_replies_from_topic statement.") remove_replies_from_topic_stmt, err = db.Prepare("UPDATE topics SET postCount = postCount - ? WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_topics_to_forum statement.") add_topics_to_forum_stmt, err = db.Prepare("UPDATE forums SET topicCount = topicCount + ? WHERE fid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing remove_topics_from_forum statement.") remove_topics_from_forum_stmt, err = db.Prepare("UPDATE forums SET topicCount = topicCount - ? WHERE fid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_forum_cache statement.") update_forum_cache_stmt, err = db.Prepare("UPDATE forums SET lastTopic = ?, lastTopicID = ?, lastReplyer = ?, lastReplyerID = ?, lastTopicTime = NOW() WHERE fid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_like statement.") create_like_stmt, err = db.Prepare("INSERT INTO likes(weight, targetItem, targetType, sentBy) VALUES(?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_likes_to_topic statement.") add_likes_to_topic_stmt, err = db.Prepare("UPDATE topics SET likeCount = likeCount + ? WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_likes_to_reply statement.") add_likes_to_reply_stmt, err = db.Prepare("UPDATE replies SET likeCount = likeCount + ? WHERE rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_activity statement.") add_activity_stmt, err = db.Prepare("INSERT INTO activity_stream(actor,targetUser,event,elementType,elementID) VALUES(?,?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing notify_watchers statement.") notify_watchers_stmt, err = db.Prepare("INSERT INTO activity_stream_matches(watcher, asid) SELECT activity_subscriptions.user, activity_stream.asid FROM activity_stream INNER JOIN activity_subscriptions ON activity_subscriptions.targetType = activity_stream.elementType and activity_subscriptions.targetID = activity_stream.elementID and activity_subscriptions.user != activity_stream.actor where asid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing notify_one statement.") notify_one_stmt, err = db.Prepare("INSERT INTO activity_stream_matches(watcher,asid) VALUES(?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_subscription statement.") add_subscription_stmt, err = db.Prepare("INSERT INTO activity_subscriptions(user,targetID,targetType,level) VALUES(?,?,?,2)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing edit_topic statement.") edit_topic_stmt, err = db.Prepare("UPDATE topics SET title = ?, content = ?, parsed_content = ?, is_closed = ? WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing edit_reply statement.") edit_reply_stmt, err = db.Prepare("UPDATE replies SET content = ?, parsed_content = ? WHERE rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing delete_reply statement.") delete_reply_stmt, err = db.Prepare("DELETE FROM replies WHERE rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing delete_topic statement.") delete_topic_stmt, err = db.Prepare("DELETE FROM topics WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing stick_topic statement.") stick_topic_stmt, err = db.Prepare("UPDATE topics SET sticky = 1 WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing unstick_topic statement.") unstick_topic_stmt, err = db.Prepare("UPDATE topics SET sticky = 0 WHERE tid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_activity_feed_by_watcher statement.") get_activity_feed_by_watcher_stmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID FROM `activity_stream_matches` INNER JOIN `activity_stream` ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE `watcher` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_last_ip statement.") update_last_ip_stmt, err = db.Prepare("UPDATE users SET last_ip = ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing login statement.") login_stmt, err = db.Prepare("SELECT `uid`,`name`,`password`,`salt` FROM `users` WHERE `name` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_session statement.") update_session_stmt, err = db.Prepare("UPDATE users SET session = ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing logout statement.") logout_stmt, err = db.Prepare("UPDATE users SET session = '' WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing set_password statement.") set_password_stmt, err = db.Prepare("UPDATE users SET password = ?, salt = ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing get_password statement.") get_password_stmt, err = db.Prepare("SELECT `password`,`salt` FROM `users` WHERE `uid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing set_avatar statement.") set_avatar_stmt, err = db.Prepare("UPDATE users SET avatar = ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing set_username statement.") set_username_stmt, err = db.Prepare("UPDATE users SET name = ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } // Add an admin version of register_stmt with more flexibility @@ -376,236 +377,236 @@ func init_database(err error) { log.Print("Preparing register statement.") register_stmt, err = db.Prepare("INSERT INTO users(`name`,`email`,`password`,`salt`,`group`,`is_super_admin`,`session`,`active`,`message`) VALUES(?,?,?,?,?,0,?,?,'')") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing username_exists statement.") username_exists_stmt, err = db.Prepare("SELECT `name` FROM `users` WHERE `name` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing change_group statement.") change_group_stmt, err = db.Prepare("update `users` set `group` = ? where `uid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_email statement.") add_email_stmt, err = db.Prepare("INSERT INTO emails(`email`,`uid`,`validated`,`token`) VALUES(?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_email statement.") update_email_stmt, err = db.Prepare("UPDATE emails SET email = ?, uid = ?, validated = ?, token = ? WHERE email = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing verify_email statement.") verify_email_stmt, err = db.Prepare("UPDATE emails SET validated = 1, token = '' WHERE email = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing activate_user statement.") activate_user_stmt, err = db.Prepare("UPDATE users SET active = 1 WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_user_level statement.") update_user_level_stmt, err = db.Prepare("UPDATE users SET level = ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing increment_user_score statement.") increment_user_score_stmt, err = db.Prepare("UPDATE users SET score = score + ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing increment_user_posts statement.") increment_user_posts_stmt, err = db.Prepare("UPDATE users SET posts = posts + ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing increment_user_bigposts statement.") increment_user_bigposts_stmt, err = db.Prepare("UPDATE users SET posts = posts + ?, bigposts = bigposts + ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing increment_user_megaposts statement.") increment_user_megaposts_stmt, err = db.Prepare("UPDATE users SET posts = posts + ?, bigposts = bigposts + ?, megaposts = megaposts + ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing increment_user_topics statement.") increment_user_topics_stmt, err = db.Prepare("UPDATE users SET topics = topics + ? WHERE uid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_profile_reply statement.") create_profile_reply_stmt, err = db.Prepare("INSERT INTO users_replies(uid,content,parsed_content,createdAt,createdBy) VALUES(?,?,?,NOW(),?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing edit_profile_reply statement.") edit_profile_reply_stmt, err = db.Prepare("UPDATE users_replies SET content = ?, parsed_content = ? WHERE rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing delete_profile_reply statement.") delete_profile_reply_stmt, err = db.Prepare("DELETE FROM users_replies WHERE rid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_forum statement.") create_forum_stmt, err = db.Prepare("INSERT INTO forums(name,active,preset) VALUES(?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing delete_forum statement.") //delete_forum_stmt, err = db.Prepare("DELETE FROM forums WHERE fid = ?") delete_forum_stmt, err = db.Prepare("update forums set name= '', active = 0 where fid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_forum statement.") update_forum_stmt, err = db.Prepare("update forums set name = ?, active = ?, preset = ? where fid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing forum_entry_exists statement.") forum_entry_exists_stmt, err = db.Prepare("SELECT `fid` FROM `forums` WHERE `name` = '' order by fid asc limit 1") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing group_entry_exists statement.") group_entry_exists_stmt, err = db.Prepare("SELECT `gid` FROM `users_groups` WHERE `name` = '' order by gid asc limit 1") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing delete_forum_perms_by_forum statement.") delete_forum_perms_by_forum_stmt, err = db.Prepare("DELETE FROM forums_permissions WHERE fid = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_forum_perms_to_forum statement.") add_forum_perms_to_forum_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) VALUES(?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_forum_perms_to_forum_admins statement.") add_forum_perms_to_forum_admins_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) SELECT `gid`,? AS fid,? AS preset,? AS permissions FROM users_groups WHERE is_admin = 1") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_forum_perms_to_forum_staff statement.") add_forum_perms_to_forum_staff_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) SELECT `gid`,? AS fid,? AS preset,? AS permissions FROM users_groups WHERE is_admin = 0 AND is_mod = 1") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_forum_perms_to_forum_members statement.") add_forum_perms_to_forum_members_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) SELECT `gid`,? AS fid,? AS preset,? AS permissions FROM users_groups WHERE is_admin = 0 AND is_mod = 0 AND is_banned = 0") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_forum_perms_to_group statement.") add_forum_perms_to_group_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) VALUES(?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_setting statement.") update_setting_stmt, err = db.Prepare("UPDATE settings SET content = ? WHERE name = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_plugin statement.") add_plugin_stmt, err = db.Prepare("INSERT INTO plugins(uname,active) VALUES(?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_plugin statement.") update_plugin_stmt, err = db.Prepare("UPDATE plugins SET active = ? WHERE uname = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_theme statement.") add_theme_stmt, err = db.Prepare("INSERT INTO `themes`(`uname`,`default`) VALUES(?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_theme statement.") update_theme_stmt, err = db.Prepare("update `themes` set `default` = ? where `uname` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_user statement.") update_user_stmt, err = db.Prepare("update `users` set `name` = ?,`email` = ?,`group` = ? where `uid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_group_rank statement.") update_group_perms_stmt, err = db.Prepare("update `users_groups` set `permissions` = ? where `gid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_group_rank statement.") update_group_rank_stmt, err = db.Prepare("update `users_groups` set `is_admin` = ?, `is_mod` = ?, `is_banned` = ? where `gid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing update_group statement.") update_group_stmt, err = db.Prepare("update `users_groups` set `name` = ?, `tag` = ? where `gid` = ?") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing create_group statement.") create_group_stmt, err = db.Prepare("INSERT INTO users_groups(name,tag,is_admin,is_mod,is_banned,permissions) VALUES(?,?,?,?,?,?)") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_modlog_entry statement.") add_modlog_entry_stmt, err = db.Prepare("INSERT INTO moderation_logs(action,elementID,elementType,ipaddress,actorID,doneAt) VALUES(?,?,?,?,?,NOW())") if err != nil { - log.Fatal(err) + return err } log.Print("Preparing add_adminlog_entry statement.") add_adminlog_entry_stmt, err = db.Prepare("INSERT INTO moderation_logs(action,elementID,elementType,ipaddress,actorID,doneAt) VALUES(?,?,?,?,?,NOW())") if err != nil { - log.Fatal(err) + return err } log.Print("Loading the usergroups.") @@ -613,7 +614,7 @@ func init_database(err error) { rows, err := db.Query("select gid,name,permissions,is_mod,is_admin,is_banned,tag from users_groups") if err != nil { - log.Fatal(err) + return err } defer rows.Close() @@ -622,7 +623,7 @@ func init_database(err error) { group := Group{ID: 0,} err := rows.Scan(&group.ID, &group.Name, &group.PermissionsText, &group.Is_Mod, &group.Is_Admin, &group.Is_Banned, &group.Tag) if err != nil { - log.Fatal(err) + return err } // Ugh, you really shouldn't physically delete these items, it makes a big mess of things @@ -633,7 +634,7 @@ func init_database(err error) { err = json.Unmarshal(group.PermissionsText, &group.Perms) if err != nil { - log.Fatal(err) + return err } if !nogrouplog { fmt.Println(group.Name + ": ") @@ -645,7 +646,7 @@ func init_database(err error) { } err = rows.Err() if err != nil { - log.Fatal(err) + return err } groupCapCount = i @@ -659,7 +660,7 @@ func init_database(err error) { //rows, err = db.Query("SELECT fid, name, active, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime FROM forums") rows, err = db.Query("select fid, name, active, preset, topicCount, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime from forums order by fid asc") if err != nil { - log.Fatal(err) + return err } defer rows.Close() @@ -668,7 +669,7 @@ func init_database(err error) { forum := Forum{ID:0,Name:"",Active:true,Preset:"all"} err := rows.Scan(&forum.ID, &forum.Name, &forum.Active, &forum.Preset, &forum.TopicCount, &forum.LastTopic, &forum.LastTopicID, &forum.LastReplyer, &forum.LastReplyerID, &forum.LastTopicTime) if err != nil { - log.Fatal(err) + return err } // Ugh, you really shouldn't physically delete these items, it makes a big mess of things @@ -680,7 +681,7 @@ func init_database(err error) { /*if forum.LastTopicID != 0 { forum.LastTopicTime, err = relative_time(forum.LastTopicTime) if err != nil { - log.Fatal(err) + return err } } else { forum.LastTopic = "None" @@ -692,7 +693,7 @@ func init_database(err error) { } err = rows.Err() if err != nil { - log.Fatal(err) + return err } forumCapCount = i @@ -702,7 +703,7 @@ func init_database(err error) { log.Print("Loading the forum permissions") rows, err = db.Query("select gid, fid, permissions from forums_permissions order by gid asc, fid asc") if err != nil { - log.Fatal(err) + return err } defer rows.Close() @@ -716,11 +717,11 @@ func init_database(err error) { var pperms ForumPerms err := rows.Scan(&gid, &fid, &perms) if err != nil { - log.Fatal(err) + return err } err = json.Unmarshal(perms, &pperms) if err != nil { - log.Fatal(err) + return err } pperms.ExtData = make(map[string]bool) pperms.Overrides = true @@ -763,7 +764,7 @@ func init_database(err error) { log.Print("Loading the settings.") rows, err = db.Query("select name, content, type, constraints from settings") if err != nil { - log.Fatal(err) + return err } defer rows.Close() @@ -774,22 +775,22 @@ func init_database(err error) { for rows.Next() { err := rows.Scan(&sname, &scontent, &stype, &sconstraints) if err != nil { - log.Fatal(err) + return err } errmsg := parseSetting(sname, scontent, stype, sconstraints) if errmsg != "" { - log.Fatal(err) + return err } } err = rows.Err() if err != nil { - log.Fatal(err) + return err } log.Print("Loading the plugins.") rows, err = db.Query("select uname, active from plugins") if err != nil { - log.Fatal(err) + return err } defer rows.Close() @@ -798,7 +799,7 @@ func init_database(err error) { for rows.Next() { err := rows.Scan(&uname, &active) if err != nil { - log.Fatal(err) + return err } // Was the plugin deleted at some point? @@ -811,13 +812,13 @@ func init_database(err error) { } err = rows.Err() if err != nil { - log.Fatal(err) + return err } log.Print("Loading the themes.") rows, err = db.Query("select `uname`, `default` from `themes`") if err != nil { - log.Fatal(err) + return err } defer rows.Close() @@ -825,7 +826,7 @@ func init_database(err error) { for rows.Next() { err := rows.Scan(&uname, &defaultThemeSwitch) if err != nil { - log.Fatal(err) + return err } // Was the theme deleted at some point? @@ -847,6 +848,7 @@ func init_database(err error) { } err = rows.Err() if err != nil { - log.Fatal(err) + return err } + return nil } diff --git a/panel_routes.go b/panel_routes.go index aef8324c..a9f6e3eb 100644 --- a/panel_routes.go +++ b/panel_routes.go @@ -907,6 +907,7 @@ func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request){ globalPerms = append(globalPerms, NameLangToggle{"EditSettings",GetGlobalPermPhrase("EditSettings"),group.Perms.EditSettings}) globalPerms = append(globalPerms, NameLangToggle{"ManageThemes",GetGlobalPermPhrase("ManageThemes"),group.Perms.ManageThemes}) globalPerms = append(globalPerms, NameLangToggle{"ManagePlugins",GetGlobalPermPhrase("ManagePlugins"),group.Perms.ManagePlugins}) + globalPerms = append(globalPerms, NameLangToggle{"ViewAdminLogs",GetGlobalPermPhrase("ViewAdminLogs"),group.Perms.ViewAdminLogs}) globalPerms = append(globalPerms, NameLangToggle{"ViewIPs",GetGlobalPermPhrase("ViewIPs"),group.Perms.ViewIPs}) pi := EditGroupPermsPage{"Group Editor",user,noticeList,group.ID,group.Name,localPerms,globalPerms,nil} @@ -1298,7 +1299,7 @@ func route_panel_logs_mod(w http.ResponseWriter, r *http.Request){ if !ok { return } - if !user.Is_Super_Mod || !user.Perms.ManageThemes { + if !user.Is_Super_Mod { NoPermissions(w,r,user) return } diff --git a/permissions.go b/permissions.go index 29a1f4da..5b6c53d0 100644 --- a/permissions.go +++ b/permissions.go @@ -45,6 +45,7 @@ var GlobalPermList []string = []string{ "EditSettings", "ManageThemes", "ManagePlugins", + "ViewAdminLogs", "ViewIPs", } @@ -75,6 +76,7 @@ type Perms struct EditSettings bool ManageThemes bool ManagePlugins bool + ViewAdminLogs bool ViewIPs bool // Forum permissions @@ -148,6 +150,7 @@ func init() { EditSettings: true, ManageThemes: true, ManagePlugins: true, + ViewAdminLogs: true, ViewIPs: true, ViewTopic: true, diff --git a/phrases.go b/phrases.go index 753a6888..1ecae3ed 100644 --- a/phrases.go +++ b/phrases.go @@ -24,6 +24,7 @@ var global_perm_phrases map[string]string = map[string]string{ "EditSettings": "Can edit settings", "ManageThemes": "Can manage themes", "ManagePlugins": "Can manage plugins", + "ViewAdminLogs": "Can view the administrator action logs", "ViewIPs": "Can view IP addresses", } diff --git a/router.go b/router.go index 3690137d..ed1c3b15 100644 --- a/router.go +++ b/router.go @@ -34,21 +34,16 @@ func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } + var /*extra_data, */prefix string + if req.URL.Path[len(req.URL.Path) - 1] != '/' { + //extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] + prefix = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] + } else { + prefix = req.URL.Path + } + router.mu.RLock() - handle, ok := router.routes[req.URL.Path] - if ok { - router.mu.RUnlock() - handle(w,req) - return - } - - if req.URL.Path[len(req.URL.Path) - 1] == '/' { - router.mu.RUnlock() - NotFound(w,req) - return - } - - handle, ok = router.routes[req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]] + handle, ok := router.routes[prefix] if ok { router.mu.RUnlock() handle(w,req) @@ -56,14 +51,7 @@ func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { } //fmt.Println(req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/')]) - handle, ok = router.routes[req.URL.Path + "/"] - if ok { - router.mu.RUnlock() - handle(w,req) - return - } - router.mu.RUnlock() NotFound(w,req) return -} \ No newline at end of file +} diff --git a/router_gen/gen_router.go b/router_gen/gen_router.go new file mode 100644 index 00000000..ec80f2cb --- /dev/null +++ b/router_gen/gen_router.go @@ -0,0 +1,38 @@ +// Code generated by. DO NOT EDIT. +/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */ +package main + +import "net/http" + +type GenRouter struct { + UploadHandler http.Handler +} + +func NewGenRouter() *GenRouter { + fs_u := http.FileServer(http.Dir("./uploads")) + return &GenRouter{http.StripPrefix("/uploads/",fs_u).ServeHTTP} +} + +func (router *GenRouter) Handle(_ string, _ http.Handler) { +} + +func (router *GenRouter) HandleFunc(_ string, _ func(http.ResponseWriter, *http.Request)) { +} + +func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { + var extra_data string + if req.URL.Path[len(req.URL.Path) - 1] != '/' { + extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] + req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] + } + switch(req.URL.Path) { + case "/overview/": + route_overview(w http.ResponseWriter, req *http.Request) + case "/pages/": + route_custom_page(w http.ResponseWriter, req *http.Request, &extra_data) + case "/topics/": + route_topics(w http.ResponseWriter, req *http.Request, &groups, &forums) + case "/uploads/": UploadHandler(w,req) + default: NotFound(w,req) + } +} diff --git a/router_gen/main.go b/router_gen/main.go new file mode 100644 index 00000000..054a5b1a --- /dev/null +++ b/router_gen/main.go @@ -0,0 +1,75 @@ +/* WIP Under Construction */ +package main + +import "log" +import "fmt" +//import "strings" +import "os" + +var route_list []Route +var route_groups []RouteGroup + +func main() { + fmt.Println("Generating the router...") + + // Load all the routes... + routes() + + var out string + var fdata string = "// Code generated by. DO NOT EDIT.\n/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */\n" + + for _, route := range route_list { + out += "\n\t\tcase \"" + route.Path + "\":\n\t\t\t" + route.Name+ "(w http.ResponseWriter, req *http.Request" + for _, item := range route.Vars { + out += ", " + item + } + out += ")" + } + + fdata += `package main + +import "net/http" + +type GenRouter struct { + UploadHandler http.Handler +} + +func NewGenRouter() *GenRouter { + fs_u := http.FileServer(http.Dir("./uploads")) + return &GenRouter{http.StripPrefix("/uploads/",fs_u).ServeHTTP} +} + +func (router *GenRouter) Handle(_ string, _ http.Handler) { +} + +func (router *GenRouter) HandleFunc(_ string, _ func(http.ResponseWriter, *http.Request)) { +} + +func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { + var extra_data string + if req.URL.Path[len(req.URL.Path) - 1] != '/' { + extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:] + req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1] + } + switch(req.URL.Path) {` + out + ` + case "/uploads/": UploadHandler(w,req) + default: NotFound(w,req) + } +} +` + write_file("./gen_router.go",fdata) + fmt.Println("Successfully generated the router") +} + +func write_file(name string, content string) { + f, err := os.Create(name) + if err != nil { + log.Fatal(err) + } + _, err = f.WriteString(content) + if err != nil { + log.Fatal(err) + } + f.Sync() + f.Close() +} diff --git a/router_gen/routes.go b/router_gen/routes.go new file mode 100644 index 00000000..8eb5652d --- /dev/null +++ b/router_gen/routes.go @@ -0,0 +1,27 @@ +package main + +type Route struct { + Name string + Path string + Vars []string +} + +type RouteGroup struct { + Path string + Routes []Route +} + +func addRoute(fname string, path string, vars ...string) { + route_list = append(route_list,Route{fname,path,vars}) +} + +func addRouteGroup(path string, routes ...Route) { + route_groups = append(route_groups,RouteGroup{path,routes}) +} + +func routes() { + //addRoute("route_static","/static/","&extra_data") + addRoute("route_overview","/overview/") + addRoute("route_custom_page","/pages/","&extra_data") + addRoute("route_topics","/topics/","&groups","&forums") +} diff --git a/templates.go b/templates.go index 8b2a39b8..fad3cb83 100644 --- a/templates.go +++ b/templates.go @@ -57,23 +57,26 @@ type CTemplateSet struct func (c *CTemplateSet) compile_template(name string, dir string, expects string, expectsInt interface{}, varList map[string]VarItem) (out string) { c.dir = dir c.doImports = true - c.funcMap = make(map[string]interface{}) - c.funcMap["and"] = "&&" - c.funcMap["not"] = "!" - c.funcMap["or"] = "||" - c.funcMap["eq"] = true - c.funcMap["ge"] = true - c.funcMap["gt"] = true - c.funcMap["le"] = true - c.funcMap["lt"] = true - c.funcMap["ne"] = true - c.funcMap["add"] = true - c.funcMap["subtract"] = true - c.funcMap["multiply"] = true - c.funcMap["divide"] = true - c.importMap = make(map[string]string) - c.importMap["io"] = "io" - c.importMap["strconv"] = "strconv" + c.funcMap = map[string]interface{}{ + "and": "&&", + "not": "!", + "or": "||", + "eq": true, + "ge": true, + "gt": true, + "le": true, + "lt": true, + "ne": true, + "add": true, + "subtract": true, + "multiply": true, + "divide": true, + } + + c.importMap = map[string]string{ + "io":"io", + "strconv":"strconv", + } c.varList = varList //c.pVarList = "" //c.pVarPosition = 0 diff --git a/templates/panel-adminlogs.html b/templates/panel-adminlogs.html new file mode 100644 index 00000000..944d86c3 --- /dev/null +++ b/templates/panel-adminlogs.html @@ -0,0 +1,29 @@ +{{template "header.html" . }} +
+
+ +
+
+ + {{if .CurrentUser.Perms.ViewAdminLogs}}{{end}} + {{if .CurrentUser.Perms.ViewAdminLogs}}{{end}} +
+{{template "panel-inner-menu.html" . }} +
+
+
+ +
+
+ {{range .Logs}} +
+ {{.Action}}
+ IP: {{.IPAddress}} + + {{.DoneAt}} + +
+ {{end}} +
+
+{{template "footer.html" . }} \ No newline at end of file diff --git a/templates/panel-modlogs.html b/templates/panel-modlogs.html index 4e556b26..756b2f66 100644 --- a/templates/panel-modlogs.html +++ b/templates/panel-modlogs.html @@ -1,5 +1,15 @@ {{template "header.html" . }} -{{template "panel-menu.html" . }} +
+
+ +
+
+ + {{if .CurrentUser.Perms.ViewAdminLogs}}{{end}} + {{if .CurrentUser.Perms.ViewAdminLogs}}{{end}} +
+{{template "panel-inner-menu.html" . }} +