diff --git a/milfs/css/style.css b/milfs/css/style.css index 5d39f70..69d8f38 100755 --- a/milfs/css/style.css +++ b/milfs/css/style.css @@ -1,8 +1,27 @@ - * { +/* * { margin: 0; padding: 0; } + */ + fieldset.fieldset-borde { + border: 2px solid #EDEDED !important; + border-radius:3px; + padding: 0 1.4em 1.4em 1.4em !important; + margin: 0 0 1.5em 0 !important; + -webkit-box-shadow: 0px 0px 0px 0px #000; + box-shadow: 0px 0px 0px 0px #000; +} + + legend.legend-area { + font-size: 1.2em !important; + font-weight: bold !important; + text-align: left !important; + width:auto; + padding:0 10px; + border-bottom:none; + } + body { background: #222; font-family: Georgia, serif; diff --git a/milfs/funciones/funciones.php b/milfs/funciones/funciones.php old mode 100755 new mode 100644 index edfc058..10b56f1 --- a/milfs/funciones/funciones.php +++ b/milfs/funciones/funciones.php @@ -1,6 +1,512 @@ 3) { +$valor = urlencode($valor); +$json = "https://nominatim.openstreetmap.org/search.php?format=json&limit=5&addressdetails=1&q=$valor"; +$data = file_get_contents("$json"); +$geocoder = json_decode($data, true); +if($data ==="[]") {$vacio=" + + No se encontraron resultados +";} + +foreach ($geocoder as $clave => $valor) { + $ciudad = $valor['address']['city']; + $municipio = $valor['address']['town']; + $pais = $valor['address']['country']; + $departamento = $valor['address']['state']; + $licencia= $valor['licence']; + $link = "$_SESSION[url]mapero.php?lat=$valor[lon]&lon=$valor[lat]&zoom=16&id=$campo"; + $linea .= " +
+ +
+ "; +//foreach ($valor as $clave => $valor) { $linea .= "CLAVE : $clave > VALOR: $valor"; } +} +$resultado = "
+ Cerrar +
+ $linea +
+
+ $vacio $licencia +
"; +} + //$div_contenido = "
$div
"; + //$respuesta->addAssign("muestra_form","innerHTML","$aviso"); + //$respuesta->addAssign("titulo_modal","innerHTML","Hola mundo"); + //$respuesta->addAssign("pie_modal","innerHTML","$pie"); + $respuesta->addAssign("muestra_geocoder","innerHTML","$resultado"); + //$respuesta->addscript("$('#muestraInfo').modal('toggle')"); + + return $respuesta; + +} +$xajax->registerFunction("geocoder"); + + +function mostrar_psi(){ +$respuesta = new xajaxResponse('utf-8'); +include("psi.php"); + //$div_contenido = "
$div
"; + $respuesta->addAssign("muestra_form","innerHTML","$aviso"); + //$respuesta->addAssign("titulo_modal","innerHTML","Hola mundo"); + //$respuesta->addAssign("pie_modal","innerHTML","$pie"); + //$respuesta->addAssign("$div","innerHTML","$resultado"); + $respuesta->addscript("$('#muestraInfo').modal('toggle')"); + + return $respuesta; + +} +$xajax->registerFunction("mostrar_psi"); + +function multiempresa_crear($tabla,$formulario,$div) { +$formulario = limpiar_caracteres($formulario); +$link=Conectarse(); + mysql_query("SET NAMES 'utf8'"); + foreach($formulario as $c=>$v){ + + $valores .= " $c = '".mysql_real_escape_string($v)."',"; + } + $valores = "$valores id_responsable = '$_SESSION[id]'"; + +$respuesta = new xajaxResponse('utf-8'); + + $insertar = "INSERT INTO $tabla set $valores"; + $sql=mysql_query($insertar,$link); + if(mysql_affected_rows($link) != 0){ + + } +if($div !='') { + + + } + $respuesta->addScript("javascript:xajax_multiempresa('empresa','$div')"); + return $respuesta; +} +$xajax->registerFunction("multiempresa_crear"); + + +function multiempresa($tabla,$div){ + if($_SESSION['id'] == 1) { + if($div =="") { + $div="contenido"; + $resultado =" Configuración multiempresa"; + return $resultado; + } +$link=Conectarse(); + +mysql_query("SET NAMES 'utf8'"); +$id_empresa= $_SESSION['id_empresa']; +$consulta = "SELECT * FROM empresa "; +$sql=mysql_query($consulta,$link); + +$resultado=" +$name + + " ; +if (mysql_num_rows($sql)!='0'){ + if($onchange !=''){$vacio ="";}else{$vacio ="";} + +$linea = 1; +while( $row = mysql_fetch_array( $sql ) ) { +$razon_social= editar_campo("empresa",$row['id'],"razon_social","","",""); +$sigla= editar_campo("empresa",$row['id'],"sigla","","",""); +$email= editar_campo("empresa",$row['id'],"email","","",""); +$web= editar_campo("empresa",$row['id'],"web","","",""); +$direccion= editar_campo("empresa",$row['id'],"direccion","","",""); +$telefono= editar_campo("empresa",$row['id'],"telefono","","",""); +$estado= editar_campo("empresa",$row['id'],"estado","","",""); + +if($row[id] !=1) {$acciones = " Estado: $estado";} +$resultado .= ""; +$linea++; + } + + + }else{ + $resultado = "
No hay resultados
"; + } + +$resultado .= " +
IdNombreSiglaEmailWebDirecciónTeléfono
$row[id]$razon_social$sigla$email$web$direccion$telefono$acciones
+Agregar empresa +
+
+ + +
+
+ Nombre + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+ +"; +//return $resultado; + //$respuesta = new xajaxResponse('utf-8'); + $respuesta = new xajaxResponse('utf-8'); + $respuesta->addAssign("$div","innerHTML","$resultado"); + return $respuesta; + } +} +$xajax->registerFunction("multiempresa"); + + + + + + +function contar_valores_formulario($campo,$key,$valor){ +$consulta = "SELECT distinct($campo) as cantidad FROM form_datos WHERE $key LIKE '$valor' "; +$link=Conectarse(); +mysql_query("SET NAMES 'UTF8'"); +$sql=mysql_query($consulta,$link); +if (mysql_num_rows($sql)!='0'){ +$resultado = mysql_num_rows($sql); +//$resultado = mysql_result($sql,0,"cantidad"); +} +//$resultado .= " $consulta"; +return $resultado; +} + + +function listar_campos_formulario($id_form,$tipo){ +$consulta = "SELECT distinct(id_campo),campo_nombre FROM form_datos,form_campos WHERE form_id = '$id_form' AND form_datos.id_campo = form_campos.id "; +$link=Conectarse(); +mysql_query("SET NAMES 'UTF8'"); +$sql=mysql_query($consulta,$link); +if (mysql_num_rows($sql)!='0'){ +while( $row = mysql_fetch_array( $sql ) ) { + if($tipo=="nombres"){ +$resultado[] = "$row[campo_nombre]";} + elseif($tipo=="select"){ + $option .= ""; + } + else{ +//$resultado .= " $row[id_campo] "; +$resultado[] = $row[id_campo]; +} +} +if($tipo=="select"){ +$resultado = " + "; + +} +//$resultado = mysql_result($sql,0,"cantidad"); +} +//$resultado .= " $consulta"; +return $resultado; +} + + +//($formulario,$div,$registros,$pagina,$formato) +function consultar_formulario($form,$registros,$pagina,$tipo){ +$respuesta = new xajaxResponse('utf-8'); +//if(is_array($form)) {$id_form = $form['id_form'];}else { $id_form = $form;} +$id_empresa = $_SESSION[id_empresa]; +if(is_array($form)) { + $fecha_inicio = $form["inicio"]; + if($fecha_inicio =="" ) { $fecha_inicio ="2000-01-01";} + $fin = $formulario["fin"]; + if( $fin !="") { $fechas = " AND timestamp BETWEEN UNIX_TIMESTAMP('$fecha_inicio') AND UNIX_TIMESTAMP('$fin 23:59:59')";} + $id_form = $form['id_form']; + $id_campo = $form['id_campo']; + $busqueda = $form['busqueda']; +if($busqueda !=''){$busca ="AND contenido LIKE '%%$form[busqueda]%%'";}else{$busca ='';} +if($id_campo !=''){$campo ="AND id_campo = '$id_campo'";}else{$campo ='';} +}else{ +$id_form = $form; +} +$consulta_principal = "SELECT control,id,form_id FROM form_datos WHERE form_id = '$id_form' AND form_datos.id_empresa = '$id_empresa' $busca $campo $fechas GROUP BY form_datos.control ORDER BY form_datos.id DESC "; +$link=Conectarse(); +mysql_query("SET NAMES 'UTF8'"); +$sql_total=mysql_query($consulta_principal,$link); +$total_registros = mysql_num_rows($sql_total);//formulario_contar($id_form); +/// PAGINACION + if ($pagina =='') {$inicio = 0; $pagina = 1; } + else { $inicio = ($pagina - 1) * $registros;} + if($total_registros < $registros) { $limite ="";} + else{$limite =" LIMIT $inicio, $registros ";} + if($tipo == "csv" ) {$consulta_limite = "$consulta_principal";} + else{$consulta_limite = $consulta_principal.$limite;} + $sql=mysql_query($consulta_limite,$link); + +//$sql=mysql_query($consulta_principal,$link); +if (mysql_num_rows($sql)!='0'){ + +/////// FILTRO + +$fecha = time (); + $ahora = date ( "Y-m-d" , $fecha ); + $campos = listar_campos_formulario($id_form,"select"); + $peticion = " +
+ + +
+
+
+ Inicio + +
+
+
+
+ Fin + +
+
+ +
+
+ Frase + +
+
+
+
+ + $campos +
+
+
+ +
+
+
+ + +
+ + "; +/////// FILTRO + +$boton_borrar = " + + + + "; + + if($formato!='csv'){ + $boton_exportar = " Exportar ";} + + $link = ""; + // $page = $_GET['page']; + $page= $pagina; + $pages= ceil($total_registros / $registros); //13; // Hardcoded for testing purpose + $limit=10 ; + if ($pages >=1 && $page <= $pages) + { + $counter = 1; + $link = ""; + if (($page -1) > 0) { + $link .= "
  • +
  • "; + } + + for ($x=$page; $x<=$pages;$x++) + { + + + if($counter < $limit){ + if ($page == $x){ + $link .= "
  • $x
  • "; + }else{ + $link .= "
  • $x
  • "; + } + } + $counter++; + } + if ($page < ($pages - ($limit/2))) + + { $link .= "
  • +
  • "; } + } + + $paginacion = ""; + + + + + $encabezado = "
    +
    + $peticion +
    +
    +
    +
    + + $paginacion +
    +
    "; + + $total_registros = mysql_num_rows($sql); + $nombres_campos = listar_campos_formulario("$id_form","nombres"); + foreach($nombres_campos as $campo_nombre=>$nombre){ + $listado_nombres .= "$nombre"; + } + $listado_nombres = "Identificador$listado_nombres "; +$listado_campos = listar_campos_formulario("$id_form"); + +while( $row = mysql_fetch_array( $sql ) ) { +//$cantidad_campos = contar_valores_formulario("id_campo","control","$row[control]"); + +$listado_campos = listar_campos_formulario("$id_form"); + +foreach($listado_campos as $campo=>$valor){ + $contenido = remplacetas('form_datos','control',$row[control],'contenido',"id_campo ='$valor' ") ; +$listado_campos .= "$contenido[0]"; + + } + if (!is_array($listado_campos)){$listado_campos="$listado_campos";}else {$listado_campos=$listado_campos;} + $menu =" + +
    +
    + + + $imagen +
    +
    + + "; +$lineas .= " $menu$row[control]$listado_campos"; + + } + +$tabla =" + + $listado_nombres + + $lineas + +
    "; +$resultado = " +$encabezado + +
    + +$tabla + +
    +"; + } +else { +$resultado ="

    No hay resultados

    $consulta_limite
    "; +$respuesta->addAlert("No hay resultados"); +return $respuesta; +} +if($tipo =="csv") { +$html = str_get_html($tabla); + // header('Content-type: application/ms-excel'); + // header('Content-Disposition: attachment; filename=sample.csv'); + $nombre_archivo ="tmp/Prueba_Formulario_".mktime()."_".$_SESSION['id'].".csv"; + //$fp = fopen("php://output", "w"); + $fp=fopen($nombre_archivo , "w"); + foreach($html->find('tr') as $element) + { + $td = array(); + foreach( $element->find('th') as $row) + { + if (strpos(trim($row->class), 'actions') === false && strpos(trim($row->class), 'checker') === false) { + $td [] = $row->plaintext; + } + } + if (!empty($td)) { + fputcsv($fp, $td); + } + + $td = array(); + foreach( $element->find('td') as $row) + { + if (strpos(trim($row->class), 'actions') === false && strpos(trim($row->class), 'checker') === false) { + $td [] = $row->plaintext; + } + } + fputcsv($fp, $td); + } + + fclose($fp); +$boton_descarga ="Descargar "; + +$datos ="$boton_descarga"; +}else { + +$datos = $resultado; +} +$div ="contenido_de_modal"; +$resultado = "
    $datos
    "; + $div_contenido = "
    $div
    "; + $respuesta->addAssign("muestra_form","innerHTML","$div_contenido"); + //$respuesta->addAssign("titulo_modal","innerHTML","Hola mundo"); + //$respuesta->addAssign("pie_modal","innerHTML","$pie"); + + + $respuesta->addAssign("$div","innerHTML","$resultado"); + if($tipo =="modal") { + $respuesta->addscript("$('#muestraInfo').modal('toggle')"); +} + return $respuesta; + +} +$xajax->registerFunction("consultar_formulario"); + + function datos_array($identificador) { $link=Conectarse(); @@ -14,10 +520,13 @@ while($row = mysql_fetch_array( $sql )) { $contenido = remplacetas('form_datos','id',$row[id],'contenido',"") ; $id_campo = remplacetas('form_datos','id',$row[id],'id_campo',"") ; - $nombre_campo = -remplacetas('form_campos','id',$id_campo[0],'campo_nombre',"") ; + $nombre_campo = remplacetas('form_campos','id',$id_campo[0],'campo_nombre',"") ; //$array[id_campo] = $row[id_campo]; $array[$nombre_campo[0]] = "$contenido[0]"; + $array['timestamp'] = "$row[timestamp]"; + $array['proceso'] = "$row[proceso]"; + $array['id'] = "$row[id]"; + $array['orden'] = "$row[orden]"; //$array[] = $row; @@ -430,7 +939,7 @@ $resultado = " "; $lista ="
    -

    Las plantillas se usan para dar formato a los datos en el momento de presentarlos, se pueden usar etiquetas HTML5, CSS3 y clases de Bootstrap

    +

    Las plantillas se usan para dar formato a los datos en el momento de presentarlos, se puede usar etiquetas HTML5, CSS3 y clases de Bootstrap

    @@ -625,9 +1134,18 @@ $xajax->registerFunction("parametrizacion_titulo"); function mostrar_modal($form,$control,$plantilla){ $respuesta = new xajaxResponse('utf-8'); +if( $control == "") { + $datos = formulario_areas($form,""); +}else { $datos = contenido_mostrar("$form","$control",'',"$plantilla"); +} $div ="contenido_de_modal"; -$resultado = "
    $datos
    "; + +$resultado = " +
    + $datos +
    +
    "; $div_contenido = "
    $div
    "; $respuesta->addAssign("muestra_form","innerHTML","$div_contenido"); //$respuesta->addAssign("titulo_modal","innerHTML","Hola mundo"); @@ -640,7 +1158,7 @@ $resultado = "
    $datos
    "; } $xajax->registerFunction("mostrar_modal"); -function portal_filtro_cadena($formulario,$id_campo,$control){ +function portal_filtro_cadena($formulario,$id_campo,$control,$div,$plantilla){ $cadena = remplacetas('form_datos','control',"$control",'contenido',"form_id = '$formulario' AND id_campo ='$id_campo' ") ; $consulta ="SELECT * FROM form_campos ,form_datos WHERE form_datos.form_id = '$formulario' AND form_campos.id = form_datos.id_campo AND form_datos.id_campo = '$id_campo' AND contenido = '$cadena[0]' @@ -651,7 +1169,10 @@ $sql=mysql_query($consulta,$link); if (mysql_num_rows($sql)!=0){ while( $row = mysql_fetch_array( $sql ) ) { - $datos = contenido_mostrar("$formulario","$row[control]",'',""); + + + $datos = contenido_mostrar("$formulario","$row[control]",'',"$plantilla"); + if($plantilla == "") { $listado .= "

    $cadena[0]{json}

    @@ -660,6 +1181,7 @@ $listado .= "
    "; +}else{$listado .= $datos; } } $resultado = "
    @@ -667,15 +1189,18 @@ $resultado = " "; } + +if ($div ==""){$div="mostrar_contenido";} +else {$div = "$div";} $respuesta = new xajaxResponse('utf-8'); -$respuesta->addAssign("mostrar_contenido","innerHTML","$resultado"); +$respuesta->addAssign("$div","innerHTML","$resultado"); return $respuesta; } $xajax->registerFunction("portal_filtro_cadena"); -function portal_filtro_campos($formulario,$id_campo){ +function portal_filtro_campos($formulario,$id_campo,$div,$plantilla){ $formulario_descripcion = remplacetas('form_id','id',"$formulario",'descripcion',"") ; $formulario_nombre = remplacetas('form_id','id',"$formulario",'nombre',"") ; $campo_nombre = remplacetas('form_campos','id',"$id_campo",'campo_nombre',"") ; @@ -688,7 +1213,7 @@ $sql=mysql_query($consulta,$link); if (mysql_num_rows($sql)!=0){ while( $row = mysql_fetch_array( $sql ) ) { -$listado .= "
  • $row[contenido]
  • "; +$listado .= "
  • $row[contenido]
  • "; } $resultado = "
    "; if($tipo=="titulos") { $td .= ""; + }else{ $td .= ""; } } - - $resultado .="$td"; +if($tipo=="titulos") { $identificador =""; }else {$identificador ="";} + $resultado .="$td $identificador "; } if($tipo =='titulos_csv' or $tipo=='linea_csv') { @@ -4412,6 +5025,8 @@ return $csv; } return $resultado; } + + // $contenido_desplegado = contenido_mostrar("$row[form_id]","$row[control]",'',"$plantilla"); function mostrar_coincidencias_plantilla($id_form,$filtro,$valor,$plantilla) { @@ -4427,8 +5042,12 @@ $sql=mysql_query($consulta,$link); $control=mysql_result($sql,0,"control"); if (mysql_num_rows($sql)!=0){ mysql_data_seek($sql, 0); -$resultado = contenido_mostrar("$id_form","$control",'',"$plantilla"); +while( $row = mysql_fetch_array( $sql ) ) + { +$resultado .= contenido_mostrar("$row[form_id]","$row[control]",'',"$plantilla"); + } + } $respuesta = new xajaxResponse('utf-8'); $respuesta->addAssign("mostrar_resultado","innerHTML",$resultado); return $respuesta; @@ -4647,6 +5266,8 @@ $respuesta->addAssign($div,"innerHTML",$resultado); return $respuesta; } $xajax->registerFunction("matriz_formulario"); + + function remplacetas($tabla,$campo,$valor,$por,$and){ $link=Conectarse(); @@ -4722,13 +5343,15 @@ $consulta = " $sql=mysql_query($consulta,$link); if (mysql_num_rows($sql)!='0'){ -$resultado = " +$resultado = "
    + Filtro "; +$resultado .= " +
    "; } else{$resultado = "

    No se encontraron resultados

    ";} @@ -4808,12 +5431,10 @@ return $respuesta; } $xajax->registerFunction("formulario_consultar"); -function formulario_campos_procesar($form){ + +function formulario_campos_procesar($form,$tipo_accion){ //$form = mysql_seguridad($form); $respuesta = new xajaxResponse('utf-8'); - - - $campo_nombre = $form["campo_nombre"]; if($campo_nombre =='') { $respuesta->addAlert("El Nombre del campo no puede estar vacío"); @@ -4835,7 +5456,7 @@ $id_campo_editar = $form["id_campo_editar"]; $link=Conectarse(); mysql_query("SET NAMES 'utf8'"); -if ($editar == 'editar'){ +if ($editar == 'editar' AND $tipo_accion =='editar'){ mysql_query(" UPDATE `form_campos` SET `campo_nombre` = '$campo_nombre', @@ -4858,7 +5479,7 @@ $id_especialista = $_SESSION['id']; $respuesta->addAssign("grupo_campo_nombre","className"," input-group has-error "); return $respuesta; } - +if($campo_identificador == "") { $campo_identificador = md5($_SESSION[id_usuario]."-".microtime()); } $consulta = " INSERT INTO `form_campos` (`id_especialista`, `campo_nombre`,`campo_descripcion`,`campo_tipo`, `campo_area`, `orden`, `activo`, `identificador`, `id_empresa`) @@ -4867,21 +5488,29 @@ $consulta = " $ultimo_id = mysql_insert_id(); $w_campo= "identificador = '$campo_identificador'"; if($sql) { + $listado_campos = select('form_campos','id','campo_nombre',"xajax_formulario_crear_campo('',(this.value),'div_campos')","id_empresa = '$_SESSION[id_empresa]' AND activo = '1'",'campo_editar'); $campos_formulario ="

    El campo se creó con éxito -
    Crear un nuevo campo

    "; +
    Crear un nuevo campo
    +
    Modificar campo $listado_campos
    + "; if($form['agregar_id_form'] !="") { $respuesta->AddScript("xajax_agregar_campos('grabar_campos','contenido','$ultimo_id','$form[agregar_id_form]') "); ///$respuesta->addAssign("$div","innerHTML",$resultado); - return $respuesta; + //return $respuesta; } }else {$campos_formulario = "

    Problemas al grabar el campo

    $consulta";} } -if($id_campo_editar !=''){$id_form_campo = $id_campo_editar;}else { -$id_form_campo = mysql_insert_id($link);} +if($id_campo_editar !='' AND $tipo_accion =='editar'){$id_form_campo = $id_campo_editar;}else { +//$id_form_campo = mysql_insert_id($link); +$id_form_campo = $ultimo_id; +} +//$respuesta->addAlert("( $campo_tipo / $id_form_campo / $ultimo_id / $form[opciones] ) $consulta"); +//$respuesta->addAssign("contenido","innerHTML","$consulta_campos_valores"); +//return $respuesta; if($campo_tipo == '23' ){ $grabar_campos_valores = "(".$id_form_campo.",'".$form[opciones]."')"; } @@ -4895,7 +5524,7 @@ foreach($opciones as $c=>$v){ //if($v !='') {$v = ucfirst(strtolower($v)); if($v !='') {$v = $v; -$grabar_campos_valores .= "($id_form_campo,'$v'),"; +$grabar_campos_valores .= "( $id_form_campo ,'$v'),"; } } @@ -4904,9 +5533,7 @@ $grabar_campos_valores =substr ("$grabar_campos_valores",0,-1); $borrar_campos_valores = "DELETE FROM `form_campos_valores` WHERE `id_form_campo` = '$id_form_campo'"; $consulta_campos_valores = "INSERT INTO form_campos_valores (id_form_campo,campo_valor) VALUES ".$grabar_campos_valores.""; -//$respuesta->addAlert("($campo_tipo) $consulta_campos_valores"); -//$respuesta->addAssign("contenido","innerHTML","$consulta_campos_valores"); -//return $respuesta; + $sql_borrar_campos_valores =mysql_query($borrar_campos_valores,$link); $sql_campos_valores =mysql_query($consulta_campos_valores,$link); @@ -5033,8 +5660,10 @@ $agregar_a_formulario = " $identificador = md5($_SESSION[id_usuario]."-".microtime()); $areas = select('form_areas','id','nombre','',"id_empresa = '$_SESSION[id_empresa]'",'campo_area'); -$resultado .= "
    -
    +$resultado .= " +
    +
    +
    @@ -5077,7 +5706,7 @@ $resultado .= "
    $agregar_a_formulario -
    +
    Grabar

    @@ -5086,7 +5715,8 @@ $resultado .= "
    -
    "; +
    +
    "; $resultado = "
    @@ -5119,7 +5749,7 @@ $consulta_campos ="SELECT id, campo_nombre, campo_descripcion, tipo_campo_accion $campos=mysql_query($consulta_campos,$link); if($campo ==''){ - $listado_campos = select('form_campos','id','campo_nombre',"xajax_formulario_crear_campo('',(this.value),'div_campos')","id_empresa = '$_SESSION[id_empresa]' AND activo = '1'",'campo_editar'); + $listado_campos = select('form_campos','id','campo_nombre',"xajax_formulario_crear_campo('',(this.value),'$div')","id_empresa = '$_SESSION[id_empresa]' AND activo = '1'",'campo_editar'); $areas = tabla_areas('form_areas','id','nombre,descripcion,estado,orden','',"",'Areas',''); $campos_formulario = " @@ -5177,6 +5807,7 @@ if($row[activo] =='1'){$activo = " ";} $formulario = "editar_campos"; $areas = select('form_areas',"id",'nombre','',"id_empresa = '$_SESSION[id_empresa]'",'campo_area',"$row[campo_area]"); + $campos_formulario .= "
    @@ -5184,6 +5815,7 @@ $campos_formulario .= " +
    @@ -5222,10 +5854,13 @@ $campos_formulario .= "
    -
    -
    Grabar
    +
    +
    Grabar
    -
    +
    +
    Clonar
    +
    +
    Cancelar
    @@ -5309,6 +5944,11 @@ $resultado .= "
    "; while( $row = mysql_fetch_array( $sql ) ) { + /* $multiple = remplacetas('form_parametrizacion','campo',"$id",'descripcion'," tabla='form_id' and opcion = '$row[id]' AND descripcion REGEXP '^multiple:' ") ; + $multiple = explode(":",$multiple[0]); + $multiple = $multiple[1];*/ + + //$multiple = $multiple[0]; $resultado .= "
    $row[id_campo] $row[campo_nombre] @@ -5323,9 +5963,13 @@ $resultado .= "
    - $row[orden] + + + + onchange =\"(document.getElementById('input_orden_$row[control]').value=(this.value));xajax_actualizar_campo('form_contenido_campos','$row[id]','orden',(this.value),'','orden_$row[control]'); \"> + $row[orden]
    @@ -5569,6 +6213,7 @@ $respuesta->addAssign($div,"innerHTML",$resultado); return $respuesta; }$xajax->registerFunction("formulario_nuevo"); + function formulario_listado($filtro_grupo,$div){ if ( !isset ( $_SESSION['id_empresa'] ) ) { $respuesta = new xajaxResponse('utf-8'); @@ -5576,7 +6221,7 @@ $respuesta->addRedirect("index.php"); return $respuesta; } - $id_empresa= $_SESSION['id']; + $id_empresa= $_SESSION['id_empresa']; if($div==''){ $div = "contenido"; $resultado = " "; @@ -5611,7 +6256,7 @@ $respuesta->addAssign("link_formulario","innerHTML",$resultado_link); $divider = 1; $columnas = intval(12/$divider); - $listado_grupos = select('form_grupo','grupo','grupo',"xajax_formulario_listado((this.value),'contenido')","AGRUPADO",''); + $listado_grupos = select_empresa('form_grupo','grupo','grupo',"xajax_formulario_listado((this.value),'contenido')","AGRUPADO",'','',"$id_empresa"); $listado_grupos ="
    Seleccione un grupo de formularios @@ -5642,7 +6287,7 @@ if (mysql_num_rows($sql)!='0' ){ while( $row = mysql_fetch_array( $sql ) ) { $id= $row['id']; $C = $id; - + $cantidad = formulario_contar($row['id']); if($cantidad >0) {$cantidad ="
  • Llenado: $cantidad veces
  • ";}else{$cantidad = "";} $propietario = remplacetas('usuarios','id',$row['propietario'],'email',"") ; @@ -5669,9 +6314,10 @@ if (mysql_num_rows($sql)!='0' ){ $primer = formulario_uso("$id",'','primer') ; - if($primer[0] !='') {$primer = "
  • Primer registro: ".date ( "Y-m-d h:i:s" , $primer[0])."
  • ";}else{$primer='';} + if($primer[0] !='') {$primer = "
  • Primer registro: ".date ( "Y-m-d h:i:s" , $primer[0])."
  • ";}else{$primer='';} $ultimo = formulario_uso("$id",'','ultimo') ; - if($ultimo[0] !='') {$ultimo = "
  • Último registro: ".date ( "Y-m-d h:i:s" , $ultimo[0])."
  • ";}else{$ultimo='';} + $ultimo_control = $ultimo[1]; + if($ultimo[0] !='') {$ultimo = "
  • Último registro: ".date ( "Y-m-d h:i:s" , $ultimo[0])."
  • ";}else{$ultimo='';} $nombre = editar_campo("form_id",$row['id'],"nombre","","",""); $orden = editar_campo("form_id",$row['id'],"orden","","",""); @@ -5700,6 +6346,7 @@ $item .= "
    +
    "; @@ -5717,7 +6364,9 @@ $item .= "
    +
    Consultas
    @@ -5920,17 +6569,29 @@ $consulta =" } $render .= " - - - +
    +
    + + +
    +
    +
    + +
    +
    + + + "; $cols='12'; } -elseif($campo_tipo_accion == 'email'){$render = "Escriba un email válido - ";} - elseif($campo_tipo_accion == 'envio'){$render = "Se enviará un correo electrónico a este email - ";} +elseif($campo_tipo_accion == 'email'){$render = " + + Escriba un email válido ";} + elseif($campo_tipo_accion == 'envio'){$render = " + + Se enviará un email";} elseif($campo_tipo_accion == 'textarea'){ $render = " "; $cols='12'; @@ -5941,20 +6602,6 @@ elseif($campo_tipo_accion == 'email'){$render = "Escriba un email válido< // $gps = leer_exif($file); $render= " "; //subir_imagen('',$id_campo[$item]); $cols='12'; } - elseif($campo_tipo_accion == 'checkbox'){ - $predefinidos = remplacetas('form_campos_valores','id_form_campo',$id_campo,'campo_valor',"") ; - - $campos = explode(":",$predefinidos[0]); - $valor_predefinido = $campos[0]; - $checked = $campos[1]; - if($value !="") { $checked ="1" ; $valor_predefinido = $value ;} - if($checked =='1') { $checked ="checked" ;} - $render= " -
    - - -
    "; //subir_imagen('',$id_campo[$item]); - } elseif($campo_tipo_accion == 'html'){ $render = " @@ -5976,11 +6623,46 @@ elseif($campo_tipo_accion == 'email'){$render = "Escriba un email válido< //$select = select('form_campos_valores','campo_valor','campo_valor','',"id_form_campo = $id_campo",$id_campo."[".$item."]"); $select = select_edit($id_campo,$id_form,$value,$id_campo."[".$item."]",$control); + $render = "$select "; $cols='12'; } + elseif($campo_tipo_accion == 'radio'){ + $select = radio_edit($id_campo,$id_form,$value,$id_campo."[".$item."]",$control); + $render = "$select "; + $cols='12'; + } + elseif($campo_tipo_accion == 'radio_agrupado_campos'){ + + $campos_valores = remplacetas('form_campos_valores','id_form_campo',$id_campo,'campo_valor',"") ; + $mensaje = remplacetas('form_campos','id',$id_campo,'campo_descripcion',"") ; + $campos = explode(":",$campos_valores[0]); + $titulos = explode(";",$campos[0]); + $campos_incluidos = explode(";",$campos[1]); + for($i=0;$i
    "; + //$select = radio_agrupado_linea($id_campo,$id_form,$value,$id_campo."[".$item."]",$control); + $render = "
    Nombre$imagen $contenido $contenido Identificador$control$campos_incluidos[$i]
    + $mensaje[0] + $listado_titulos + $listado_campos +
    "; + $cols='12'; + } + elseif($campo_tipo_accion == 'radio_agrupado_linea'){ + + //$select = select('form_campos_valores','campo_valor','campo_valor','',"id_form_campo = $id_campo",$id_campo."[".$item."]"); + $select = radio_agrupado_linea($id_campo,$id_form,$value,$id_campo."[".$item."]",$control); + $render = "$select
    "; + $cols='12'; + } + elseif($campo_tipo_accion == 'checkbox'){ + + //$select = select('form_campos_valores','campo_valor','campo_valor','',"id_form_campo = $id_campo",$id_campo."[".$item."]"); + $select = checkbox_edit($id_campo,$id_form,$value,$id_campo."[".$item."]",$control); $render = "$select ";} elseif($campo_tipo_accion == 'combo'){ //$select = select('form_campos_valores','campo_valor','campo_valor','',"id_form_campo = $id_campo",$id_campo."[".$item."]"); $select = combo_select($id_campo,$id_form,$value,$id_campo."[".$item."]",$control,""); - $render = "$select ";} + $render = "$select "; + $cols='12'; } elseif($campo_tipo_accion == 'relacion'){ $select = relacion_select($id_campo,$id_form,$value,$id_campo."[".$item."]",$control,""); $render = "$select "; @@ -5992,6 +6674,14 @@ elseif($campo_tipo_accion == 'email'){$render = "Escriba un email válido< elseif($campo_tipo_accion == 'base'){ $select = buscador_base($id_campo,$id_form,$value,$id_campo."[".$item."]",$control,""); $render = "$select ";} + elseif($campo_tipo_accion == 'vinculado'){ + $vinculado = remplacetas('form_campos_valores','id_form_campo',$id_campo,'campo_valor',"") ; + $select = formulario_areas($vinculado[0],'campos'); + $render = " + $select + "; + $cols='12'; + } elseif($campo_tipo_accion == 'number'){ $render = " @@ -5999,13 +6689,22 @@ elseif($campo_tipo_accion == 'email'){$render = "Escriba un email válido< elseif($campo_tipo_accion == 'password'){ $render = " -
    - -
    -
    - -
    - ";} +
    +
    +
    + $campo_nombre + +
    +
    +
    +
    + Confirmar + +
    +
    +
    + "; + $cols='12'; } elseif($campo_tipo_accion == 'unico'){ $render ="
    "; @@ -6108,8 +6807,11 @@ function formulario_valor_campo($perfil,$id_campo,$valor,$id_control,$orden){ //if($id_control !=""){ $control ="AND `control` = '$id_control'";}else {$control ="";} $campo_multiple = remplacetas("form_contenido_campos","id_campo",$id_campo,"multiple"," id_form ='$perfil'"); +$tipo_campo = remplacetas("form_campos","id","$id_campo","campo_tipo",""); $campo_multiple = $campo_multiple[0]; -if($campo_multiple !="1"){ $limite =" asc limit 1 ";}else {$limite =" asc ";} +if($tipo_campo[0] =="24") {$campo_multiple = "1";} +/// SI EL CAMPO ES MULTIPLE O CHECK BOX MUESTRA LAS MULTIPLES ENTRADAS +if($campo_multiple !="1" ){ $limite =" asc limit 1 ";}else {$limite =" asc ";} if(@$orden !=""){ $campo_orden =" AND orden ='$orden' ";}else {$campo_orden ="";} $link=Conectarse(); @@ -6160,7 +6862,7 @@ while( $row = mysql_fetch_array( $sql ) ) { $identificador = explode(',',$row[identificador]); $identificador = $identificador[0]; $contenido_campo = remplacetas('form_datos','id',$identificador,'contenido',"") ; - $contenido .= "$contenido_campo[0]
    "; + $contenido .= "$contenido_campo[0] "; } } // $contenido .="$consulta"; @@ -6324,7 +7026,7 @@ if(($V !='' ) && (is_numeric($c)) AND $repetido !=1 ) { if($consulta_grabada =='1') { -if($tipo == "embebido" ) +if($tipo == "embebidoX" ) { $exito ="

    @@ -6350,17 +7052,31 @@ if($tipo == "embebido" ) $envio = email_contenido("$formulario[form_id]","$formulario[control]","$campo_envio[0]",''); } - -$impresion = formulario_imprimir("$formulario[form_id]","$formulario[control]","preview"); +if($tipo = "embebido") { +$otro_formulario =" + + Llenar otro formulario + +"; +}else { + $otro_formulario = " + + Llenar otro formulario + + + "; +} +$impresion = formulario_imprimir("","$formulario[control]","preview"); +//$impresion = mostrar_identificador($formulario['control']); $exito =" - $impresion + + $impresion +

    Gracias por llenar el formulario $formulario[form_nombre]

    - - Llenar otro formulario - + $otro_formulario
    $envio @@ -6377,7 +7093,7 @@ $impresion = formulario_imprimir("$formulario[form_id]","$formulario[control]"," //$propietario = remplacetas('usuarios','id',$propietario[0],'email',"") ; $email_envio = remplacetas('form_parametrizacion','campo',"$formulario[form_id]",'descripcion'," tabla='form_id' and opcion = 'email'") ; if($email_envio[0] !="") { - $impresion = formulario_imprimir("$formulario[form_id]","$formulario[control]","preview"); + $impresion = formulario_imprimir("","$formulario[control]","preview"); $id_empresa = remplacetas('form_id','id',$formulario[form_id],'id_empresa',"") ; $id_empresa = $id_empresa[0]; @@ -6483,7 +7199,7 @@ if($control !='' AND $tipo =='' ) { $modificable = remplacetas('form_id','id',$id,'modificable') ; if($modificable[0] != "1" and (!isset ( $_SESSION[id]) )) { - $resultado ="

    Acceso restringido

    No se pueden consultar los datos.
    "; + $resultado ="

    Acceso restringido

    No se puede consultar los datos.
    "; $respuesta->addAssign("muestra_form","innerHTML","$resultado"); $respuesta->addAssign("titulo_modal","innerHTML","$cabecera"); $respuesta->addAssign("pie_modal","innerHTML","$pie"); @@ -6531,7 +7247,7 @@ $campo_imagen = $campo_imagen[0]; if ($campo_imagen[0] != "") { -$subir_imagen = subir_imagen('',"$campo_imagen"."[0]"); +$subir_imagen = subir_imagen("$id","$campo_imagen"."[0]"); } $muestra_form = "
    @@ -6556,6 +7272,8 @@ $subir_imagen = subir_imagen('',"$campo_imagen"."[0]"); mysql_data_seek($sql, 0); while( $row = mysql_fetch_array( $sql ) ) { + $tipo_campo = remplacetas("form_campos","id","$row[id_campo]","campo_tipo",""); + //if($tipo_campo[0] =="24") { $row[multiple] = "1";} if($row[multiple] ==='1' AND $tipo =='edit'){ $campos = formulario_campos_render_multiple($row[id_campo],$id,$control_edit); }else{ @@ -6662,15 +7380,15 @@ $consulta = "SELECT $value, $descripcion FROM $tabla WHERE 1 $w $group ORDER BY $sql=mysql_query($consulta,$link); if($nombre==''){$name=$tabla."_".$value;}else{$name = "$nombre";} if (mysql_num_rows($sql)!='0'){ - if($onchange !=''){$vacio ="";}else{$vacio ="";} + if($onchange !=''){$vacio ="";}else{$vacio ="";} $resultado=""; @@ -6678,6 +7396,39 @@ $resultado .= ""; return $resultado; } + +function select_empresa($tabla,$value,$descripcion,$onchange,$where,$nombre,$valor,$id_empresa){ +$link=Conectarse(); +$campos = explode(",",$descripcion); +$campo1 = $campos[0]; +$campo2 = $campos[1]; +$debug = "($tabla,$value,$descripcion,$onchange,$where)"; +mysql_query("SET NAMES 'utf8'"); +$id_empresa= $_SESSION['id_empresa']; +if($where =='AGRUPADO'){$group="GROUP BY $value ";} +elseif($where != ''){$w = "AND ".$where;}else{ $w="";} +$busca = array("[","]"); +if( strpos( $onchange,'[') !== false ){$fila=str_replace($busca,'',$onchange);$onchange='';}; +$consulta = "SELECT $value, $descripcion FROM $tabla WHERE id_empresa = '$id_empresa' $w $group ORDER BY $campo1 "; +$sql=mysql_query($consulta,$link); +if($nombre==''){$name=$tabla."_".$value;}else{$name = "$nombre";} +if (mysql_num_rows($sql)!='0'){ + if($onchange !=''){$vacio ="";}else{$vacio ="";} +$resultado=""; + }else{$resultado = "
    No hay resultados $consulta
    ";} + +return $resultado; +} function select_edit($id_campo,$form_id,$valor,$name,$control){ $link=Conectarse(); @@ -6700,8 +7451,107 @@ $resultado .= ""; return $resultado; } + + + + +function radio_agrupado_linea($id_campo,$form_id,$valor,$name,$control){ +$link=Conectarse(); +mysql_query("SET NAMES 'utf8'"); + +$consulta = "SELECT * FROM form_campos_valores , form_campos WHERE form_campos_valores.id_form_campo = form_campos.id AND id_form_campo ='$id_campo' "; +$sql=mysql_query($consulta,$link); +$valor = remplacetas("form_datos","control","$control","contenido","id_campo ='$id_campo' "); +if (mysql_num_rows($sql)!='0'){ +$nombre_linea = mysql_result($sql,0,"campo_nombre"); +$descripcion_linea = mysql_result($sql,0,"campo_descripcion"); + mysql_data_seek($sql, 0); +while( $row = mysql_fetch_array( $sql ) ) { +if($row[campo_valor] ==="$valor[0]"){$selected="checked";}else{$selected ="";} +$lineas .= " "; + } +$resultado .= "
    $nombre_linea
    $lineas"; + }else{$resultado = "
    No hay resultados $consulta
    ";} + +return $resultado; +} + +function radio_linea($id_campo,$form_id,$valor,$name,$control){ +$link=Conectarse(); +mysql_query("SET NAMES 'utf8'"); + +$consulta = "SELECT * FROM form_campos_valores , form_campos WHERE form_campos_valores.id_form_campo = form_campos.id AND id_form_campo ='$id_campo' "; +$sql=mysql_query($consulta,$link); +// $value = remplacetas("form_datos","control","$control","contenido","id_campo ='$id_campo' "); +if (mysql_num_rows($sql)!='0'){ +$nombre_linea = mysql_result($sql,0,"campo_nombre"); +$descripcion_linea = mysql_result($sql,0,"campo_descripcion"); + mysql_data_seek($sql, 0); +while( $row = mysql_fetch_array( $sql ) ) { +if($row[campo_valor] ==="$valor"){$selected="checked";}else{$selected ="";} +$lineas .= " "; + } +$resultado .= "
    $nombre_linea
    $lineas"; + }else{$resultado = "
    No hay resultados $consulta
    ";} + +return $resultado; +} +function radio_edit($id_campo,$form_id,$valor,$name,$control){ +$link=Conectarse(); +mysql_query("SET NAMES 'utf8'"); + +$consulta = "SELECT * FROM form_campos_valores WHERE id_form_campo ='$id_campo' "; +$sql=mysql_query($consulta,$link); +// $value = remplacetas("form_datos","control","$control","contenido","id_campo ='$id_campo' "); +if (mysql_num_rows($sql)!='0'){ + +$resultado=" + + " ; +while( $row = mysql_fetch_array( $sql ) ) { +if($row[campo_valor] ==="$valor"){$selected="checked";}else{$selected ="";} +$resultado .= "
    "; + } +$resultado .= ""; + }else{$resultado = "
    No hay resultados
    ";} + +return $resultado; +} +function checkbox_edit($id_campo,$form_id,$valor,$name,$control){ +$link=Conectarse(); +mysql_query("SET NAMES 'utf8'"); + +$consulta = "SELECT * FROM form_campos_valores WHERE id_form_campo ='$id_campo' "; +$sql=mysql_query($consulta,$link); +// $value = remplacetas("form_datos","control","$control","contenido","id_campo ='$id_campo' "); +if (mysql_num_rows($sql)!='0'){ + $name = explode("[",$name); + $name = $name[0]; + $fila="0"; + +while( $row = mysql_fetch_array( $sql ) ) { + $value = remplacetas("form_datos","control","$control","contenido","id_campo ='$id_campo' and contenido ='$row[campo_valor]' "); + + $nombre= "$name"."[".$fila."]"; +//if($row[campo_valor] ==="$valor"){$selected="checked";}else{$selected ="";} +if($value[0] ==="$row[campo_valor]"){$selected="checked";}else{$selected ="";} +$resultado .= "
    + +
    "; + $fila++; + } +$resultado .= ""; + }else{$resultado = "
    No hay resultados
    ";} + +return $resultado; +} + + function rango($tabla,$campo,$key,$valor,$selected,$nombre,$onchange){ $link=Conectarse(); mysql_query("SET NAMES 'utf8'"); @@ -6793,8 +7643,8 @@ if($pos == "") { //// si no es un email $respuesta->addAssign("$campo","value","$pos"); $respuesta->addAssign("$campo_confirmacion","value",""); - $respuesta->addAppend("$campo"."_grupo","className"," has-error "); - $respuesta->addAppend("$campo_confirmacion"."_grupo","className"," has-error "); + $respuesta->addAssign("$campo"."_grupo","className"," input-group has-error "); + $respuesta->addAssign("$campo_confirmacion"."_grupo","className"," input-group has-error "); $respuesta->addScript("document.getElementById('$campo').focus(); "); // document.getElementById('mobileno').focus(); @@ -6804,8 +7654,8 @@ if($pos == "") { //// si no es un email $respuesta->addAssign("$campo","className"," form-control "); $respuesta->addAssign("$campo_confirmacion","className"," form-control "); - $respuesta->addAssign("$campo"."_grupo","className"," has-success "); - $respuesta->addAssign("$campo_confirmacion"."_grupo","className"," has-success "); + $respuesta->addAssign("$campo"."_grupo","className"," input-group has-success "); + $respuesta->addAssign("$campo_confirmacion"."_grupo","className"," input-group has-success "); } return $respuesta; } @@ -6981,10 +7831,11 @@ function obtener_ip() function milfs(){ $crear_campos = formulario_crear_campo('','',''); $listado = formulario_listado('',''); - $consultas = formulario_consultar('',''); + //$consultas = formulario_consultar('',''); $importador = formulario_importador(''); $limpiar_cache = borrar_tmp(''); $configuracion= configuracion(''); + $login = login_boton(''); $menu = " @@ -6994,7 +7845,7 @@ function milfs(){
  • $crear_campos
  • $listado -
  • $consultas
  • +
  • $importador
  • $limpiar_cache
  • Presentación
  • diff --git a/milfs/funciones/login.php b/milfs/funciones/login.php old mode 100755 new mode 100644 index fbef0d0..bdb6241 --- a/milfs/funciones/login.php +++ b/milfs/funciones/login.php @@ -1,4 +1,55 @@ +$name +IdUsernameNombreEmailDocumentoEmpresaDocumento + " ; +if (mysql_num_rows($sql)!='0'){ + if($onchange !=''){$vacio ="";}else{$vacio ="";} + +$linea = 1; +while( $row = mysql_fetch_array( $sql ) ) { +$username= editar_campo("$tabla",$row['id'],"username","","",""); +$p_nombre= editar_campo("$tabla",$row['id'],"p_nombre","","",""); +$p_apellido= editar_campo("$tabla",$row['id'],"p_apellido","","",""); +$empresa_id= editar_campo("$tabla",$row['id'],"id_empresa","","",""); + + + + +if($row[id] !=1) {$acciones = "";} +$resultado .= "$row[id]$username$p_nombre $p_apellido$row[email]$row[documento_numero] $empresa_id $row[documento_numero]$acciones "; +$linea++; + } + + + }else{ + $resultado = "
    No hay resultados
    "; + } + + if($div =="") { + $div="contenido"; + // $resultado ="Configuración multiempresa"; + return $resultado; + } + $respuesta->addScript("javascript:xajax_multiempresa('empresa','$div')"); + return $respuesta; +} +$xajax->registerFunction("usuarios_listado"); + function login_boton($formulario){ if($formulario =='x') { session_destroy(); @@ -31,42 +82,52 @@ $xajax->registerFunction("login_boton"); function registro_express($formulario,$accion) { - $formulario = mysql_seguridad($formulario); -// if(is_array($formulario) ){$nombre_formulario = $formulario['nombre_formulario'];}else{$nombre_formulario = "$formulario";} + //$formulario = mysql_seguridad($formulario); + require("includes/datos.php"); if($nombre_formulario =="") {$nombre_formulario = "login";} -/* - foreach($formulario as $c=>$v){ - -//LISTA ELEMENTOS DE UN ARRAY -if (is_array($v) ){ - foreach($v as $C=>$V){ - if($V != '') {$resultado .= "$$c = \$formulario[$c][$C]; // $V

    ";} - } - - - } else { - if($v !='') {$resultado .= "$$c = \$formulario[$c]; // $v

    ";} - } - - } - */ $boton ="
    Grabar
    "; $respuesta = new xajaxResponse('utf-8'); + + if($accion =='confirmar') { - - $div = "registro_confirmacion_email"; - -if($formulario[password_express_confirmar] =="" OR $formulario[password_express_confirmar] != $formulario[password_express] ){ - $resultado ="
    Por favor escribe y confirma una clave.
    $boton"; - $respuesta->addAssign("password_express"."_grupo","className"," input-group has-error "); - $respuesta->addAlert("Por favor escribe y confirma la clave"); - $respuesta->addScript("document.getElementById('password_express').focus(); "); - $respuesta->addAssign("$div","innerHTML",$resultado); -return $respuesta; - - } - if($formulario[email_express_confirmar] !="") { + $div = "registro_confirmacion_email"; + $email_existe = remplacetas("$tabla_autenticacion","email",$formulario[email_express_confirmar],"email",""); + $documento_existe = remplacetas("$tabla_autenticacion","documento_numero",$formulario[documento_express],"documento_numero",""); + if($email_existe[0] !="" or $formulario[email_express_confirmar] ==="") { + $respuesta->addAlert("No se ha especificado un email o ya está en uso "); + $respuesta->addAssign("email_express_grupo","className"," input-group has-error "); + ///$respuesta->addAssign("debug","innerHTML","

    $email_existe[2]"); + $respuesta->addScript("document.getElementById('email_express').focus(); "); + return $respuesta; + } + if($documento_existe[0] !="" OR $formulario[documento_express] === "") { + $respuesta->addAlert("No se ha proporcionado un documento único // $formulario[documento_express] // "); + $respuesta->addAssign("documento_express_grupo","className"," input-group has-error "); + $respuesta->addScript("document.getElementById('documento_express').focus(); "); + return $respuesta; + } + if( !isset($formulario[password_express_confirmar]) ){ + $resultado ="
    Por favor escribe una clave. $formulario[password_express_confirmar] // $formulario[password_express]
    $boton"; + $respuesta->addAssign("password_express"."_grupo","className"," input-group has-error "); + $respuesta->addAlert("Por favor escribe una la clave "); + $respuesta->addScript("document.getElementById('password_express').focus(); "); + $respuesta->addAssign("$div","innerHTML",$resultado); + return $respuesta; + } + if($formulario[password_express_confirmar] =="" or $formulario[password_express_confirmar] !== $formulario[password_express] ){ + $resultado ="
    Por favor escribe y confirma una clave. $formulario[password_express_confirmar] // $formulario[password_express]
    $boton"; + $respuesta->addAssign("password_express"."_grupo","className"," input-group has-error "); + $respuesta->addAlert("Por favor escribe y confirma la clave XXX"); + $respuesta->addScript("document.getElementById('password_express').focus(); "); + $respuesta->addAssign("$div","innerHTML",$resultado); + return $respuesta; + } + if($formulario[email_express_confirmar] ==="") { + $resultado .= "$boton
    No hay un email válido // $formulario[email_express_confirmar]
    "; + $respuesta->addAssign("$div","innerHTML",$resultado); + return $respuesta; + }else{ $email_envio = $formulario['email_express_confirmar']; $rrn = rand(123,999); @@ -82,22 +143,21 @@ return $respuesta; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; -$headers .= "From: Comunidad QWERTY.co \r\n"; -$headers .= "Reply-To: comunidad@qwerty.co\r\n"; -$headers .= "Return-path: comunidad@qwerty.co\r\n"; +$headers .= "From: $razon_social[0] <$email[0]>\r\n"; +$headers .= "Reply-To: $email[0]\r\n"; +$headers .= "Return-path: $email[0]\r\n"; $asunto= "Código de validación"; $cuerpo ="
    -

    Comunidad QWERTY.co

    +

    Registro


    Código de validación

    -

    Bienvenido a nuestra comunidad QWERTY.co Por favor digita el siguente código para validar tu cuenta.

    +

    Bienvenido a nuestra aplicación. Por favor digita el siguente código para validar tu cuenta.

    $rrn

    -

    Toda la ayuda que necesitas la puedes encontrar en nuestra sección de respuestas a preguntas frecuentes: http://qwerty.co/faq.

    $aviso "; @@ -129,9 +189,6 @@ mail("$email_envio","$asunto","$cuerpo","$headers") ;
    $boton "; - }else{ - $resultado .= "$boton
    No hay un email válido
    "; - } $respuesta->addAssign("$div","innerHTML",$resultado); @@ -176,6 +233,8 @@ $rrn = $formulario[rrn]; // $codificado = md5("$codigo_confirmacion"); if($rrn == $codificado) { $control = $formulario[control]; // nuevo_ +$id_empresa = $formulario[id_empresa]; // nuevo_ +if($id_empresa =="") {$id_empresa= $_SESSION['id_empresa'];} $nombre_formulario = $formulario[nombre_formulario]; // nuevo_ $email_express = $formulario[email_express]; // aa@gmail.com $email_express_confirmar = $formulario[email_express_confirmar]; // aa@gmail.com @@ -183,14 +242,17 @@ $nombre_express = $formulario[nombre_express]; // nombre $apellido_express = $formulario[apellido_express]; // apellido $telefono_express = $formulario[telefono_express]; // 324343 $password_express = $formulario[password_express]; // 1234 +$documento = $formulario[documento_express]; // 1234 $password_express_confirmar = $formulario[password_express_confirmar]; // 23456 $ip = obtener_ip(); $link = Conectarse(); mysql_query("SET NAMES 'utf8'"); -$consulta = "INSERT INTO usuarios (username,p_nombre,p_apellido,email,bio,passwd,control,status,lastip,id_empresa) - VALUES ('$email_express_confirmar','$nombre_express','$apellido_express','$email_express_confirmar','','".MD5($password_express_confirmar)."','$control','1','$ip','$_SESSION[id_empresa]')"; +$consulta = "INSERT INTO $tabla_autenticacion (username,p_nombre,p_apellido,email,passwd,control,status,lastip,id_empresa,documento_numero) + VALUES ('$email_express_confirmar','$nombre_express','$apellido_express','$email_express_confirmar','".MD5($password_express_confirmar)."','$control','1','$ip','$id_empresa','$documento')"; +//$respuesta->addAssign("debug","innerHTML",$consulta); +//return $respuesta; $sql_consulta=mysql_query($consulta,$link); if($sql_consulta) { $id = mysql_insert_id(); @@ -226,14 +288,29 @@ return $respuesta; elseif($accion =="nuevo") { //$respuesta = new xajaxResponse('utf-8'); $div="contenido"; + if($_SESSION['id'] == 1) { +$empresa = select('empresa','id','razon_social','',"estado = '1'",'id_empresa'); +$empresa =" +
    + Empresa + $empresa +
    + +"; +} +$listado_usuarios = usuarios_listado($tabla_autenticacion,""); $form = " +
    - Datos de contacto + Usuario + $empresa
    -
    +
    +
    + @@ -242,8 +319,8 @@ $form = " onchange=\"xajax_validar_usuario('email',(this.value),'email_express','login'); \" >
    -
    - +
    +
    @@ -255,7 +332,8 @@ $form = "
    -
    +
    +
    @@ -263,9 +341,9 @@ $form = "
    -
    -
    -
    + +
    +
    @@ -275,7 +353,19 @@ $form = "
    -
    +
    + +
    + + + + + +
    +
    +
    +
    @@ -287,7 +377,8 @@ $form = "
    -
    +
    +
    @@ -297,6 +388,7 @@ $form = "
    +
    @@ -308,7 +400,7 @@ $form = "
    -
    +

    $boton @@ -319,6 +411,11 @@ $boton
    + + +$listado_usuarios + + "; $respuesta->addAssign("$div","innerHTML",$form); return $respuesta; @@ -393,11 +490,12 @@ $resultado = "
    "; if(!isset($_SESSION['id'])){ print $resultado; }else { -$nuevo = "
    Usuario nuevo
    "; + print $nuevo ; } return; } + include("includes/datos.php"); $div='contenido'; $respuesta = new xajaxResponse('utf-8'); @@ -429,7 +527,7 @@ $mensaje ="Por favor escribe tu correo o usuario si olvidaste t return $respuesta; }else { -$consulta = "SELECT id,email,control,id_empresa FROM usuarios WHERE (email = '$email' OR username = '$email' )"; +$consulta = "SELECT id,email,control,id_empresa FROM $tabla_autenticacion WHERE (email = '$email' OR username = '$email' ) LIMIT 1"; $sql=mysql_query($consulta,$link); if (mysql_num_rows($sql)!='0') { @@ -438,7 +536,7 @@ $correo = mysql_result($sql,0,"email"); $control = mysql_result($sql,0,"control"); $id_usuario = mysql_result($sql,0,"id"); $id_empresa = mysql_result($sql,0,"id_empresa"); -$firma ="UPDATE `usuarios` SET `firma_recuperacion` = '$firma_recuperacion' WHERE `usuarios`.`id` = '$id_usuario';"; +$firma ="UPDATE $tabla_autenticacion SET `firma_recuperacion` = '$firma_recuperacion' WHERE `id` = '$id_usuario' LIMIT 1;"; $cambiar_firma=mysql_query($firma,$link); $tipo='success'; @@ -485,7 +583,7 @@ $mensaje ="El correo o usuario no se encuentra registrado aún. return $respuesta; } -$consulta = "SELECT * FROM usuarios WHERE (email = '$email' OR username = '$email' )AND passwd = '$password' LIMIT 1"; +$consulta = "SELECT * FROM $tabla_autenticacion WHERE (email = '$email' OR username = '$email' )AND passwd = '$password' LIMIT 1"; $sql=mysql_query($consulta,$link); @@ -511,7 +609,7 @@ $consulta = "SELECT * FROM usuarios WHERE (email = '$email' OR username = '$emai $resultado .=" $sucursal -

    Hola $_SESSION[username]

    "; +

    Hola $_SESSION[username]

    "; $respuesta->addRedirect("index.php"); } }else{ @@ -527,7 +625,8 @@ $consulta = "SELECT * FROM usuarios WHERE (email = '$email' OR username = '$emai $xajax->registerFunction("revisar_ingreso"); function cambiar_password_formato($change) { - $firma_recuperacion = remplacetas("usuarios","firma_recuperacion",$change,"firma_recuperacion") ; + require("includes/datos.php"); + $firma_recuperacion = remplacetas("$tabla_autenticacion","firma_recuperacion",$change,"firma_recuperacion") ; if($firma_recuperacion[0] =='') { $formato ="

    Lo sentimos

    El Link ya no es válido

    "; return $formato; @@ -571,14 +670,15 @@ return $formato; function cambiar_password($formulario){ // if ( !isset ( $_SESSION['id'] ) ) { return;} $respuesta = new xajaxResponse('utf-8'); + require("includes/datos.php"); $formulario = mysql_seguridad($formulario); $actual= $formulario[password_actual]; $nuevo= $formulario[password_nuevo]; $confirmacion= $formulario[password_confirmacion]; $firma = $formulario[firma_recuperacion]; -$firma_recuperacion = remplacetas("usuarios","firma_recuperacion",$formulario[firma_recuperacion],"firma_recuperacion") ; +$firma_recuperacion = remplacetas("$tabla_autenticacion","firma_recuperacion",$formulario[firma_recuperacion],"firma_recuperacion") ; if(isset($firma)) {$actual = $firma; $id_usuario = $firma_recuperacion[1]; }else{$id_usuario = $_SESSION[id]; } -$verifica = remplacetas("usuarios","id",$_SESSION[id],"passwd") ; +$verifica = remplacetas("$tabla_autenticacion","id",$_SESSION[id],"passwd") ; $size= strlen($nuevo); if($nuevo != $confirmacion OR $actual =="" ){ @@ -602,7 +702,7 @@ elseif($formulario[firma_recuperacion] =='' AND $verifica[0] != MD5($actual) ){ $link=Conectarse(); mysql_query("SET NAMES 'utf8'"); $nueva_firma = sha1(mktime()); - $consulta = "UPDATE usuarios SET passwd = '".MD5($nuevo)."' , firma_recuperacion = '$nueva_firma' WHERE id = $id_usuario;"; + $consulta = "UPDATE $tabla_autenticacion SET passwd = '".MD5($nuevo)."' , firma_recuperacion = '$nueva_firma' WHERE id = $id_usuario LIMIT 1;"; $sql_consulta=mysql_query($consulta,$link); if($sql_consulta) { $resultado = "
    La clave se cambió con éxito.
    "; diff --git a/milfs/images/iconos/negro.png b/milfs/images/iconos/negro.png index eb77ffe..9f4463a 100644 Binary files a/milfs/images/iconos/negro.png and b/milfs/images/iconos/negro.png differ diff --git a/milfs/images/iron.jpg b/milfs/images/iron.jpg new file mode 100644 index 0000000..c94eb40 Binary files /dev/null and b/milfs/images/iron.jpg differ diff --git a/milfs/images/oscuro40.png b/milfs/images/oscuro40.png new file mode 100644 index 0000000..fafe371 Binary files /dev/null and b/milfs/images/oscuro40.png differ diff --git a/milfs/includes/datos.php b/milfs/includes/datos.php index 40ec719..b7f3deb 100755 --- a/milfs/includes/datos.php +++ b/milfs/includes/datos.php @@ -5,8 +5,9 @@ $servidor="localhost"; $db="milfs"; $path_instalacion ="/var/www/html/milfs"; $path_images_secure ="/var/www/images_secure"; -$url = "http://localhost/milfs"; +$url = "http://localhost/milfs/"; /// Depende de la variable http://php.net/upload-max-filesize o en el .htaccess $upload_size = 6 ; // Tamaño permitido para las imagenes en MB $mapbox_token = "pk.eyJ1IjoiZmNhc3Ryb3QiLCJhIjoiY2lnOWw1bmd1MG93eXVsbTJpcmluYTBxdCJ9.yG7C1rEH6-MpZBEEb68IVg"; +$tabla_autenticacion="usuarios"; ?> diff --git a/milfs/includes/simple_html_dom.php b/milfs/includes/simple_html_dom.php new file mode 100644 index 0000000..bc2cf0a --- /dev/null +++ b/milfs/includes/simple_html_dom.php @@ -0,0 +1,1721 @@ +size is the "real" number of bytes the dom was created from. + * but for most purposes, it's a really good estimation. + * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors. + * Allow the user to tell us how much they trust the html. + * Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node. + * This allows for us to find tags based on the text they contain. + * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag. + * Paperg: added parse_charset so that we know about the character set of the source document. + * NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the + * last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection. + * + * Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that. + * PaperG (John Schlick) Added get_display_size for "IMG" tags. + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @author S.C. Chen + * @author John Schlick + * @author Rus Carroll + * @version 1.5 ($Rev: 196 $) + * @package PlaceLocalInclude + * @subpackage simple_html_dom + */ + +/** + * All of the Defines for the classes below. + * @author S.C. Chen + */ +define('HDOM_TYPE_ELEMENT', 1); +define('HDOM_TYPE_COMMENT', 2); +define('HDOM_TYPE_TEXT', 3); +define('HDOM_TYPE_ENDTAG', 4); +define('HDOM_TYPE_ROOT', 5); +define('HDOM_TYPE_UNKNOWN', 6); +define('HDOM_QUOTE_DOUBLE', 0); +define('HDOM_QUOTE_SINGLE', 1); +define('HDOM_QUOTE_NO', 3); +define('HDOM_INFO_BEGIN', 0); +define('HDOM_INFO_END', 1); +define('HDOM_INFO_QUOTE', 2); +define('HDOM_INFO_SPACE', 3); +define('HDOM_INFO_TEXT', 4); +define('HDOM_INFO_INNER', 5); +define('HDOM_INFO_OUTER', 6); +define('HDOM_INFO_ENDSPACE',7); +define('DEFAULT_TARGET_CHARSET', 'UTF-8'); +define('DEFAULT_BR_TEXT', "\r\n"); +define('DEFAULT_SPAN_TEXT', " "); +define('MAX_FILE_SIZE', 600000); +// helper functions +// ----------------------------------------------------------------------------- +// get html dom from file +// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. +function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) +{ + // We DO force the tags to be terminated. + $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); + // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done. + $contents = file_get_contents($url, $use_include_path, $context, $offset); + // Paperg - use our own mechanism for getting the contents as we want to control the timeout. + //$contents = retrieve_url_contents($url); + if (empty($contents) || strlen($contents) > MAX_FILE_SIZE) + { + return false; + } + // The second parameter can force the selectors to all be lowercase. + $dom->load($contents, $lowercase, $stripRN); + return $dom; +} + +// get html dom from string +function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) +{ + $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); + if (empty($str) || strlen($str) > MAX_FILE_SIZE) + { + $dom->clear(); + return false; + } + $dom->load($str, $lowercase, $stripRN); + return $dom; +} + +// dump html dom tree +function dump_html_tree($node, $show_attr=true, $deep=0) +{ + $node->dump($node); +} + + +/** + * simple html dom node + * PaperG - added ability for "find" routine to lowercase the value of the selector. + * PaperG - added $tag_start to track the start position of the tag in the total byte index + * + * @package PlaceLocalInclude + */ +class simple_html_dom_node +{ + public $nodetype = HDOM_TYPE_TEXT; + public $tag = 'text'; + public $attr = array(); + public $children = array(); + public $nodes = array(); + public $parent = null; + // The "info" array - see HDOM_INFO_... for what each element contains. + public $_ = array(); + public $tag_start = 0; + private $dom = null; + + function __construct($dom) + { + $this->dom = $dom; + $dom->nodes[] = $this; + } + + function __destruct() + { + $this->clear(); + } + + function __toString() + { + return $this->outertext(); + } + + // clean up memory due to php5 circular references memory leak... + function clear() + { + $this->dom = null; + $this->nodes = null; + $this->parent = null; + $this->children = null; + } + + // dump node's tree + function dump($show_attr=true, $deep=0) + { + $lead = str_repeat(' ', $deep); + + echo $lead.$this->tag; + if ($show_attr && count($this->attr)>0) + { + echo '('; + foreach ($this->attr as $k=>$v) + echo "[$k]=>\"".$this->$k.'", '; + echo ')'; + } + echo "\n"; + + if ($this->nodes) + { + foreach ($this->nodes as $c) + { + $c->dump($show_attr, $deep+1); + } + } + } + + + // Debugging function to dump a single dom node with a bunch of information about it. + function dump_node($echo=true) + { + + $string = $this->tag; + if (count($this->attr)>0) + { + $string .= '('; + foreach ($this->attr as $k=>$v) + { + $string .= "[$k]=>\"".$this->$k.'", '; + } + $string .= ')'; + } + if (count($this->_)>0) + { + $string .= ' $_ ('; + foreach ($this->_ as $k=>$v) + { + if (is_array($v)) + { + $string .= "[$k]=>("; + foreach ($v as $k2=>$v2) + { + $string .= "[$k2]=>\"".$v2.'", '; + } + $string .= ")"; + } else { + $string .= "[$k]=>\"".$v.'", '; + } + } + $string .= ")"; + } + + if (isset($this->text)) + { + $string .= " text: (" . $this->text . ")"; + } + + $string .= " HDOM_INNER_INFO: '"; + if (isset($node->_[HDOM_INFO_INNER])) + { + $string .= $node->_[HDOM_INFO_INNER] . "'"; + } + else + { + $string .= ' NULL '; + } + + $string .= " children: " . count($this->children); + $string .= " nodes: " . count($this->nodes); + $string .= " tag_start: " . $this->tag_start; + $string .= "\n"; + + if ($echo) + { + echo $string; + return; + } + else + { + return $string; + } + } + + // returns the parent of node + // If a node is passed in, it will reset the parent of the current node to that one. + function parent($parent=null) + { + // I am SURE that this doesn't work properly. + // It fails to unset the current node from it's current parents nodes or children list first. + if ($parent !== null) + { + $this->parent = $parent; + $this->parent->nodes[] = $this; + $this->parent->children[] = $this; + } + + return $this->parent; + } + + // verify that node has children + function has_child() + { + return !empty($this->children); + } + + // returns children of node + function children($idx=-1) + { + if ($idx===-1) + { + return $this->children; + } + if (isset($this->children[$idx])) return $this->children[$idx]; + return null; + } + + // returns the first child of node + function first_child() + { + if (count($this->children)>0) + { + return $this->children[0]; + } + return null; + } + + // returns the last child of node + function last_child() + { + if (($count=count($this->children))>0) + { + return $this->children[$count-1]; + } + return null; + } + + // returns the next sibling of node + function next_sibling() + { + if ($this->parent===null) + { + return null; + } + + $idx = 0; + $count = count($this->parent->children); + while ($idx<$count && $this!==$this->parent->children[$idx]) + { + ++$idx; + } + if (++$idx>=$count) + { + return null; + } + return $this->parent->children[$idx]; + } + + // returns the previous sibling of node + function prev_sibling() + { + if ($this->parent===null) return null; + $idx = 0; + $count = count($this->parent->children); + while ($idx<$count && $this!==$this->parent->children[$idx]) + ++$idx; + if (--$idx<0) return null; + return $this->parent->children[$idx]; + } + + // function to locate a specific ancestor tag in the path to the root. + function find_ancestor_tag($tag) + { + global $debugObject; + if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } + + // Start by including ourselves in the comparison. + $returnDom = $this; + + while (!is_null($returnDom)) + { + if (is_object($debugObject)) { $debugObject->debugLog(2, "Current tag is: " . $returnDom->tag); } + + if ($returnDom->tag == $tag) + { + break; + } + $returnDom = $returnDom->parent; + } + return $returnDom; + } + + // get dom node's inner html + function innertext() + { + if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; + if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + + $ret = ''; + foreach ($this->nodes as $n) + $ret .= $n->outertext(); + return $ret; + } + + // get dom node's outer text (with tag) + function outertext() + { + global $debugObject; + if (is_object($debugObject)) + { + $text = ''; + if ($this->tag == 'text') + { + if (!empty($this->text)) + { + $text = " with text: " . $this->text; + } + } + $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text); + } + + if ($this->tag==='root') return $this->innertext(); + + // trigger callback + if ($this->dom && $this->dom->callback!==null) + { + call_user_func_array($this->dom->callback, array($this)); + } + + if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; + if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + + // render begin tag + if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) + { + $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup(); + } else { + $ret = ""; + } + + // render inner text + if (isset($this->_[HDOM_INFO_INNER])) + { + // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added. + if ($this->tag != "br") + { + $ret .= $this->_[HDOM_INFO_INNER]; + } + } else { + if ($this->nodes) + { + foreach ($this->nodes as $n) + { + $ret .= $this->convert_text($n->outertext()); + } + } + } + + // render end tag + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) + $ret .= 'tag.'>'; + return $ret; + } + + // get dom node's plain text + function text() + { + if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; + switch ($this->nodetype) + { + case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + case HDOM_TYPE_COMMENT: return ''; + case HDOM_TYPE_UNKNOWN: return ''; + } + if (strcasecmp($this->tag, 'script')===0) return ''; + if (strcasecmp($this->tag, 'style')===0) return ''; + + $ret = ''; + // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. + // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening. + // WHY is this happening? + if (!is_null($this->nodes)) + { + foreach ($this->nodes as $n) + { + $ret .= $this->convert_text($n->text()); + } + + // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all. + if ($this->tag == "span") + { + $ret .= $this->dom->default_span_text; + } + + + } + return $ret; + } + + function xmltext() + { + $ret = $this->innertext(); + $ret = str_ireplace('', '', $ret); + return $ret; + } + + // build node's text with tag + function makeup() + { + // text, comment, unknown + if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + + $ret = '<'.$this->tag; + $i = -1; + + foreach ($this->attr as $key=>$val) + { + ++$i; + + // skip removed attribute + if ($val===null || $val===false) + continue; + + $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; + //no value attr: nowrap, checked selected... + if ($val===true) + $ret .= $key; + else { + switch ($this->_[HDOM_INFO_QUOTE][$i]) + { + case HDOM_QUOTE_DOUBLE: $quote = '"'; break; + case HDOM_QUOTE_SINGLE: $quote = '\''; break; + default: $quote = ''; + } + $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote; + } + } + $ret = $this->dom->restore_noise($ret); + return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>'; + } + + // find elements by css selector + //PaperG - added ability for find to lowercase the value of the selector. + function find($selector, $idx=null, $lowercase=false) + { + $selectors = $this->parse_selector($selector); + if (($count=count($selectors))===0) return array(); + $found_keys = array(); + + // find each selector + for ($c=0; $c<$count; ++$c) + { + // The change on the below line was documented on the sourceforge code tracker id 2788009 + // used to be: if (($levle=count($selectors[0]))===0) return array(); + if (($levle=count($selectors[$c]))===0) return array(); + if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); + + $head = array($this->_[HDOM_INFO_BEGIN]=>1); + + // handle descendant selectors, no recursive! + for ($l=0; $l<$levle; ++$l) + { + $ret = array(); + foreach ($head as $k=>$v) + { + $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k]; + //PaperG - Pass this optional parameter on to the seek function. + $n->seek($selectors[$c][$l], $ret, $lowercase); + } + $head = $ret; + } + + foreach ($head as $k=>$v) + { + if (!isset($found_keys[$k])) + $found_keys[$k] = 1; + } + } + + // sort keys + ksort($found_keys); + + $found = array(); + foreach ($found_keys as $k=>$v) + $found[] = $this->dom->nodes[$k]; + + // return nth-element or array + if (is_null($idx)) return $found; + else if ($idx<0) $idx = count($found) + $idx; + return (isset($found[$idx])) ? $found[$idx] : null; + } + + // seek for given conditions + // PaperG - added parameter to allow for case insensitive testing of the value of a selector. + protected function seek($selector, &$ret, $lowercase=false) + { + global $debugObject; + if (is_object($debugObject)) { $debugObject->debugLogEntry(1); } + + list($tag, $key, $val, $exp, $no_key) = $selector; + + // xpath index + if ($tag && $key && is_numeric($key)) + { + $count = 0; + foreach ($this->children as $c) + { + if ($tag==='*' || $tag===$c->tag) { + if (++$count==$key) { + $ret[$c->_[HDOM_INFO_BEGIN]] = 1; + return; + } + } + } + return; + } + + $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0; + if ($end==0) { + $parent = $this->parent; + while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) { + $end -= 1; + $parent = $parent->parent; + } + $end += $parent->_[HDOM_INFO_END]; + } + + for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) { + $node = $this->dom->nodes[$i]; + + $pass = true; + + if ($tag==='*' && !$key) { + if (in_array($node, $this->children, true)) + $ret[$i] = 1; + continue; + } + + // compare tag + if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;} + // compare key + if ($pass && $key) { + if ($no_key) { + if (isset($node->attr[$key])) $pass=false; + } else { + if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; + } + } + // compare value + if ($pass && $key && $val && $val!=='*') { + // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right? + if ($key == "plaintext") { + // $node->plaintext actually returns $node->text(); + $nodeKeyValue = $node->text(); + } else { + // this is a normal search, we want the value of that attribute of the tag. + $nodeKeyValue = $node->attr[$key]; + } + if (is_object($debugObject)) {$debugObject->debugLog(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);} + + //PaperG - If lowercase is set, do a case insensitive test of the value of the selector. + if ($lowercase) { + $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue)); + } else { + $check = $this->match($exp, $val, $nodeKeyValue); + } + if (is_object($debugObject)) {$debugObject->debugLog(2, "after match: " . ($check ? "true" : "false"));} + + // handle multiple class + if (!$check && strcasecmp($key, 'class')===0) { + foreach (explode(' ',$node->attr[$key]) as $k) { + // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form. + if (!empty($k)) { + if ($lowercase) { + $check = $this->match($exp, strtolower($val), strtolower($k)); + } else { + $check = $this->match($exp, $val, $k); + } + if ($check) break; + } + } + } + if (!$check) $pass = false; + } + if ($pass) $ret[$i] = 1; + unset($node); + } + // It's passed by reference so this is actually what this function returns. + if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret);} + } + + protected function match($exp, $pattern, $value) { + global $debugObject; + if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} + + switch ($exp) { + case '=': + return ($value===$pattern); + case '!=': + return ($value!==$pattern); + case '^=': + return preg_match("/^".preg_quote($pattern,'/')."/", $value); + case '$=': + return preg_match("/".preg_quote($pattern,'/')."$/", $value); + case '*=': + if ($pattern[0]=='/') { + return preg_match($pattern, $value); + } + return preg_match("/".$pattern."/i", $value); + } + return false; + } + + protected function parse_selector($selector_string) { + global $debugObject; + if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} + + // pattern of CSS selectors, modified from mootools + // Paperg: Add the colon to the attrbute, so that it properly finds like google does. + // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check. +// Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured. +// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression. +// farther study is required to determine of this should be documented or removed. +// $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; + $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is"; + preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER); + if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);} + + $selectors = array(); + $result = array(); + //print_r($matches); + + foreach ($matches as $m) { + $m[0] = trim($m[0]); + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; + // for browser generated xpath + if ($m[1]==='tbody') continue; + + list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); + if (!empty($m[2])) {$key='id'; $val=$m[2];} + if (!empty($m[3])) {$key='class'; $val=$m[3];} + if (!empty($m[4])) {$key=$m[4];} + if (!empty($m[5])) {$exp=$m[5];} + if (!empty($m[6])) {$val=$m[6];} + + // convert to lowercase + if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);} + //elements that do NOT have the specified attribute + if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;} + + $result[] = array($tag, $key, $val, $exp, $no_key); + if (trim($m[7])===',') { + $selectors[] = $result; + $result = array(); + } + } + if (count($result)>0) + $selectors[] = $result; + return $selectors; + } + + function __get($name) { + if (isset($this->attr[$name])) + { + return $this->convert_text($this->attr[$name]); + } + switch ($name) { + case 'outertext': return $this->outertext(); + case 'innertext': return $this->innertext(); + case 'plaintext': return $this->text(); + case 'xmltext': return $this->xmltext(); + default: return array_key_exists($name, $this->attr); + } + } + + function __set($name, $value) { + switch ($name) { + case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; + case 'innertext': + if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; + return $this->_[HDOM_INFO_INNER] = $value; + } + if (!isset($this->attr[$name])) { + $this->_[HDOM_INFO_SPACE][] = array(' ', '', ''); + $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE; + } + $this->attr[$name] = $value; + } + + function __isset($name) { + switch ($name) { + case 'outertext': return true; + case 'innertext': return true; + case 'plaintext': return true; + } + //no value attr: nowrap, checked selected... + return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]); + } + + function __unset($name) { + if (isset($this->attr[$name])) + unset($this->attr[$name]); + } + + // PaperG - Function to convert the text from one character set to another if the two sets are not the same. + function convert_text($text) + { + global $debugObject; + if (is_object($debugObject)) {$debugObject->debugLogEntry(1);} + + $converted_text = $text; + + $sourceCharset = ""; + $targetCharset = ""; + + if ($this->dom) + { + $sourceCharset = strtoupper($this->dom->_charset); + $targetCharset = strtoupper($this->dom->_target_charset); + } + if (is_object($debugObject)) {$debugObject->debugLog(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);} + + if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0)) + { + // Check if the reported encoding could have been incorrect and the text is actually already UTF-8 + if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) + { + $converted_text = $text; + } + else + { + $converted_text = iconv($sourceCharset, $targetCharset, $text); + } + } + + // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output. + if ($targetCharset == 'UTF-8') + { + if (substr($converted_text, 0, 3) == "\xef\xbb\xbf") + { + $converted_text = substr($converted_text, 3); + } + if (substr($converted_text, -3) == "\xef\xbb\xbf") + { + $converted_text = substr($converted_text, 0, -3); + } + } + + return $converted_text; + } + + /** + * Returns true if $string is valid UTF-8 and false otherwise. + * + * @param mixed $str String to be tested + * @return boolean + */ + static function is_utf8($str) + { + $c=0; $b=0; + $bits=0; + $len=strlen($str); + for($i=0; $i<$len; $i++) + { + $c=ord($str[$i]); + if($c > 128) + { + if(($c >= 254)) return false; + elseif($c >= 252) $bits=6; + elseif($c >= 248) $bits=5; + elseif($c >= 240) $bits=4; + elseif($c >= 224) $bits=3; + elseif($c >= 192) $bits=2; + else return false; + if(($i+$bits) > $len) return false; + while($bits > 1) + { + $i++; + $b=ord($str[$i]); + if($b < 128 || $b > 191) return false; + $bits--; + } + } + } + return true; + } + /* + function is_utf8($string) + { + //this is buggy + return (utf8_encode(utf8_decode($string)) == $string); + } + */ + + /** + * Function to try a few tricks to determine the displayed size of an img on the page. + * NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types. + * + * @author John Schlick + * @version April 19 2012 + * @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out. + */ + function get_display_size() + { + global $debugObject; + + $width = -1; + $height = -1; + + if ($this->tag !== 'img') + { + return false; + } + + // See if there is aheight or width attribute in the tag itself. + if (isset($this->attr['width'])) + { + $width = $this->attr['width']; + } + + if (isset($this->attr['height'])) + { + $height = $this->attr['height']; + } + + // Now look for an inline style. + if (isset($this->attr['style'])) + { + // Thanks to user gnarf from stackoverflow for this regular expression. + $attributes = array(); + preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $attributes[$match[1]] = $match[2]; + } + + // If there is a width in the style attributes: + if (isset($attributes['width']) && $width == -1) + { + // check that the last two characters are px (pixels) + if (strtolower(substr($attributes['width'], -2)) == 'px') + { + $proposed_width = substr($attributes['width'], 0, -2); + // Now make sure that it's an integer and not something stupid. + if (filter_var($proposed_width, FILTER_VALIDATE_INT)) + { + $width = $proposed_width; + } + } + } + + // If there is a width in the style attributes: + if (isset($attributes['height']) && $height == -1) + { + // check that the last two characters are px (pixels) + if (strtolower(substr($attributes['height'], -2)) == 'px') + { + $proposed_height = substr($attributes['height'], 0, -2); + // Now make sure that it's an integer and not something stupid. + if (filter_var($proposed_height, FILTER_VALIDATE_INT)) + { + $height = $proposed_height; + } + } + } + + } + + // Future enhancement: + // Look in the tag to see if there is a class or id specified that has a height or width attribute to it. + + // Far future enhancement + // Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width + // Note that in this case, the class or id will have the img subselector for it to apply to the image. + + // ridiculously far future development + // If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page. + + $result = array('height' => $height, + 'width' => $width); + return $result; + } + + // camel naming conventions + function getAllAttributes() {return $this->attr;} + function getAttribute($name) {return $this->__get($name);} + function setAttribute($name, $value) {$this->__set($name, $value);} + function hasAttribute($name) {return $this->__isset($name);} + function removeAttribute($name) {$this->__set($name, null);} + function getElementById($id) {return $this->find("#$id", 0);} + function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);} + function getElementByTagName($name) {return $this->find($name, 0);} + function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);} + function parentNode() {return $this->parent();} + function childNodes($idx=-1) {return $this->children($idx);} + function firstChild() {return $this->first_child();} + function lastChild() {return $this->last_child();} + function nextSibling() {return $this->next_sibling();} + function previousSibling() {return $this->prev_sibling();} + function hasChildNodes() {return $this->has_child();} + function nodeName() {return $this->tag;} + function appendChild($node) {$node->parent($this); return $node;} + +} + +/** + * simple html dom parser + * Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector. + * Paperg - change $size from protected to public so we can easily access it + * Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not. Default is to NOT trust it. + * + * @package PlaceLocalInclude + */ +class simple_html_dom +{ + public $root = null; + public $nodes = array(); + public $callback = null; + public $lowercase = false; + // Used to keep track of how large the text was when we started. + public $original_size; + public $size; + protected $pos; + protected $doc; + protected $char; + protected $cursor; + protected $parent; + protected $noise = array(); + protected $token_blank = " \t\r\n"; + protected $token_equal = ' =/>'; + protected $token_slash = " />\r\n\t"; + protected $token_attr = ' >'; + // Note that this is referenced by a child node, and so it needs to be public for that node to see this information. + public $_charset = ''; + public $_target_charset = ''; + protected $default_br_text = ""; + public $default_span_text = ""; + + // use isset instead of in_array, performance boost about 30%... + protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1); + protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1); + // Known sourceforge issue #2977341 + // B tags that are not closed cause us to return everything to the end of the document. + protected $optional_closing_tags = array( + 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1), + 'th'=>array('th'=>1), + 'td'=>array('td'=>1), + 'li'=>array('li'=>1), + 'dt'=>array('dt'=>1, 'dd'=>1), + 'dd'=>array('dd'=>1, 'dt'=>1), + 'dl'=>array('dd'=>1, 'dt'=>1), + 'p'=>array('p'=>1), + 'nobr'=>array('nobr'=>1), + 'b'=>array('b'=>1), + 'option'=>array('option'=>1), + ); + + function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) + { + if ($str) + { + if (preg_match("/^http:\/\//i",$str) || is_file($str)) + { + $this->load_file($str); + } + else + { + $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); + } + } + // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html. + if (!$forceTagsClosed) { + $this->optional_closing_array=array(); + } + $this->_target_charset = $target_charset; + } + + function __destruct() + { + $this->clear(); + } + + // load html from string + function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) + { + global $debugObject; + + // prepare + $this->prepare($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); + // strip out comments + $this->remove_noise("''is"); + // strip out cdata + $this->remove_noise("''is", true); + // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037 + // Script tags removal now preceeds style tag removal. + // strip out ";} - + if( isset($_REQUEST['psi'])){$onload ="";} ?> + + + + + + + - - - - - - -

    "; ?> +
    + + + + +
    +
    +
    Agregar
    +
    +
    +
    + Filtro + +
    +
    + +
    + +
    +
    + +
    + +
    + + +
    + + + + +