index.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php declare(strict_types=1); ?>
  2. <p>
  3. <?= _('This service allows you to send files on the server using SFTP, and to make them publicly available with HTTP.') ?>
  4. </p>
  5. <?php displayIndex(); ?>
  6. <section>
  7. <h2><?= _('Currently hosted sites') ?></h2>
  8. <?php
  9. $sites = query('select', 'sites', ['username' => $_SESSION['id'] ?? '']);
  10. if ($sites === [])
  11. echo ' <p>∅<p>' . LF;
  12. else {
  13. echo ' <dl>' . LF;
  14. foreach ($sites as $site) {
  15. $url = match ($site['type']) {
  16. 'subpath' => 'https://' . CONF['ht']['subpath_domain'] . '/' . $site['address'] . '/',
  17. 'subdomain' => 'https://' . $site['address'] . '.' . CONF['ht']['subdomain_domain'] . '/',
  18. 'onion' => 'http://' . $site['address'] . '/',
  19. 'dns' => 'https://' . $site['address'] . '/',
  20. };
  21. ?>
  22. <dt><code>/<?= $site['site_dir'] ?></code></dt>
  23. <dd>
  24. <a href="<?= $url ?>" rel="external"><?= $url ?></a>
  25. </dd>
  26. <?php
  27. }
  28. echo ' </dl>' . LF;
  29. }
  30. ?>
  31. </section>
  32. <section>
  33. <h2><?= _('Adding a site access') ?></h2>
  34. <p><?= sprintf(_('In order to be able to set up an HTTP site with this service, a subdirectory for this site must be created inside the SFTP space first. The name of this subdirectory can only contain %1$s, %2$s, %3$s, %4$s and %5$s.'), '<abbr title="abcdefghijklmnopqrstuvwxyz"><code>a</code>-<code>z</code></abbr>', '<abbr title="ABCDEFGHIJKLMNOPQRSTUVWXYZ"><code>A</code>-<code>Z</code></abbr>', '<abbr title="0123456789"><code>0</code>-<code>9</code></abbr>', '<code>_</code>', '<code>-</code>') ?></p>
  35. </section>
  36. <section>
  37. <h2><?= _('Connecting to the SFTP server') ?></h2>
  38. <?php
  39. $sftp_url = 'sftp://' . (defined('DISPLAY_USERNAME') ? DISPLAY_USERNAME : '&lt;username&gt;') . '@' . CONF['ht']['sftp_domain'] . ':' . CONF['ht']['public_sftp_port'] . '/';
  40. ?>
  41. <a href="<?= $sftp_url ?>"><?= $sftp_url ?></a>
  42. <dl>
  43. <dt><?= _('Server') ?></dt>
  44. <dd>
  45. <code><?= CONF['ht']['sftp_domain'] ?></code>
  46. </dd>
  47. <dt><?= _('Port') ?></dt>
  48. <dd>
  49. <code><?= CONF['ht']['public_sftp_port'] ?></code><?php if (CONF['ht']['public_sftp_port'] === 22) echo " (par défaut)"; ?>
  50. </dd>
  51. <dt><?= _('Directory') ?></dt>
  52. <dd>
  53. <code>/</code>
  54. </dd>
  55. <dt><?= _('Username') ?></dt>
  56. <dd>
  57. <code><?= defined('DISPLAY_USERNAME') ? DISPLAY_USERNAME : '&lt;username&gt;' ?></code>
  58. </dd>
  59. <dt><?= _('Password') ?></dt>
  60. <dd>
  61. <?= _('The one of your account') ?>
  62. </dd>
  63. </dl>
  64. <section>
  65. <h3><?= _('Authenticating the server') ?></h3>
  66. <p><?= _('An SSHFP record is available.') ?></p>
  67. <details>
  68. <summary><?= _('Plain public key') ?></summary>
  69. <code><?= file_get_contents(CONF['ht']['sftp_pub']) ?></code>
  70. </details>
  71. <details open="">
  72. <summary><?= _('Public key fingerprint') ?></summary>
  73. <code><?= file_get_contents(CONF['ht']['sftp_fp']) ?></code>
  74. </details>
  75. <details>
  76. <summary><?= _('ASCII art') ?></summary>
  77. <pre><?= file_get_contents(CONF['ht']['sftp_asciiart']) ?></pre>
  78. </details>
  79. </section>
  80. </section>
  81. <section>
  82. <h2>HTTP</h2>
  83. <h3>CSP</h3>
  84. <p>
  85. <?= _('A content security policy (CSP) forbids Web browsers from loading JavaScript or third-party resources.') ?>
  86. </p>
  87. <h3><?= _('<code>.htaccess</code> configuration') ?></h3>
  88. <p>
  89. <?= _('You can change the way the HTTP server answers to requests in a directory by setting some directives in a file named <code>.htaccess</code> at the root of this directory. Only the following directives are allowed:') ?>
  90. </p>
  91. <ul>
  92. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#files"><code>&lt;Files&gt;</code></a></li>
  93. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#filesmatch"><code>&lt;FilesMatch&gt;</code></a></li>
  94. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirect"><code>Redirect</code></a></li>
  95. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectmatch"><code>RedirectMatch</code></a></li>
  96. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectpermanent"><code>RedirectPermanent</code></a></li>
  97. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirecttemp"><code>RedirectTemp</code></a></li>
  98. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#errordocument"><code>ErrorDocument</code></a></li>
  99. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype"><code>AddType</code></a></li>
  100. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#forcetype"><code>ForceType</code></a></li>
  101. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#defaultlanguage"><code>DefaultLanguage</code></a></li>
  102. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#addanguage"><code>AddLanguage</code></a></li>
  103. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_negotiation.html#languagepriority"><code>LanguagePriority</code></a></li>
  104. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_negotiation.html#forcelanguagepriority"><code>ForceLanguagePriority</code></a></li>
  105. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex"><code>DirectoryIndex</code></a></li>
  106. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryslash"><code>DirectorySlash</code></a></li>
  107. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removetype"><code>RemoveType</code></a></li>
  108. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removeoutputfilter"><code>RemoveOutputFilter</code></a></li>
  109. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removelanguage"><code>RemoveLanguage</code></a></li>
  110. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removeencoding"><code>RemoveEncoding</code></a></li>
  111. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removecharset"><code>RemoveCharset</code></a></li>
  112. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_expires.html#expiresactive"><code>ExpiresActive</code></a></li>
  113. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_expires.html#expiresdefault"><code>ExpiresDefault</code></a></li>
  114. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_expires.html#expiresbytype"><code>ExpiresByType</code></a></li>
  115. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#defaulticon"><code>DefaultIcon</code></a></li>
  116. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#adddescription"><code>AddDescription</code></a></li>
  117. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addalt"><code>AddAlt</code></a></li>
  118. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addaltbyencoding"><code>AddAltByEncoding</code></a></li>
  119. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addaltbytype"><code>AddAltByType</code></a></li>
  120. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addicon"><code>AddIcon</code></a></li>
  121. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addiconbyencoding"><code>AddIconByEncoding</code></a></li>
  122. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addiconbytype"><code>AddIconByType</code></a></li>
  123. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexignore"><code>IndexIgnore</code></a></li>
  124. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexignorereset"><code>IndexIgnoreReset</code></a></li>
  125. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexoptions"><code>IndexOptions</code></a></li>
  126. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexorderdefault"><code>IndexOrderDefault</code></a></li>
  127. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#headername"><code>HeaderName</code></a></li>
  128. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#readmename"><code>ReadmeName</code></a></li>
  129. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexstylesheet"><code>IndexStyleSheet</code></a></li>
  130. <li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_headers.html#header"><code>Header</code></a></li>
  131. </ul>
  132. </section>
  133. <section>
  134. <h2><?= _('Accounts capabilities') ?></h2>
  135. <dl>
  136. <dt><span aria-hidden="true">⏳ </span><em><?= _('Testing') ?></em></dt>
  137. <dd>
  138. <ul>
  139. <li><?= sprintf(_('%s of SFTP quota'), ((CONF['ht']['user_quota_testing'] >> 30) >= 1) ? CONF['ht']['user_quota_testing'] >> 30 . ' ' . _('<abbr title="gibibyte">GiB</abbr>') : CONF['ht']['user_quota_testing'] >> 20 . ' ' . _('<abbr title="mebibyte">MiB</abbr>')) ?></li>
  140. <li><?= _('Let\'s Encrypt certificate from the staging environment (not trusted by clients)') ?></li>
  141. </ul>
  142. </dd>
  143. <dt><span aria-hidden="true">👤 </span><em><?= _('Approved') ?></em></dt>
  144. <dd>
  145. <ul>
  146. <li><?= sprintf(_('%s of SFTP quota'), ((CONF['ht']['user_quota_approved'] >> 30) >= 1) ? CONF['ht']['user_quota_approved'] >> 30 . ' ' . _('<abbr title="gibibyte">GiB</abbr>') : CONF['ht']['user_quota_approved'] >> 20 . ' ' . _('<abbr title="mebibyte">MiB</abbr>')) ?></li>
  147. <li><?= _('Stable Let\'s Encrypt certificates') ?></li>
  148. </ul>
  149. </dd>
  150. </dl>
  151. </section>