2022-12-22 00:44:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (dirsStatuses('subpath')[$_POST['dir']] !== false)
|
|
|
|
output(403, 'Wrong value for <code>dir</code>.');
|
|
|
|
|
2023-06-04 22:18:10 +00:00
|
|
|
if (preg_match('/' . SUBPATH_REGEX . '/D', $_POST['path']) !== 1)
|
2023-01-21 00:27:52 +00:00
|
|
|
output(403, _('Invalid path.'));
|
2022-12-22 00:44:57 +00:00
|
|
|
|
|
|
|
if (query('select', 'sites', ['address' => $_POST['path'], 'type' => 'subpath']) !== [])
|
2023-01-21 00:27:52 +00:00
|
|
|
output(403, _('This path already exists on this service. Use another one.'));
|
2022-12-22 00:44:57 +00:00
|
|
|
|
|
|
|
rateLimit();
|
|
|
|
|
|
|
|
addSite($_SESSION['id'], $_POST['dir'], $_POST['path'], 'subpath');
|
|
|
|
|
2023-04-09 22:50:42 +00:00
|
|
|
if (symlink('../../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . CONF['ht']['subpath_domain'] . '/' . $_POST['path']) !== true)
|
2022-12-22 00:44:57 +00:00
|
|
|
output(500, 'Unable to create symlink.');
|
|
|
|
|
2023-01-21 00:27:52 +00:00
|
|
|
output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']));
|