This commit is contained in:
2023-08-08 17:04:21 +00:00
parent 31ecda89b2
commit ec382e989a
147 changed files with 18206 additions and 18063 deletions

View File

@@ -1,51 +1,51 @@
<?
$information = [
'GET' => [],
];
header('Content-Type: application/json charset=utf-8');
$ruta = "../";
require_once "../class/c_login.php";
// check if the session is started
if (!isset($_SESSION['user'])) {
http_response_code(500);
echo json_encode([
'error' => 'No se ha iniciado sesión'
]);
exit;
}
$user = unserialize($_SESSION['user']);
try {
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// check parameters
array_walk($information['GET'], function ($value) {
if (!array_key_exists($value, $_GET)) {
http_response_code(400);
echo json_encode(['error' => "$value is required"]);
exit;
}
});
// step 1: get subrutas
$data = $db->get('facultad');
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
} else {
http_response_code(405);
echo json_encode(['error' => 'method not allowed']);
exit;
}
} catch (PDOException $th) {
http_response_code(500);
echo json_encode([
'error' => $th->getMessage(),
'query' => $db->getLastQuery(),
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
} catch (Exception $th) {
http_response_code(500);
echo json_encode([
'error' => $th->getMessage(),
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
<?
$information = [
'GET' => [],
];
header('Content-Type: application/json charset=utf-8');
$ruta = "../";
require_once "../class/c_login.php";
// check if the session is started
if (!isset($_SESSION['user'])) {
http_response_code(500);
echo json_encode([
'error' => 'No se ha iniciado sesión'
]);
exit;
}
$user = unserialize($_SESSION['user']);
try {
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// check parameters
array_walk($information['GET'], function ($value) {
if (!array_key_exists($value, $_GET)) {
http_response_code(400);
echo json_encode(['error' => "$value is required"]);
exit;
}
});
// step 1: get subrutas
$data = $db->get('facultad');
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
} else {
http_response_code(405);
echo json_encode(['error' => 'method not allowed']);
exit;
}
} catch (PDOException $th) {
http_response_code(500);
echo json_encode([
'error' => $th->getMessage(),
'query' => $db->getLastQuery(),
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
} catch (Exception $th) {
http_response_code(500);
echo json_encode([
'error' => $th->getMessage(),
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}