Limpieza e intento de modernizar informe de ventas
This commit is contained in:
4
public/api/.htaccess
Normal file
4
public/api/.htaccess
Normal file
@ -0,0 +1,4 @@
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^ index.php [QSA,L]
|
34
public/api/index.php
Normal file
34
public/api/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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') {
|
||||
$data = json_decode($post['data']);
|
||||
echo json_encode($data);
|
||||
}
|
1
public/api/keys
Normal file
1
public/api/keys
Normal file
@ -0,0 +1 @@
|
||||
[1]
|
Reference in New Issue
Block a user