setup_webapp.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary" id="btn-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. <?php
  11. if (!empty($_SESSION['error_msg'])) {
  12. echo "<p class=\"inline-alert inline-alert-danger\"> → ".htmlentities($_SESSION['error_msg'])."</p>";
  13. } else {
  14. if (!empty($_SESSION['ok_msg'])) {
  15. echo "<p class=\"inline-alert inline-alert-success\"> → ".$_SESSION['ok_msg']."</p>";
  16. }
  17. }
  18. ?>
  19. <button class="button" type="submit" form="vstobjects">
  20. <i class="fas fa-floppy-disk icon-purple"></i><?= _("Save") ?>
  21. </button>
  22. </div>
  23. </div>
  24. </div>
  25. <!-- End toolbar -->
  26. <div class="container animate__animated animate__fadeIn">
  27. <?php if (!empty($WebappInstaller->getOptions())): ?>
  28. <form id="vstobjects" method="POST" name="v_setup_webapp">
  29. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  30. <input type="hidden" name="ok" value="true">
  31. <div class="form-container">
  32. <h1 class="form-title"><?= sprintf(_("Install %s"), $WebappInstaller->info()["name"]) ?></h1>
  33. <?php if (!$WebappInstaller->isDomainRootClean()): ?>
  34. <div class="alert alert-info" role="alert">
  35. <i class="fas fa-info"></i>
  36. <div>
  37. <p class="u-mb10"><?= _("Data loss warning!") ?></p>
  38. <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>
  39. <p><?php echo sprintf(_("Please make sure ~/web/%s/public_html is empty!"), $v_domain); ?></p>
  40. </div>
  41. </div>
  42. <?php endif; ?>
  43. <div class="u-mt20">
  44. <?php foreach ($WebappInstaller->getOptions() as $form_name => $form_control): ?>
  45. <?php
  46. $f_name = $WebappInstaller->formNs() . '_' . $form_name;
  47. $f_type = $form_control;
  48. $f_value = '';
  49. if (isset($form_control['label'])) {
  50. $f_label = htmlentities($form_control['label']);
  51. } else {
  52. $f_label = ucwords(str_replace(['.','_'], ' ', $form_name));
  53. }
  54. $f_placeholder = '';
  55. if (is_array($form_control)) {
  56. $f_type = (!empty($form_control['type']))?$form_control['type']:'text';
  57. $f_value = (!empty($form_control['value']))?$form_control['value']:'';
  58. $f_placeholder = (!empty($form_control['placeholder']))?$form_control['placeholder']:'';
  59. }
  60. $f_value = htmlentities($f_value);
  61. $f_label = htmlentities($f_label);
  62. $f_name = htmlentities($f_name);
  63. $f_placeholder = htmlentities($f_placeholder);
  64. ?>
  65. <div class="u-mb10">
  66. <?php if ($f_type != "boolean"): ?>
  67. <label for="<?= $f_name ?>" class="form-label">
  68. <?= $f_label ?>
  69. <?php if ($f_type === "password"): ?> / <a href="javascript:applyRandomStringToTarget('<?= $f_name ?>');" class="form-link"><?= _("generate") ?></a> <?php endif; ?>
  70. </label>
  71. <?php endif; ?>
  72. <?php if (in_array($f_type, ['select']) && count($form_control['options']) ):?>
  73. <select class="form-select" name="<?=$f_name?>" id="<?=$f_name?>">
  74. <?php foreach ($form_control['options'] as $key => $option){
  75. if(is_numeric($key)){
  76. $key = $option;
  77. }
  78. ?>
  79. <?php $selected = (!empty($form_control['value']) && $key == $form_control['value'])?'selected':''?>
  80. <option value="<?=$key?>" <?=$selected?>><?=htmlentities($option)?></option>
  81. <?php }; ?>
  82. </select>
  83. <?php elseif (in_array($f_type, ["boolean"])): ?>
  84. <div class="form-check">
  85. <?php $checked = !empty($f_value) ? "checked" : ""; ?>
  86. <input class="form-check-input" type="checkbox" name="<?= $f_name ?>" id="<?= $f_name ?>" <?= $checked ?> value="true">
  87. <label for="<?= $f_name ?>"><?= $f_label ?></label>
  88. </div>
  89. <?php else: ?>
  90. <input type="text" class="form-control" name="<?= $f_name ?>" id="<?= $f_name ?>" placeholder="<?= $f_placeholder ?>" value="<?= $f_value ?>">
  91. <?php endif; ?>
  92. </div>
  93. <?php endforeach; ?>
  94. </div>
  95. </div>
  96. </form>
  97. <?php endif; ?>
  98. </div>