PDA

View Full Version : Wap search engine help!


wappo
01-11-2004, 04:59 PM
Hi, everyone i have this perl script which allows people to search wap on a mobile phone and it searchs a text database called db.txt which is set out like this:

Title of the first site<x>Keywords key1 key2<x>http://wap.firstsite.com<x>Description of the first site.
Title of the second site<x>Keywords key1 key2<x>http://wap.secondsite.com<x>Description of the second site.


But the problem is it does not ever come back with any results! Here is the search engine script below and you can test out the wap search engine out on a wap emulator just click me (http://wapsilon.com/?t=t%3Bf%3D1&u=http%3A%2F%2Fmembers.lycos.co.uk%2Fwapload%2Findex.wml)

Perl Script:

#!/usr/local/bin/perl
#Write here the path of your text-based database
$dblocation="/db.txt";

#Read the content of the form
&parse_form;
#Open database
&apri;
#Search
&trova;
#Print output
&html;
&html1;



#######################################################################
##Project by Dario Lillo
##Released under GNU license
#######################################################################
sub parse_form {
$valore=$ARGV[0];
}

sub apri {
open(FILE,"$dblocation");
@LINES = <FILE>;
close(FILE);
}

sub trova {
$contarighe=0;
$contarisultati=0;
@datrovare = split(/\s+/, $valore);
foreach $riga (@LINES) {
foreach $chiave (@datrovare) {
if (!($riga=~ /$chiave/i)) {
$trovato='no';
last;
} else {
$trovato='yes';
}
}
if ($trovato eq 'yes') {
$risultati[$contarisultati]=$contarighe;
$contarisultati++;
}
$contarighe++;
}
}
sub html {

print <<"dario";
Content-type: text/vnd.wap.wml

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="card1" title="Results">
<p>

dario
}
sub html1 {
if ($contarisultati>0){
foreach $risultato (@risultati) {
@ris=split (/<x>/, $LINES[$risultato]);
print "<a href='$ris[2]'>$ris[0]</a><br/>$ris[3]\n";
}
}else {print "No results";}
print "</p></card></wml>";

}




Please reply,
Wappo! http://members.lycos.co.uk/wapload/wappo.gif