milfs/website/milfs/json.php

90 lines
2.9 KiB
PHP
Raw Normal View History

2014-09-25 15:46:41 +00:00
<?php
//ini_set('display_errors', 'On');
require ('xajax/xajax.inc.php');
$xajax = new xajax();
require ('funciones/funciones.php');
require ('funciones/convert.php');
require ("includes/markdown.php");
require ("funciones/conex.php");
2014-09-25 15:46:41 +00:00
$fecha_inicio = mysql_seguridad($_REQUEST[inicio]);
$fin = mysql_seguridad($_REQUEST[fin]);
$perfil = mysql_seguridad($_REQUEST[id]);
2014-09-25 15:46:41 +00:00
$id = mysql_seguridad($_REQUEST[id]);
$busqueda = mysql_seguridad($_REQUEST[cadena]);
$campo = buscar_campo_tipo($id,"14");
$id_campo = $campo[0];
$link=Conectarse();
2014-10-07 11:28:54 +00:00
/*
$consulta = " SELECT distinct(contenido) as data, control,form_datos.form_id as id, timestamp
FROM form_datos
2014-09-25 15:46:41 +00:00
WHERE form_datos.id_campo = '$id_campo'
2014-10-07 11:28:54 +00:00
AND form_id = '$id'
2014-09-25 15:46:41 +00:00
";
2014-10-07 11:28:54 +00:00
*/
$consulta = "SELECT form_id as id, control, GROUP_CONCAT(contenido ORDER by timestamp desc ) as data
2014-10-07 11:28:54 +00:00
FROM `form_datos`
WHERE form_id = '$id'
AND id_campo ='$id_campo' $valor
group by control
ORDER BY orden desc";
//echo $consulta;
2014-09-25 15:46:41 +00:00
mysql_query("SET NAMES 'UTF8'");
$sql = mysql_query($consulta,$link) or die("error al ejecutar consulta ");
if (mysql_num_rows($sql)!='0'){
$id = 1;
$features = array();
while( $row = mysql_fetch_array( $sql ) ) {
$marcador = array();
$propiedades = array();
//$marcador["id"] = $id;
//$titulo = remplacetas("form_datos","control","$row[control]","contenido","id_campo ='28' AND timestamp ='$row[timestamp]'");
2014-09-25 15:46:41 +00:00
//$marcador["id"] = $id;
//$identificador=mysql_result($sql,0,"identificador");
$identificador = explode(',',$row[data]);
$identificador = $identificador[0];
$campos = explode(" ",$identificador);
2014-09-25 15:46:41 +00:00
$lat = $campos[0];
$lon = $campos[1];
$zoom = $campos[2];
$marcador["type"] = "Point";
$marcador["coordinates"] = array($lat,$lon);
//$marcador["loc"] = array('lat'=>$lat,'lon'=>$lon);
2015-10-27 21:35:37 +00:00
$formulario = formulario_imprimir($perfil,$row[control],'');
2014-10-06 17:13:44 +00:00
$propiedades["name"] ="<div class='container-fluid' id='contenedor_datos' >$formulario</div>";
2014-09-25 15:46:41 +00:00
//formulario_imprimir($id,$control)
//$marcador["zoom"] = $zoom;
2015-10-27 21:35:37 +00:00
$geometria .= "{\"type\":\"Feature\",\"geometry\":".json_encode($marcador,JSON_NUMERIC_CHECK).",\"properties\":".json_encode($propiedades,JSON_NUMERIC_CHECK)."}";
2014-09-25 15:46:41 +00:00
$features[] = $marcador;
//$resultado .= "<li> $row[tipo]<br> <a href=\"#\" onclick=\"javascript:loadMarker($id);return false;\"><b>$row[title]</b></a><br>$row[description]<hr> </li>";
$id++;
}
}
//-75.58295 6.25578 16
//encode and output jsonObject
header('Content-Type: application/json');
//echo $consulta;
$resultado = " { \"type\": \"FeatureCollection\",
\"features\": ";
$resultado .= json_encode($features,JSON_NUMERIC_CHECK);
$resultado .= "}";
//echo $resultado;
$geometria = substr("$geometria",0,-1);
$geometria = "{
\"type\": \"FeatureCollection\",
\"features\": [$geometria ]}";
echo $geometria;
?>