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