/* 后台图片处理 */ func (this *ImageController) Pictureedit() { /* 相册显示 */ var status int status1 := this.GetString("status") if status1 == "" { status = 0 } else { status, _ = strconv.Atoi(status1) } if status == 0 { this.Data["yifabu"] = true } else { this.Data["yifabu"] = false } userid := this.GetSession("sessionuid") userid1 := userid.(int) pictureinfo, err := models.Pictureread(userid1, status) //获取已发布和回收站数量 count1, err := models.Imagereadcount(userid, 0) count2, err := models.Imagereadcount(userid, 1) if err != nil { return } this.Data["count1"] = count1 this.Data["count2"] = count2 this.Data["pictureinfo"] = pictureinfo this.TplNames = "message/image.html" }
/* 主页面输出 */ func (this *AdminController) Main() { /* 获取session和cookie,管理员和用户的session和cookie都要获取,并进行分类处理输出对应模板 */ //普通用户 sessionuid := this.GetSession("sessionuid") cookieaccount := this.Ctx.GetCookie("cookieaccount") //管理员 sessionaid := this.GetSession("sessionaid") cookieadmin := this.Ctx.GetCookie("cookieadmin") //判断用户类型 if len(cookieadmin) > 0 { //管理员 this.Data["hostname"], _ = os.Hostname() this.Data["goversion"] = runtime.Version() this.Data["os"] = runtime.GOOS this.Data["cpunum"] = runtime.NumCPU() this.Data["arch"] = runtime.GOARCH this.Data["admin"] = true this.TplNames = "layout.html" return } else if sessionaid != nil { //管理员 this.Data["hostname"], _ = os.Hostname() this.Data["goversion"] = runtime.Version() this.Data["os"] = runtime.GOOS this.Data["cpunum"] = runtime.NumCPU() this.Data["arch"] = runtime.GOARCH //输出网站内容统计信息 article0, _ := models.Articletypesumwithstatus(0) article1, _ := models.Articletypesumwithstatus(1) article2, _ := models.Articletypesumwithstatus(2) diary0, _ := models.Diarytypesumwithstatic(0) diary1, _ := models.Diarytypesumwithstatic(1) diary2, _ := models.Diarytypesumwithstatic(2) shuo, _ := models.Shuosumwithall() picture0, _ := models.Imagereadcountwithstatic(0) picture1, _ := models.Imagereadcountwithstatic(1) usersum, _ := models.Usersum() this.Data["article0"] = article0 this.Data["article1"] = article1 this.Data["article2"] = article2 this.Data["diary0"] = diary0 this.Data["diary1"] = diary1 this.Data["diary2"] = diary2 this.Data["shuo"] = shuo this.Data["picture0"] = picture0 this.Data["picture1"] = picture1 this.Data["usersum"] = usersum this.Data["admin"] = true this.TplNames = "layout.html" } else if len(cookieaccount) > 0 { //普通用户 account := DecodeCookie(cookieaccount) userinfo, _ := models.Userinfo(account) //输出文章数量,日记数量,碎言碎语数量,照片数量 userid := userinfo.Id article0, _ := models.Articletypesum(userid, 0) article1, _ := models.Articletypesum(userid, 1) article2, _ := models.Articletypesum(userid, 2) diary0, _ := models.Diarytypesum(userid, 0) diary1, _ := models.Diarytypesum(userid, 1) diary2, _ := models.Diarytypesum(userid, 2) shuo, _ := models.Shuosum(userid) picture0, _ := models.Imagereadcount(userid, 0) picture1, _ := models.Imagereadcount(userid, 1) this.Data["article0"] = article0 this.Data["article1"] = article1 this.Data["article2"] = article2 this.Data["diary0"] = diary0 this.Data["diary1"] = diary1 this.Data["diary2"] = diary2 this.Data["shuo"] = shuo this.Data["picture0"] = picture0 this.Data["picture1"] = picture1 this.Data["admin"] = false this.TplNames = "layout.html" } else if sessionuid != nil { //普通用户,读取用户uid userinfo, _ := models.Userinfowithuid(sessionuid) //输出文章数量,日记数量,碎言碎语数量,照片数量 userid := userinfo.Id article0, _ := models.Articletypesum(userid, 0) article1, _ := models.Articletypesum(userid, 1) article2, _ := models.Articletypesum(userid, 2) diary0, _ := models.Diarytypesum(userid, 0) diary1, _ := models.Diarytypesum(userid, 1) diary2, _ := models.Diarytypesum(userid, 2) shuo, _ := models.Shuosum(userid) picture0, _ := models.Imagereadcount(userid, 0) picture1, _ := models.Imagereadcount(userid, 1) this.Data["article0"] = article0 this.Data["article1"] = article1 this.Data["article2"] = article2 this.Data["diary0"] = diary0 this.Data["diary1"] = diary1 this.Data["diary2"] = diary2 this.Data["shuo"] = shuo this.Data["picture0"] = picture0 this.Data["picture1"] = picture1 this.Data["admin"] = false this.TplNames = "layout.html" } else { //返回登录界面 this.Redirect("/", 301) } }