Esempio n. 1
0
func (this *UserAgent) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	ua := this.GetString("ua")
	if ua == "" {
		resp.Status = RS.RS_params_error
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|参数错误。"}
		return
	}
	resp.Data = useragent.ParseByString(ua)
}
Esempio n. 2
0
func (this *TopicController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	resp.Data = "Not Found."
	id := this.Ctx.Input.Param(":id")
	ID, err := strconv.Atoi(id)
	if err == nil {
		topic := models.TMgr.GetTopic(int32(ID))
		if topic != nil {
			resp.Data = string(topic.Content)
		}
	}
}
Esempio n. 3
0
func (this *DataController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	log.Debugf("flag = %s", flag)
	switch flag {
	case "base":
		this.Base(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
Esempio n. 4
0
func (this *BlogrollController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	log.Debugf("flag=%s", flag)
	switch flag {
	case "save":
		this.saveBlogroll(resp)
	case "modify":
		this.getBlogroll(resp)
	case "delete":
		this.doDelete(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
Esempio n. 5
0
func (this *UserController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	switch flag {
	case "info":
		this.userInfo(resp)
	case "modifyinfo":
		this.doModifyInfo(resp)
	case "modpasswd":
		this.modifyPasswd(resp)
	case "domodpasswd":
		this.doModifyPasswd(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
Esempio n. 6
0
func (this *SysconfigController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	flag := this.GetString("flag")
	log.Debugf("flag = %s", flag)
	switch flag {
	case "deleteverify":
		this.deleteVerify(resp)
	case "addverify":
		this.addVerify(resp)
	case "updatesitemap":
		this.updateSitemap(resp)
	case "getsitemap":
		this.getSitemap(resp)
	default:
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "参数错误|未知的flag标志。"}
	}
}
Esempio n. 7
0
func (this *AuthController) Post() {
	resp := helper.NewResponse()
	defer resp.WriteJson(this.Ctx.ResponseWriter)
	username := this.GetString("username")
	password := this.GetString("password")

	if username == "" || password == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		resp.WriteJson(this.Ctx.ResponseWriter)
		return
	}
	if code := models.UMgr.Login(username, password); code == RS.RS_user_inexistence {
		resp.Status = code
		resp.Tips(helper.WARNING, code)
	} else if code == RS.RS_password_error {
		resp.Status = code
		resp.Tips(helper.WARNING, code)
	} else {
		models.Blogger.LoginIp = this.Ctx.Request.RemoteAddr
		this.SetSession(SESSIONNAME, username)
		resp.Data = "/admin/data"
	}
}
Esempio n. 8
0
	if err != nil {
		panic(err)
	}
	err = t.Execute(w, "")
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}

// 过滤登录
var FilterUser = func(ctx *context.Context) {
	val, ok := ctx.Input.Session(background.SESSIONNAME).(string)
	if !ok || val == "" {
		if ctx.Request.Method == "GET" {
			ctx.Redirect(302, "/login")
		} else if ctx.Request.Method == "POST" {
			resp := helper.NewResponse()
			resp.Status = RS.RS_user_not_login
			resp.Data = "/login"
			resp.WriteJson(ctx.ResponseWriter)
		}
	}
}

// 重定向到https
var RedirectHttps = func(ctx *context.Context) {
	if beego.BConfig.Listen.EnableHTTPS && ctx.Input.Scheme() == "http" {
		ctx.Redirect(301, fmt.Sprintf("%s%s", controllers.Domain, ctx.Input.URL()))
	}
}