[koderz.org]

PHP + Namazu

I found a PHP4 module to access Namazu (fast + free search engine found at http://www.namazu.org/ ) indexes directly from within PHP. I had to ftp to japan (ftp://night.fminn.nagano.nagano.jp/php4/) to obtain the software, but here it is!

 

Installation of namazu/php:

 

Download php4_namazu-2.1.0.tar.gz

 

Build + install php the way you like it

cd /tmp/php-4.1.1

./configure --with-many-options && make && make install

i used: ./configure --with-apxs --with-openssl --with-zlib --with-bz2 --enable-ftp \

--with-gd --with-gettext --with-mysql=/usr --with-jpeg-dir=/usr/include --with-ttf \

--enable-gd-native-ttf --with-png-dir=/usr/include --with-zlib-dir=/usr/include \

--with-xpm-dir=/usr/include --with-freetype-dir=/usr/include/freetype2 \

--with-config-file-path=/etc --with-t1lib=/usr/include

cd ext

 

Extract php4_namazu-2.1.0.tar.gz + install

 

tar xfz /tmp/php4_namazu-2.1.0.tar.gz

cd namazu

phpize

./configure --with-namazu

make && su -c "make install"

 

*** check ext/namazu/sample for source examples!!

 

Check path of namazu.so, has to be in /etc/php.ini

* extension_dir = /usr/local/lib/php/20010901 (or something)

 

Source example:

 

<?

if ( ! extension_loaded('namazu')) {

if ( ! dl('namazu.so')) { die('error'); }

}

$idxname['php'] = "/usr/local/var/namazu/PHP";

# $idxname['somename'] = "/usr/local/var/namazu/idx2";

# $idxname[] = "/usr/local/var/namazu/idx3";

$nmzid = nmz_open($idxname);

$hlist = nmz_search($nmzid, "session");

/* do stuff with the list */

$num = nmz_num_hits($hlist);

$hits = array();

$subject = array();

$fields = array( "subject", "uri", "title", "from", "author", "date", "summary", "size",);

for($i = 0; $i < $num; $i++){

foreach ($fields as $f) {

$val = nmz_result_field($hlist, $i, $f);

$record[$f] = $val;

}

$record['score'] = nmz_result_score($hlist, $i);

$record['uri'] = ereg_replace("$DOCUMENT_ROOT","",$record['uri']);

$hits[] = (object)$record;

}

print "$num hits";

print_r($hits);

nmz_free_result($hlist);

?>

 

 


Get the source!

php4_namazu-2.1.0.tar.gz


Setup Pilot/Evolution sync on RH 8.0
getfreedb - Audio CD listings generator
rpminst - Remote .rpm file installer
PHP + Namazu
PHP5 + Namazu
PHP + ImageMagick
 --  Comments to leening-at-koderz.org