func (self *RContactHandler) Get() { var cid int64 = 5 self.Data["catpage"] = "contact" self.Data["topics"] = models.GetAllTopicByCid(cid, 0, 0, 0, "id") self.Data["nodes"] = models.GetAllNodeByCid(cid, 0, 0, 0, "id") self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") switch { case self.Ctx.Request.RequestURI == "/root-contact": self.Data["asidepage"] = "root_contact" self.TplNames = "root/contact.html" case self.Ctx.Request.RequestURI == "/root-contact-node-list": self.Data["asidepage"] = "root_contact_node" self.TplNames = "root/contact_node.html" case self.Ctx.Request.RequestURI == "/root-contact-new-node": self.Data["asidepage"] = "root_contact_new_node" self.TplNames = "root/contact_new_node.html" case self.Ctx.Request.RequestURI == "/root-contact-topic-list": self.Data["asidepage"] = "root_contact_topic_list" self.TplNames = "root/contact_topic_list.html" } self.Render() }
//用户等级划分:正数是普通用户,负数是管理员各种等级划分,为0则尚未注册 func (self *BaseHandler) Prepare() { sess_username, _ = self.GetSession("username").(string) sess_uid, _ = self.GetSession("userid").(int64) sess_role, _ = self.GetSession("userrole").(int64) sess_email, _ = self.GetSession("useremail").(string) if sess_role == 0 { self.Data["Userid"] = 0 self.Data["Username"] = "" self.Data["Userrole"] = 0 self.Data["Useremail"] = "" } else { self.Data["Userid"] = sess_uid self.Data["Username"] = sess_username self.Data["Userrole"] = sess_role self.Data["Useremail"] = sess_email } self.Data["categorys"] = models.GetAllCategory() self.Data["nodes"] = models.GetAllNode() self.Data["nodes_hotness_topbar"] = models.GetAllNodeByCid(0, 0, 16, 0, "hotness") self.Data["topics_5s"] = models.GetAllTopic(0, 5, "id") self.Data["topics_10s"] = models.GetAllTopic(0, 10, "id") self.Data["nodes_10s"] = models.GetAllNodeByCid(0, 0, 10, 0, "id") self.Data["replys_5s"] = models.GetReplyByPid(0, 0, 5, "id") self.Data["replys_10s"] = models.GetReplyByPid(0, 0, 10, "id") self.Data["author"] = models.GetKV("author") self.Data["title"] = models.GetKV("title") self.Data["title_en"] = models.GetKV("title_en") self.Data["keywords"] = models.GetKV("keywords") self.Data["description"] = models.GetKV("description") self.Data["company"] = models.GetKV("company") self.Data["copyright"] = models.GetKV("copyright") self.Data["site_email"] = models.GetKV("site_email") self.Data["tweibo"] = models.GetKV("tweibo") self.Data["sweibo"] = models.GetKV("sweibo") self.Data["timenow"] = time.Now() self.Data["statistics"] = models.GetKV("statistics") }
func (self *MainHandler) Get() { page, _ := self.GetInt("page") curtab, _ := self.GetInt("tab") cid, _ := self.GetInt(":cid") limit := 25 home := "false" if cid == 0 { home = "true" } self.Data["home"] = home self.Data["curcate"] = cid self.Data["curtab"] = curtab topics_rcs := len(models.GetAllTopicByCid(cid, 0, 0, 0, "hotness")) topics_pages, topics_pageout, topics_beginnum, topics_endnum, offset := helper.Pages(topics_rcs, int(page), limit) self.Data["topics_latest"] = models.GetAllTopicByCid(cid, offset, limit, 0, "id") self.Data["topics_hotness"] = models.GetAllTopicByCid(cid, offset, limit, 0, "hotness") self.Data["topics_views"] = models.GetAllTopicByCid(cid, offset, limit, 0, "views") self.Data["topics_reply_count"] = models.GetAllTopicByCid(cid, offset, limit, 0, "reply_count") self.Data["topics_pagesbar_tab1"] = helper.Pagesbar("tab=1&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) self.Data["topics_pagesbar_tab2"] = helper.Pagesbar("tab=2&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) self.Data["topics_pagesbar_tab3"] = helper.Pagesbar("tab=3&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) self.Data["topics_pagesbar_tab4"] = helper.Pagesbar("tab=4&", topics_rcs, topics_pages, topics_pageout, topics_beginnum, topics_endnum, 1) nodes_rcs := len(models.GetAllNodeByCid(cid, 0, 0, 0, "hotness")) nodes_pages, nodes_pageout, nodes_beginnum, nodes_endnum, offset := helper.Pages(nodes_rcs, int(page), limit) self.Data["nodes_latest"] = models.GetAllNodeByCid(cid, offset, limit, 0, "id") self.Data["nodes_hotness"] = models.GetAllNodeByCid(cid, offset, limit, 0, "hotness") self.Data["nodes_pagesbar_tab5"] = helper.Pagesbar("tab=5&", nodes_rcs, nodes_pages, nodes_pageout, nodes_beginnum, nodes_endnum, 1) self.Data["nodes_pagesbar_tab6"] = helper.Pagesbar("tab=6&", nodes_rcs, nodes_pages, nodes_pageout, nodes_beginnum, nodes_endnum, 1) self.Layout = "layout.html" self.TplNames = "index.html" //self.Render() }
func (self *RServicesHandler) Get() { var cid int64 = 3 self.Data["catpage"] = "services" self.Data["nodes"] = models.GetAllNodeByCid(cid, 0, 0, 0, "id") self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") self.Data["topics"] = models.GetAllTopicByCid(cid, 0, 0, 0, "id") switch { case helper.Rex(self.Ctx.Request.RequestURI, "^/root-services-del/([0-9]+)$"): self.Data["asidepage"] = "root_services_list" self.TplNames = "root/services_list.html" case self.Ctx.Request.RequestURI == "/root-services-new-node": //新建內容分类 self.Data["asidepage"] = "root_services_new_node" self.TplNames = "root/services_new_node.html" case self.Ctx.Request.RequestURI == "/root-services-node-list": //內容分类列表 self.Data["asidepage"] = "root_services_node" self.TplNames = "root/services_node.html" case self.Ctx.Request.RequestURI == "/root-services-topic-list": //內容列表 self.Data["asidepage"] = "root-services-topic-list" self.TplNames = "root/services_topic_list.html" case self.Ctx.Request.RequestURI == "/root-services": //设置內容 self.Data["asidepage"] = "root_services" self.TplNames = "root/services.html" } self.Render() }
func (self *RAboutHandler) Get() { self.Data["catpage"] = "about" tid, _ := self.GetInt(":tid") self.Data["topic"] = models.GetTopic(tid) self.Data["topics"] = models.GetAllTopicByCid(1, 0, 0, 1, "id") self.Data["nodes"] = models.GetAllNodeByCid(1, 0, 0, 0, "id") self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") switch { case self.Ctx.Request.RequestURI == "/root-about": //发布内容 self.Data["asidepage"] = "root_about" self.TplNames = "root/about.html" self.Render() case self.Ctx.Request.RequestURI == "/root-about-topic-list": //内容列表 self.Data["asidepage"] = "root-about-topic-list" self.TplNames = "root/about_topic_list.html" self.Render() case self.Ctx.Request.RequestURI == "/root-about-new-node": //创建分类 self.Data["asidepage"] = "root_about_new_node" self.TplNames = "root/about_new_node.html" self.Render() case self.Ctx.Request.RequestURI == "/root-about-node-list": //分类列表 self.Data["asidepage"] = "root_about_node" self.TplNames = "root/about_node.html" self.Render() } }
func (self *RApi) Get() { switch { case helper.Rex(self.Ctx.Request.RequestURI, "^/root-about-gallery-edit/([0-9]+)$"): //# Gallery编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.WriteString(outtimesz) } else { editmid, _ := self.GetInt(":editmid") img := models.GetFile(editmid) self.Data["img"] = img self.TplNames = "root/gallery_editurl.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-about-gallery-del/([0-9]+)$"): //# Gallery删除GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":delmid"); mid != 0 { if e := models.DelFile(mid); e != nil { self.Data["MsgErr"] = "删除图片文件失败!" } else { self.Data["MsgErr"] = "成功删除图片文件!" } } else { self.Data["MsgErr"] = "错误对象!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Ctx.Redirect(302, "/root-gallery") } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-about-node-del/([0-9]+)$"): //#ABOUT 节点删除 GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":nid"); mid != 0 { if e := models.DelNode(mid); e != nil { self.Data["MsgErr"] = "删除节点失败!" } else { self.Data["MsgErr"] = "成功删除节点!" } } else { self.Data["MsgErr"] = "错误节点!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-about-node-list", 302) } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-contact-node-del/([0-9]+)$"): //#contact 节点删除 GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":nid"); mid != 0 { if e := models.DelNode(mid); e != nil { self.Data["MsgErr"] = "删除节点失败!" } else { self.Data["MsgErr"] = "成功删除节点!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-contact-node-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-about-topic-del/([0-9]+)$"): //#ABOUT 内容删除GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":tid"); mid != 0 { if e := models.DelTopic(mid); e != nil { self.Data["MsgErr"] = "删除内容失败!" } else { self.Data["MsgErr"] = "成功删除内容!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-about-topic-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-crafts-topic-del/([0-9]+)$"): // crafts 内容删除GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Redirect("/root-login", 302) } else { if mid, _ := self.GetInt(":tid"); mid != 0 { if e := models.DelTopic(mid); e != nil { self.Data["MsgErr"] = "删除内容失败!" } else { self.Data["MsgErr"] = "成功删除内容!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-crafts-topic-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-services-topic-del/([0-9]+)$"): // services 内容删除GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Redirect("/root-login", 302) } else { if mid, _ := self.GetInt(":tid"); mid != 0 { if e := models.DelTopic(mid); e != nil { self.Data["MsgErr"] = "删除内容失败!" } else { self.Data["MsgErr"] = "成功删除内容!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-services-topic-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-about-topic-edit/([0-9]+)$"): //ABOUT 内容编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Redirect("/root-login", 302) } else { self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") tid, _ := self.GetInt(":tid") tid_handler := models.GetTopic(tid) self.Data["catpage"] = "about" self.Data["asidepage"] = "root_about_topic_edit" self.Data["topic"] = tid_handler self.TplNames = "root/about.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-services-topic-edit/([0-9]+)$"): // services 内容编辑 GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Redirect("/root-login", 302) } else { var cid int64 = 3 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") tid, _ := self.GetInt(":tid") tid_handler := models.GetTopic(tid) self.Data["catpage"] = "services" self.Data["asidepage"] = "root-services-topic-edit" self.Data["topic"] = tid_handler self.Data["inode"] = models.GetNode(tid_handler.Nid) self.Data["nodes"] = models.GetAllNodeByCid(cid, 0, 0, 0, "id") self.TplNames = "root/published.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-contact-topic-edit/([0-9]+)$"): //CONTACT 内容编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Redirect("/root-login", 302) } else { var cid int64 = 6 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") tid, _ := self.GetInt(":tid") tid_handler := models.GetTopic(tid) self.Data["asidepage"] = "root-contact-topic-edit" self.Data["topic"] = tid_handler self.Data["inode"] = models.GetNode(tid_handler.Nid) self.Data["catpage"] = "contact" self.Data["nodes"] = models.GetAllNodeByCid(cid, 0, 0, 0, "id") self.TplNames = "root/contact.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-crafts-topic-edit/([0-9]+)$"): //crafts 内容编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Redirect("/root-login", 302) } else { var cid int64 = 4 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") tid, _ := self.GetInt(":tid") tid_handler := models.GetTopic(tid) self.Data["catpage"] = "crafts" self.Data["asidepage"] = "root-crafts-topic-edit" self.Data["topic"] = tid_handler self.Data["inode"] = models.GetNode(tid_handler.Nid) self.Data["nodes"] = models.GetAllNodeByCid(cid, 0, 0, 0, "id") self.TplNames = "root/published.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-information-topic-del/([0-9]+)$"): //information 内容删除GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":tid"); mid != 0 { if e := models.DelTopic(mid); e != nil { self.Data["MsgErr"] = "删除内容失败!" } else { self.Data["MsgErr"] = "成功删除内容!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-information-topic-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-contact-topic-del/([0-9]+)$"): //contact 内容删除GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":tid"); mid != 0 { if e := models.DelTopic(mid); e != nil { self.Data["MsgErr"] = "删除内容失败!" } else { self.Data["MsgErr"] = "成功删除内容!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-contact-topic-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-about-node-edit/([0-9]+)$"): // about 节点编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { nid, _ := self.GetInt(":nid") //var cid int64 = 6 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") self.Data["catpage"] = "about" self.Data["asidepage"] = "root_about_node_edit" self.Data["node"] = models.GetNode(nid) self.TplNames = "root/published_node.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-contact-node-edit/([0-9]+)$"): //contact 节点编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { nid, _ := self.GetInt(":nid") //var cid int64 = 6 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") self.Data["catpage"] = "contact" self.Data["asidepage"] = "root_contact_node_edit" self.Data["node"] = models.GetNode(nid) self.TplNames = "root/published_node.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-services-node-edit/([0-9]+)$"): //services 节点编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { nid, _ := self.GetInt(":nid") //var cid int64 = 6 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") self.Data["catpage"] = "services" self.Data["asidepage"] = "root_services_node_edit" self.Data["node"] = models.GetNode(nid) self.TplNames = "root/published_node.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-information-node-edit/([0-9]+)$"): //information 节点编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { nid, _ := self.GetInt(":nid") self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") self.Data["catpage"] = "information" self.Data["asidepage"] = "root-information-node-edit" self.Data["node"] = models.GetNode(nid) self.TplNames = "root/published_node.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-crafts-node-edit/([0-9]+)$"): //crafts节点编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { nid, _ := self.GetInt(":nid") self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") self.Data["catpage"] = "crafts" self.Data["asidepage"] = "root-crafts-node-edit" self.Data["node"] = models.GetNode(nid) self.TplNames = "root/published_node.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-information-topic-edit/([0-9]+)$"): //information 内容编辑GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { var cid int64 = 5 self.Data["MsgErr"], _ = self.GetSession("MsgErr").(string) self.DelSession("MsgErr") tid, _ := self.GetInt(":tid") tid_handler := models.GetTopic(tid) self.Data["catpage"] = "information" self.Data["asidepage"] = "root-information-topic-edit" self.Data["topic"] = tid_handler self.Data["inode"] = models.GetNode(tid_handler.Nid) self.Data["nodes"] = models.GetAllNodeByCid(cid, 0, 0, 0, "id") self.TplNames = "root/published.html" self.Render() } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-services-node-del/([0-9]+)$"): //services 节点删除 GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":nid"); mid != 0 { if e := models.DelNode(mid); e != nil { self.Data["MsgErr"] = "删除节点失败!" } else { self.Data["MsgErr"] = "成功删除节点!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-services-node-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-information-node-del/([0-9]+)$"): //#INFORMATION 节点删除 GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":nid"); mid != 0 { if e := models.DelNode(mid); e != nil { self.Data["MsgErr"] = "删除节点失败!" } else { self.Data["MsgErr"] = "成功删除节点!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-information-node-list", 302) } } case helper.Rex(self.Ctx.Request.RequestURI, "^/root-crafts-node-del/([0-9]+)$"): //#crafts 删除节点 GET状态 if sess_role, _ := self.GetSession("userrole").(int64); sess_role != -1000 { self.Ctx.Redirect(302, "/root-login") } else { if mid, _ := self.GetInt(":nid"); mid != 0 { if e := models.DelNode(mid); e != nil { self.Data["MsgErr"] = "删除节点失败!" } else { self.Data["MsgErr"] = "成功删除节点!" } self.SetSession("MsgErr", self.Data["MsgErr"]) self.Redirect("/root-crafts-node-list", 302) } } } }