module_settings_act_domains.go 565 B

123456789101112131415161718192021222324252627
  1. package modules
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "golang-fave/engine/wrapper"
  6. )
  7. func (this *Modules) RegisterAction_SettingsDomains() *Action {
  8. return this.newAction(AInfo{
  9. Mount: "settings-domains",
  10. WantAdmin: true,
  11. }, func(wrap *wrapper.Wrapper) {
  12. pf_content := wrap.R.FormValue("content")
  13. // Save content
  14. err := ioutil.WriteFile(wrap.DConfig+string(os.PathSeparator)+".domains", []byte(pf_content), 0664)
  15. if err != nil {
  16. wrap.MsgError(err.Error())
  17. return
  18. }
  19. // Reload current page
  20. wrap.Write(`window.location.reload(false);`)
  21. })
  22. }