servnest/pg-act/ht/add-subdomain.php
2023-07-17 21:15:18 +02:00

19 lines
817 B
PHP

<?php declare(strict_types=1);
if (dirsStatuses('subdomain')[$_POST['dir']] !== false)
output(403, 'Wrong value for <code>dir</code>.');
if (preg_match('/' . SUBDOMAIN_REGEX . '/D', $_POST['subdomain']) !== 1)
output(403, _('Invalid domain label.'));
if (query('select', 'sites', ['address' => $_POST['subdomain'], 'type' => 'subdomain']) !== [])
output(403, _('This domain already exists on this service. Use another one.'));
rateLimit();
addSite($_SESSION['id'], $_POST['dir'], $_POST['subdomain'], 'subdomain');
if (symlink('../../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . $_POST['subdomain'] . '.' . CONF['ht']['subdomain_domain']) !== true)
output(500, 'Unable to create symlink.');
output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']));