servnest/pg-act/ht/add-subdomain.php

20 lines
761 B
PHP

<?php
if (dirsStatuses('subdomain')[$_POST['dir']] !== false)
output(403, 'Wrong value for <code>dir</code>.');
if (preg_match('/^[a-z0-9]{1,32}$/D', $_POST['subdomain']) !== 1)
output(403, 'Label de domaine invalide.');
if (query('select', 'sites', ['address' => $_POST['subdomain'], 'type' => 'subdomain']) !== [])
output(403, 'Ce domaine est déjà utilisé sur ce service. Utilisez-en un autre.');
rateLimit();
addSite($_SESSION['id'], $_POST['dir'], $_POST['subdomain'], 'subdomain');
if (symlink(CONF['ht']['ht_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['subdomain_path'] . '/' . $_POST['subdomain']) !== true)
output(500, 'Unable to create symlink.');
output(200, 'Accès HTTP par sous-chemin ajouté sur ce dossier !');