You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB

  1. local etlua = require "etlua"
  2. local utils = require "utils"
  3. local yqtemplateform = utils.readfile("yqform.etlua")
  4. local form = etlua.compile(yqtemplateform)
  5. return {
  6. desc = "Creates Yokoka’s quest-style personal status page",
  7. run = function(fcgi)
  8. fcgi.print("Content-Type: text/html; charset=utf-8\r\n\r\n")
  9. local data = ""
  10. if fcgi.getenv("REQUEST_METHOD") == "POST" then
  11. local content_type = fcgi.getenv("CONTENT_TYPE")
  12. local boundary = content_type:match("; boundary=(.*)$")
  13. local post_data = fcgi.post()
  14. data = "Content type:" .. content_type .. "\n Boundary: " .. boundary .. "\n"
  15. local args = {}
  16. for w in string.gmatch(post_data, "(.-)" .. boundary) do
  17. local name, dtype, value = utils.parse_form_entry(w)
  18. args[name] = { t = dtype, v = value }
  19. end
  20. for k, v in pairs(args) do
  21. data = data .. k .. ": "
  22. if v.t then
  23. data = data .. "[FILE:" .. v.t .. "]\n"
  24. else
  25. data = data .. v.v .. "\n"
  26. end
  27. end
  28. end
  29. fcgi.print(
  30. form {
  31. data = data,
  32. classes = {
  33. "Beast",
  34. "Swordsman",
  35. "Spirit Bird",
  36. "Twin Blades",
  37. "Healer",
  38. "Summoner",
  39. "Tamer",
  40. "Pugilist",
  41. "Mounted Fighter",
  42. "Fruit Animal",
  43. "Spellcaster"
  44. },
  45. elements = {
  46. "Fire", "Water", "Earth", "Air",
  47. "Wood", "Electricity", "Metals", "Dreams",
  48. "Light", "Darkness", "Sun", "Moon",
  49. "Smoke", "Ice", "Crystal", "Sound",
  50. "Poison", "Lightning", "Weapons", "Fortune",
  51. "Healing", "Curses", "Day", "Night"
  52. }
  53. }
  54. )
  55. end
  56. }