<?php 
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET");
header("Allow: GET");
?>
[
<?php 

include 'concha.php';
include 'url_amigable.php';
error_reporting(E_ERROR | E_WARNING | E_PARSE);


mysql_connect ("$host", "$usuario", "$contra");
mysql_select_db ("$basedatos");
$sql = "SELECT * FROM notas ORDER BY ID desc LIMIT 20";
$consulta = mysql_query ($sql);
while ($row = mysql_fetch_array($consulta)) {

    $ID = $row["ID"];
    $carpetafoto = $row["carpetafoto"];
    $foto = $row["foto"]; 
    $ext_img = $row["ext_img"];
    $titulo = $row["titulo"];
    $texto = $row["texto"];
    $bajada = $row["bajada"];
    $audio = $row["audio"];
    $d = $row["d"];
    $m = $row["m"];
    $m2 = $row["m"];
    $a = $row["a"];
    $tag1 = $row["tag1"];
    $tag2 = $row["tag2"];
    $tag3 = $row["tag3"];
    $tag4 = $row["tag4"];
    $tag5 = $row["tag5"];
    $youtube = $row["youtube"];
    $visitas = $row["visitas"];
    
    $bajada = str_replace('"','',$bajada);
    $titulo = str_replace('"','',$titulo);
    $titulo = nl2br($titulo);
    $bajada = nl2br($bajada);
    
    
    $titulo = eregi_replace("[\n|\r|\n\r]", " ", $titulo);
    $bajada = eregi_replace("[\n|\r|\n\r]", " ", $bajada);
    
    $titulo = str_replace("<br />","",$titulo);
    $bajada = str_replace("<br />","",$bajada);
    $titulo = trim($titulo);
    $bajada = trim($bajada);
    $numero = $numero + 1;
     
?>
    {
        "ID": "<?php echo $ID ?>",
        "foto": "<?php echo $dom ?>/<?php echo $carpetafoto ?>/thumbnail_<?php echo $foto ?><?php echo $ext_img ?>",
        "titulo": "<?php echo $titulo ?>",
        "bajada": "<?php echo $bajada ?>",
        "contenido": "<?php echo $dom ?>/nota_solo_html.php?ID=<?php echo $ID ?>"
    }
<? 

//echo $numero;

    if ($numero == 3) { } else if($numero) {?>,<?} else {} ?>
    
<?} mysql_free_result($consulta);?>

]
