declare(strict_types=1);

This commit is contained in:
Miraty 2023-07-17 21:15:18 +02:00
parent 3436d0243f
commit 40e67b0c0c
96 changed files with 97 additions and 54 deletions

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
const USERNAME_REGEX = '^.{1,1024}$';
const PASSWORD_REGEX = '^(?=.*[\p{Ll}])(?=.*[\p{Lu}])(?=.*[\p{N}]).{8,1024}|.{10,1024}$';

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
function output(int $code, string $msg = '', array $logs = [''], array $data = []): never {
http_response_code($code);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
function parseZoneFile(string $zone_content, array $types, bool|string $filter_domain = false, bool $filter_include_subdomains = true): array {
$parsed_zone_content = [];

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
const SUBPATH_REGEX = '^[a-z0-9-]{4,63}$';
const ED25519_PUBKEY_REGEX = '^[a-zA-Z0-9/+]{68}$';

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
const SOA_VALUES = [
'ttl' => 10800,

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
const SUBDOMAIN_REGEX = '^(?!\-)(?!..\-\-)[a-z0-9-]{4,63}(?<!\-)$';

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
umask(0077);
set_error_handler(function ($level, $message, $file = '', $line = 0) {

View File

@ -1,4 +1,5 @@
<?php // Test that the current setup is working
<?php declare(strict_types=1);
// Test that the current setup is working
require __DIR__ . '/../init.php';

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
require __DIR__ . '/../init.php';
const MAX_TESTING_ACCOUNT_AGE = 86400 * 10;

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
require __DIR__ . '/../init.php';
foreach (query('select', 'ns-syncs') as $sync) {

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
RFC 7344: Automating DNSSEC Delegation Trust Maintenance
RFC 8078: Managing DS Records from the Parent via CDS/CDNSKEY

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
RFC 7477: Child-to-Parent Synchronization in DNS
*/

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
define('PAGES', [
'index' => [

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if ($_SESSION['type'] !== 'testing')
output(403, _('This account is already approved.'));

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
checkPasswordFormat($_POST['password']);

View File

@ -1,3 +0,0 @@
<?php
logout();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
checkPasswordFormat($_POST['new-password']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (CONF['common']['services']['auth'] !== 'enabled')
output(403, _('Registrations are currently closed on this installation.'));

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (checkPassword($_SESSION['id'], $_POST['current-password']) !== true)
output(403, _('Wrong current password.'));

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
checkUsernameFormat($_POST['new-username']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$_POST['domain'] = formatDomain($_POST['domain']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (dirsStatuses('onion')[$_POST['dir']] !== false)
output(403, 'Wrong value for <code>dir</code>.');

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (dirsStatuses('subdomain')[$_POST['dir']] !== false)
output(403, 'Wrong value for <code>dir</code>.');

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (dirsStatuses('subpath')[$_POST['dir']] !== false)
output(403, 'Wrong value for <code>dir</code>.');

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (preg_match('/^(?<type>subpath|subdomain|onion|dns):(?<address>[a-z0-9._-]{1,256})$/D', $_POST['site'], $site) !== 1)
output(403, 'Malformed value for <code>site</code>.');

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$el_nb = count($_POST['keys']);
if ($el_nb < 1 OR $el_nb > 8)

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
nsCheckZonePossession($_POST['zone']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
nsCheckZonePossession($_POST['zone']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$el_nb = count($_POST['syncs']);
if ($el_nb < 1 OR $el_nb > 8)

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$values = nsParseCommonRequirements();

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
$_POST['domain'] = formatAbsoluteDomain($_POST['domain']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
nsCheckZonePossession($_POST['zone']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (!in_array($_POST['algo'], ['8', '13', '14', '15', '16'], true))
output(403, 'Wrong value for <code>algo</code>.');

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
regCheckDomainPossession($_POST['domain']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
regCheckDomainPossession($_POST['domain']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
regCheckDomainPossession($_POST['domain']);

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (preg_match('/' . SUBDOMAIN_REGEX . '/D', $_POST['subdomain']) !== 1)
output(403, _('This format of subdomain is not allowed.'));

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
if (preg_match('/' . SUBDOMAIN_REGEX . '/D', $_POST['subdomain']) !== 1)
output(403, _('This format of subdomain is not allowed.'));

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
regCheckDomainPossession($_POST['domain']);

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('This form allows to use an approval key to validate your account. Approval keys are distributed by an administrator upon request.') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<?php displayIndex(); ?>
<h2 id="type"><?= _('Account type') ?></h2>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p><?= _('New?') ?> <a href="register"><?= _('Create an account') ?></a></p>
<form method="post">

View File

@ -1,3 +1,3 @@
<?php
<?php declare(strict_types=1);
logout();

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<label for="current-password"><?= _('Current password') ?></label><br>
<input required="" autocomplete="current-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="current-password" name="current-password" type="password" placeholder="<?= PLACEHOLDER_PASSWORD ?>"><br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p><?= _('Already have an account?') ?> <a href="login"><?= _('Log in') ?></a></p>
<?= (CONF['common']['services']['auth'] !== 'enabled') ? '<p><strong>' . _('Registrations are currently closed on this installation.') . '</strong></p>' : '' ?>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('This will delete every resource managed by the current account, including registered domains, hosted DNS records, websites files and cryptographic keys for Onion services and DNSSEC.') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<label for="current-password"><?= _('Current password') ?></label><br>
<input required="" autocomplete="current-password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="current-password" name="current-password" type="password" placeholder="<?= PLACEHOLDER_PASSWORD ?>"><br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('A Let\'s Encrypt certificate will be obtained.') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<label for="dir"><?= _('Target directory') ?></label><br>
<select required="" name="dir" id="dir">

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= sprintf(_('The subdomain can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters. It can\'t have an hyphen (%3$s) in first, last or both third and fourth position.'), '<abbr title="abcdefghijklmnopqrstuvwxyz"><code>a</code>-<code>z</code></abbr>', '<abbr title="0123456789"><code>0</code>-<code>9</code></abbr>', '<code>-</code>') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= sprintf(_('The path can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters.'), '<abbr title="abcdefghijklmnopqrstuvwxyz"><code>a</code>-<code>z</code></abbr>', '<abbr title="0123456789"><code>0</code>-<code>9</code></abbr>', '<code>-</code>') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<label for="site"><?= _('Access to delete') ?></label><br>
<select required="" name="site" id="site">

View File

@ -1,3 +1,4 @@
<?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>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('In addition to your password, you can also access your SFTP space using Ed25519 SSH keys. A key can be granted modification rights to the full space (<code>/</code>) or to any arbitrary subdirectory. A key is always allowed to list any directory content.') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<nav>
<p>
<span aria-hidden="true">➡️ </span><em><a href="<?= CONF['common']['about_url'] ?>"><?= _('About this installation') ?></a></em>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="flag"><?= _('Flag') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="cname"><?= _('Canonical name') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="dname"><?= _('Delegation name') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<label for="zone"><?= _('Zone to be changed') ?></label>
<br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<label for="action"><?= _('Action') ?></label>
<select name="action" id="action">
<option value="add"<?= ($_POST['action'] ?? NULL) === 'add' ? ' selected=""' : '' ?>><?= _('Add') ?></option>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('This service allows to host and manage DNS records inside a DNS zone.') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="ip"><?= _('IP address') ?></label><br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<fieldset>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="priority"><?= _('Priority') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="ns"><?= _('Name server') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<input type="radio" name="print" id="table" value="table" checked="">
<label for="table"><?= _('Records table') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= sprintf(_('AAAA, A and CAA records are regularly copied from the source domain to the target domain. Their TTLs are set to %s seconds.'), SYNC_TTL) ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/ns/form.ns.php'; ?>
<label for="txt"><?= _('Text') ?></label>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= sprintf(_('To prove that you own this domain, it must have a NS record equal to %s when the form is being processed.'), '<code>' . getAuthToken() . '._domain-verification.' . SERVER_NAME . '.</code>') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<label for="zone"><?= _('Zone') ?></label>
<select required="" name="zone" id="zone">

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/reg/select-action.inc.php'; ?>
<br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/reg/select-action.inc.php'; ?>
<fieldset>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= sprintf(_('This domain name registry allows to register domains ending with <code>%1$s</code>, for instance <code><em>domain</em>%1$s</code>.'), '.' . key(CONF['reg']['suffixes'])) ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/reg/select-action.inc.php'; ?>
<br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<form method="post">
<?php require ROOT_PATH . '/pg-view/reg/select-domain.inc.php'; ?>
<br>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('Register a new domain on your account.') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<label for="action"><?= _('Action') ?></label>
<select name="action" id="action">
<option value="add"<?= ($_POST['action'] ?? NULL) === 'add' ? ' selected=""' : '' ?>><?= _('Add') ?></option>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<label for="domain"><?= _('Domain') ?></label>
<br>
<select required="" name="domain" id="domain">

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= sprintf(_('To prove that you are allowed to receive the domain by its current owner, the domain must have an NS record equal to %s when the form is being processed. The NS record will be automatically deleted once validated.'), '<code>' . getAuthToken() . '._transfer-verification.' . SERVER_NAME . '.</code>') ?>
</p>

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<p>
<?= _('This will unregister the domain, making it registerable by anyone again (after a delay of 1 year plus half the registration period, with a maximum of 8 years).') ?>
</p>

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
require 'init.php';
$pageAddress = substr($_SERVER['REQUEST_URI'], strlen(CONF['common']['prefix']) + 1);

View File

@ -1,4 +1,5 @@
<?php // ServNest authenticator for SFTPGo https://github.com/drakkan/sftpgo/blob/main/docs/external-auth.md
<?php declare(strict_types=1);
// ServNest authenticator for SFTPGo https://github.com/drakkan/sftpgo/blob/main/docs/external-auth.md
const DEBUG = false;
!DEBUG or ob_start();

View File

@ -1,3 +1,4 @@
<?php declare(strict_types=1); ?>
<!DOCTYPE html>
<html lang="<?= LOCALE ?>"<?= empty(SERVICE) ? '' : ' class="' . SERVICE . '"' ?>>
<head>