示例#1
0
func (this *SysconfigController) updateSitemap(resp *helper.Response) {
	content := this.GetString("content")
	if content == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	_, err := os.Stat(models.SiteFile)
	if err != nil && !strings.Contains(err.Error(), "no such file") {
		log.Error(err)
		return
	} else {
		os.Remove(models.SiteFile)
	}
	f, err := os.Create(models.SiteFile)
	if err != nil {
		log.Error(err)
		return
	}
	defer f.Close()
	_, err = f.WriteString(content)
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|" + err.Error()}
	}
}
示例#2
0
func (this *SysconfigController) deleteVerify(resp *helper.Response) {
	name := this.GetString("name")
	if name == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	models.ManageConf.DelVerification(name)
}
示例#3
0
文件: trash.go 项目: deepzz0/goblog
func (this *TrashController) doDelete(resp *helper.Response) {
	id, err := this.GetInt32("id")
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	if topic := models.TMgr.GetWaitDelTopic(id); topic == nil {
		resp.Status = RS.RS_not_found
		resp.Tips(helper.WARNING, RS.RS_not_found)
	} else {
		if err := models.TMgr.ImmeDelTopic(topic); err != nil {
			resp.Status = RS.RS_failed
			resp.Err = helper.Error{Level: helper.WARNING, Msg: "错误|" + err.Error()}
			return
		}
	}
}
示例#4
0
func (this *SysconfigController) addVerify(resp *helper.Response) {
	name := this.GetString("name")
	content := this.GetString("content")
	if name == "" || content == "" {
		resp.Status = RS.RS_params_error
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	verify := models.ManageConf.GetVerification(name)
	if verify != nil {
		resp.Status = RS.RS_duplicate_add
		resp.Tips(helper.WARNING, RS.RS_duplicate_add)
		return
	}
	verify = models.NewVerify()
	verify.Name = name
	verify.Content = content
	models.ManageConf.AddVerification(verify)
}
示例#5
0
文件: trash.go 项目: deepzz0/goblog
func (this *TrashController) doRestore(resp *helper.Response) {
	id, err := this.GetInt32("id")
	if err != nil {
		resp.Status = RS.RS_failed
		resp.Tips(helper.WARNING, RS.RS_params_error)
		return
	}
	if topic := models.TMgr.GetWaitDelTopic(id); topic == nil {
		resp.Status = RS.RS_not_found
		resp.Tips(helper.WARNING, RS.RS_not_found)
		return
	} else {
		if code := models.TMgr.RestoreTopic(topic); code != RS.RS_success {
			resp.Status = code
			resp.Tips(helper.WARNING, code)
			return
		}
	}
}