add-subpath.php 777 B

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