<?php
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
// recibe the parameters sended by this search
$titulo=$_POST["titulo"];
$des=$_POST["descripcion"];
$etiqueta=$_POST["etiqueta"];
$provincia=$_POST["provincia"];
function conexiondata()
{
$bd_host = "localhost";
$bd_usuario = "usuariodb";
$bd_password = "*******";
$bd_base = "database";
if (!($link=mysql_connect($bd_host,$bd_usuario,$bd_password)))
{ echo "Error conectando a la base de datos.";
exit();
}
if (!mysql_select_db($bd_base,$link))
{ echo "Error seleccionando la base de datos.";
exit();
}
return $link;
}
function listado($stitulo, $sdes, $setiqueta,$sprovincia)
{ $info="<div id='wrap'><h1>Bienvenidos a la biblioteca </h1>";
$info.='<script type="text/javascript" src="http://www.domain.com/tablesorter/jquery-latest.js"></script> ';
$info.='<script type="text/javascript" src="http://www.domain.com//tablesorter/jquery.tablesorter.js"></script> ';
$info.='<script type="text/javascript" id="js"> $(document).ready(function() { $("table").tablesorter({sortList: [[0,0],[2,0]]});}); </script>';
$con=conexiondata();
$info.="<table width='800' border='0' cellspacing='0' cellpadding='0'>
<tr><td>El buscador te permite ubicar rápidamente documentos sobre un tema particular que te interesa y que luego puedes descargar.
</td> <td></td></tr></table>";
$info.="<div id='content'>
<form action='search.php' method='post'>
<br />
<div><span class='title'>Titulo </span>
<input name='titulo' type='text' value='' size='30' />
<span class='title'>Descripción</span>
<input name='descripcion' type='text' size='30' />
</div>
<br>
<div><span class='title'>Etiqueta</span>
<input name='etiqueta' type='text' id='etiqueta' title='Etiquetas' size='30'>
<span class='title'>Provincia</span>
<select name='provincia' id='provincia'>
<option value=''>Seleccione ...</option>
</select>
</div>
<span class='title'> <input name='search' type='submit' value='Enviar'/> </span>
<span class='title'><input type='reset' name='reset' value='Limpiar' /></span>
</form></div> ";
$info.="<table class='tablesorter' cellspacing='1'><thead><tr><th>Nombre</th><th>Fecha</th><th>Propietario</th></tr></thead> ";
$info.="<tbody>";
$consulta="SELECT a1.id as idarchivo, a1.string ,a2.*, a3.username, a4.*
FROM elggmetastrings as a1, elggmetadata as a2, elggusers_entity as a3, elggobjects_entity as a4
WHERE( a1.string LIKE '%.doc%' OR a1.string LIKE '%.pdf%' OR a1.string LIKE '%.ppt%' OR a1.string LIKE '%.xls%' OR a1.string LIKE '%.zip%')
AND a1.string LIKE '%file/%' ";
// echo $stitulo .'/'.$sdes.' /'.$setiqueta.'/'.$sprovincia;
if (strlen($stitulo)>0) // se envio el titulo
$consulta.=" AND LCASE(title) LIKE '%$stitulo%' ";
if (strlen($sdes)>0) // envio de descripcion
$consulta.=" AND LCASE(description) LIKE '%$sdes%' ";
if (strlen($setiqueta)>0) // envio de provincia
$consulta.=" AND ((LCASE(description) LIKE '%$setiqueta%') OR (LCASE(title) LIKE '%$setiqueta%') OR (LCASE(a1.string) LIKE '%$setiqueta%') ) ";
if (strlen($sprovincia)>0) // envio de provincia
$consulta.=" AND username LIKE '%$sprovincia%' ";
$consulta.="AND a2.value_id=a1.id
AND a2.entity_guid=a4.guid
AND a2.owner_guid=a3.guid
GROUP BY a2.entity_guid";
$sql=mysql_query($consulta,$con);
$enlaceurl="http://www.domino.com/pg/file/";
while($row = mysql_fetch_array($sql))
{ $enlace=$enlaceurl;
$enlace.=$row['username'].'/read/'.$row['entity_guid'];
$titular=substr($row['title'], 0, 65);
$info.='<tr><td><a href="'.$enlace.'">'.$titular.' ...</a></td><td>'.date("m-d-Y H:i:sa",$row['time_created']).' </td> <td> '.$row['username'].'</td> </tr>';
}
$info.="</tbody></table>";
$info.="</div>";
return $info;
}
// Get input
$md_type = 'simpletype';
$tag = get_input('tag');
$search_viewtype = get_input('search_viewtype');
$friends = (int) get_input('friends_guid',0);
if ($friends) {
if ($owner_guid = get_user_friends($user_guid, $subtype, 999999, 0)) {
foreach($owner_guid as $key => $friend)
$owner_guid[$key] = (int) $friend->getGUID();
} else {
$owner_guid = array();
}
} else {
$owner_guid = get_input('owner_guid',0);
if (substr_count($owner_guid,',')) {
$owner_guid = explode(",",$owner_guid);
}
}
$page_owner = get_input('page_owner',0);
if ($page_owner) {
set_page_owner($page_owner);
} else {
if ($friends) {
set_page_owner($friends);
} else {
if ($owner_guid > 0 && !is_array($owner_guid))
set_page_owner($owner_guid);
}
}
if (is_callable('group_gatekeeper')) group_gatekeeper();
if (empty($tag)) {
$area2 = elgg_view_title(elgg_echo('file:type:all'));
} else {
if (is_array($owner_guid)) {
$area2 = elgg_view_title(elgg_echo("file:friends:type:" . $tag));
} else if (page_owner() && page_owner() != $_SESSION['guid']) {
$area2 = elgg_view_title(sprintf(elgg_echo("file:user:type:" . $tag),page_owner_entity()->name));
} else{
$area2 = elgg_view_title(elgg_echo("file:type:" . $tag));
}
}
if ($friends) {
$area1 = get_filetype_cloud($friends,true);
} else if ($owner_guid) {
$area1 = get_filetype_cloud($owner_guid);
} else {
$area1 = get_filetype_cloud();
}
// Set context
set_context('search');
$limit = 10;
if ($search_viewtype == "gallery") $limit = 12;
if (!empty($tag)) {
$area2 .= list_entities_from_metadata($md_type, $tag, 'object', 'file', $owner_guid, $limit);
} else {
$area2 .= list_entities("object", "file", $owner_guid, $limit);
}
set_context("file");
//$body = elgg_view_layout('',$area1, $area2);
$area2=listado(strtolower($titulo), strtolower($des),strtolower($etiqueta),strtolower($provincia));
$body = elgg_view_layout('','', $area2);
page_draw(sprintf(elgg_echo('searchtitle'),$tag),$body);
?>
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.