|
|
|
@ -14,12 +14,6 @@ if (!defined('_ECRIRE_INC_VERSION')) return;
|
|
|
|
|
*/
|
|
|
|
|
function action_api_selecteur_dist() {
|
|
|
|
|
|
|
|
|
|
$response_404 = function() {
|
|
|
|
|
http_response_code(404);
|
|
|
|
|
header('Status: 404 Not Found');
|
|
|
|
|
exit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$response_200 = function($json) {
|
|
|
|
|
// On renvoie une ressource JSON
|
|
|
|
|
header('Status: 200 OK');
|
|
|
|
@ -28,11 +22,27 @@ function action_api_selecteur_dist() {
|
|
|
|
|
exit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$response_403 = function() {
|
|
|
|
|
http_response_code(403);
|
|
|
|
|
header('Status: 403 Forbidden');
|
|
|
|
|
exit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$response_404 = function() {
|
|
|
|
|
http_response_code(404);
|
|
|
|
|
header('Status: 404 Not Found');
|
|
|
|
|
exit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Il faut au moins le sélecteur dans l'argument sinon rien
|
|
|
|
|
if (!$selecteur = _request('arg')) {
|
|
|
|
|
$response_404();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!autoriser('autocomplete', $selecteur, null, null, ['args' => $_GET ?? []])) {
|
|
|
|
|
$response_403();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// API traitée en PHP
|
|
|
|
|
if (_request('php')) {
|
|
|
|
|
$selecteur_php = charger_fonction($selecteur, 'selecteurs', true);
|
|
|
|
|