add-subpath.php 722 B

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