session_start();
if (file_exists('../../MyDBi.php')) {
    require_once '../../MyDBi.php';
} else {
    require_once 'MyDBi.php';
}
$data = file_get_contents("php://input");
$decoded = json_decode($data);
if ($decoded != null) {
    if ($decoded->function == 'saveNoticia') {
        saveNoticia($decoded->noticia);
    } elseif ($decoded->function == 'updateNoticia') {
        updateNoticia($decoded->noticia);
    } elseif ($decoded->function == 'deleteNoticia') {
        deleteNoticia($decoded->noticia_id);
    } elseif ($decoded->function == 'saveComentario') {
        saveComentario($decoded->comentario);
    } elseif ($decoded->function == 'updateComentario') {
        updateComentario($decoded->comentario);
    } elseif ($decoded->function == 'deleteComentario') {
        deleteComentario($decoded->comentario_id);
    }
} else {
    $function = $_GET["function"];
    if ($function == 'getNoticias') {
        getNoticias();
    }
}
function deleteComentario($comentario_id)
{
session_start();
if (file_exists('../../MyDBi.php')) {
    require_once '../../MyDBi.php';
} else {
    require_once 'MyDBi.php';
}
$data = file_get_contents("php://input");
$decoded = json_decode($data);
if ($decoded != null) {
    if ($decoded->function == 'saveNoticia') {
        saveNoticia($decoded->noticia);
    } elseif ($decoded->function == 'updateNoticia') {
        updateNoticia($decoded->noticia);
    } elseif ($decoded->function == 'deleteNoticia') {
        deleteNoticia($decoded->id);
    } elseif ($decoded->function == 'saveComentario') {
        saveComentario($decoded->comentario);
    } elseif ($decoded->function == 'updateComentario') {
        updateComentario($decoded->comentario);
    } elseif ($decoded->function == 'deleteComentario') {
        deleteComentario($decoded->id);
    }
} else {
    $function = $_GET["function"];
    if ($function == 'getNoticias') {
        getNoticias();
    } elseif ($function == 'getComentarios') {
        getComentarios();
    }
}