servnest/pg-view/ht/index.php

138 lines
4.4 KiB
PHP

<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 setup 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>SFTP</h2>
<?php
$quota = ($_SESSION['type'] ?? '' === 'approved') ? CONF['ht']['user_quota_approved'] : CONF['ht']['user_quota_testing'];
?>
<p>
<?= sprintf(_('The SFTP space is limited to %s. Indicate the following values to your SFTP client to access it.'), (($quota >> 30) >= 1) ? $quota >> 30 . ' ' . _('<abbr title="gibibyte">GiB</abbr>') : $quota >> 20 . ' ' . _('<abbr title="mebibyte">MiB</abbr>')) ?>
</p>
<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>
<h3><?= _('Connecting to the server') ?></h3>
<a href="sftp://<?= isset($_SESSION['display-username']) ? $_SESSION['display-username'] : '&lt;username&gt;'; ?>@<?= CONF['ht']['sftp_domain'] ?>:<?= CONF['ht']['public_sftp_port'] ?>/">sftp://<?= isset($_SESSION['display-username']) ? $_SESSION['display-username'] : '&lt;username&gt;'; ?>@<?= CONF['ht']['sftp_domain'] ?>:<?= CONF['ht']['public_sftp_port'] ?>/</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><?= isset($_SESSION['display-username']) ? $_SESSION['display-username'] : '&lt;username&gt;'; ?></code>
</dd>
<dt><?= _('Password') ?></dt>
<dd>
<?= _('The one of your account') ?>
</dd>
</dl>
</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><?= _('gzip compression') ?></h3>
<p>
<?= _('Static <em>gzip</em> compression is supported: if the client supports it and the file is available, <code>path.gz</code> is served instead of <code>path</code>.') ?>
</p>
<h3><?= _('Index page') ?></h3>
<p>
<?= _('When a request hits a directory, the first of the following files that exists <em>inside this directory</em> is served:') ?>
</p>
<ol>
<li><code>index.html</code></li>
<li><code>index.md</code></li>
<li><code>index.gmi</code></li>
</ol>
<h3><?= _('404 error page') ?></h3>
<p>
<?= _('When a request ends in a <code>404</code> error, the first of the following files that exists <em>at the root of the site</em> is served:') ?>
</p>
<ol>
<li><code>404.html</code></li>
<li><code>404.md</code></li>
<li><code>404.gmi</code></li>
</ol>
</section>