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.

65 lines
1.9 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. --- @type [table]
  6. local classes = {
  7. { n = "Beast", f = "c01.beast.png" },
  8. { n = "Swordsman", f = "c02.swordsman.png" },
  9. { n = "Spirit Bird", f = "c03.spirit-bird.png" },
  10. { n = "Twin Blades", f = "c04.twin-blades.png" },
  11. { n = "Healer", f = "c05.healer.png" },
  12. { n = "Summoner", f = "c06.summoner.png" },
  13. { n = "Tamer", f = "c07.tamer.png" },
  14. { n = "Pugilist", f = "c08.pugilist.png" },
  15. { n = "Mounted Fighter", f = "c09.mounted-fighter.png" },
  16. { n = "Fruit Animal", f = "c10.fruit-animal.png" },
  17. { n = "Spellcaster", f = "c11.spellcaster.png" }
  18. }
  19. return {
  20. desc = "Creates Yokoka’s quest-style personal status page",
  21. run = function(fcgi)
  22. fcgi.print("Content-Type: text/html; charset=utf-8\r\n\r\n")
  23. local data = ""
  24. local args = nil
  25. if fcgi.getenv("REQUEST_METHOD") == "POST" then
  26. args = {}
  27. local content_type = fcgi.getenv("CONTENT_TYPE")
  28. local boundary = content_type:match("; boundary=(.*)$")
  29. local post_data = fcgi.post()
  30. data = "Content type:" .. content_type .. "\n Boundary: " .. boundary .. "\n"
  31. for w in string.gmatch(post_data, "(.-)" .. boundary) do
  32. local name, dtype, value = utils.parse_form_entry(w)
  33. args[name] = { t = dtype, v = value }
  34. end
  35. for k, v in pairs(args) do
  36. data = data .. k .. ": "
  37. if v.t then
  38. data = data .. "[FILE:" .. v.t .. "]\n"
  39. else
  40. data = data .. v.v .. "\n"
  41. end
  42. end
  43. end
  44. fcgi.print(
  45. form {
  46. encoder = require "base64".encode,
  47. readfile = utils.readfile,
  48. args = args,
  49. classes = classes
  50. elements = {
  51. "Fire", "Water", "Earth", "Air",
  52. "Wood", "Electricity", "Metals", "Dreams",
  53. "Light", "Darkness", "Sun", "Moon",
  54. "Smoke", "Ice", "Crystal", "Sound",
  55. "Poison", "Lightning", "Weapons", "Fortune",
  56. "Healing", "Curses", "Day", "Night"
  57. }
  58. }
  59. )
  60. end
  61. }