Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/03/2006, 02:28
Avatar de blogger
blogger
 
Fecha de Ingreso: diciembre-2005
Ubicación: frente al monitor
Mensajes: 398
Antigüedad: 18 años, 4 meses
Puntos: 12
Obtener el ultimo valor guardado

Recientemente baje un script para crear un buscador en mi pagina, para ser más especificos me baje el Smart Fetch.

Para los que no saben como funciona, el Smart Fetch es un buscador que funciona por medio de una base de datos en un archivo TXT. El mismo script te permite alimentar la base de datos, solo se llenan los campos requeridos.

El archivo TXT guarda la información segun el siguiente orden:
[list]; Titulo ; Descripción ; URL ; Palabras Clave;

Ahora, codigo utilizado para la busqueda es:

Código:
<html>
<head>
<style>
A:link      	{text-decoration: none; color: #11116E;}
A:visited   	{text-decoration: none; color: #11116E;}
A:hover      	{font-style: normal; color: #000000; text-decoration: underline;}
BODY 			{font-family: Verdana; font-size: 10pt;  }
TD 				{font-family: Verdana; color: #000000; font-size: 8pt;}
SELECT       	{font-family:Verdana;font-size:10pt;background:#FFFFFF;color:#000000;}
INPUT       	{font-family:Verdana;font-size:10pt;background:#FFFFFF;color:#000000;}
TEXTAREA     	{font-family:Verdana;font-size:10pt;background:#FFFFFF;color:#000000;}
hr		{color: #11116E; background-color: #11116E; height: 1px;}
</style>
</head>
<?
//Copyright Scriptsez.net
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
//$results_per_page - how many results you want to be displayed per page?
$results_per_page=5;
if($action == "dict_find") {
$user = file("site.txt");
$lis = 0;
if(strlen($keyword) <= 2){
	echo "<hr noshade size=2 color=#333399><CENTER><FORM action=\"?action=dict_find\" method=post><B>Search:</B> <INPUT name=keyword size=38><FONT class=f1>&nbsp;<INPUT name=submit_dict type=submit value= Search></form></CENTER><hr noshade size=2 color=#333399>";
	print "<p><BR><BR><BR><b>Your keyword must be longer than 3 characters</b><br><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><BR><BR><BR>";
}
else{
	for($x=0;$x<sizeof($user);$x++) {
		$temp = explode(";",$user[$x]);
		$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];";
		$such = strchr($temp[4],$keyword);
			if($such) {
				$list[$lis] = $opp[$x];
				$lis++; 
			}
	}
		function getmicrotime(){
		list($usec, $sec) = explode(" ",microtime());
	   return ((float)$usec + (float)$sec);
	}

	$time = microtime(); 
	$time = number_format($time,3); 

if(sizeof($list) != "0") {
		
		echo "<hr noshade size=2 color=#333399><CENTER><FORM action=\"?action=dict_find\" method=post><B>Search:</B> <INPUT name=keyword size=38><FONT class=f1>&nbsp;<INPUT name=submit_dict type=submit value= Search></form></CENTER><hr noshade size=2 color=#333399>";
		echo "<BR><font face=arial><p><b>",sizeof($list),"</b> Results found for \"$keyword\"<BR></p></font>";
		}else{
		
		echo "<hr noshade size=2 color=#333399><CENTER><FORM action=\"?action=dict_find\" method=post><B>Search:</B> <INPUT name=keyword size=38><FONT class=f1>&nbsp;<INPUT name=submit_dict type=submit value= Search></form></CENTER><hr noshade size=2 color=#333399>";
	echo "<p><b>&nbsp;No results found for $keyword.</b><BR><BR><BR><BR>";
	}
$latest_max = sizeof($list);
$u = $a - $latest_max;
if (is_file("site.txt"))
	{
	$s=sizeof($list);
if ($page=='' or !$page) { $page=1; }
$end=$results_per_page*$page;
$start=$end-$results_per_page;

if ($start<>'0') {
	$new_page=$page-1;
	$prev="<a href='?action=dict_find&keyword=$keyword&page=$new_page'><---Previous page</a>";
}
else {
	$prev="";
}

if ($end<$s) {
	$new_page1=$page+1;
	$next="<a href='?action=dict_find&keyword=$keyword&page=$new_page1'>Next page---></a>";
}
else {
	$next="";
}
$today = time();
for ($i=$start; $i<$end; $i++){
	if(substr($list[$i], 0, 6 )=="[list]")
	{
	sort($list);
    $p=explode(';', $list[$i]);
	echo "<li><font face=arial><a href=$p[3]><b>$p[1]</a><BR>$p[2]<BR></FONT>";
}
}
$pages=$s/$results_per_page;
$pages1=round($pages, 2);
$p= explode(".", $pages1);
$pcount=count($p);
$ext=$p[$pcount-2];
if ($ext!=0) {
	$num=$p[0]+1;
}

else {
	$num=$p[0];
}
echo "<table width='100%'><tr><td align='left'>$prev</td><td align='center'>";
for ($i=1; $i<=$num; $i++) {
	if ($i==$page) {
echo "<B>&nbsp;$i&nbsp;</B> ";

	}
	else {
echo "<a href='?action=dict_find&keyword=$keyword&page=$i'>[$i]</a>";
}
}
echo "</td><td align='right'>$next</td></tr></table>";
}
}
}
if($action == "submit") {
$fp = fopen ("site.txt", "a+");
fwrite ($fp, "[list];");
fwrite ($fp, $title);
fwrite ($fp, ";");
fwrite ($fp, $description);
fwrite ($fp, ";");
fwrite ($fp, $link);
fwrite ($fp, ";");
fwrite ($fp, $keywords);
fwrite ($fp, ";");
fwrite ($fp, "\n");
fclose ($fp);
print "<pre><font face=arial size=3>Site has been added successfully<br><br>";
	}
if($action == "add") {
echo " <center><font face=arial>Submit a site:</center><br></font><form name=\"add\" method=\"post\" action=\"?action=submit\">";
echo "<font face=arial size=2>Tltle:<FONT COLOR=\"#FF0066\">*</FONT><BR> <input type=text name=title size=30><br>The title of your site.</font><br><br>";
echo "<font face=arial size=2>Description:<FONT COLOR=\"#FF0066\">*</FONT> <BR><input type=text name=description size=50><br>Description of your site.</font><br><br>";
echo "<font face=arial size=2>Url:<FONT COLOR=\"#FF0066\">*</FONT><BR><input type=text name=link value=http:// size=30><br>Link of your site.</font><br><br>";
echo "<font face=arial size=2>Keywords:<FONT COLOR=\"#FF0066\">*</FONT><BR><input type=text name=keywords size=30><br>Seperate keywords by spaces</font><br><br><input type=submit value=Submit><BR><BR><FONT COLOR=\"#FF0066\">*</FONT>&nbsp;=&nbsp;Required</form>";
}
?>
</center>
</body>
</html></center>
 <body>
 <CENTER><hr><FORM action="?action=dict_find" method=post>
	<FONT SIZE="2">Search For:</FONT>
			<input type="text" name="keyword" size="40" maxlength="100">
			<input type="submit" value="Search"><BR><font size=2><BR><a href='?action=add'>Add a website</a></font><BR><hr><BR><FONT SIZE="1" >Powered By <A HREF="http://www.scriptsez.net">Smart Fetch</A></FONT>
	</form></CENTER>
	</body>
	</html>
Lo que yo quiero hacer es que aparescan en mi pagina los ultimos registros almacenados en el archivo TXT, como un listado para que las personas vean cuales son los nuevos registros.

No se si me explique bien, por lo cual si tienen alguna duda estoy a sus ordenes.
__________________
http://exegesis-biblica.com/