cvs: pear /PECL/namazu Makefile.in README.en README.ja config.m4 php_namazu.c php_namazu.h php_namazu_globals.h /PECL/namazu/sample form.php
search.php search2.php

From: Date: Wed, 09 Jan 2002 09:08:40 +0000
Subject: cvs: pear /PECL/namazu Makefile.in README.en README.ja config.m4 php_namazu.c php_namazu.h php_namazu_globals.h /PECL/namazu/sample form.php
search.php search2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1872@lists.php.net to get a copy of this message
yohgaki Wed Jan 9 04:08:40 2002 EDT Added files: /pear/PECL/namazu Makefile.in README.en README.ja config.m4 php_namazu.c php_namazu.h php_namazu_globals.h /pear/PECL/namazu/sample form.php search.php search2.php Log: Fulltext search engine interface.

Index: pear/PECL/namazu/Makefile.in +++ pear/PECL/namazu/Makefile.in LTLIBRARY_NAME = libnamazu.la LTLIBRARY_SOURCES = php_namazu.c LTLIBRARY_SHARED_NAME = namazu.la LTLIBRARY_SHARED_LIBADD = $(NAMAZU_SHARED_LIBADD) EXTRA_INCLUDES = $(NAMAZU_INCLUDE) include $(top_srcdir)/build/dynlib.mk Index: pear/PECL/namazu/README.en +++ pear/PECL/namazu/README.en PHP4 "namazu" module Namazu is a full-text search system. This module an interface to the Namazu library. PHP is freesoft. The current version is available at http://www.php.net/ Namazu is freesoft. You can find more information at http://www.namazu.org/ * functions bool nmz_set_sortorder(string order) Set the sort order. order : ("ascending" | "descending") Example: nmz_set_sortorder("ascending"); bool nmz_set_sortmethod(string method) Set the sort method. method : ("score" | "date" | "field:{field_name}") Example: nmz_set_sortmethod("field:from"); bool nmz_set_loggingmode(int mode) set "NMZ.slog" output mode. mode : zero => logging off, not zero => logging on Example: nmz_set_loggingmode(0); nmz_set_loggingmode(1); nmz_set_loggingmode(TRUE); nmz_set_loggingmode(FALSE); int nmz_open(mixed index) Open the Namazu index index: index name string or array of string. Example: $idxname[] = "/usr/local/var/namazu/idx1"; $idxname[] = "/usr/local/var/namazu/idx2"; $idxname[] = "/usr/local/var/namazu/idx3"; $nmzid = nmz_open($idxname); bool nmz_close(int identifier) Close the Namazu index identifier: Identifier of index returned by nmz_open(). Example: nmz_close($nmzid); int nmz_search(int identifier, string query) Serch on the Namazu index. identifier: Identifier of index. query : query string Example: $hlist = nmz_search($nmzid, "Namazu"); bool nmz_free_result(int hlist) Free the search result. hlist: Identifier of search result returned by nmz_search(). Example: nmz_free_result($hlist); int nmz_num_hits(int hlist) Get the document count that inculuded in the search result. hlist : Identifier of search result. Example: $num = nmz_num_hits($hlist); int nmz_result_score(int hlist, int row) Returns the score of a document. hlist: Identifier of search result row: row number Example: $score = array(); for($i = 0; $i < $num; $i++){ $score[$i] = nmz_result_score($hlist, $i); } int nmz_result_date(int hlist, int row) Returns the date of a document. hlist : Identifier of search result row : row number Example: $date = array(); for($i = 0; $i < $num; $i++){ $ts = nmz_result_date($hlist, $i); if($ts){ $date[$i] = date('Y/m/d',$ts); }else{ $date[$i] = ''; } } string nmz_result_field(int hlist, int row, string field) Returns the field data of a document. hlist : Identifier of search result row : row number field : field name Example: $subject = array(); for($i = 0; $i < $num; $i++){ $str = nmz_result_field($hlist, $i, "subject"); if($str){ $subject[$i] = htmlspecialchars($str); }else{ $subject[$i] = ''; } } array nmz_fetch_score(int hlist, [int limit]) Fetch score as an enumerated array. hlist : Identifier of search result limit : limit array nmz_fetch_date(int hlist, [int limit]) Fetch date as an enumerated array. hlist : Identifier of search result limit : limit array nmz_fetch_field(int hlist, string field [, int limit]) Fetch field data as an enumerated array. hlist : Identifier of search result field : field name limit : limit array nmz_get_querytoken(int hlist) Get query token. hlist : Identifier of search result * php.ini - namazu.sortorder default sort order ("ascending" | "descending") Example: namazu.sortorder = ascending - namazu.sortmethod default sort method ("score" | "date" | "field:{field_name}") Example: namazu.sortmethod = field:from - namazu.loggingmode default "NMZ.slog" output mode (Off | On) Example: namazu.loggingmode = On * Install - shared module $ tar xzf php-4.X.X_namazu-X.X.tar.gz $ cd namazu $ phpize $ ./configure --with-namazu $ make install - static module in the "php-4.X.X/ext" directory, $ tar xzf php-4.X.X_namazu-X.X.tar.gz $ cd .. $ rm configure $ ./buildconf $ ./configure --with-namazu --other_option $ make install * sample script sample/simple sample/multiindex 2000.5.19 Takuya Tsukada <tsukada@fminn.nagano.nagano.jp> Index: pear/PECL/namazu/README.ja +++ pear/PECL/namazu/README.ja PHP4 "namazu" module Namazu ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¸¡º÷¤Ç¤­¤ë PHP4 ¤Î¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£ PHP ¤Ï¥Õ¥ê¡¼¥½¥Õ¥È¤Ç¤¢¤ê¡¢²¼µ­¤Î¾ì½ê¤«¤éÆþ¼ê²Äǽ¤Ç¤¹¡£ http://www.php.net/ Namazu ¤Ë´Ø¤·¤Æ¤Ï²¼µ­¤Î¾ì½ê¤ò»²¾È²¼¤µ¤¤¡£ http://www.namazu.org/ ¡¦´Ø¿ô bool nmz_set_sortorder(string order) ¾º½ç¡¢¹ß½ç¤Î»ØÄê °ú¿ô¡§ order : ("ascending" | "descending") Ìá¤êÃÍ¡§ ÀßÄ꤬´°Î»¤·¤¿¾ì¹ç¤Ï TRUE ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ nmz_set_sortorder("ascending"); bool nmz_set_sortmethod(string method) ¸¡º÷·ë²Ì¤ÎʤÙÂØ¤¨ÊýË¡¤ò»ØÄê °ú¿ô¡§ method : ÊýË¡¤ò»ØÄꤹ¤ëʸ»úÎó ("score" | "date" | "field:{field_name}") Ìá¤êÃÍ¡§ ÀßÄ꤬´°Î»¤·¤¿¾ì¹ç¤Ï TRUE ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ nmz_set_sortmethod("field:from"); bool nmz_set_loggingmode(int mode) NMZ.slog¤Î½ÐÎÏÀßÄê °ú¿ô¡§ mode : 0 => ½ÐÎϤ·¤Ê¤¤¡¢ 0 °Ê³° => ½ÐÎϤ¹¤ë Ìá¤êÃÍ¡§ ÀßÄ꤬´°Î»¤·¤¿¾ì¹ç¤Ï TRUE ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ nmz_set_loggingmode(0); nmz_set_loggingmode(1); nmz_set_loggingmode(TRUE); nmz_set_loggingmode(FALSE); bool nmz_set_lang(string language) ¸À¸ì¤ÎÀßÄê °ú¿ô¡§ language : ¸À¸ì̾ Ìá¤êÃÍ¡§ ÀßÄ꤬´°Î»¤·¤¿¾ì¹ç¤Ï TRUE ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ nmz_set_lang("ja"); string nmz_get_lang(void) ¸À¸ì¤Î¼èÆÀ °ú¿ô¡§ Ìá¤êÃÍ¡§ ¸À¸ì̾¤òɽ¤¹Ê¸»úÎó¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ echo nmz_get_lang(); string nmz_get_lang_ctype(void) ¸À¸ì¤Î¼èÆÀ °ú¿ô¡§ Ìá¤êÃÍ¡§ ¸À¸ì̾¤òɽ¤¹Ê¸»úÎó¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ echo nmz_get_lang_ctype(); bool nmz_is_lang_ja(void) ¸À¸ì¤¬ÆüËܸ줫 °ú¿ô¡§ Ìá¤êÃÍ¡§ ¸À¸ì¤ÎÀßÄ꤬ÆüËܸì¤Ê¤éTRUE¡¢¤½¤ì°Ê³°¤Ê¤é FALSE ¡£ int nmz_open(mixed index) ¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò³«¤¯ °ú¿ô¡§ index : ¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¼¨¤¹Ê¸»úÎó¤Þ¤¿¤Ï¡¢Ê¸»úÎó¤ÎÇÛÎó Ìá¤êÃÍ¡§ ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¼±Ê̻ҡ£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ $idxname[] = "/usr/local/var/namazu/idx1"; $idxname[] = "/usr/local/var/namazu/idx2"; $idxname[] = "/usr/local/var/namazu/idx3"; $nmzid = nmz_open($idxname); * º£¤Î¤È¤³¤íƱ»þ¤Ë³«¤±¤ë¥¤¥ó¥Ç¥Ã¥¯¥¹·²¤Ï£±¤Ä¤À¤±¤Ç¤¹¡£ bool nmz_close(int identifier) ¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÊĤ¸¤ë °ú¿ô¡§ identifier : ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¼±ÊÌ»Ò ¡Ênmz_open()¤ÎÌá¤êÃÍ¡Ë Ìá¤êÃÍ¡§ ½èÍý¤¬´°Î»¤·¤¿¾ì¹ç¤Ï TRUE ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ nmz_close($nmzid); int nmz_search(int identifier, string query) ¸¡º÷¼°¤Ë°ìÃפ¹¤ëʸ½ñ¤ò¥¤¥ó¥Ç¥Ã¥¯¥¹¾å¤«¤é¸¡º÷¤¹¤ë °ú¿ô¡§ identifier : ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¼±ÊÌ»Ò ¡Ênmz_open()¤ÎÌá¤êÃÍ¡Ë query : ¸¡º÷¼°¤òɽ¤¹Ê¸»úÎó Ìá¤êÃÍ¡§ ¸¡º÷·ë²Ì¤Î¼±Ê̻ҡ£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ $result = nmz_search($nmzid, "Namazu"); bool nmz_free_result(int result) ¸¡º÷·ë²Ì¤ò³«Êü¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò ¡Ênmz_search()¤ÎÌá¤êÃÍ¡Ë Ìá¤êÃÍ¡§ ½èÍý¤¬´°Î»¤·¤¿¾ì¹ç¤Ï TRUE ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ nmz_free_result($result); int nmz_num_hits(int result) ¸¡º÷·ë²Ì¤Ë´Þ¤Þ¤ì¤ëʸ½ñ¿ô¤ò¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò Ìá¤êÃÍ¡§ ʸ½ñ¿ô¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ $num = nmz_num_hits($result); int nmz_result_score(int result, int row) ¸¡º÷·ë²ÌÆâ¤Î»ØÄꤷ¤¿ÈÖ¹æ¤ËÂбþ¤¹¤ëʸ½ñ¤ÎÅÀ¿ô¤ò¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò row : ÈÖ¹æ Ìá¤êÃÍ¡§ ʸ½ñ¤ÎÅÀ¿ô¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ $score = array(); for($i = 0; $i < $num; $i++){ $score[$i] = nmz_result_score($result, $i); } int nmz_result_date(int result, int row) ¸¡º÷·ë²ÌÆâ¤Î»ØÄꤷ¤¿ÈÖ¹æ¤ËÂбþ¤¹¤ëʸ½ñ¤ÎÆüÉÕ¤ò¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò row : ÈÖ¹æ Ìá¤êÃÍ¡§ ʸ½ñ¤ÎÆüÉÕ¤ò¼¨¤¹¿ôÃÍ¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ $date = array(); for($i = 0; $i < $num; $i++){ $ts = nmz_result_date($result, $i); if($ts){ $date[$i] = date('Y/m/d',$ts); }else{ $date[$i] = ''; } } string nmz_result_field(int result, int row, string field) ¸¡º÷·ë²ÌÆâ¤Î»ØÄꤷ¤¿ÈÖ¹æ¤ËÂбþ¤¹¤ëʸ½ñ¤Î¥Õ¥£¡¼¥ë¥ÉÆâÍÆ¤ò¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò row : ÈÖ¹æ field : ¥Õ¥£¡¼¥ë¥É̾ Ìá¤êÃÍ¡§ ¥Õ¥£¡¼¥ë¥ÉÆâÍÆ¤Îʸ»úÎó¡£²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ Îã¡§ $subject = array(); for($i = 0; $i < $num; $i++){ $str = nmz_result_field($result, $i, "subject"); if($str){ $subject[$i] = htmlspecialchars($str); }else{ $subject[$i] = ''; } } array nmz_fetch_score(int result, [int limit[, int offset]]) ¸¡º÷·ë²ÌÆâ¤Î³ÆÊ¸½ñ¤ÎÅÀ¿ô¤òÇÛÎó¤Ç¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò limit : ¼èÆÀ¤¹¤ëʸ½ñ¿ô¤Î¾å¸ÂÃÍ offset : ¼èÆÀ¤¹¤ëÀèÆ¬¤Îʸ½ñ¤ÎÈÖ¹æ Ìá¤êÃÍ¡§ ³ÆÊ¸½ñ¤ÎÅÀ¿ô¤òÍ×ÁǤ˻ý¤ÄÇÛÎó¡£ ²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ array nmz_fetch_date(int result, [int limit[, int offset]]) ¸¡º÷·ë²ÌÆâ¤Î³ÆÊ¸½ñ¤ÎÆüÉÕ¤òÇÛÎó¤Ç¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò limit : ¼èÆÀ¤¹¤ëʸ½ñ¿ô¤Î¾å¸ÂÃÍ offset : ¼èÆÀ¤¹¤ëÀèÆ¬¤Îʸ½ñ¤ÎÈÖ¹æ Ìá¤êÃÍ¡§ ³ÆÊ¸½ñ¤ÎÆüÉÕ¤ò¼¨¤¹¿ôÃͤòÍ×ÁǤ˻ý¤ÄÇÛÎó¡£ ²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ array nmz_fetch_field(int result, string field [int limit[, int offset]]) ¸¡º÷·ë²ÌÆâ¤Î³ÆÊ¸½ñ¤Î¥Õ¥£¡¼¥ë¥ÉÆâÍÆ¤òÇÛÎó¤Ç¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò field : ¥Õ¥£¡¼¥ë¥É̾ limit : ¼èÆÀ¤¹¤ëʸ½ñ¿ô¤Î¾å¸ÂÃÍ offset : ¼èÆÀ¤¹¤ëÀèÆ¬¤Îʸ½ñ¤ÎÈÖ¹æ Ìá¤êÃÍ¡§ ³ÆÊ¸½ñ¤Î¥Õ¥£¡¼¥ë¥ÉÆâÍÆ¤Îʸ»úÎó¤òÍ×ÁǤ˻ý¤ÄÇÛÎó¡£ ²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ array nmz_get_querytoken(int result) ¸¡º÷¼°¤Ë´Þ¤Þ¤ì¤ëñ¸ì¤òÇÛÎó¤Ç¼èÆÀ¤¹¤ë °ú¿ô¡§ result : ¸¡º÷·ë²Ì¤Î¼±ÊÌ»Ò Ìá¤êÃÍ¡§ ʸ»úÎó¤òÍ×ÁǤ˻ý¤ÄÇÛÎó¡£ ²¿¤é¤«¤Î¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï FALSE ¡£ * º£¤Î¤È¤³¤íľÁ°¤Ë¹Ô¤Ã¤¿¸¡º÷¤Ë¤Ä¤¤¤Æ¤Î¤ß¼èÆÀ²Äǽ¤Ç¤¹¡£ string nmz_codeconv_query(string query) ¸¡º÷¼°¤Îʸ»úÎó¤òÊÑ´¹¤¹¤ë °ú¿ô¡§ query : ¸¡º÷¼°¤Îʸ»úÎó Ìá¤êÃÍ¡§ ÊÑ´¹¸å¤Îʸ»úÎó¡£ ¡¦php.ini - namazu.sortorder ¥Ç¥Õ¥©¥ë¥È¤ÎʤÙÂØ¤¨½ç¤ò»ØÄê¡£(descending | ascending) Îã¡§ namazu.sortorder = ascending - namazu.sortmethod ¥Ç¥Õ¥©¥ë¥È¤ÎʤÙÂØ¤¨ÊýË¡¤ò»ØÄê¡£(score | date | field:{field_name}) Îã¡§ namazu.sortmethod = field:from - namazu.loggingmode ¥Ç¥Õ¥©¥ë¥È¤ÎNMZ.slog¤Ø¤Î½ÐÎϤò»ØÄê¡£(Off | On) Îã¡§ namazu.loggingmode = On - namazu.lang ¥Ç¥Õ¥©¥ë¥È¤Î¸À¸ì¤ò»ØÄê¡£ Îã¡§ namazu.lang = ja ¡¦ºî¤êÊý¤Ï¡¢ - ¶¦Í­¥â¥¸¥å¡¼¥ë $ tar xzf php-4.X.X_namazu-X.X.tar.gz $ cd namazu $ phpize $ ./configure --with-namazu $ make install - ÀÅŪ¥â¥¸¥å¡¼¥ë php-4.X.X/ext ¥Ç¥£¥ì¥¯¥È¥ê¤Ç $ tar xzf php-4.X.X_namazu-X.X.tar.gz $ cd .. $ rm configure $ ./buildconf $ ./configure --with-namazu --¤½¤Î¾¥ª¥×¥·¥ç¥ó $ make install ¡¦ ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥µ¡¼¥Ð¡¼¤Ç¤Îưºî¤Ë¤Ä¤¤¤Æ Namazu ¥â¥¸¥å¡¼¥ë¤Ç¤Ï¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤ÎÇÓ¾À©¸æ¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£ ¤³¤Î¥â¥¸¥å¡¼¥ë¤Î´Ø¿ô¤ò»ÈÍѤ¹¤ëÁ°¤Ë¤Ïɬ¤º nmz_open() ¤Ç¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò ¥ª¡¼¥×¥ó¤·¤Æ²¼¤µ¤¤¡£nmz_open() ¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤êÇÓ¾¥í¥Ã¥¯¤¬¤«¤«¤ê¤Þ¤¹¡£ ¥í¥Ã¥¯¤Î²ò½ü¤Ï nmz_cloze() Æâ¤Ç¹Ô¤ï¤ì¤Þ¤¹¡£ ÇÓ¾¥í¥Ã¥¯¤ò¤«¤±¤º¤Ë nmz_set_sortorder() Åù¤Î´Ø¿ô¤ÇÀßÄê¤ò¹Ô¤Ã¤Æ¤â¡¢ ¾¤Î¥¹¥ì¥Ã¥É¤«¤éÀßÄ꤬¾å½ñ¤­¤µ¤ì¤Æ¤·¤Þ¤¦»ö¤¬¤¢¤ê¤¨¤Þ¤¹¡£ °Ê¾å¤ÎÅÀ¤òƧ¤Þ¤¨¤Æ¼ÂºÝ¤Ë¤Ï PHP ¤ò¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¥³¥ó¥Ñ¥¤¥ë¤·¤¿¾ì¹ç¤Ë¤Ï nmz_open() ¤ÎÃæ¤Ç¥Ç¥Õ¥©¥ë¥ÈÃͤؤνé´ü²½¤¬¹Ô¤ï¤ì¤Þ¤¹¡£ ¡¦ ¸À¸ì¤Î»ØÄê¤Ë¤Ä¤¤¤Æ php.ini ¤Î namazu.lang ¤Þ¤¿¤Ï¡¢nmz_set_lang() ´Ø¿ô¤Ç¸À¸ì¤Î»ØÄ꤬½ÐÍè¤Þ¤¹¡£ ¤·¤«¤·¡¢Apache ¤Ê¤É¤Î¥µ¡¼¥Ð¡¼¥â¥¸¥å¡¼¥ë¤È¤·¤Æ PHP ¤ò»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢ ¤³¤ÎÀßÄê¤ò¹Ô¤¦¤ÈÉûºîÍѤ¬½Ð¤ë¾ì¹ç¤â¤¢¤ê¤Þ¤¹¡£ ¤Ç¤¹¤«¤é¡¢¼¡¤Î¤è¤¦¤ÊÊýË¡¤¬Â¾¤Ø¤Î±Æ¶Á¤¬¾¯¤Ê¤¤¤È»×¤¤¤Þ¤¹¡£ <?php /* ¾¤ÎPHP´Ø¿ô¤Îưºî¤ËÂФ·¤Æ¡¢É¬Íפʤé locale ¤ÎÀßÄê¤ò¹Ô¤¦ */ /* setlocale(LC_ALL, "ja_JP.eucJP"); */ /* setlocale(LC_ALL, ""); */ /* ´Ä¶­ÊÑ¿ô¤ò¥»¥Ã¥È */ putenv("LC_CTYPE=ja_JP.eucJP"); putenv("LC_MESSAGES=ja_JP.eucJP"); /* PHP¤Î putenv() ¤Ï½ªÎ»»þ¤Ë´Ä¶­ÊÑ¿ô¤ò¸µ¤ËÌᤷ¤Þ¤¹ */ /* Namazu¥â¥¸¥å¡¼¥ë¤Î´Ø¿ô¤ò»ÈÍѤ¹¤ë */ echo nmz_get_lang(), "<br>\n"; echo nmz_get_lang_ctype(), "<br>\n"; echo nmz_is_lang_ja(), "<br>\n"; ?> ¡¦¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È sample ¤Ë´Êñ¤Ê»ÈÍÑÊýË¡¤Î»²¹Í¤Ë¤Ê¤ë¥¹¥¯¥ê¥×¥È¤¬¤¢¤ê¤Þ¤¹¡£ ¤¿¤À¤·¡¢¤³¤ì¤Ï¼ÂºÝ¤Î±¿ÍѤˤϤ½¤Î¤Þ¤Þ»ÈÍѤ·¤Ê¤¤¤Ç²¼¤µ¤¤¡£ ½ÅÍפÊÉôʬ¤Ï¤¢¤Ê¤¿¼«¿È¤Ç½½Ê¬¸¡Æ¤¤·¡¢½ñ¤­´¹¤¨¤Æ²¼¤µ¤¤¡£ ¡¦ÍúÎò 2000.12.24 Version 2.1.0 - PHP-4.1.0 ¤ËÂбþ¡¢°ÊÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ïư¤­¤Þ¤»¤ó¡£ - nmz_fetch_* ´Ø¿ô¤Î°ú¿ô¤Ë offset ¤òÄɲᣠ(¤¤¤ï¤­¤ê ¤µ¤ó Äó¶¡) - php.ini ¤Ë namazu.lang ¤òÄɲᣠ(¤¤¤ï¤­¤ê ¤µ¤ó Äó¶¡) - ´Ø¿ô¤ÎÄɲà nmz_codeconv_query nmz_set_lang nmz_get_lang nmz_get_lang_ctype nmz_is_lang_ja 2000.8.3 Version 2.0.1 - NMZ.slog ¤Î½ÐÎÏÀßÄê¡¢nmz_set_loggingmode()´Ø¿ôµÚ¤Ó¡¢ php.ini ¤Î namazu.loggingmode - nmz_get_querytoken() ´Ø¿ô¤ÎÄɲà - ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤ÎÇÓ¾À©¸æ 2000.5.19 Version 2.0 ÄÍÅÄ ÂîÌé <tsukada@fminn.nagano.nagano.jp> Index: pear/PECL/namazu/config.m4 +++ pear/PECL/namazu/config.m4 dnl $Id: config.m4,v 1.1 2002/01/09 09:08:39 yohgaki Exp $ dnl config.m4 for extension namazu PHP_ARG_WITH(namazu,for Namazu support, [ --with-namazu[=DIR] Include Namazu support. DIR is the Namazu base install directory, defaults to /usr/local.]) if test "$PHP_NAMAZU" != "no"; then if test "$PHP_NAMAZU" = "yes"; then NAMAZU_INCDIR=/usr/local/include NAMAZU_LIBDIR=/usr/local/lib else NAMAZU_INCDIR=$PHP_NAMAZU/include NAMAZU_LIBDIR=$PHP_NAMAZU/lib fi NAMAZU_INCLUDE="-I$NAMAZU_INCDIR" AC_DEFINE(HAVE_NAMAZU,1,[ ]) PHP_ADD_LIBRARY_WITH_PATH(nmz, $NAMAZU_LIBDIR, NAMAZU_SHARED_LIBADD) PHP_EXTENSION(namazu,$ext_shared) fi PHP_SUBST(NAMAZU_INCLUDE) PHP_SUBST(NAMAZU_SHARED_LIBADD) Index: pear/PECL/namazu/php_namazu.c +++ pear/PECL/namazu/php_namazu.c /* php_namazu.c This program is free software; you can redistribute it and/or modify it under the terms of one of the following licenses: - the GNU General Public License version 2 - the PHP License version 2.02 Auther: Takuya Tsukada <tsukada@fminn.nagano.nagano.jp> History: 2000.5.19 Release 2.0 */ /* $Id $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "namazu/libnamazu.h" #include "namazu/field.h" #include "namazu/hlist.h" #include "namazu/idxname.h" #include "namazu/i18n.h" #include "namazu/l10n-ja.h" #include "namazu/search.h" #include "namazu/query.h" #include "namazu/codeconv.h" #include "php.h" #include "php_ini.h" #include "php_namazu.h" #include "php_namazu_globals.h" #ifdef ZTS #include "TSRM.h" #endif /* True globals, no need for thread safety */ static int le_nmzres; #ifdef ZTS static MUTEX_T php_namazu_lock_id = NULL; #define php_namazu_lock() tsrm_mutex_lock(php_namazu_lock_id) #define php_namazu_unlock() tsrm_mutex_unlock(php_namazu_lock_id) #else #define php_namazu_lock() #define php_namazu_unlock() #endif function_entry namazu_functions[] = { PHP_FE(nmz_set_sortorder, NULL) PHP_FE(nmz_set_sortmethod, NULL) PHP_FE(nmz_set_lang, NULL) PHP_FE(nmz_get_lang, NULL) PHP_FE(nmz_get_lang_ctype, NULL) PHP_FE(nmz_is_lang_ja, NULL) PHP_FE(nmz_set_loggingmode, NULL) PHP_FE(nmz_open, NULL) PHP_FE(nmz_close, NULL) PHP_FE(nmz_search, NULL) PHP_FE(nmz_num_hits, NULL) PHP_FE(nmz_result_score, NULL) PHP_FE(nmz_result_date, NULL) PHP_FE(nmz_result_field, NULL) PHP_FE(nmz_fetch_score, NULL) PHP_FE(nmz_fetch_date, NULL) PHP_FE(nmz_fetch_field, NULL) PHP_FE(nmz_free_result, NULL) PHP_FE(nmz_get_querytoken, NULL) PHP_FE(nmz_codeconv_query, NULL) PHP_FE(nmz_info, NULL) {NULL, NULL, NULL} }; zend_module_entry namazu_module_entry = { STANDARD_MODULE_HEADER, "namazu", namazu_functions, PHP_MODULE_STARTUP_N(namazu), PHP_MODULE_SHUTDOWN_N(namazu), PHP_MODULE_ACTIVATE_N(namazu), PHP_MODULE_DEACTIVATE_N(namazu), PHP_MODULE_INFO_N(namazu), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; ZEND_DECLARE_MODULE_GLOBALS(namazu) #ifdef COMPILE_DL_NAMAZU ZEND_GET_MODULE(namazu) #endif /* hlist destructor */ static void php_namazu_free_hlist(zend_rsrc_list_entry *rsrc TSRMLS_DC) { php_nmzresult_t *result = (php_nmzresult_t *)rsrc->ptr; nmz_free_hlist(result->hlist); efree(result); } /* php.ini */ static PHP_INI_MH(OnUpdate_namazu_sortorder) { if (new_value != NULL) { if (strcasecmp("ascending", new_value) == 0) { NMZG(sortorder) = ASCENDING; } else if (strcasecmp("descending", new_value) == 0) { NMZG(sortorder) = DESCENDING; } else { return FAILURE; } } return SUCCESS; } static PHP_INI_MH(OnUpdate_namazu_sortmethod) { NMZG(sortfield) = (char *)0; if (new_value != NULL) { if (strcasecmp("score", new_value) == 0) { NMZG(sortmethod) = SORT_BY_SCORE; } else if (strcasecmp("date", new_value) == 0) { NMZG(sortmethod) = SORT_BY_DATE; } else if (strncasecmp("field:", new_value, 6) == 0 && new_value_length < BUFSIZE) { NMZG(sortmethod) = SORT_BY_FIELD; NMZG(sortfield) = &new_value[6]; } else { return FAILURE; } } return SUCCESS; } PHP_INI_BEGIN() PHP_INI_ENTRY("namazu.sortorder", NULL, PHP_INI_ALL, OnUpdate_namazu_sortorder) PHP_INI_ENTRY("namazu.sortmethod", NULL, PHP_INI_ALL, OnUpdate_namazu_sortmethod) STD_PHP_INI_ENTRY("namazu.lang", NULL, PHP_INI_ALL, OnUpdateString, lang, zend_namazu_globals, namazu_globals) STD_PHP_INI_BOOLEAN("namazu.loggingmode", "0", PHP_INI_ALL, OnUpdateInt, loggingmode, zend_namazu_globals, namazu_globals) PHP_INI_END() /* module globals initialize */ static void php_namazu_init_globals(zend_namazu_globals *pglobals) { pglobals->status = 0; pglobals->idxcount = 0; pglobals->sortorder = DESCENDING; pglobals->sortmethod = SORT_BY_SCORE; pglobals->sortfield = (char *)0; pglobals->lang = (char *)0; pglobals->loggingmode = 0; } PHP_MODULE_STARTUP_D(namazu) { #ifdef ZTS php_namazu_lock_id = tsrm_mutex_alloc(); #endif ZEND_INIT_MODULE_GLOBALS(namazu, php_namazu_init_globals, NULL); REGISTER_INI_ENTRIES(); le_nmzres = zend_register_list_destructors_ex(php_namazu_free_hlist, NULL, "Namazu result", module_number); return SUCCESS; } PHP_MODULE_SHUTDOWN_D(namazu) { UNREGISTER_INI_ENTRIES(); #ifdef ZTS tsrm_mutex_free(php_namazu_lock_id); php_namazu_lock_id = NULL; #endif return SUCCESS; } PHP_MODULE_ACTIVATE_D(namazu) { NMZG(idxcount) = 0; #ifndef ZTS nmz_set_sortmethod(NMZG(sortmethod)); nmz_set_sortorder(NMZG(sortorder)); nmz_set_loggingmode((int)NMZG(loggingmode)); if (NMZG(sortfield)) { nmz_set_sortfield(NMZG(sortfield)); } if (NMZG(lang)) { if (nmz_set_lang(NMZG(lang)) == NULL) { return FAILURE; } } #endif return SUCCESS; } PHP_MODULE_DEACTIVATE_D(namazu) { if (NMZG(status) & PHP_NAMAZU_STATUS_OPEN) { nmz_free_internal(); php_namazu_unlock(); NMZG(status) &= ~PHP_NAMAZU_STATUS_OPEN; } return SUCCESS; } PHP_MODULE_INFO_D(namazu) { DISPLAY_INI_ENTRIES(); } /* {{{ proto bool nmz_set_sortorder(string order) Set the sort order */ PHP_FUNCTION(nmz_set_sortorder) { zval **arg_order; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_order) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_order); if (strcasecmp("ascending", Z_STRVAL_PP(arg_order)) == 0) { nmz_set_sortorder(ASCENDING); } else if (strcasecmp("descending", Z_STRVAL_PP(arg_order)) == 0) { nmz_set_sortorder(DESCENDING); } else { php_error(E_WARNING, "Illegal argument"); RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool nmz_set_sortmethod(string method) Set the sort method (score, date, field:name) */ PHP_FUNCTION(nmz_set_sortmethod) { zval **arg_method; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_method) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_method); if (strcasecmp("score", Z_STRVAL_PP(arg_method)) == 0) { nmz_set_sortmethod(SORT_BY_SCORE); } else if (strcasecmp("date", Z_STRVAL_PP(arg_method)) == 0) { nmz_set_sortmethod(SORT_BY_DATE); } else if (strncasecmp("field:", Z_STRVAL_PP(arg_method), 6) == 0 && Z_STRLEN_PP(arg_method) < BUFSIZE) { nmz_set_sortmethod(SORT_BY_FIELD); nmz_set_sortfield(&(Z_STRVAL_PP(arg_method)[6])); } else { php_error(E_WARNING, "Illegal argument"); RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool nmz_set_lang(string lang) Set the language */ PHP_FUNCTION(nmz_set_lang) { zval **arg_lang; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_lang) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_lang); if (nmz_set_lang(Z_STRVAL_PP(arg_lang)) == NULL) { RETVAL_FALSE; } else { RETVAL_TRUE; } } /* }}} */ /* {{{ proto string nmz_get_lang(void) Get the language */ PHP_FUNCTION(nmz_get_lang) { char *lang; lang = nmz_get_lang(); if (lang) { RETVAL_STRING(lang, 1); } else { RETVAL_FALSE; } } /* }}} */ /* {{{ proto string nmz_get_lang_ctype(void) Get the language */ PHP_FUNCTION(nmz_get_lang_ctype) { char *lang; lang = nmz_get_lang_ctype(); if (lang) { RETVAL_STRING(lang, 1); } else { RETVAL_FALSE; } } /* }}} */ /* {{{ proto bool nmz_is_lang_ja(void) */ PHP_FUNCTION(nmz_is_lang_ja) { if (nmz_is_lang_ja()) { RETVAL_TRUE; } else { RETVAL_FALSE; } } /* }}} */ /* {{{ proto bool nmz_set_loggingmode(bool mode) Set the logging mode (NMZ.slog) */ PHP_FUNCTION(nmz_set_loggingmode) { zval **arg_mode; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_mode) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(arg_mode); nmz_set_loggingmode((int)Z_LVAL_PP(arg_mode)); RETURN_TRUE; } /* }}} */ /* {{{ proto int nmz_open(mixed index) Open namazu index */ PHP_FUNCTION(nmz_open) { zval **arg_index, **entry; HashTable *target_hash; int i, err; if (NMZG(status) & PHP_NAMAZU_STATUS_OPEN) { php_error(E_WARNING, "Unable to open more than one index group"); RETURN_FALSE; } if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_index) == FAILURE) { WRONG_PARAM_COUNT; } php_namazu_lock(); err = 0; #ifdef ZTS nmz_set_sortmethod(NMZG(sortmethod)); nmz_set_sortorder(NMZG(sortorder)); nmz_set_loggingmode((int)NMZG(loggingmode)); if (NMZG(sortfield)) { nmz_set_sortfield(NMZG(sortfield)); } if (NMZG(lang)) { if (nmz_set_lang(NMZG(lang)) == NULL) { err = 1; } } #endif switch(Z_TYPE_PP(arg_index)) { case IS_ARRAY: target_hash = Z_ARRVAL_PP(arg_index); zend_hash_internal_pointer_reset(target_hash); i = zend_hash_num_elements(target_hash); while (i > 0) { if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) { break; } convert_to_string_ex(entry); if (nmz_add_index(Z_STRVAL_PP(entry)) != SUCCESS) { php_error(E_WARNING, "invalid index name %s", Z_STRVAL_PP(arg_index)); err = 1; break; } zend_hash_move_forward(target_hash); i--; } break; default: convert_to_string_ex(arg_index); if (nmz_add_index(Z_STRVAL_PP(arg_index)) != SUCCESS) { php_error(E_WARNING, "invalid index name %s", Z_STRVAL_PP(arg_index)); err = 1; } break; } if (err) { nmz_free_internal(); php_namazu_unlock(); RETVAL_FALSE; } else { NMZG(status) |= PHP_NAMAZU_STATUS_OPEN; NMZG(idxcount)++; RETVAL_LONG(1); } } /* {{{ proto bool nmz_close(int identifier) Close namazu index */ PHP_FUNCTION(nmz_close) { zval **arg_id; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_id) == FAILURE) { WRONG_PARAM_COUNT; } if (NMZG(status) & PHP_NAMAZU_STATUS_OPEN) { nmz_free_internal(); php_namazu_unlock(); NMZG(status) &= ~PHP_NAMAZU_STATUS_OPEN; } RETURN_TRUE; } /* {{{ proto int nmz_free_result(int result) Free namazu resource */ PHP_FUNCTION(nmz_free_result) { zval **arg_result; php_nmzresult_t *nmzres; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_result) == FAILURE) { WRONG_PARAM_COUNT; } if (Z_TYPE_PP(arg_result) == IS_RESOURCE && Z_LVAL_PP(arg_result) == 0) { RETURN_FALSE; } ZEND_FETCH_RESOURCE(nmzres, php_nmzresult_t *, arg_result, -1, "Namazu result", le_nmzres); zend_list_delete(Z_RESVAL_PP(arg_result)); RETURN_TRUE; } /* }}} */ /* {{{ proto int nmz_search(int identifier, string query) Search on the namazu index */ PHP_FUNCTION(nmz_search) { zval **arg_idxid, **arg_query; php_nmzresult_t *nmzres; if (!(NMZG(status) & PHP_NAMAZU_STATUS_OPEN)) { php_error(E_WARNING, "call nmz_search() befor open the index"); RETURN_FALSE; } if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg_idxid, &arg_query) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_query); nmzres = (php_nmzresult_t *)ecalloc(1, sizeof(php_nmzresult_t)); nmzres->hlist = nmz_search(Z_STRVAL_PP(arg_query)); if (nmzres->hlist.stat == ERR_FATAL) { nmz_free_hlist(nmzres->hlist); efree(nmzres); php_error(E_WARNING, "libnmz: %s", nmz_get_dyingmsg()); RETURN_FALSE; } nmzres->idxcount = NMZG(idxcount); ZEND_REGISTER_RESOURCE(return_value, nmzres, le_nmzres); } /* }}} */ /* {{{ proto int nmz_num_hits(int result) Get number of hits in result */ PHP_FUNCTION(nmz_num_hits) { zval **arg_result; php_nmzresult_t *nmzres; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_result) == FAILURE) { WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(nmzres, php_nmzresult_t *, arg_result, -1, "Namazu result", le_nmzres); if (nmzres->idxcount != NMZG(idxcount)) { php_error(E_WARNING, "Supplied argument is not a result of current index"); RETURN_FALSE; } RETURN_LONG(nmzres->hlist.num); } /* }}} */ static void _php_nmz_result(INTERNAL_FUNCTION_PARAMETERS, int type) { zval **arg_result, **arg_row, **arg_field; php_nmzresult_t *nmzres; char *buf; int i; if (type == 2) { if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg_result, &arg_row, &arg_field) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_field); } else { if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg_result, &arg_row) == FAILURE) { WRONG_PARAM_COUNT; } } ZEND_FETCH_RESOURCE(nmzres, php_nmzresult_t *, arg_result, -1, "Namazu result", le_nmzres); if (nmzres->idxcount != NMZG(idxcount)) { php_error(E_WARNING, "Supplied argument is not a result of current index"); RETURN_FALSE; } convert_to_long_ex(arg_row); i = Z_LVAL_PP(arg_row); if (i < 0 || i >= nmzres->hlist.num) { php_error(E_WARNING, "Invalid row number. (%d)", i); RETURN_FALSE; } switch (type) { case 1: RETVAL_LONG(nmzres->hlist.data[i].date); break; case 2: buf = (char *)emalloc(2*BUFSIZE*sizeof(char)); buf[0] = '\0'; buf[1] = '\0'; nmz_get_field_data(nmzres->hlist.data[i].idxid, nmzres->hlist.data[i].docid, (*arg_field)->value.str.val, buf); RETVAL_STRING(buf, 1); efree(buf); break; default: RETVAL_LONG(nmzres->hlist.data[i].score); break; } } /* {{{ proto int nmz_result_score(int result, int row) Get the score in a result */ PHP_FUNCTION(nmz_result_score) { _php_nmz_result(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ /* {{{ proto int nmz_result_date(int result, int row) Get the date in a result */ PHP_FUNCTION(nmz_result_date) { _php_nmz_result(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ /* {{{ proto string nmz_result_field(int result, int row, string field) Get the field of the specified name in a result */ PHP_FUNCTION(nmz_result_field) { _php_nmz_result(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2); } /* }}} */ static void _php_nmz_fetch_intval(INTERNAL_FUNCTION_PARAMETERS, int type) { zval **arg_result, **arg_limit, **arg_offset; php_nmzresult_t *nmzres; int i, limit, offset; switch(ZEND_NUM_ARGS()) { case 1: if (zend_get_parameters_ex(1, &arg_result) == FAILURE) { RETURN_FALSE; } break; case 2: if (zend_get_parameters_ex(2, &arg_result, &arg_limit) == FAILURE) { RETURN_FALSE; } break; case 3: if (zend_get_parameters_ex(3, &arg_result, &arg_limit, &arg_offset) == FAILURE) { RETURN_FALSE; } break; default: WRONG_PARAM_COUNT; break; } ZEND_FETCH_RESOURCE(nmzres, php_nmzresult_t *, arg_result, -1, "Namazu result", le_nmzres); if (nmzres->idxcount != NMZG(idxcount)) { php_error(E_WARNING, "Supplied argument is not a result of current index"); RETURN_FALSE; } limit = nmzres->hlist.num; offset = 0; if (ZEND_NUM_ARGS() >= 2) { convert_to_long_ex(arg_limit); if (limit > Z_LVAL_PP(arg_limit)) { limit = Z_LVAL_PP(arg_limit); } } if (ZEND_NUM_ARGS() == 3) { convert_to_long_ex(arg_offset); if (limit > Z_LVAL_PP(arg_offset)) { offset = Z_LVAL_PP(arg_offset); } } /* Initialize return array */ if (array_init(return_value) == FAILURE) { RETURN_FALSE; } switch (type) { case 0: for (i = offset; i < limit; i++) { add_next_index_long(return_value, nmzres->hlist.data[i].score); } break; default: for (i = offset; i < limit; i++) { add_next_index_long(return_value, nmzres->hlist.data[i].date); } break; } } /* {{{ proto array nmz_fetch_score(int hlist, [int limit[, int offset]]) Get the score of all row in a result */ PHP_FUNCTION(nmz_fetch_score) { _php_nmz_fetch_intval(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ /* {{{ proto array nmz_fetch_date(int hlist, [int limit[, int offset]]) Get the date of all row in a result */ PHP_FUNCTION(nmz_fetch_date) { _php_nmz_fetch_intval(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ /* {{{ proto array nmz_fetch_field(int hlist, string field [, int limit[, int offset]]) Get the field of all row in a result */ PHP_FUNCTION(nmz_fetch_field) { zval **arg_result, **arg_field, **arg_limit, **arg_offset; php_nmzresult_t *nmzres; char *buf; int i, limit, offset; switch(ZEND_NUM_ARGS()) { case 2: if (zend_get_parameters_ex(2, &arg_result, &arg_field) == FAILURE) { RETURN_FALSE; } break; case 3: if (zend_get_parameters_ex(3, &arg_result, &arg_field, &arg_limit) == FAILURE) { RETURN_FALSE; } break; case 4: if (zend_get_parameters_ex(4, &arg_result, &arg_field, &arg_limit, &arg_offset) == FAILURE) { RETURN_FALSE; } break; default: WRONG_PARAM_COUNT; break; } convert_to_string_ex(arg_field); ZEND_FETCH_RESOURCE(nmzres, php_nmzresult_t *, arg_result, -1, "Namazu result", le_nmzres); if (nmzres->idxcount != NMZG(idxcount)) { php_error(E_WARNING, "Supplied argument is not a result of current index"); RETURN_FALSE; } limit = nmzres->hlist.num; offset = 0; if (ZEND_NUM_ARGS() >= 3) { convert_to_long_ex(arg_limit); if (limit > Z_LVAL_PP(arg_limit)) { limit = Z_LVAL_PP(arg_limit); } } if (ZEND_NUM_ARGS() == 4) { convert_to_long_ex(arg_offset); if (limit > Z_LVAL_PP(arg_offset)) { offset = Z_LVAL_PP(arg_offset); } } /* Initialize return array */ if (array_init(return_value) == FAILURE) { RETURN_FALSE; } buf = (char *)emalloc(2*BUFSIZE*sizeof(char)); for (i = offset; i < limit; i++) { buf[0] = '\0'; buf[1] = '\0'; nmz_get_field_data(nmzres->hlist.data[i].idxid, nmzres->hlist.data[i].docid, (*arg_field)->value.str.val, buf); add_next_index_string(return_value, buf, 1); } efree(buf); } /* }}} */ /* {{{ proto array nmz_get_querytoken(int hlist) Get query tokens as array */ PHP_FUNCTION(nmz_get_querytoken) { zval **arg_hlist; char *query; int i, n; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_hlist) == FAILURE) { WRONG_PARAM_COUNT; } n = nmz_get_querytokennum(); if (n <= 0) { RETURN_FALSE; } /* Initialize return array */ if (array_init(return_value) == FAILURE) { RETURN_FALSE; } for (i = 0; i < n; i++) { query = nmz_get_querytoken(i); if (query) { add_next_index_string(return_value, query, 1); } } } /* }}} */ /* {{{ proto string nmz_codeconv_query(string query) Convert code */ PHP_FUNCTION(nmz_codeconv_query) { zval **arg_query; char *query; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_query) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_query); query = estrndup(Z_STRVAL_PP(arg_query), Z_STRLEN_PP(arg_query)); if (!query) { RETURN_FALSE; } nmz_codeconv_query(query); RETVAL_STRING(query, 0); } /* }}} */ /* {{{ proto void nmz_info(void) Print namazu infomation */ PHP_FUNCTION(nmz_info) { int n; char *p; p = nmz_get_lang(); PUTS("language: "); if (p) { PUTS(p); } PUTS("<br>\n"); n = nmz_get_sortmethod(); PUTS("sort method: "); if (n == SORT_BY_SCORE) { PUTS("score"); } else if (n == SORT_BY_DATE) { PUTS("date"); } else if (n == SORT_BY_FIELD) { PUTS("field:"); PUTS(nmz_get_sortfield()); } PUTS("<br>\n"); n = nmz_get_sortorder(); PUTS("sort order: "); if (n == ASCENDING) { PUTS("ascending"); } else if (n == DESCENDING) { PUTS("descending"); } PUTS("<br>\n"); RETURN_TRUE; } /* }}} */ Index: pear/PECL/namazu/php_namazu.h +++ pear/PECL/namazu/php_namazu.h /* php_namazu.h */ /* $Id $ */ #ifndef _PHP_NAMAZU_H #define _PHP_NAMAZU_H #if HAVE_NAMAZU extern zend_module_entry namazu_module_entry; #define namazu_module_ptr &namazu_module_entry #define PHP_NAMAZU_STATUS_OPEN 0x01 #define PHP_NAMAZU_STATUS_SEARCH 0x10 PHP_MODULE_STARTUP_D(namazu); PHP_MODULE_SHUTDOWN_D(namazu); PHP_MODULE_ACTIVATE_D(namazu); PHP_MODULE_DEACTIVATE_D(namazu); PHP_MODULE_INFO_D(namazu); /* php function registration */ PHP_FUNCTION(nmz_set_sortorder); PHP_FUNCTION(nmz_set_sortmethod); PHP_FUNCTION(nmz_set_lang); PHP_FUNCTION(nmz_get_lang); PHP_FUNCTION(nmz_get_lang_ctype); PHP_FUNCTION(nmz_is_lang_ja); PHP_FUNCTION(nmz_set_loggingmode); PHP_FUNCTION(nmz_open); PHP_FUNCTION(nmz_close); PHP_FUNCTION(nmz_free_result); PHP_FUNCTION(nmz_search); PHP_FUNCTION(nmz_num_hits); PHP_FUNCTION(nmz_result_score); PHP_FUNCTION(nmz_result_date); PHP_FUNCTION(nmz_result_field); PHP_FUNCTION(nmz_fetch_score); PHP_FUNCTION(nmz_fetch_date); PHP_FUNCTION(nmz_fetch_field); PHP_FUNCTION(nmz_get_querytoken); PHP_FUNCTION(nmz_codeconv_query); PHP_FUNCTION(nmz_info); #else #define namazu_module_ptr NULL #endif /* HAVE_NAMAZU */ #define phpext_namazu_ptr namazu_module_ptr #endif /* _PHP_NAMAZU_H */ Index: pear/PECL/namazu/php_namazu_globals.h +++ pear/PECL/namazu/php_namazu_globals.h /* php_namazu_globals.h */ /* $Id: php_namazu_globals.h,v 1.1 2002/01/09 09:08:39 yohgaki Exp $ */ #ifndef _PHP_NAMAZU_GLOBALS_H #define _PHP_NAMAZU_GLOBALS_H typedef struct { int idxcount; NmzResult hlist; } php_nmzresult_t; ZEND_BEGIN_MODULE_GLOBALS(namazu) int status; int idxcount; enum nmz_sortorder sortorder; enum nmz_sortmethod sortmethod; char *sortfield; char *lang; long loggingmode; ZEND_END_MODULE_GLOBALS(namazu); #ifdef ZTS #define NMZG(v) TSRMG(namazu_globals_id, zend_namazu_globals *, v) #else #define NMZG(v) (namazu_globals.v) #endif #endif /* _PHP_NAMAZU_GLOBALS_H */ Index: pear/PECL/namazu/sample/form.php +++ pear/PECL/namazu/sample/form.php <?php /* Namazu ¸¡º÷¥×¥í¥°¥é¥à PHP */ $idxname='/home/nmzidx/namazu-users-ja'; $idxfiles = ''; $idxkeys = ''; $idxdate = ''; $str = $idxname . '/NMZ.status'; $fd = fopen($str,'r'); if ($fd) { $idxfiles = trim(strchr(fgets($fd, 200),' ')); $idxkeys = trim(strchr(fgets($fd, 200),' ')); fclose($fd); $ts = filemtime($str); if ($ts) { $idxdate = date('Y/m/d',$ts); } } header("Content-Type: text/html; charset=EUC-JP"); ?> <html> <head> <title>Namazu a full text retrieval search system</title> </head> <body> <h1>Namazu ¤Ë¤è¤ëÁ´Ê¸¸¡º÷¥·¥¹¥Æ¥à</h1> <p> ¸½ºß¡¢<?php echo $idxfiles; ?> ¤Î¥Õ¥¡¥¤¥ë¤¬¥¤¥ó¥Ç¥Ã¥¯¥¹²½¤µ¤ì¡¢ <?php echo $idxkeys; ?> ¸Ä¤Î¥­¡¼¥ï¡¼¥É¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ </p> <p> <strong>¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎºÇ½ª¹¹¿·Æü: <?php echo $idxdate; ?></strong> </p> <hr> <form method="post" action="search.php"> <p> <strong>¸¡º÷¼°:</strong> <input type="text" name="key" size="40"> <input type="submit" name="submit" value="Search!"> </p> <p> <strong>ɽ¼¨·ï¿ô:</strong> <select name="max"> <option value="10">10 <option selected value="20">20 <option value="30">30 <option value="50">50 <option value="100">100 </select> <strong>ɽ¼¨·Á¼°:</strong> <select name="result"> <option selected value="normal">ɸ½à <option value="short">´Ê·é </select> <strong>¥½¡¼¥È:</strong> <select name="sort"> <option selected value="score">¥¹¥³¥¢ <option value="date:late">ÆüÉÕ (¿·¤·¤¤½ç) <option value="date:early">ÆüÉÕ (¸Å¤¤½ç) <option value="field:subject:ascending">Âê̾ (¾º½ç) <option value="field:subject:descending">Âê̾ (¹ß½ç) <option value="field:from:ascending">Ãø¼Ô (¾º½ç) <option value="field:from:descending">Ãø¼Ô (¹ß½ç) <option value="field:size:ascending">¥µ¥¤¥º (¾º½ç) <option value="field:size:descending">¥µ¥¤¥º (¹ß½ç) <option value="field:uri:ascending">URI (¾º½ç) <option value="field:uri:descending">URI (¹ß½ç) </select> </p> </form> <hr> </body> </html> Index: pear/PECL/namazu/sample/search.php +++ pear/PECL/namazu/sample/search.php <?php /* Namazu ¸¡º÷¥×¥í¥°¥é¥à PHP */ /* global variables for THIS script */ $idxname='/home/nmzidx/namazu-users-ja'; $LF=' '; $formmethod = 'post'; $formaction = $_SERVER['PHP_SELF']; $max = 20; $nmax = 1; $key = ''; $result = ''; $bresult = 1; $nsort = 0; $sort = ''; $nmzid = FALSE; $hlist = FALSE; $nhit = -3; $idxfiles = ''; $idxkeys = ''; $idxdate = ''; $score = FALSE; $summary = FALSE; $subject = FALSE; $size = FALSE; $from = FALSE; $date = FALSE; $uri = FALSE; /* load Namazu module */ if ( ! extension_loaded('namazu')) { if ( ! dl('namazu.so')) { echo 'error'; exit; } } /* Treat HTTP input vars */ if ( ! empty($_POST['key'])) { $key = $_POST['key']; } else if ( ! empty($_GET['key'])) { $key = $_GET['key']; } if ( ! empty($_POST['max'])) { $max = (int)$_POST['max']; } else if ( ! empty($_GET['max'])) { $max = (int)$_GET['max']; } if ( ! empty($_POST['result'])) { $result = $_POST['result']; } else if ( ! empty($_GET['result'])) { $result = $_GET['result']; } if ( ! empty($_POST['sort'])) { $sort = $_POST['sort']; } else if ( ! empty($_GET['sort'])) { $sort = $_GET['sort']; } /* chaeck input variables */ if ($max <= 0) { $max = 20; } if ($max > 1000) { $max = 1000; } if ($max <= 10) { $nmax = 0; } else if($max <= 20) { $nmax = 1; } else if($max <= 30) { $nmax = 2; } else if($max <= 50) { $nmax = 3; } else { $nmax = 4; } if ($result == 'short') { $bresult = 0; } /* open Namazu index */ $nmzid = nmz_open($idxname); /* set search parameter */ nmz_set_sortmethod('score'); nmz_set_sortorder('descending'); if ($sort == 'score') { $nsort = 0; } else if ($sort == 'date:late') { nmz_set_sortmethod('date'); $nsort = 1; } else if ($sort == 'date:early') { nmz_set_sortmethod('date'); nmz_set_sortorder('ascending'); $nsort = 2; } else if ( ! empty($sort)) { $array = explode(':', $sort); if (count($array) >= 3 && $array[0] == 'field') { if ($array[1] == 'subject') { $nsort = 4; nmz_set_sortmethod('field:subject'); } else if ($array[1] == 'from') { $nsort = 6; nmz_set_sortmethod('field:from'); } else if($array[1] == 'size') { $nsort = 8; nmz_set_sortmethod('field:size'); } else { $nsort = 10; nmz_set_sortmethod('field:uri'); } if ($array[2] == 'ascending') { nmz_set_sortorder('ascending'); $nsort--; } } } /* search */ if (empty($key)) { $nhit = -1; $key = ''; } else if (strlen($key) > 200) { $nhit = -2; $key = ''; } else { $nhit = -3; if ($nmzid) { $hlist = nmz_search($nmzid, $key); if ($hlist) { $nhit = nmz_num_hits($hlist); $n = $nhit; if ($n > $max) { $n = $max; } $score = nmz_fetch_score($hlist, $n); $summary = nmz_fetch_field($hlist, 'summary', $n); $subject = nmz_fetch_field($hlist, 'subject', $n); $size = nmz_fetch_field($hlist, 'size', $n); $from = nmz_fetch_field($hlist, 'from', $n); $date = nmz_fetch_field($hlist, 'date', $n); $uri = nmz_fetch_field($hlist, 'uri', $n); nmz_free_result($hlist); } } } if ($nmzid) { nmz_close($nmzid); } /* fetch index statistics */ $str = $idxname . '/NMZ.status'; $fd = fopen($str, 'r'); if ($fd) { $idxfiles = trim(strchr(fgets($fd, 200), ' ')); $idxkeys = trim(strchr(fgets($fd, 200), ' ')); fclose($fd); $ts = filemtime($str); if ($ts) { $idxdate = date('Y/m/d', $ts); } } $selected = 'selected '; $key = htmlspecialchars($key); header("Content-Type: text/html; charset=EUC-JP"); ?> <html> <head> <title>Namazu the full text retrieval search system: &lt;<?php echo $key; ?>&gt;</TITLE> </head> <body> <h1>Namazu ¤Ë¤è¤ëÁ´Ê¸¸¡º÷¥·¥¹¥Æ¥à</h1> <p> ¸½ºß¡¢<?php echo $idxfiles; ?> ¤Î¥Õ¥¡¥¤¥ë¤¬¥¤¥ó¥Ç¥Ã¥¯¥¹²½¤µ¤ì¡¢ <?php echo $idxkeys; ?> ¸Ä¤Î¥­¡¼¥ï¡¼¥É¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ </p> <p> <strong>¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎºÇ½ª¹¹¿·Æü: <?php echo $idxdate; ?></strong> </p> <hr> <form method="<?php echo $formmethod; ?>" action="<?php echo $formaction; ?>"> <p> <strong>¸¡º÷¼°:</strong> <input type="text" name="key" SIZE="40" VALUE="<?php echo $key; ?>"> <input type="submit" name="submit" VALUE="Search!"> </p> <p> <strong>ɽ¼¨·ï¿ô:</strong> <select name="max"> <option <?php if($nmax <= 0){ echo $selected;} ?>value="10">10 <option <?php if($nmax == 1){ echo $selected;} ?>value="20">20 <option <?php if($nmax == 2){ echo $selected;} ?>value="30">30 <option <?php if($nmax == 3){ echo $selected;} ?>value="50">50 <option <?php if($nmax >= 4){ echo $selected;} ?>value="100">100 </select> <strong>ɽ¼¨·Á¼°:</strong> <select name="result"> <option <?php if($bresult){ echo $selected;} ?>value="normal">ɸ½à <option <?php if(!$bresult){ echo $selected;} ?>value="short">´Ê·é </select> <strong>¥½¡¼¥È:</strong> <select name="sort"> <option <?php if($nsort <= 0){ echo $selected;} ?>value="score">¥¹¥³¥¢ <option <?php if($nsort == 1){ echo $selected;} ?>value="date:late">ÆüÉÕ (¿·¤·¤¤½ç) <option <?php if($nsort == 2){ echo $selected;} ?>value="date:early">ÆüÉÕ (¸Å¤¤½ç) <option <?php if($nsort == 3){ echo $selected;} ?>value="field:subject:ascending">Âê̾ (¾º½ç) <option <?php if($nsort == 4){ echo $selected;} ?>value="field:subject:descending">Âê̾ (¹ß½ç) <option <?php if($nsort == 5){ echo $selected;} ?>value="field:from:ascending">Ãø¼Ô (¾º½ç) <option <?php if($nsort == 6){ echo $selected;} ?>value="field:from:descending">Ãø¼Ô (¹ß½ç) <option <?php if($nsort == 7){ echo $selected;} ?>value="field:size:ascending">¥µ¥¤¥º (¾º½ç) <option <?php if($nsort == 8){ echo $selected;} ?>value="field:size:descending">¥µ¥¤¥º (¹ß½ç) <option <?php if($nsort == 9){ echo $selected;} ?>value="field:uri:ascending">URI (¾º½ç) <option <?php if($nsort >= 10){ echo $selected;} ?>value="field:uri:descending">URI (¹ß½ç) </select> </p> </form> <hr> <h2>¸¡º÷·ë²Ì</h2> <?php if ($nhit >= 0) { echo '<p><strong>¸¡º÷¼°¤Ë¥Þ¥Ã¥Á¤¹¤ë ' , $nhit , ' ¸Ä¤Îʸ½ñ¤¬¸«¤Ä¤«¤ê¤Þ¤·¤¿¡£</strong></p>' , $LF; echo '<dl>' , $LF; $n = count($uri); for ($i = 0; $i < $n; $i++){ echo '<dt>' , ($i+1) , '. <strong><a href="' , $uri[$i] , '">' , htmlspecialchars($subject[$i]) , '</a></strong> (score:' , $score[$i] , ')' , $LF , '<dd><strong>From</strong>:<em>' , htmlspecialchars($from[$i]) , '</em><br>' , $LF , '<strong>Date</strong>:<em>' , $date[$i] , '</em><br>' , $LF; if ($bresult) { echo '<dd>' , htmlspecialchars($summary[$i]) , $LF; } echo '<dd> size (' , $size[$i] , ' bytes)<br><br>' , $LF , $LF; } echo '</dl>' , $LF; } else if ($nhit == -1) { echo '<strong>empty query</strong>'; } else if ($nhit == -2) { echo '<strong>too long query</strong>'; } else{ echo '<strong>Search failure</strong>'; } ?> <hr> </html> </body> Index: pear/PECL/namazu/sample/search2.php +++ pear/PECL/namazu/sample/search2.php <?php /* Namazu ¸¡º÷¥×¥í¥°¥é¥à PHP */ /* global variables for THIS script */ $idxname='/home/nmzidx/namazu-users-ja'; $LF=' '; $formmethod = 'post'; $formaction = $_SERVER['PHP_SELF']; $max = 20; $nmax = 1; $key = ''; $result = ''; $bresult = 1; $nsort = 0; $sort = ''; $nmzid = FALSE; $hlist = FALSE; $nhit = -3; $idxfiles = ''; $idxkeys = ''; $idxdate = ''; /* load Namazu module */ if ( ! extension_loaded('namazu')) { if ( ! dl('namazu.so')) { echo 'error'; exit; } } /* Treat HTTP input vars */ if ( ! empty($_POST['key'])) { $key = $_POST['key']; } else if ( ! empty($_GET['key'])) { $key = $_GET['key']; } if ( ! empty($_POST['max'])) { $max = (int)$_POST['max']; } else if ( ! empty($_GET['max'])) { $max = (int)$_GET['max']; } if ( ! empty($_POST['result'])) { $result = $_POST['result']; } else if ( ! empty($_GET['result'])) { $result = $_GET['result']; } if ( ! empty($_POST['sort'])) { $sort = $_POST['sort']; } else if ( ! empty($_GET['sort'])) { $sort = $_GET['sort']; } /* chaeck input variables */ if ($max <= 0) { $max = 20; } if ($max > 1000) { $max = 1000; } if ($max <= 10) { $nmax = 0; } else if($max <= 20) { $nmax = 1; } else if($max <= 30) { $nmax = 2; } else if($max <= 50) { $nmax = 3; } else { $nmax = 4; } if ($result == 'short') { $bresult = 0; } /* open Namazu index */ $nmzid = nmz_open($idxname); /* set search parameter */ nmz_set_sortmethod('score'); nmz_set_sortorder('descending'); if ($sort == 'score') { $nsort = 0; } else if ($sort == 'date:late') { nmz_set_sortmethod('date'); $nsort = 1; } else if ($sort == 'date:early') { nmz_set_sortmethod('date'); nmz_set_sortorder('ascending'); $nsort = 2; } else if ( ! empty($sort)) { $array = explode(':', $sort); if (count($array) >= 3 && $array[0] == 'field') { if ($array[1] == 'subject') { $nsort = 4; nmz_set_sortmethod('field:subject'); } else if ($array[1] == 'from') { $nsort = 6; nmz_set_sortmethod('field:from'); } else if($array[1] == 'size') { $nsort = 8; nmz_set_sortmethod('field:size'); } else { $nsort = 10; nmz_set_sortmethod('field:uri'); } if ($array[2] == 'ascending') { nmz_set_sortorder('ascending'); $nsort--; } } } /* search */ if (empty($key)) { $nhit = -1; $key = ''; } else if (strlen($key) > 200) { $nhit = -2; $key = ''; } else { $nhit = -3; if ($nmzid) { $hlist = nmz_search($nmzid, $key); if ($hlist) { $nhit = nmz_num_hits($hlist); } } } /* fetch index statistics */ $str = $idxname . '/NMZ.status'; $fd = fopen($str, 'r'); if ($fd) { $idxfiles = trim(strchr(fgets($fd, 200), ' ')); $idxkeys = trim(strchr(fgets($fd, 200), ' ')); fclose($fd); $ts = filemtime($str); if ($ts) { $idxdate = date('Y/m/d', $ts); } } $selected = 'selected '; $key = htmlspecialchars($key); header("Content-Type: text/html; charset=EUC-JP"); ?> <html> <head> <title>Namazu the full text retrieval search system: &lt;<?php echo $key; ?>&gt;</TITLE> </head> <body> <h1>Namazu ¤Ë¤è¤ëÁ´Ê¸¸¡º÷¥·¥¹¥Æ¥à</h1> <p> ¸½ºß¡¢<?php echo $idxfiles; ?> ¤Î¥Õ¥¡¥¤¥ë¤¬¥¤¥ó¥Ç¥Ã¥¯¥¹²½¤µ¤ì¡¢ <?php echo $idxkeys; ?> ¸Ä¤Î¥­¡¼¥ï¡¼¥É¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ </p> <p> <strong>¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎºÇ½ª¹¹¿·Æü: <?php echo $idxdate; ?></strong> </p> <hr> <form method="<?php echo $formmethod; ?>" action="<?php echo $formaction; ?>"> <p> <strong>¸¡º÷¼°:</strong> <input type="text" name="key" SIZE="40" VALUE="<?php echo $key; ?>"> <input type="submit" name="submit" VALUE="Search!"> </p> <p> <strong>ɽ¼¨·ï¿ô:</strong> <select name="max"> <option <?php if($nmax <= 0){ echo $selected;} ?>value="10">10 <option <?php if($nmax == 1){ echo $selected;} ?>value="20">20 <option <?php if($nmax == 2){ echo $selected;} ?>value="30">30 <option <?php if($nmax == 3){ echo $selected;} ?>value="50">50 <option <?php if($nmax >= 4){ echo $selected;} ?>value="100">100 </select> <strong>ɽ¼¨·Á¼°:</strong> <select name="result"> <option <?php if($bresult){ echo $selected;} ?>value="normal">ɸ½à <option <?php if(!$bresult){ echo $selected;} ?>value="short">´Ê·é </select> <strong>¥½¡¼¥È:</strong> <select name="sort"> <option <?php if($nsort == 0){ echo $selected;} ?>value="score">¥¹¥³¥¢ <option <?php if($nsort == 1){ echo $selected;} ?>value="date:late">ÆüÉÕ (¿·¤·¤¤½ç) <option <?php if($nsort == 2){ echo $selected;} ?>value="date:early">ÆüÉÕ (¸Å¤¤½ç) <option <?php if($nsort == 3){ echo $selected;} ?>value="field:subject:ascending">Âê̾ (¾º½ç) <option <?php if($nsort == 4){ echo $selected;} ?>value="field:subject:descending">Âê̾ (¹ß½ç) <option <?php if($nsort == 5){ echo $selected;} ?>value="field:from:ascending">Ãø¼Ô (¾º½ç) <option <?php if($nsort == 6){ echo $selected;} ?>value="field:from:descending">Ãø¼Ô (¹ß½ç) <option <?php if($nsort == 7){ echo $selected;} ?>value="field:size:ascending">¥µ¥¤¥º (¾º½ç) <option <?php if($nsort == 8){ echo $selected;} ?>value="field:size:descending">¥µ¥¤¥º (¹ß½ç) <option <?php if($nsort == 9){ echo $selected;} ?>value="field:uri:ascending">URI (¾º½ç) <option <?php if($nsort == 10){ echo $selected;} ?>value="field:uri:descending">URI (¹ß½ç) </select> </p> </form> <hr> <h2>¸¡º÷·ë²Ì</h2> <?php if ($nhit >= 0) { echo '<p><strong>¸¡º÷¼°¤Ë¥Þ¥Ã¥Á¤¹¤ë ' , $nhit , ' ¸Ä¤Îʸ½ñ¤¬¸«¤Ä¤«¤ê¤Þ¤·¤¿¡£</strong></p>' , $LF; $n = $nhit; if ($n > $max) { $n = $max; } echo '<dl>' , $LF; for ($i = 0; $i < $n; $i++){ echo '<dt>' , ($i+1) , '. <strong><a href="' , nmz_result_field($hlist,$i,'uri') , '">' , htmlspecialchars(nmz_result_field($hlist,$i,'subject')) , '</a></strong> (score:' , nmz_result_score($hlist,$i) , ')' , $LF , '<dd><strong>From</strong>:<em>' , htmlspecialchars(nmz_result_field($hlist,$i,'from')) , '</em><br>' , $LF , '<strong>Date</strong>:<em>' , nmz_result_field($hlist,$i,'date') , '</em><br>' , $LF; if ($bresult) { echo '<dd>' , htmlspecialchars(nmz_result_field($hlist,$i,'summary')) , $LF; } echo '<dd> size (' , nmz_result_field($hlist,$i,'size') , ' bytes)<br><br>' , $LF , $LF; } echo '</dl>' , $LF; } else if ($nhit == -1) { echo '<strong>empty query</strong>'; } else if ($nhit == -2) { echo '<strong>too long query</strong>'; } else { echo '<strong>Search failure</strong>'; } if ( ! empty($hlist)) { nmz_free_result($hlist); } if ( ! empty($nmzid)) { nmz_close($nmzid); } ?> <hr> </html> </body>
« previous php.pear.cvs (#1872) next »