action_mysql.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package actions
  2. import (
  3. "fmt"
  4. )
  5. func action_mysql(e *Action) {
  6. /*
  7. action := e.R.FormValue("action")
  8. e.write(fmt.Sprintf(`
  9. ModalShowMsg('MySQL Action', 'Hello from web server (%s)');
  10. `, action))
  11. */
  12. pf_host := e.R.FormValue("host")
  13. pf_name := e.R.FormValue("name")
  14. pf_user := e.R.FormValue("user")
  15. pf_password := e.R.FormValue("password")
  16. if pf_host == "" {
  17. e.write(fmt.Sprintf(`ModalShowMsg('Error', 'Please specify host for mysql connection');`))
  18. return
  19. }
  20. if pf_name == "" {
  21. e.write(fmt.Sprintf(`ModalShowMsg('Error', 'Please specify mysql database name');`))
  22. return
  23. }
  24. if pf_user == "" {
  25. e.write(fmt.Sprintf(`ModalShowMsg('Error', 'Please specify mysql user');`))
  26. return
  27. }
  28. // Try connect to mysql
  29. // Try to install all tables
  30. // Save mysql config file
  31. err := e.MySqlConfigWrite(pf_host, pf_name, pf_user, pf_password)
  32. /*
  33. if pf_host == "" || pf_name == "" || pf_user == "" || pf_password == "" {
  34. e.write(fmt.Sprintf(`ModalShowMsg('Error', 'Not all fields are filed');`))
  35. return
  36. }
  37. */
  38. // Reload current page
  39. e.write(fmt.Sprintf(`window.location.reload(false);`))
  40. }