setup_webapp.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary button-back js-button-back" href="/add/webapp/?domain=<?= htmlentities($v_domain) ?>">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
  7. </a>
  8. </div>
  9. <div class="toolbar-buttons">
  10. <button type="submit" class="button" form="vstobjects">
  11. <i class="fas fa-floppy-disk icon-purple"></i><?= _("Save") ?>
  12. </button>
  13. </div>
  14. </div>
  15. </div>
  16. <!-- End toolbar -->
  17. <!-- Begin form -->
  18. <div class="container animate__animated animate__fadeIn">
  19. <?php if (!empty($WebappInstaller->getOptions())) { ?>
  20. <form id="vstobjects" method="POST" name="v_setup_webapp">
  21. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  22. <input type="hidden" name="ok" value="true">
  23. <div class="form-container">
  24. <h1 class="form-title"><?= sprintf(_("Install %s"), $WebappInstaller->info()["name"]) ?></h1>
  25. <?php show_alert_message($_SESSION); ?>
  26. <?php if (!$WebappInstaller->isDomainRootClean()) { ?>
  27. <div class="alert alert-info" role="alert">
  28. <i class="fas fa-info"></i>
  29. <div>
  30. <p class="u-mb10"><?= _("Data Loss Warning!") ?></p>
  31. <p class="u-mb10"><?= _("Your web folder already has files uploaded to it. The installer will overwrite your files and/or the installation might fail.") ?></p>
  32. <p><?php echo sprintf(_("Please make sure ~/web/%s/public_html is empty!"), $v_domain); ?></p>
  33. </div>
  34. </div>
  35. <?php } ?>
  36. <?php
  37. foreach ($WebappInstaller->getOptions() as $form_name => $form_control) {
  38. $field_name = $WebappInstaller->formNs() . "_" . $form_name;
  39. $field_type = $form_control;
  40. $field_value = "";
  41. $field_label =
  42. isset($form_control["label"])
  43. ? htmlentities($form_control["label"])
  44. : ucwords(str_replace([".","_"], " ", $form_name));
  45. $field_placeholder = "";
  46. if (is_array($form_control)) {
  47. $field_type = !empty($form_control["type"]) ? $form_control["type"] : "text";
  48. $field_value = !empty($form_control["value"]) ? $form_control["value"] : "";
  49. $field_placeholder = !empty($form_control["placeholder"]) ? $form_control["placeholder"] : "";
  50. }
  51. $field_value = htmlentities($field_value);
  52. $field_label = htmlentities($field_label);
  53. $field_name = htmlentities($field_name);
  54. $field_placeholder = htmlentities($field_placeholder);
  55. ?>
  56. <div class="u-mb10">
  57. <?php if ($field_type != "boolean"): ?>
  58. <label for="<?= $field_name ?>" class="form-label">
  59. <?= $field_label ?>
  60. <?php if ($field_type == "password"): ?>
  61. <button type="button" title="<?= _("Generate") ?>" class="u-unstyled-button u-ml5 js-generate-password">
  62. <i class="fas fa-arrows-rotate icon-green"></i>
  63. </button>
  64. <?php endif; ?>
  65. </label>
  66. <?php endif; ?>
  67. <?php if ($field_type == 'select' && count($form_control['options'])): ?>
  68. <select class="form-select" name="<?= $field_name ?>" id="<?= $field_name ?>">
  69. <?php foreach ($form_control['options'] as $key => $option):
  70. $key = !is_numeric($key) ? $key : $option;
  71. $selected = !empty($form_control['value'] && $key == $form_control['value']) ? 'selected' : ''; ?>
  72. <option value="<?= $key ?>" <?= $selected ?>>
  73. <?= htmlentities($option) ?>
  74. </option>
  75. <?php endforeach; ?>
  76. </select>
  77. <?php elseif ($field_type == "boolean"):
  78. $checked = !empty($field_value) ? "checked" : ""; ?>
  79. <div class="form-check">
  80. <input
  81. class="form-check-input"
  82. type="checkbox"
  83. name="<?= $field_name ?>"
  84. id="<?= $field_name ?>"
  85. value="true"
  86. <?= $checked ?>
  87. >
  88. <label for="<?= $field_name ?>">
  89. <?= $field_label ?>
  90. </label>
  91. </div>
  92. <?php else: ?>
  93. <?php if ($field_type == "password"): ?>
  94. <div class="u-pos-relative">
  95. <input
  96. type="text"
  97. class="form-control js-password-input"
  98. name="<?= $field_name ?>"
  99. id="<?= $field_name ?>"
  100. placeholder="<?= $field_placeholder ?>"
  101. >
  102. <div class="password-meter">
  103. <meter max="4" class="password-meter-input js-password-meter"></meter>
  104. </div>
  105. </div>
  106. <?php else: ?>
  107. <input
  108. type="text"
  109. class="form-control"
  110. name="<?= $field_name ?>"
  111. id="<?= $field_name ?>"
  112. placeholder="<?= $field_placeholder ?>"
  113. >
  114. <?php endif; ?>
  115. <?php endif; ?>
  116. </div>
  117. <?php } ?>
  118. </div>
  119. </form>
  120. <?php } ?>
  121. </div>
  122. <!-- End form -->