This commit is contained in:
2021-03-25 23:33:37 -03:00
parent cd1ee7d446
commit 8fe357cc95
16 changed files with 216 additions and 58 deletions

View File

@ -1,35 +1,8 @@
<?php
include_once realpath(dirname(__DIR__, 2) . '/bootstrap/autoload.php');
$get = $_GET;
$post = $_POST;
function get_keys() {
$filename = realpath('./keys');
$keys = [];
if ($filename !== false) {
$keys = json_decode(trim(file_get_contents($filename)));
}
return $keys;
}
function validate_key($keys, $key) {
if (array_search($key, $keys) !== false) {
return true;
}
return false;
}
$keys = get_keys();
$key = $get['API_KEY'];
if (!validate_key($keys, $key)) {
throw new Exception('Error en la identificacion.');
}
$p = $get['page'] ?? $get['p'];
$a = $get['action'] ?? $get['a'];
if ($p == 'precios' and $a == 'importar') {
echo json_encode($post);
} else {
echo route_api();
}
$__environment = 'api';
include_once implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__, 2),
'setup',
'app.php'
]);
$app->run();