-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
40 lines (35 loc) · 883 Bytes
/
api.php
File metadata and controls
40 lines (35 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
if( $_SERVER['CONTENT_TYPE'] != 'application/json' )
{
die;
}
header('Content-Type: application/json; charset=utf-8');
include_once 'funciones/funciones.php';
include_once 'clases/db.php';
$json = file_get_contents('php://input');
$usuario = json_decode( $json, false );
switch( $usuario->accion )
{
case 'eliminar':
$resultado = $db->eliminar_usuario( $usuario );
break;
case 'editar':
$resultado = $db->editar_usuario( $usuario );
break;
case 'crear':
$resultado = $db->crear_usuario( $usuario );
break;
case 'buscar':
$resultado = $db->buscar_usuario( $usuario );
break;
default:
$resultado = [
'resultado' => 'error',
'titulo' => 'Eso no se hace',
'texto' => 'No existe esa acción. Tu dirección IP <strong>' . $_SERVER['REMOTE_ADDR'] . '</strong> fue informada al FBI'
];
break;
}
echo json_encode( $resultado );
exit();
//die();