servnest/pg-view/ht/index.php
2023-07-17 21:15:18 +02:00

181 lines
9.8 KiB
PHP

<?php declare(strict_types=1); ?>
<p>
<?= _('This service allows you to send files on the server using SFTP, and to make them publicly available with HTTP.') ?>
</p>
<?php displayIndex(); ?>
<section>
<h2><?= _('Currently hosted sites') ?></h2>
<?php
$sites = query('select', 'sites', ['username' => $_SESSION['id'] ?? '']);
if ($sites === [])
echo ' <p>∅<p>' . LF;
else {
echo ' <dl>' . LF;
foreach ($sites as $site) {
$url = match ($site['type']) {
'subpath' => 'https://' . CONF['ht']['subpath_domain'] . '/' . $site['address'] . '/',
'subdomain' => 'https://' . $site['address'] . '.' . CONF['ht']['subdomain_domain'] . '/',
'onion' => 'http://' . $site['address'] . '/',
'dns' => 'https://' . $site['address'] . '/',
};
?>
<dt><code>/<?= $site['site_dir'] ?></code></dt>
<dd>
<a href="<?= $url ?>" rel="external"><?= $url ?></a>
</dd>
<?php
}
echo ' </dl>' . LF;
}
?>
</section>
<section>
<h2><?= _('Adding a site access') ?></h2>
<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>
</section>
<section>
<h2><?= _('Connecting to the SFTP server') ?></h2>
<?php
$sftp_url = 'sftp://' . (defined('DISPLAY_USERNAME') ? DISPLAY_USERNAME : '&lt;username&gt;') . '@' . CONF['ht']['sftp_domain'] . ':' . CONF['ht']['public_sftp_port'] . '/';
?>
<a href="<?= $sftp_url ?>"><?= $sftp_url ?></a>
<dl>
<dt><?= _('Server') ?></dt>
<dd>
<code><?= CONF['ht']['sftp_domain'] ?></code>
</dd>
<dt><?= _('Port') ?></dt>
<dd>
<code><?= CONF['ht']['public_sftp_port'] ?></code><?php if (CONF['ht']['public_sftp_port'] === 22) echo " (par défaut)"; ?>
</dd>
<dt><?= _('Directory') ?></dt>
<dd>
<code>/</code>
</dd>
<dt><?= _('Username') ?></dt>
<dd>
<code><?= defined('DISPLAY_USERNAME') ? DISPLAY_USERNAME : '&lt;username&gt;' ?></code>
</dd>
<dt><?= _('Password') ?></dt>
<dd>
<?= _('The one of your account') ?>
</dd>
</dl>
<section>
<h3><?= _('Authenticating the server') ?></h3>
<p><?= _('An SSHFP record is available.') ?></p>
<details>
<summary><?= _('Plain public key') ?></summary>
<code><?= file_get_contents(CONF['ht']['sftp_pub']) ?></code>
</details>
<details open="">
<summary><?= _('Public key fingerprint') ?></summary>
<code><?= file_get_contents(CONF['ht']['sftp_fp']) ?></code>
</details>
<details>
<summary><?= _('ASCII art') ?></summary>
<pre><?= file_get_contents(CONF['ht']['sftp_asciiart']) ?></pre>
</details>
</section>
</section>
<section>
<h2>HTTP</h2>
<h3>CSP</h3>
<p>
<?= _('A content security policy (CSP) forbids Web browsers from loading JavaScript or third-party resources.') ?>
</p>
<h3><?= _('<code>.htaccess</code> configuration') ?></h3>
<p>
<?= _('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:') ?>
</p>
<ul>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#files"><code>&lt;Files&gt;</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#filesmatch"><code>&lt;FilesMatch&gt;</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirect"><code>Redirect</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectmatch"><code>RedirectMatch</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectpermanent"><code>RedirectPermanent</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_alias.html#redirecttemp"><code>RedirectTemp</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#errordocument"><code>ErrorDocument</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype"><code>AddType</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/core.html#forcetype"><code>ForceType</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#defaultlanguage"><code>DefaultLanguage</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#addanguage"><code>AddLanguage</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_negotiation.html#languagepriority"><code>LanguagePriority</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_negotiation.html#forcelanguagepriority"><code>ForceLanguagePriority</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex"><code>DirectoryIndex</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryslash"><code>DirectorySlash</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removetype"><code>RemoveType</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removeoutputfilter"><code>RemoveOutputFilter</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removelanguage"><code>RemoveLanguage</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removeencoding"><code>RemoveEncoding</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_mime.html#removecharset"><code>RemoveCharset</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_expires.html#expiresactive"><code>ExpiresActive</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_expires.html#expiresdefault"><code>ExpiresDefault</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_expires.html#expiresbytype"><code>ExpiresByType</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#defaulticon"><code>DefaultIcon</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#adddescription"><code>AddDescription</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addalt"><code>AddAlt</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addaltbyencoding"><code>AddAltByEncoding</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addaltbytype"><code>AddAltByType</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addicon"><code>AddIcon</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addiconbyencoding"><code>AddIconByEncoding</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#addiconbytype"><code>AddIconByType</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexignore"><code>IndexIgnore</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexignorereset"><code>IndexIgnoreReset</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexoptions"><code>IndexOptions</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexorderdefault"><code>IndexOrderDefault</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#headername"><code>HeaderName</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#readmename"><code>ReadmeName</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexstylesheet"><code>IndexStyleSheet</code></a></li>
<li><a rel="external help" href="https://httpd.apache.org/docs/current/mod/mod_headers.html#header"><code>Header</code></a></li>
</ul>
</section>
<section>
<h2><?= _('Accounts capabilities') ?></h2>
<dl>
<dt><span aria-hidden="true">⏳ </span><em><?= _('Testing') ?></em></dt>
<dd>
<ul>
<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>
<li><?= _('Let\'s Encrypt certificate from the staging environment (not trusted by clients)') ?></li>
</ul>
</dd>
<dt><span aria-hidden="true">👤 </span><em><?= _('Approved') ?></em></dt>
<dd>
<ul>
<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>
<li><?= _('Stable Let\'s Encrypt certificates') ?></li>
</ul>
</dd>
</dl>
</section>