He intentado con esto:
Código PHP:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Buscador de Canarismos</title>
<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; }
</style>
<title>hr</title>
</head>
<?
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 == "search" && "list") {
$user = file("site.dat");
$lis = 0;
if(strlen($keyword) <= 3){
print "<p><BR><BR><BR><b>Tu palabra es demasiado corta, ha de tener como mínimo tres letras.</b><br>";
}
else{
for($x=0;$x<sizeof($user);$x++) {
$temp = explode(";",$user[$x]);
$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3]";
$such = stristr($opp[$x],$keyword);
if($such) {
$list[$lis] = $opp[$x];
$lis++;
}else{
$meta = metaphone($keyword);
$meta2 = metaphone($opp[$x]);
$such = stristr($meta2,$meta);
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") {
//sort($keyword);
echo "<font face=arial><p><b>",sizeof($list),"</b> Resultados encontrados de la palabra $keyword<BR>Tiempo de búsqueda $time segundos.</p></font>";
$fa = fopen ("tempurl.txt", "w");
fwrite ($fa, "");
fclose ($fa);
for($y=0;$y<sizeof($list);$y++) {
$temp = explode(";",$list[$y]);
$fa = fopen ("tempurl.txt", "a++");
fwrite ($fa, $temp[0]);
fwrite ($fa, ";");
fwrite ($fa, $temp[1]);
fwrite ($fa, ";");
fwrite ($fa, $temp[2]);
fwrite ($fa, ";");
fwrite ($fa, "\n");
fclose ($fa);
}
?>
<?
if (is_file("tempurl.txt"))
{
$fp=file("tempurl.txt");
$s=sizeof($fp);
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=list&page=$new_page'><---Página anterior</a>";
}
else {
$prev="";
}
if ($end<$s) {
$new_page1=$page+1;
$next="<a href='?action=list&page=$new_page1'>Página siguiente;---></a>";
}
else {
$next="";
}
for ($i=$start; $i<$end; $i++)
{
$p=explode(';', $fp[$i]);
echo "<dl><dd><font face=arial size=3><a href='$p[2]'><b>$p[0]</a></b><BR>$p[1]<BR><FONT SIZE=\"2\" COLOR=\"#00000\">$p[2]</FONT></dL>";
}
}
$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'>";
echo "";
for ($i=1; $i<=$num; $i++) {
if ($i==$page) {
echo "<B> $i </B> ";
}
else {
echo "<a href='?action=list&page=$i'>[$i]</a>";
}
}
echo "</td><td align='right'>$next</td></table>";
}
else{
echo "<p><b>Lo sentimos, no hay resultados en nuestra base de datos de la palabra $keyword.</b><br>";
}
}
}
if($action == "submit") {
$fp = fopen ("site.dat", "a+");
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>Palabra añadida correctamente<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> = Required</form>";
}
?>
<?php
if($action == "list" && "search") {
?>
<?
if (is_file("tempurl.txt"))
{
$fp=file("tempurl.txt");
$s=sizeof($fp);
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=list&page=$new_page'><---Página anterior</a>";
}
else {
$prev="";
}
if ($end<$s) {
$new_page1=$page+1;
$next="<a href='?action=list&page=$new_page1'>Página siguiente---></a>";
}
else {
$next="";
}
for ($i=$start; $i<$end; $i++)
{
$p=explode(';', $fp[$i]);
echo "<dl><dd><font face=arial size=3><a href='$p[2]'><b>$p[0]</a></b><BR>$p[1]<BR><FONT SIZE=\"2\" COLOR=\"#00000\">$p[2]</FONT></dL>";
}
}
$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'>";
echo "Page:";
for ($i=1; $i<=$num; $i++) {
if ($i==$page) {
echo "<B> $i </B>";
}
else {
echo "<a href='?action=list&page=$i'>[$i]</a>";
}
}
echo "</td><td align='right'>$next</td></table>";
}
?>
</center>
</body>
</html></center>
<body>
<CENTER><form action="?action=search&list&page=1" method="post" name="searchform">
<FONT SIZE="2"><img src="img/lupa.png" width="20" height="20" alt="lupa" /></FONT>
<input type="text" name="keyword" size="20" maxlength="100">
<input type="submit" value="Buscar"><BR><font size=2><BR>
</form></CENTER>
</body>
</html>