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.

62 lines
1.6 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. local args = nil
  11. if fcgi.getenv("REQUEST_METHOD") == "POST" then
  12. args = {}
  13. local content_type = fcgi.getenv("CONTENT_TYPE")
  14. local boundary = content_type:match("; boundary=(.*)$")
  15. local post_data = fcgi.post()
  16. data = "Content type:" .. content_type .. "\n Boundary: " .. boundary .. "\n"
  17. for w in string.gmatch(post_data, "(.-)" .. boundary) do
  18. local name, dtype, value = utils.parse_form_entry(w)
  19. args[name] = { t = dtype, v = value }
  20. end
  21. for k, v in pairs(args) do
  22. data = data .. k .. ": "
  23. if v.t then
  24. data = data .. "[FILE:" .. v.t .. "]\n"
  25. else
  26. data = data .. v.v .. "\n"
  27. end
  28. end
  29. end
  30. fcgi.print(
  31. form {
  32. encoder = require"base64".encode,
  33. args = args,
  34. classes = {
  35. "Beast",
  36. "Swordsman",
  37. "Spirit Bird",
  38. "Twin Blades",
  39. "Healer",
  40. "Summoner",
  41. "Tamer",
  42. "Pugilist",
  43. "Mounted Fighter",
  44. "Fruit Animal",
  45. "Spellcaster"
  46. },
  47. elements = {
  48. "Fire", "Water", "Earth", "Air",
  49. "Wood", "Electricity", "Metals", "Dreams",
  50. "Light", "Darkness", "Sun", "Moon",
  51. "Smoke", "Ice", "Crystal", "Sound",
  52. "Poison", "Lightning", "Weapons", "Fortune",
  53. "Healing", "Curses", "Day", "Night"
  54. }
  55. }
  56. )
  57. end
  58. }