add_db.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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="/list/db/">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= tohtml( _("Back")) ?>
  7. </a>
  8. </div>
  9. <div class="toolbar-buttons">
  10. <?php if (($_SESSION["role"] == "admin" && $accept === "true") || $_SESSION["role"] !== "admin") { ?>
  11. <button type="submit" class="button" form="main-form">
  12. <i class="fas fa-floppy-disk icon-purple"></i><?= tohtml( _("Save")) ?>
  13. </button>
  14. <?php } ?>
  15. </div>
  16. </div>
  17. </div>
  18. <!-- End toolbar -->
  19. <div class="container">
  20. <form
  21. x-data="{
  22. showAdvanced: <?= tohtml(empty($v_adv) ? "false" : "true") ?>
  23. }"
  24. id="main-form"
  25. name="v_add_db"
  26. method="post"
  27. >
  28. <input type="hidden" name="token" value="<?= tohtml($_SESSION["token"]) ?>">
  29. <input type="hidden" name="ok" value="Add">
  30. <div class="form-container">
  31. <h1 class="u-mb20"><?= tohtml( _("Add Database")) ?></h1>
  32. <?php show_alert_message($_SESSION); ?>
  33. <?php if ($_SESSION["role"] == "admin" && $accept !== "true") { ?>
  34. <div class="alert alert-danger" role="alert">
  35. <i class="fas fa-exclamation"></i>
  36. <p><?= htmlify_trans(sprintf(_("It is strongly advised to {create a standard user account} before adding %s to the server due to the increased privileges the admin account possesses and potential security risks."), _('a database')), '</a>', '<a href="/add/user/">') ?></p>
  37. </div>
  38. <?php } ?>
  39. <?php if ($_SESSION["role"] == "admin" && empty($accept)) { ?>
  40. <div class="u-side-by-side u-mt20">
  41. <a href="/add/user/" class="button u-width-full u-mr10"><?= tohtml( _("Add User")) ?></a>
  42. <a href="/add/db/?<?= tohtml(http_build_query(["accept" => 'true'])) ?>" class="button button-danger u-width-full u-ml10"><?= tohtml( _("Continue")) ?></a>
  43. </div>
  44. <?php } ?>
  45. <?php if (($_SESSION["role"] == "admin" && $accept === "true") || $_SESSION["role"] !== "admin") { ?>
  46. <p class="hint u-mb20">
  47. <?php
  48. $prefix_hint = tohtml(_("Prefix %s will be automatically added to database name and database user"));
  49. $prefix_hint_html = '<span class="u-text-bold">' . tohtml($user_plain) . '_</span>';
  50. printf($prefix_hint, $prefix_hint_html);
  51. ?>
  52. </p>
  53. <div class="u-mb10">
  54. <label for="v_database" class="form-label"><?= tohtml( _("Database")) ?></label>
  55. <input type="text" class="form-control js-db-hint-database-name" name="v_database" id="v_database" value="<?= tohtml(trim($v_database, "'")) ?>">
  56. <small class="hint"></small>
  57. </div>
  58. <div class="u-mb10">
  59. <label for="v_type" class="form-label"><?= tohtml( _("Type")) ?></label>
  60. <select class="form-select" name="v_type" id="v_type">
  61. <?php
  62. foreach ($db_types as $key => $value) {
  63. echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($value)."\"";
  64. if ((!empty($v_type)) && ( $value == $v_type )) echo ' selected';
  65. echo ">".htmlentities($value)."</option>";
  66. }
  67. ?>
  68. </select>
  69. </div>
  70. <div class="u-mb10">
  71. <label for="v_dbuser" class="form-label u-side-by-side">
  72. <?= tohtml( _("Username")) ?>
  73. <em><small>(<?= tohtml(sprintf(_("Maximum %s characters length, including prefix"), 32)) ?>)</small></em>
  74. </label>
  75. <input type="text" class="form-control js-db-hint-username" name="v_dbuser" id="v_dbuser" value="<?= tohtml(trim($v_dbuser, "'")) ?>">
  76. <small class="hint"></small>
  77. </div>
  78. <div class="u-mb10">
  79. <label for="v_password" class="form-label">
  80. <?= tohtml( _("Password")) ?>
  81. <button type="button" title="<?= tohtml( _("Generate")) ?>" class="u-unstyled-button u-ml5 js-generate-password">
  82. <i class="fas fa-arrows-rotate icon-green"></i>
  83. </button>
  84. </label>
  85. <div class="u-pos-relative u-mb10">
  86. <input type="text" class="form-control js-password-input" name="v_password" id="v_password">
  87. <div class="password-meter">
  88. <meter max="4" class="password-meter-input js-password-meter"></meter>
  89. </div>
  90. </div>
  91. </div>
  92. <?php require $_SERVER["HESTIA"] . "/web/templates/includes/password-requirements.php"; ?>
  93. <div class="u-mb20">
  94. <label for="v_db_email" class="form-label">
  95. <?= tohtml( _("Email login credentials to:")) ?>
  96. </label>
  97. <input type="email" class="form-control" name="v_db_email" id="v_db_email" value="<?= tohtml(trim($v_db_email, "'")) ?>">
  98. </div>
  99. <div class="u-mb20">
  100. <button x-on:click="showAdvanced = !showAdvanced" type="button" class="button button-secondary">
  101. <?= tohtml( _("Advanced Options")) ?>
  102. </button>
  103. </div>
  104. <div x-cloak x-show="showAdvanced">
  105. <div class="u-mb10">
  106. <label for="v_host" class="form-label"><?= tohtml( _("Host")) ?></label>
  107. <select class="form-select" name="v_host" id="v_host">
  108. <?php
  109. foreach ($db_hosts as $value) {
  110. echo "\n\t\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($value)."\"";
  111. if ((!empty($v_host)) && ( $value == $v_host )) echo ' selected';
  112. echo ">".htmlentities($value)."</option>";
  113. }
  114. ?>
  115. </select>
  116. </div>
  117. <div class="u-mb10">
  118. <label for="v_charset" class="form-label"><?= tohtml( _("Charset")) ?></label>
  119. <select class="form-select" name="v_charset" id="v_charset">
  120. <option value=big5 <?php if ((!empty($v_charset)) && ( $v_charset == 'big5')) echo 'selected'; ?>>big5</option>
  121. <option value=dec8 <?php if ((!empty($v_charset)) && ( $v_charset == 'dec8')) echo 'selected'; ?>>dec8</option>
  122. <option value=cp850 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp850')) echo 'selected'; ?>>cp850</option>
  123. <option value=hp8 <?php if ((!empty($v_charset)) && ( $v_charset == 'hp8')) echo 'selected'; ?>>hp8</option>
  124. <option value=koi8r <?php if ((!empty($v_charset)) && ( $v_charset == 'koi8r')) echo 'selected'; ?>>koi8r</option>
  125. <option value=latin1 <?php if ((!empty($v_charset)) && ( $v_charset == 'latin1')) echo 'selected'; ?>>latin1</option>
  126. <option value=latin2 <?php if ((!empty($v_charset)) && ( $v_charset == 'latin2')) echo 'selected'; ?>>latin2</option>
  127. <option value=swe7 <?php if ((!empty($v_charset)) && ( $v_charset == 'swe7')) echo 'selected'; ?>>swe7</option>
  128. <option value=ascii <?php if ((!empty($v_charset)) && ( $v_charset == 'ascii')) echo 'selected'; ?>>ascii</option>
  129. <option value=ujis <?php if ((!empty($v_charset)) && ( $v_charset == 'ujis')) echo 'selected'; ?>>ujis</option>
  130. <option value=sjis <?php if ((!empty($v_charset)) && ( $v_charset == 'sjis')) echo 'selected'; ?>>sjis</option>
  131. <option value=hebrew <?php if ((!empty($v_charset)) && ( $v_charset == 'hebrew')) echo 'selected'; ?>>hebrew</option>
  132. <option value=tis620 <?php if ((!empty($v_charset)) && ( $v_charset == 'tis620')) echo 'selected'; ?>>tis620</option>
  133. <option value=euckr <?php if ((!empty($v_charset)) && ( $v_charset == 'euckr')) echo 'selected'; ?>>euckr</option>
  134. <option value=koi8u <?php if ((!empty($v_charset)) && ( $v_charset == 'koi8u')) echo 'selected'; ?>>koi8u</option>
  135. <option value=gb2312 <?php if ((!empty($v_charset)) && ( $v_charset == 'gb2312')) echo 'selected'; ?>>gb2312</option>
  136. <option value=greek <?php if ((!empty($v_charset)) && ( $v_charset == 'greek')) echo 'selected'; ?>>greek</option>
  137. <option value=cp1250 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp1250')) echo 'selected'; ?>>cp1250</option>
  138. <option value=gbk <?php if ((!empty($v_charset)) && ( $v_charset == 'gbk')) echo 'selected'; ?>>gbk</option>
  139. <option value=latin5 <?php if ((!empty($v_charset)) && ( $v_charset == 'latin5')) echo 'selected'; ?>>latin5</option>
  140. <option value=armscii8 <?php if ((!empty($v_charset)) && ( $v_charset == 'armscii8')) echo 'selected'; ?>>armscii8</option>
  141. <option value=utf8 <?php if ((!empty($v_charset)) && ( $v_charset == 'utf8')) echo 'selected'; ?>>utf8</option>
  142. <option value=utf8mb4 <?php if ((!empty($v_charset)) && ( $v_charset == 'utf8mb4')) echo 'selected'; ?> <?php if (empty($v_charset)) echo 'selected'; ?>>utf8mb4</option>
  143. <option value=ucs2 <?php if ((!empty($v_charset)) && ( $v_charset == 'ucs2')) echo 'selected'; ?>>ucs2</option>
  144. <option value=cp866 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp866')) echo 'selected'; ?>>cp866</option>
  145. <option value=keybcs2 <?php if ((!empty($v_charset)) && ( $v_charset == 'keybcs2')) echo 'selected'; ?>>keybcs2</option>
  146. <option value=macce <?php if ((!empty($v_charset)) && ( $v_charset == 'macce')) echo 'selected'; ?>>macce</option>
  147. <option value=macroman <?php if ((!empty($v_charset)) && ( $v_charset == 'macroman')) echo 'selected'; ?>>macroman</option>
  148. <option value=cp852 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp852')) echo 'selected'; ?>>cp852</option>
  149. <option value=latin7 <?php if ((!empty($v_charset)) && ( $v_charset == 'latin7')) echo 'selected'; ?>>latin7</option>
  150. <option value=cp1251 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp1251')) echo 'selected'; ?>>cp1251</option>
  151. <option value=cp1256 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp1256')) echo 'selected'; ?>>cp1256</option>
  152. <option value=cp1257 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp1257')) echo 'selected'; ?>>cp1257</option>
  153. <option value=binary <?php if ((!empty($v_charset)) && ( $v_charset == 'binary')) echo 'selected'; ?>>binary</option>
  154. <option value=geostd8 <?php if ((!empty($v_charset)) && ( $v_charset == 'geostd8')) echo 'selected'; ?>>geostd8</option>
  155. <option value=cp932 <?php if ((!empty($v_charset)) && ( $v_charset == 'cp932')) echo 'selected'; ?>>cp932</option>
  156. <option value=eucjpms <?php if ((!empty($v_charset)) && ( $v_charset == 'eucjpms')) echo 'selected'; ?>>eucjpms</option>
  157. </select>
  158. </div>
  159. </div>
  160. <?php } ?>
  161. </div>
  162. </form>
  163. </div>