2022-12-22 00:44:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (dirsStatuses('subpath')[$_POST['dir']] !== false)
|
|
|
|
output(403, 'Wrong value for <code>dir</code>.');
|
|
|
|
|
|
|
|
if (preg_match('/^[a-z0-9]{1,32}$/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');
|
|
|
|
|
|
|
|
if (symlink(CONF['ht']['ht_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['subpath_path'] . '/' . $_POST['path']) !== true)
|
|
|
|
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']));
|