From: foobar Date: Sun, 6 Mar 2005 19:24:21 +0000 (+0000) Subject: - Moved ext/fam and ext/mnogosearch to PECL X-Git-Tag: RELEASE_0_3~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d6e939f9b49d98b735ac6ed6bcf721ac32b8a27;p=php - Moved ext/fam and ext/mnogosearch to PECL --- diff --git a/NEWS b/NEWS index a034411dc6..83397e4a7f 100644 --- a/NEWS +++ b/NEWS @@ -2,10 +2,12 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2004, PHP 5.1.0 - Moved extensions to PECL: - . ext/dio (Jani, Derick) - . ext/yp (Jani, Derick) - . ext/w32api (Jani, Derick) - . ext/cpdf (Tony, Derick) + . ext/cpdf (Tony, Derick) + . ext/dio (Jani, Derick) + . ext/fam (Jani, Derick) + . ext/mnogosearch (Jani, Derick) + . ext/w32api (Jani, Derick) + . ext/yp (Jani, Derick) - Changed stream_filter_(ap|pre)pend() to return resource. (Sara) - Changed mysqli_exception and sqlite_exception to use RuntimeException as base if SPL extension is present. (Georg, Marcus) diff --git a/ext/fam/CREDITS b/ext/fam/CREDITS deleted file mode 100644 index 60e3234a4c..0000000000 --- a/ext/fam/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -fam -Sascha Schumann diff --git a/ext/fam/config.m4 b/ext/fam/config.m4 deleted file mode 100644 index 63a6efcdfa..0000000000 --- a/ext/fam/config.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension fam - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. - -dnl If your extension references something external, use with: - -PHP_ARG_WITH(fam, for fam support, -[ --with-fam Include fam support]) - -if test "$PHP_FAM" != "no"; then - dnl Write more examples of tests here... - - dnl # --with-fam -> check with-path -SEARCH_PATH="/usr/local /usr" # you might want to change this -SEARCH_FOR="/include/fam.h" # you most likely want to change this -if test -r $PHP_FAM/$SEARCH_FOR; then # path given as parameter - FAM_DIR=$PHP_FAM -else # search default path list - AC_MSG_CHECKING([for fam files in default path]) - for i in $SEARCH_PATH ; do - if test -r $i/$SEARCH_FOR; then - FAM_DIR=$i - AC_MSG_RESULT(found in $i) - fi - done -fi - -if test -z "$FAM_DIR"; then - AC_MSG_RESULT([not found]) - AC_MSG_ERROR([Please reinstall the fam distribution]) -fi - -# --with-fam -> add include path -PHP_ADD_INCLUDE($FAM_DIR/include) - -# --with-fam -> chech for lib and symbol presence -LIBNAME=fam # you may want to change this -LIBSYMBOL=FAMOpen # you most likely want to change this - -PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, -[ - PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $FAM_DIR/$PHP_LIBDIR, FAM_SHARED_LIBADD) - AC_DEFINE(HAVE_FAMLIB,1,[ ]) -],[ - AC_MSG_ERROR([wrong fam lib version or lib not found]) -],[ - -L$FAM_DIR/$PHP_LIBDIR -lm -ldl -]) - -PHP_SUBST(FAM_SHARED_LIBADD) - - PHP_NEW_EXTENSION(fam, fam.c, $ext_shared) -fi diff --git a/ext/fam/fam.c b/ext/fam/fam.c deleted file mode 100644 index 24e3395e3b..0000000000 --- a/ext/fam/fam.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_fam.h" - -#include - -/* If you declare any globals in php_fam.h uncomment this: -ZEND_DECLARE_MODULE_GLOBALS(fam) -*/ - -/* True global resources - no need for thread safety here */ -static int le_fam, le_fam_r; - -/* {{{ fam_functions[] - * - * Every user visible function must have an entry in fam_functions[]. - */ -function_entry fam_functions[] = { - PHP_FE(fam_open, NULL) - PHP_FE(fam_close, NULL) - PHP_FE(fam_monitor_directory, NULL) - PHP_FE(fam_monitor_file, NULL) - PHP_FE(fam_monitor_collection, NULL) - PHP_FE(fam_suspend_monitor, NULL) - PHP_FE(fam_resume_monitor, NULL) - PHP_FE(fam_cancel_monitor, NULL) - PHP_FE(fam_pending, NULL) - PHP_FE(fam_next_event, NULL) - {NULL, NULL, NULL} /* Must be the last line in fam_functions[] */ -}; -/* }}} */ - -/* {{{ fam_module_entry - */ -zend_module_entry fam_module_entry = { -#if ZEND_MODULE_API_NO >= 20010901 - STANDARD_MODULE_HEADER, -#endif - "fam", - fam_functions, - PHP_MINIT(fam), - NULL, - NULL, - NULL, - PHP_MINFO(fam), -#if ZEND_MODULE_API_NO >= 20010901 - "0.1", /* Replace with version number for your extension */ -#endif - STANDARD_MODULE_PROPERTIES -}; -/* }}} */ - -#ifdef COMPILE_DL_FAM -ZEND_GET_MODULE(fam) -#endif - -/* {{{ php_fam_init_globals - */ -/* Uncomment this function if you have INI entries -static void php_fam_init_globals(zend_fam_globals *fam_globals) -{ - fam_globals->global_value = 0; - fam_globals->global_string = NULL; -} -*/ -/* }}} */ - -static void rsrc_close_fam(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - FAMConnection *fc = (FAMConnection *) rsrc->ptr; - FAMClose(fc); - efree(fc); -} - -static void rsrc_close_fam_r(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - /* No need to close */ - efree(rsrc->ptr); -} - -/* {{{ PHP_MINIT_FUNCTION - */ -PHP_MINIT_FUNCTION(fam) -{ - le_fam = zend_register_list_destructors_ex(rsrc_close_fam, NULL, "fam connections", module_number); - le_fam_r = zend_register_list_destructors_ex(rsrc_close_fam_r, NULL, "fam requests", module_number); - /* If you have INI entries, uncomment these lines - ZEND_INIT_MODULE_GLOBALS(fam, php_fam_init_globals, NULL); - REGISTER_INI_ENTRIES(); - */ - - - REGISTER_LONG_CONSTANT("FAMChanged", FAMChanged, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMDeleted", FAMDeleted, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMStartExecuting", FAMStartExecuting, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMStopExecuting", FAMStopExecuting, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMCreated", FAMCreated, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMMoved", FAMMoved, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMAcknowledge", FAMAcknowledge, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMExists", FAMExists, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FAMEndExist", FAMEndExist, CONST_PERSISTENT); - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION - */ -PHP_MINFO_FUNCTION(fam) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "fam support", "enabled"); - php_info_print_table_end(); - - /* Remove comments if you have entries in php.ini - DISPLAY_INI_ENTRIES(); - */ -} -/* }}} */ - - -/* {{{ proto resource fam_open([string appname]) - Open FAM connection */ -PHP_FUNCTION(fam_open) -{ - char *appname = NULL; - int argc = ZEND_NUM_ARGS(); - int appname_len; - FAMConnection *fc; - int r; - - if (zend_parse_parameters(argc TSRMLS_CC, "|s", &appname, &appname_len) == FAILURE) - return; - - fc = emalloc(sizeof *fc); - r = FAMOpen2(fc, appname); - - if (r < 0) { - efree(fc); - RETURN_FALSE; - } - - ZEND_REGISTER_RESOURCE(return_value, fc, le_fam); -} -/* }}} */ - -/* {{{ proto void fam_close(resource id) - Close FAM connection */ -PHP_FUNCTION(fam_close) -{ - int argc = ZEND_NUM_ARGS(); - zval *id; - - if (zend_parse_parameters(argc TSRMLS_CC, "r", &id) == FAILURE) - return; - - zend_list_delete(Z_RESVAL_P(id)); -} -/* }}} */ - -/* {{{ proto resource fam_monitor_directory(resource id, string dirname) - Monitor a directory for changes */ -PHP_FUNCTION(fam_monitor_directory) -{ - char *dirname = NULL; - int argc = ZEND_NUM_ARGS(); - int dirname_len; - zval *id; - FAMRequest *fr; - FAMConnection *fc; - - if (zend_parse_parameters(argc TSRMLS_CC, "rs", &id, &dirname, &dirname_len) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - - fr = emalloc(sizeof *fr); - - if (FAMMonitorDirectory(fc, dirname, fr, NULL) < 0) { - efree(fr); - RETURN_FALSE; - } - - ZEND_REGISTER_RESOURCE(return_value, fr, le_fam_r); -} -/* }}} */ - -/* {{{ proto resource fam_monitor_file(resource id, string filename) - Monitor a regular file for changes */ -PHP_FUNCTION(fam_monitor_file) -{ - char *filename = NULL; - int argc = ZEND_NUM_ARGS(); - int filename_len; - zval *id; - FAMRequest *fr; - FAMConnection *fc; - - if (zend_parse_parameters(argc TSRMLS_CC, "rs", &id, &filename, &filename_len) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - - fr = emalloc(sizeof *fr); - - if (FAMMonitorFile(fc, filename, fr, NULL) < 0) { - efree(fr); - RETURN_FALSE; - } - - ZEND_REGISTER_RESOURCE(return_value, fr, le_fam_r); -} -/* }}} */ - -/* {{{ proto resource fam_monitor_collection(resource id, string dirname, int depth, string mask) - Monitor a collection of files in a directory for changes */ -PHP_FUNCTION(fam_monitor_collection) -{ - char *dirname = NULL; - char *mask = NULL; - int argc = ZEND_NUM_ARGS(); - int dirname_len; - int mask_len; - zval *id; - long depth; - FAMRequest *fr; - FAMConnection *fc; - - if (zend_parse_parameters(argc TSRMLS_CC, "rsls", &id, &dirname, &dirname_len, &depth, &mask, &mask_len) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - - fr = emalloc(sizeof *fr); - - if (FAMMonitorCollection(fc, dirname, fr, NULL, depth, mask) < 0) { - efree(fr); - RETURN_FALSE; - } - - ZEND_REGISTER_RESOURCE(return_value, fr, le_fam_r); - -} -/* }}} */ - -/* {{{ proto bool fam_suspend_monitor(resource id, resource monitor_id) - Temporary suspend monitoring */ -PHP_FUNCTION(fam_suspend_monitor) -{ - int argc = ZEND_NUM_ARGS(); - zval *id; - zval *monitor_id; - FAMRequest *fr; - FAMConnection *fc; - - if (zend_parse_parameters(argc TSRMLS_CC, "rr", &id, &monitor_id) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - ZEND_FETCH_RESOURCE(fr, FAMRequest *, &monitor_id, -1, "fam", le_fam_r); - ZEND_VERIFY_RESOURCE(fr); - - if (FAMSuspendMonitor(fc, fr) < 0) - RETURN_FALSE; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool fam_resume_monitor(resource id, resource monitor_id) - Resume suspended monitoring */ -PHP_FUNCTION(fam_resume_monitor) -{ - int argc = ZEND_NUM_ARGS(); - zval *id; - zval *monitor_id; - FAMRequest *fr; - FAMConnection *fc; - - if (zend_parse_parameters(argc TSRMLS_CC, "rr", &id, &monitor_id) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - ZEND_FETCH_RESOURCE(fr, FAMRequest *, &monitor_id, -1, "fam", le_fam_r); - ZEND_VERIFY_RESOURCE(fr); - - if (FAMResumeMonitor(fc, fr) < 0) - RETURN_FALSE; - RETURN_TRUE; - -} -/* }}} */ - -/* {{{ proto bool fam_cancel_monitor(resource id, resource monitor_id) - Terminate monitoring */ -PHP_FUNCTION(fam_cancel_monitor) -{ - int argc = ZEND_NUM_ARGS(); - zval *id; - zval *monitor_id; - FAMRequest *fr; - FAMConnection *fc; - int r; - - if (zend_parse_parameters(argc TSRMLS_CC, "rr", &id, &monitor_id) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - ZEND_FETCH_RESOURCE(fr, FAMRequest *, &monitor_id, -1, "fam", le_fam_r); - ZEND_VERIFY_RESOURCE(fr); - - r = FAMCancelMonitor(fc, fr); - - zend_list_delete(Z_RESVAL_P(monitor_id)); - - if (r < 0) - RETURN_FALSE; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int fam_pending(resource id) - Check for pending FAM events */ -PHP_FUNCTION(fam_pending) -{ - int argc = ZEND_NUM_ARGS(); - zval *id; - FAMConnection *fc; - - if (zend_parse_parameters(argc TSRMLS_CC, "r", &id) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - - RETVAL_LONG(FAMPending(fc)); -} -/* }}} */ - -/* {{{ proto array fam_next_event(resource id) - Get next pending FAM event */ -PHP_FUNCTION(fam_next_event) -{ - int argc = ZEND_NUM_ARGS(); - zval *id; - FAMConnection *fc; - FAMEvent fe; - - if (zend_parse_parameters(argc TSRMLS_CC, "r", &id) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(fc, FAMConnection *, &id, -1, "fam", le_fam); - ZEND_VERIFY_RESOURCE(fc); - - if (FAMNextEvent(fc, &fe) < 0) - RETURN_FALSE; - - array_init(return_value); - if (fe.hostname) - add_assoc_string(return_value, "hostname", fe.hostname, 1); - add_assoc_string(return_value, "filename", fe.filename, 1); - add_assoc_long(return_value, "code", fe.code); -} -/* }}} */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/fam/package.xml b/ext/fam/package.xml deleted file mode 100644 index 41f46b8a65..0000000000 --- a/ext/fam/package.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - fam - File Alteration Monitor Functions - - - sas - Sascha Schumann - sascha@schumann.cx - lead - - - -FAM monitors files and directories, notifying interested -applications of changes. -A PHP script may specify a list of files for FAM to monitor -using the functions provided by this extension. -The FAM process is started when the first connection from -any application to it is opened. It exits after all -connections to it have been closed. - - PHP - - beta - 5.0.0rc1 - 2004-03-19 - -package.xml added to support intallation using pear installer - - - - - - - - - - - - - - - - - diff --git a/ext/fam/php_fam.h b/ext/fam/php_fam.h deleted file mode 100644 index 28c4e97851..0000000000 --- a/ext/fam/php_fam.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifndef PHP_FAM_H -#define PHP_FAM_H - -extern zend_module_entry fam_module_entry; -#define phpext_fam_ptr &fam_module_entry - -#ifdef PHP_WIN32 -#define PHP_FAM_API __declspec(dllexport) -#else -#define PHP_FAM_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -PHP_MINIT_FUNCTION(fam); -PHP_MINFO_FUNCTION(fam); - -PHP_FUNCTION(fam_open); -PHP_FUNCTION(fam_close); -PHP_FUNCTION(fam_monitor_directory); -PHP_FUNCTION(fam_monitor_file); -PHP_FUNCTION(fam_monitor_collection); -PHP_FUNCTION(fam_suspend_monitor); -PHP_FUNCTION(fam_resume_monitor); -PHP_FUNCTION(fam_cancel_monitor); -PHP_FUNCTION(fam_pending); -PHP_FUNCTION(fam_next_event); - -/* - Declare any global variables you may need between the BEGIN - and END macros here: - -ZEND_BEGIN_MODULE_GLOBALS(fam) - int global_value; - char *global_string; -ZEND_END_MODULE_GLOBALS(fam) -*/ - -/* In every utility function you add that needs to use variables - in php_fam_globals, call TSRM_FETCH(); after declaring other - variables used by that function, or better yet, pass in TSRMLS_CC - after the last function argument and declare your utility function - with TSRMLS_DC after the last declared argument. Always refer to - the globals in your function as FAM_G(variable). You are - encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ - -#ifdef ZTS -#define FAM_G(v) TSRMG(fam_globals_id, zend_fam_globals *, v) -#else -#define FAM_G(v) (fam_globals.v) -#endif - -#endif /* PHP_FAM_H */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - */ diff --git a/ext/mnogosearch/CREDITS b/ext/mnogosearch/CREDITS deleted file mode 100644 index 3ab998a1da..0000000000 --- a/ext/mnogosearch/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -mnoGoSearch -Sergey Kartashoff, Alex Barkov, Ramil Kalimullin diff --git a/ext/mnogosearch/README b/ext/mnogosearch/README deleted file mode 100644 index 2b4315796e..0000000000 --- a/ext/mnogosearch/README +++ /dev/null @@ -1,24 +0,0 @@ -$Source$ -$Id$ - -mnoGoSearch extension module for PHP. - -For details please refer to http://www.mnogosearch.org/ - -If used with mysql you should not use bundled mysql library -in the php distribution. You should use native mysql -library. To do this you should compile php with specefying mysql-dir -(for example --with-mysql=/usr, not --with-mysql). - -To compile PHP with CVS versions of mnogosearch (not with official releases) -you must open configure script of mnogosearch in your editor. Find -line like the following: - -VERSION=x.x.x-`date "+%d%m%Y"` - -where x.x.x is the mnogosearch version number like 3.2.16 or so. -Then just remove -`date "+%d%m%Y"`. After that this line should be -VERSION=x.x.x - -After complete you should reconfigure, recompile, reinstall mnogosearch and -php. diff --git a/ext/mnogosearch/config.m4 b/ext/mnogosearch/config.m4 deleted file mode 100644 index 497838fbc4..0000000000 --- a/ext/mnogosearch/config.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl -dnl $Source$ -dnl $Id$ -dnl - -PHP_ARG_WITH(mnogosearch,for mnoGoSearch support, -[ --with-mnogosearch[=DIR] - Include mnoGoSearch support. DIR is the mnoGoSearch - base install directory, defaults to /usr/local/mnogosearch.]) - - if test "$PHP_MNOGOSEARCH" != "no"; then - - if test "$PHP_MNOGOSEARCH" = "yes"; then - MNOGOSEARCH_BINDIR=/usr/local/mnogosearch/bin - MNOGOSEARCH_INCDIR=/usr/local/mnogosearch/include - MNOGOSEARCH_LIBDIR=/usr/local/mnogosearch/lib - else - MNOGOSEARCH_BINDIR=$PHP_MNOGOSEARCH/bin - MNOGOSEARCH_INCDIR=$PHP_MNOGOSEARCH/include - MNOGOSEARCH_LIBDIR=$PHP_MNOGOSEARCH/lib - fi - - AC_MSG_CHECKING(for mnoGoSearch version) - - if test -x "$MNOGOSEARCH_BINDIR/udm-config"; then - MNOGOSEARCH_VERSION=`$MNOGOSEARCH_BINDIR/udm-config --version` - MNOGOSEARCH_VERSION_ID=`$MNOGOSEARCH_BINDIR/udm-config --version-id` - - if test $? -ne 0; then - AC_MSG_RESULT(<= 3.1.9) - AC_MSG_ERROR(mnoGoSearch 3.1.10 at least required) - fi - - if test "$MNOGOSEARCH_VERSION_ID" -lt 30110; then - AC_MSG_RESULT(<= 3.1.9) - AC_MSG_ERROR(mnoGoSearch 3.1.10 at least required) - fi - - AC_MSG_RESULT($MNOGOSEARCH_VERSION) - - PHP_EVAL_LIBLINE(`$MNOGOSEARCH_BINDIR/udm-config --libs`, MNOGOSEARCH_SHARED_LIBADD) - else - AC_MSG_ERROR(udm-config script not found in $MNOGOSEARCH_BINDIR) - fi - - PHP_ADD_INCLUDE($MNOGOSEARCH_INCDIR) - - AC_DEFINE(HAVE_MNOGOSEARCH,1,[ ]) - - PHP_NEW_EXTENSION(mnogosearch, php_mnogo.c, $ext_shared) - PHP_SUBST(MNOGOSEARCH_SHARED_LIBADD) - - fi diff --git a/ext/mnogosearch/index.php b/ext/mnogosearch/index.php deleted file mode 100644 index 40cde6264f..0000000000 --- a/ext/mnogosearch/index.php +++ /dev/null @@ -1,1055 +0,0 @@ -, - * mnoGoSearch Developers Team - */ - -if (!extension_loaded('mnogosearch')) { - print "This script requires PHP 4.0.5+ with mnoGoSearch extension"; - exit; -} - -// maximal page number to view -$MAX_NP=1000; - -// maximum results per page -$MAX_PS=100; - -// (optional) Enable autowild feature for url limits -// 'yes' - default value, can be 'yes' or 'no' -// $auto_wild='yes'; - -/* variables section */ - -if (Udm_Api_Version() >= 30204) { - $dbaddr='mysql://mnogo:mnogo@/mnogo/?dbmode=single'; -} else { - $dbaddr='mysql://mnogo:mnogo@/mnogo/'; - $dbmode='single'; -} - -$localcharset='koi8-r'; -$browsercharset='utf-8'; -$phrase=$cache=$crosswords='no'; -$ispelluseprefixes=$trackquery='no'; -$spell_host=$vardir=$datadir=''; -$ispellmode='text'; - -$affix_file=array(); -$spell_file=array(); -$stopwordtable_arr=array(); -$stopwordfile_arr=array(); -$synonym_arr=array(); -$searchd_arr=array(); - -// $affix_file['en']='/opt/udm/ispell/en.aff'; -// $affix_file['ru']='/opt/udm/ispell/ru.aff'; -// $spell_file['en']='/opt/udm/ispell/en.dict'; -// $spell_file['ru']='/opt/udm/ispell/ru.dict'; - $stopwordtable_arr[]='stopword'; -// $stopwordfile_arr[]='stopwords.txt'; -// $synonym_arr[]='/opt/udm/synonym/english.syn'; -$searchd_arr[]='localhost'; - -$minwordlength=1; -$maxwordlength=32; - -$storedocurl="/cgi-bin/storedoc.cgi"; - -/* initialisation section */ - -if(isset($HTTP_GET_VARS)){ - while(list($var, $val)=each($HTTP_GET_VARS)){ - $$var=$val; - } -} -if(isset($HTTP_POST_VARS)){ - while(list($var, $val)=each($HTTP_POST_VARS)){ - $$var=$val; - } -} -if(isset($HTTP_COOKIE_VARS)){ - while(list($var, $val)=each($HTTP_COOKIE_VARS)){ - $$var=$val; - } -} -if(isset($HTTP_SERVER_VARS)){ - while(list($var, $val)=each($HTTP_SERVER_VARS)){ - $$var=$val; - } -} - -$self=$PHP_SELF; - -if ($ps=="") $ps=20; -if ($np=="") $np=0; -if ($o=="") $o=0; - -if (($dt!='back') && ($dt!='er') && ($dt!='range')) $dt='back'; -if ($dp=="") $dp=0; -if (($dx!=0) && ($dx!=-1) && ($dx!=1)) $dx=0; -if ($dy<1970) $dy=1970; -if (($dm<0) || ($dm>11)) $dm=0; -if (($dd<=0) || ($dd>31)) $dd="01"; - -$db=urldecode($db); -$de=urldecode($de); - -if ($db=="") $db='01/01/1970'; -if ($de=="") $de='31/12/2020'; - -// define this to enable stored support -// $storedaddr="localhost"; -$storedocurl='/cgi-bin/storedoc.cgi'; - -if (isset($q)) { - $q=urldecode($q); - $have_query_flag=1; -} else { - $have_query_flag=0; -} - -$ul=urldecode($ul); -$tag=urldecode($t); -$lang=urldecode($lang); - -$query_orig=$q; - -if (isset($CHARSET_SAVED_QUERY_STRING)) { - $q_local=urldecode($CHARSET_SAVED_QUERY_STRING); - if (preg_match('/q=([^&]*)\&/',$q_local,$param)) { - $q_local=urlencode($param[1]); - } elseif (preg_match('/q=(.*)$/',$q_local,$param)) { - $q_local=urlencode($param[1]); - } else { - $q_local=urlencode($q); - } -} else { - $q_local=urlencode($q); -} - -$ul_local=urlencode($ul); -$t_local=urlencode($tag); -$db_local=urlencode($db); -$de_local=urlencode($de); -$lang_local=urlencode($lang); - -if (($MAX_NP > 0) && ($np>$MAX_NP)) $np=$MAX_NP; -if (($MAX_PS > 0) && ($ps>$MAX_PS)) $ps=$MAX_PS; - -// ----------------------------------------------- -// print_bottom() -// ----------------------------------------------- -function print_bottom(){ - print ("
\n"); - print ("Powered by mnoGoSearch
\n"); - print ("

\n"); -} - - -// ----------------------------------------------- -// print_error_local($str) -// ----------------------------------------------- -function print_error_local($str){ - print ("

An error occured!\n"); - print ("

$str

\n"); - print_bottom(); - exit; -} - -// ----------------------------------------------- -// exit_local() -// ----------------------------------------------- -function exit_local($print_err = 1) { - drop_temp_table($print_err); - exit; -} - -// ----------------------------------------------- -// format_lastmod($lastmod) -// ----------------------------------------------- -function format_lastmod($lastmod) { - $temp=$lastmod; - if (!$temp) $temp = 'undefined'; - else $temp = strftime('%a, %d %b %Y %H:%M:%S %Z',$temp); - - return $temp; -} - -// ----------------------------------------------- -// format_dp($dp) -// ----------------------------------------------- -function format_dp($dp) { - $result=0; - - while ($dp != '') { - if (preg_match('/^([\-\+]?\d+)([sMhdmy]?)/',$dp,$param)) { - switch ($param[2]) { - case 's': $multiplier=1; break; - case 'M': $multiplier=60; break; - case 'h': $multiplier=3600; break; - case 'd': $multiplier=3600*24; break; - case 'm': $multiplier=3600*24*31; break; - case 'y': $multiplier=3600*24*365; break; - default: $multiplier=1; - } - - $result += $param[1]*$multiplier; - $dp=preg_replace("/^[\-\+]?\d+$param[2]/",'',$dp); - } else { - return 0; - } - } - - return $result; -} - -// ----------------------------------------------- -// format_userdate($date) -// ----------------------------------------------- -function format_userdate($date) { - $result=0; - - if (preg_match('/^(\d+)\/(\d+)\/(\d+)$/',$date,$param)) { - $day=$param[1]; - $mon=$param[2]; - $year=$param[3]; - - $result=mktime(0,0,0,$mon,$day,$year); - } - - return $result; -} - -// ----------------------------------------------- -// ParseDocText($text) -// ----------------------------------------------- -function ParseDocText($text){ - global $all_words; - global $hlbeg, $hlend; - - $str=$text; - - if (Udm_Api_Version() < 30200) { - for ($i=0; $i\?\/\,\.]+)($word)/i","\\1$hlbeg\\2$hlend",$str); - $str = preg_replace("/^($word)/i","$hlbeg\\1$hlend",$str); - } - } else { - $str = str_replace("\2",$hlbeg,$str); - $str = str_replace("\3",$hlend,$str); - } - - return $str; -} - -// ----------------------------------------------- -// print_template($t,$echo=1) -// ----------------------------------------------- -function print_template($t,$echo=1){ - global $templates, $udm_agent; - global $first_doc, $last_doc, $found, $query_orig, $error, $self; - global $nav, $wordinfo; - global $url, $ue, $o, $cat; - global $clones, $searchtime; - global $title, $rating, $desc, $contype, $lastmod, $docsize, $ndoc; - global $keyw, $text, $category; - global $crc, $Randoms, $rec_id, $DEBUG; - global $lang_url_translation, $phpver; - - - $str=$templates["$t"][$o]; - if ($str == '') $str=$templates["$t"][0]; - - $str=ereg_replace('\$f', "$first_doc", $str); - $str=ereg_replace('\$l', "$last_doc", $str); - $str=ereg_replace('\$t', "$found", $str); - $str=ereg_replace('\$A', $self, $str); - - $str=ereg_replace('\$Q', HtmlSpecialChars(StripSlashes($query_orig)), $str); - $str=ereg_replace('\$q', urlencode($query_orig), $str); - $str=eregi_replace('\$UE', $ue, $str); - - $str=ereg_replace('\$E', $error, $str); - $str=ereg_replace('\$W', $wordinfo, $str); - - $str=ereg_replace('\$V', $nav, $str); - - if ($lang_url_translation == 'yes') { - $nolangurl = ereg_replace("\.[a-z]{2}\.[a-z]{2,4}$", "", $url); - $str=ereg_replace('\$DU', $nolangurl, $str); - } else { - $str=ereg_replace('\$DU', $url, $str); - } - - $str=ereg_replace('\$DT', $title, $str); - $str=ereg_replace('\$DR', "$rating", $str); - $str=ereg_replace('\$DX', $text, $str); - $str=ereg_replace('\$DE', ($desc != '')?$desc:$text, $str); - $str=ereg_replace('\$DC', $contype, $str); - $str=ereg_replace('\$DM', $lastmod, $str); - $str=ereg_replace('\$DS', "$docsize", $str); - $str=ereg_replace('\$DN', "$ndoc", $str); - $str=ereg_replace('\$DD', $desc, $str); - $str=ereg_replace('\$DK', $keyw, $str); - $str=ereg_replace('\$SearchTime', "$searchtime", $str); - - if ($phpver >= 40006) { - if (ereg('\$CP',$str)) { - if ($temp_cp_arr=Udm_Cat_Path($udm_agent,$cat)) { - reset($temp_cp_arr); - $temp_cp=''; - for ($i=0; $i$cp_name "; - } - $str=ereg_replace('\$CP', $temp_cp, $str); - } else $str=ereg_replace('\$CP', '', $str); - } - - if (ereg('\$CS',$str)) { - if ($temp_cp_arr=Udm_Cat_List($udm_agent,$cat)) { - reset($temp_cp_arr); - $temp_cp=''; - for ($i=0; $i$cp_name
"; - } - $str=ereg_replace('\$CS', $temp_cp, $str); - } else $str=ereg_replace('\$CS', '', $str); - } - - if (ereg('\$DY',$str)) { - if ($temp_cp_arr=Udm_Cat_Path($udm_agent,$category)) { - reset($temp_cp_arr); - $temp_cp=''; - for ($i=0; $i$cp_name "; - } - $str=ereg_replace('\$DY', $temp_cp, $str); - } else $str=ereg_replace('\$DY', '', $str); - } - } else { - $str=ereg_replace('\$CP', '', $str); - $str=ereg_replace('\$CS', '', $str); - $str=ereg_replace('\$DY', '', $str); - } - - $sub=$str; - while($sub=strstr($sub,'$r')){ - $sub=substr($sub,2); - $pos=0; - $num=''; - - while(($sub[$pos]>='0')&&($sub[$pos]<='9')){ - $num.=$sub[$pos++]; - } - - $str=ereg_replace('\$r'.$num, ''.$Randoms[$num], $str); - } - -// if (strstr($str,'$CL')&&($t=='res')) { -// if (strtolower($clones) == 'no') { -// $str=ereg_replace('\$CL', '', $str); -// } elseif ($crc<>'') { -// } - $str=ereg_replace('\$CL', $clon, $str); -// } - - if($echo) echo $str; else return $str; -} - -// ----------------------------------------------- -// make_nav($query_orig) -// ----------------------------------------------- -function make_nav($query_orig){ - global $found,$np,$isnext,$ps,$tag,$ul,$self,$o,$m,$cat; - global $dt, $dp, $dx, $dm, $dy, $dd, $db, $de, $lang, $wm, $wf; - global $q_local,$ul_local,$t_local,$db_local,$de_local,$lang_local; - - if($np>0){ - $prevp=$np-1; - $prev_href="$self?q=$q_local&np=$prevp&m=$m". - ($ps==20?'':"&ps=$ps"). - ($tag==''?'':"&t=$t_local"). - ($ul==''?'':"&ul=$ul_local"). - ($wm==''?'':"&wm=$wm"). - ($wf==''?'':"&wf=$wf"). - (!$o?'':"&o=$o"). - ($dt=='back'?'':"&dt=$dt"). - (!$dp?'':"&dp=$dp"). - (!$dx?'':"&dx=$dx"). - ($dd=='01'?'':"&dd=$dd"). - (!$dm?'':"&dm=$dm"). - ($dy=='1970'?'':"&dy=$dy"). - ($db=='01/01/1970'?'':"&db=$db_local"). - ($de=='31/12/2020'?'':"&de=$de_local"). - ($cat==''?'':"&cat=$cat"). - ($lang==''?'':"&lang=$lang_local"); - - $nav_left="Prev\n"; - } elseif ($np==0) { - $nav_left="Prev\n"; - } - - if($isnext==1) { - $nextp=$np+1; - $next_href="$self?q=$q_local&np=$nextp&m=$m". - ($ps==20?'':"&ps=$ps"). - ($tag==''?'':"&t=$t_local"). - ($ul==''?'':"&ul=$ul_local"). - ($wm==''?'':"&wm=$wm"). - ($wf==''?'':"&wf=$wf"). - (!$o?'':"&o=$o"). - ($dt=='back'?'':"&dt=$dt"). - (!$dp?'':"&dp=$dp"). - (!$dx?'':"&dx=$dx"). - ($dd=='01'?'':"&dd=$dd"). - (!$dm?'':"&dm=$dm"). - ($dy=='1970'?'':"&dy=$dy"). - ($db=='01/01/1970'?'':"&db=$db_local"). - ($de=='31/12/2020'?'':"&de=$de_local"). - ($cat==''?'':"&cat=$cat"). - ($lang==''?'':"&lang=$lang_local"); - - $nav_right="Next\n"; - } else { - $nav_right="Next\n"; - } - - $nav_bar0='$NP'; - $nav_bar1='$NP'; - - $tp=ceil($found/$ps); - - $cp=$np+1; - - if ($cp>5) { - $lp=$cp-5; - } else { - $lp=1; - } - - $rp=$lp+10-1; - if ($rp>$tp) { - $rp=$tp; - $lp=$rp-10+1; - if ($lp<1) $lp=1; - } - - - if ($lp!=$rp) { - for ($i=$lp; $i<=$rp;$i++) { - $realp=$i-1; - - if ($i==$cp) { - $nav_bar=$nav_bar.$nav_bar0; - } else { - $nav_bar=$nav_bar.$nav_bar1; - } - - $href="$self?q=$q_local&np=$realp&m=$m". - ($ps==20?'':"&ps=$ps"). - ($tag==''?'':"&t=$t_local"). - ($ul==''?'':"&ul=$ul_local"). - ($wm==''?'':"&wm=$wm"). - ($wf==''?'':"&wf=$wf"). - (!$o?'':"&o=$o"). - ($dt=='back'?'':"&dt=$dt"). - (!$dp?'':"&dp=$dp"). - (!$dx?'':"&dx=$dx"). - ($dd=='01'?'':"&dd=$dd"). - (!$dm?'':"&dm=$dm"). - ($dy=='1970'?'':"&dy=$dy"). - ($db=='01/01/1970'?'':"&db=$db_local"). - ($de=='31/12/2020'?'':"&de=$de_local"). - ($cat==''?'':"&cat=$cat"). - ($lang==''?'':"&lang=$lang_local"); - - $nav_bar=ereg_replace('\$NP',"$i",$nav_bar); - $nav_bar=ereg_replace('\$NH',"$href",$nav_bar); - } - - $nav="$nav_left $nav_bar $nav_right
\n"; - } elseif ($found) { - $nav="$nav_left $nav_right
\n"; - } - - return $nav; -} - -// ----------------------------------------------- -// M A I N -// ----------------------------------------------- - - if (preg_match("/^(\d+)\.(\d+)\.(\d+)/",phpversion(),$param)) { - $phpver=$param[1]; - if ($param[2] < 9) { - $phpver .= "0$param[2]"; - } else { - $phpver .= "$param[2]"; - } - if ($param[3] < 9) { - $phpver .= "0$param[3]"; - } else { - $phpver .= "$param[3]"; - } - } else { - print "Cannot determine php version: ".phpversion()."\n"; - exit; - } - - $have_spell_flag=0; - - if (Udm_Api_Version() >= 30204) { - $udm_agent=Udm_Alloc_Agent($dbaddr); - } else { - $udm_agent=Udm_Alloc_Agent($dbaddr,$dbmode); - } - - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PAGE_SIZE,$ps); - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PAGE_NUM,$np); - - if ($phpver >= 40006) { - if ($temp_cp_arr=Udm_Cat_Path($udm_agent,$cat)) { - reset($temp_cp_arr); - $temp_cp=''; - for ($i=0; $i$cp_name "; - } - $t_CP=$temp_cp; - } - - if ($temp_cp_arr=Udm_Cat_List($udm_agent,$cat)) { - reset($temp_cp_arr); - $temp_cp=''; - for ($i=0; $i$cp_name
"; - } - $t_CS=$temp_cp; - } - - if ($temp_cp_arr=Udm_Cat_Path($udm_agent,$category)) { - reset($temp_cp_arr); - $temp_cp=''; - for ($i=0; $i$cp_name "; - } - $t_DY=$temp_cp; - } - } - - $trackquery=strtolower($trackquery); - if ($trackquery == 'yes') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_TRACK_MODE,UDM_TRACK_ENABLED); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_TRACK_MODE,UDM_TRACK_DISABLED); - } - - $phrase=strtolower($phrase); - if ($phrase == 'yes') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PHRASE_MODE,UDM_PHRASE_ENABLED); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PHRASE_MODE,UDM_PHRASE_DISABLED); - } - - $cache=strtolower($cache); - if ($cache == 'yes') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CACHE_MODE,UDM_CACHE_ENABLED); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CACHE_MODE,UDM_CACHE_DISABLED); - } - - $ispelluseprefixes=strtolower($ispelluseprefixes); - if ($ispelluseprefixes == 'yes') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_ISPELL_PREFIXES,UDM_PREFIXES_ENABLED); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_ISPELL_PREFIXES,UDM_PREFIXES_DISABLED); - } - - if (Udm_Api_Version() >= 30111) { - $crosswords=strtolower($crosswords); - if ($crosswords == 'yes') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CROSS_WORDS,UDM_CROSS_WORDS_ENABLED); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CROSS_WORDS,UDM_CROSS_WORDS_DISABLED); - } - } - - if ($localcharset != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CHARSET,$localcharset); - } - - if (Udm_Api_Version() >= 30200) { - if ($localcharset == '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CHARSET,'utf-8'); - if ($browsercharset != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_BROWSER_CHARSET,$browsercharset); - Header ("Content-Type: text/html; charset=$browsercharset"); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_BROWSER_CHARSET,'utf-8'); - Header ("Content-Type: text/html; charset=utf-8"); - } - if ($hlbeg != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLBEG,$hlbeg); - } else { - $hlbeg=''; - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLBEG,''); - } - if ($hlend != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLEND,$hlend); - } else { - $hlend=''; - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLEND,''); - } - } - - - for ($i=0; $i < count($stopwordtable_arr); $i++) { - if ($stopwordtable_arr[$i] != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_STOPTABLE,$stopwordtable_arr[$i]); - } - } - - for ($i=0; $i < count($stopwordfile_arr); $i++) { - if ($stopwordfile_arr[$i] != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_STOPFILE,$stopwordfile_arr[$i]); - } - } - - if (Udm_Api_Version() >= 30203) { - for ($i=0; $i < count($synonym_arr); $i++) { - if ($synonym_arr[$i] != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SYNONYM,$synonym_arr[$i]); - } - } - - for ($i=0; $i < count($searchd_arr); $i++) { - if ($searchd_arr[$i] != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCHD,$searchd_arr[$i]); - } - } - - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QSTRING,$QUERY_STRING); - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_REMOTE_ADDR,$REMOTE_ADDR); - } - - if (Udm_Api_Version() >= 30204) { - if ($have_query_flag)Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QUERY,$query_orig); - if ($storedaddr != '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_STORED,$storedaddr); - } - - if ($m=='any') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ANY); - } elseif ($m=='all') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ALL); - } elseif ($m=='bool') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_BOOL); - } elseif ($m=='phrase') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_PHRASE); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ALL); - } - - if ($wm=='wrd') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_WORD); - } elseif ($wm=='beg') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_BEGIN); - } elseif ($wm=='end') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_END); - } elseif ($wm=='sub') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_SUBSTR); - } else { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_WORD); - } - - if ($minwordlength >= 0) { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_MIN_WORD_LEN,$minwordlength); - } - - if ($maxwordlength >= 0) { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_MAX_WORD_LEN,$maxwordlength); - } - - if ($phpver >= 40007) { - if ($vardir != '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_VARDIR,$vardir); - if ($datadir != '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_VARDIR,$datadir); - } - - if ($wf != '') { - Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WEIGHT_FACTOR,$wf); - } - - if ($ul != '') { - $auto_wild=strtolower($auto_wild); - if (($auto_wild == 'yes') || - ($auto_wild == '')) { - if ((substr($ul,0,7) == 'http://') || - (substr($ul,0,8) == 'https://') || - (substr($ul,0,7) == 'news://') || - (substr($ul,0,6) == 'ftp://')) { - Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_URL,"$ul%"); - } else { - Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_URL,"%$ul%"); - } - } else { - Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_URL,$ul); - } - } - - if ($tag != '') Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_TAG,$tag); - if ($cat != '') Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_CAT,$cat); - if ($lang != '')Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_LANG,$lang); - - if (($dt == 'back') && ($dp != '0')) { - $recent_time=format_dp($dp); - if ($recent_time != 0) { - $dl=time()-$recent_time; - Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,">$dl"); - } - } elseif ($dt=='er') { - $recent_time=mktime(0,0,0,($dm+1),$dd,$dy); - if ($dx == -1) { - Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,"<$recent_time"); - } elseif ($dx == 1) { - Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,">$recent_time"); - } - } elseif ($dt=='range') { - $begin_time=format_userdate($db); - if ($begin_time) Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,">$begin_time"); - - $end_time=format_userdate($de); - if ($end_time) Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,"<$end_time"); - } - -// if ($have_query_flag) $q=ParseQ($q); - -?> - - - - mnoGoSearch: <? echo HtmlSpecialChars(StripSlashes($query_orig)); ?> - - - -
- -
- - - - - - - - - - - - - -
-
- -Search for: -
- -Results per page: - - -Match: - - - -Search for: - - -
- -Search through: - - -in: - - -Language: - - -Restrict search: - - -
- - - - - - - - - - - - - - -
-Limit results to pages published within a specified period of time.
-(Please select only one option) -
> -
> - - -or on - - - -, - -
> - -Between - -and - -
- -
-
-
- - -= 30112) { - if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_SERVER,$spell_host,'',1)) { - print_error_local("Error loading ispell data from server $spell_host"); - } else $have_spell_flag=1; - } - } elseif ($ispellmode == 'text') { - reset($affix_file); - while (list($t_lang,$file)=each($affix_file)) { - if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_AFFIX,$t_lang,$file,0)) { - print_error_local("Error loading ispell data from file"); - } else $have_spell_flag=1; - - $temp=$spell_file[$t_lang]; - for ($i=0; $iYou should give at least one word to search for.\n"); - print_bottom(); - return; -} - -$res=Udm_Find($udm_agent,$q); - -if(($errno=Udm_Errno($udm_agent))>0){ - print_error_local(Udm_Error($udm_agent)); -} else { - $found=Udm_Get_Res_Param($res,UDM_PARAM_FOUND); - $rows=Udm_Get_Res_Param($res,UDM_PARAM_NUM_ROWS); - $wordinfo=Udm_Get_Res_Param($res,UDM_PARAM_WORDINFO); - $searchtime=Udm_Get_Res_Param($res,UDM_PARAM_SEARCHTIME); - $first_doc=Udm_Get_Res_Param($res,UDM_PARAM_FIRST_DOC); - $last_doc=Udm_Get_Res_Param($res,UDM_PARAM_LAST_DOC); - - if (!$found) { - print ("Search Time: $searchtime
Search results:\n"); - print ("$wordinfo
Sorry, but search returned no results.

\n"); - print ("Try to produce less restrictive search query.

\n"); - - print_bottom(); - return; - } - - $from=IntVal($np)*IntVal($ps); - $to=IntVal($np+1)*IntVal($ps); - - if($to>$found) $to=$found; - if (($from+$ps)<$found) $isnext=1; - $nav=make_nav($query_orig); - - print("Search Time: $searchtime
Search results: $wordinfo
\n"); - print("Displaying documents $first_doc-$last_doc of total $found found.\n"); - - $stored_link=-1; - if ((Udm_Api_Version() == 30203) && ($storedaddr != '')) { - $stored_link=Udm_Open_Stored($udm_agent,$storedaddr); - } - - for($i=0;$i<$rows;$i++){ - $excerpt_flag=0; - if (Udm_Api_Version() >= 30204) { - $excerpt_flag=Udm_Make_Excerpt($udm_agent, $res, $i); - } - - $ndoc=Udm_Get_Res_Field($res,$i,UDM_FIELD_ORDER); - $rating=Udm_Get_Res_Field($res,$i,UDM_FIELD_RATING); - $url=Udm_Get_Res_Field($res,$i,UDM_FIELD_URL); - $contype=Udm_Get_Res_Field($res,$i,UDM_FIELD_CONTENT); - $docsize=Udm_Get_Res_Field($res,$i,UDM_FIELD_SIZE); - $lastmod=format_lastmod(Udm_Get_Res_Field($res,$i,UDM_FIELD_MODIFIED)); - - $title=Udm_Get_Res_Field($res,$i,UDM_FIELD_TITLE); - $title=($title) ? htmlspecialChars($title):'No title'; - - $title=ParseDocText($title); - $text=ParseDocText(htmlspecialChars(Udm_Get_Res_Field($res,$i,UDM_FIELD_TEXT))); - $keyw=ParseDocText(htmlspecialChars(Udm_Get_Res_Field($res,$i,UDM_FIELD_KEYWORDS))); - $desc=ParseDocText(htmlspecialChars(Udm_Get_Res_Field($res,$i,UDM_FIELD_DESC))); - - $crc=Udm_Get_Res_Field($res,$i,UDM_FIELD_CRC); - $rec_id=Udm_Get_Res_Field($res,$i,UDM_FIELD_URLID); - - if (Udm_Api_Version() >= 30203) { - $doclang=Udm_Get_Res_Field($res,$i,UDM_FIELD_LANG); - $doccharset=Udm_Get_Res_Field($res,$i,UDM_FIELD_CHARSET); - } - - if ($phpver >= 40006) { - $category=Udm_Get_Res_Field($res,$i,UDM_FIELD_CATEGORY); - } else { - $category=''; - } - - print ("
$ndoc.$title\n"); - print ("[$rating]
\n"); - print (($desc != '')?$desc:$text."...
$t_DY
  • \n"); - print ("$url\n"); - print ("($contype) $lastmod, $docsize bytes
\n"); - - if (Udm_Api_Version() == 30203) { - if ((($stored_link>0) && (Udm_Check_Stored($udm_agent,$stored_link,Udm_CRC32($udm_agent,$url)))) || - ($stored_link==-1)) { - $storedstr="$storedocurl?rec_id=".Udm_CRC32($udm_agent,$url). - "&DM=".urlencode($lastmod). - "&DS=$docsize". - "&L=$doclang". - "&CS=$doccharset". - "&DU=".urlencode($url). - "&q=".urlencode($query_orig); - print ("
Cached copy\n"); - } - } elseif (Udm_Api_Version() >= 30204) { - if ($excerpt_flag) { - $storedstr="$storedocurl?rec_id=".Udm_CRC32($udm_agent,$save_url). - "&DM=".urlencode($lastmod). - "&DS=$docsize". - "&L=$doclang". - "&CS=$doccharset". - "&DU=".urlencode($save_url). - "&q=".urlencode($query_orig); - print_template('stored'); - } - } - } - - if ((Udm_Api_Version() == 30203) && - ($stored_link>0)) { - Udm_Close_Stored($udm_agent, $stored_link); - } - - print("
$nav
\n"); - print_bottom(); - - // Free result - Udm_Free_Res($res); -} - - if ($have_spell_flag) Udm_Free_Ispell_Data($udm_agent); - Udm_Free_Agent($udm_agent); -?> diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c deleted file mode 100644 index 4e9e0f7bdc..0000000000 --- a/ext/mnogosearch/php_mnogo.c +++ /dev/null @@ -1,2667 +0,0 @@ -/* $Source$ */ -/* $Id$ */ - -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: | - | Initial version by Alex Barkov | - | and Ramil Kalimullin | - | Further development by Sergey Kartashoff | - +----------------------------------------------------------------------+ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_mnogo.h" -#include "ext/standard/php_standard.h" -#include "ext/standard/info.h" -#include "php_globals.h" - -#ifdef HAVE_MNOGOSEARCH - -#define UDMSTRSIZ 1024*5 - -#define UDM_FIELD_URLID 1 -#define UDM_FIELD_URL 2 -#define UDM_FIELD_CONTENT 3 -#define UDM_FIELD_TITLE 4 -#define UDM_FIELD_KEYWORDS 5 -#define UDM_FIELD_DESC 6 -#define UDM_FIELD_TEXT 7 -#define UDM_FIELD_SIZE 8 -#define UDM_FIELD_RATING 9 -#define UDM_FIELD_MODIFIED 10 -#define UDM_FIELD_ORDER 11 -#define UDM_FIELD_CRC 12 -#define UDM_FIELD_CATEGORY 13 -#define UDM_FIELD_LANG 14 -#define UDM_FIELD_CHARSET 15 -#define UDM_FIELD_SITEID 16 -#define UDM_FIELD_POP_RANK 17 -#define UDM_FIELD_ORIGINID 18 - -/* udm_set_agent_param constants */ -#define UDM_PARAM_PAGE_SIZE 1 -#define UDM_PARAM_PAGE_NUM 2 -#define UDM_PARAM_SEARCH_MODE 3 -#define UDM_PARAM_CACHE_MODE 4 -#define UDM_PARAM_TRACK_MODE 5 -#define UDM_PARAM_CHARSET 6 -#define UDM_PARAM_STOPTABLE 7 -#define UDM_PARAM_STOPFILE 8 -#define UDM_PARAM_WEIGHT_FACTOR 9 -#define UDM_PARAM_WORD_MATCH 10 -#define UDM_PARAM_PHRASE_MODE 11 -#define UDM_PARAM_MIN_WORD_LEN 12 -#define UDM_PARAM_MAX_WORD_LEN 13 -#define UDM_PARAM_ISPELL_PREFIXES 14 -#define UDM_PARAM_CROSS_WORDS 15 -#define UDM_PARAM_VARDIR 16 -#define UDM_PARAM_LOCAL_CHARSET 17 -#define UDM_PARAM_BROWSER_CHARSET 18 -#define UDM_PARAM_HLBEG 19 -#define UDM_PARAM_HLEND 20 -#define UDM_PARAM_SYNONYM 21 -#define UDM_PARAM_SEARCHD 22 /* unused */ -#define UDM_PARAM_QSTRING 23 -#define UDM_PARAM_REMOTE_ADDR 24 -#define UDM_PARAM_QUERY 25 -#define UDM_PARAM_STORED 26 -#define UDM_PARAM_GROUPBYSITE 27 -#define UDM_PARAM_SITEID 28 -#define UDM_PARAM_DETECT_CLONES 29 -#define UDM_PARAM_SORT_ORDER 30 -#define UDM_PARAM_RESULTS_LIMIT 31 -#define UDM_PARAM_EXCERPT_SIZE 32 -#define UDM_PARAM_EXCERPT_PADDING 33 - -/* udm_add_search_limit constants */ -#define UDM_LIMIT_URL 1 -#define UDM_LIMIT_TAG 2 -#define UDM_LIMIT_LANG 3 -#define UDM_LIMIT_CAT 4 -#define UDM_LIMIT_DATE 5 -#define UDM_LIMIT_TYPE 6 - -/* word match type */ -#define UDM_MATCH_WORD 0 -#define UDM_MATCH_BEGIN 1 -#define UDM_MATCH_SUBSTR 2 -#define UDM_MATCH_END 3 - -/* track modes */ -#define UDM_TRACK_ENABLED 1 -#define UDM_TRACK_DISABLED 0 - -/* cache modes */ -#define UDM_CACHE_ENABLED 1 -#define UDM_CACHE_DISABLED 0 - -/* phrase modes */ -#define UDM_PHRASE_ENABLED 1 -#define UDM_PHRASE_DISABLED 0 - -/* prefix modes */ -#define UDM_PREFIXES_ENABLED 1 -#define UDM_PREFIXES_DISABLED 0 - -/* crosswords modes */ -#define UDM_CROSS_WORDS_ENABLED 1 -#define UDM_CROSS_WORDS_DISABLED 0 - -/* General modes */ -#define UDM_ENABLED 1 -#define UDM_DISABLED 0 - -/* udm_get_res_param constants */ -#define UDM_PARAM_NUM_ROWS 256 -#define UDM_PARAM_FOUND 257 -#define UDM_PARAM_WORDINFO 258 -#define UDM_PARAM_SEARCHTIME 259 -#define UDM_PARAM_FIRST_DOC 260 -#define UDM_PARAM_LAST_DOC 261 -#define UDM_PARAM_WORDINFO_ALL 262 - -/* udm_load_ispell_data constants */ -#define UDM_ISPELL_TYPE_AFFIX 1 -#define UDM_ISPELL_TYPE_SPELL 2 -#define UDM_ISPELL_TYPE_DB 3 -#define UDM_ISPELL_TYPE_SERVER 4 - -/* True globals, no need for thread safety */ -static int le_link,le_res; - -#include -#include - -/* {{{ mnogosearch_functions[] - */ -function_entry mnogosearch_functions[] = { - PHP_FE(udm_api_version, NULL) - -#if UDM_VERSION_ID >= 30200 - PHP_FE(udm_check_charset, NULL) -#if UDM_VERSION_ID >= 30203 - PHP_FE(udm_crc32, NULL) -#endif -#if UDM_VERSION_ID >= 30204 - PHP_FE(udm_parse_query_string, NULL) - PHP_FE(udm_make_excerpt, NULL) - PHP_FE(udm_set_agent_param_ex, NULL) - PHP_FE(udm_get_agent_param_ex, NULL) - PHP_FE(udm_get_res_field_ex, NULL) -#endif -#if UDM_VERSION_ID >= 30211 - PHP_FE(udm_hash32, NULL) - PHP_FE(udm_alloc_agent_array, NULL) -#endif -#if UDM_VERSION_ID >= 30216 - PHP_FE(udm_store_doc_cgi, NULL) -#endif -#endif - - PHP_FE(udm_alloc_agent, NULL) - PHP_FE(udm_set_agent_param, NULL) - - PHP_FE(udm_load_ispell_data, NULL) - PHP_FE(udm_free_ispell_data, NULL) - - PHP_FE(udm_add_search_limit, NULL) - PHP_FE(udm_clear_search_limits, NULL) - - PHP_FE(udm_errno, NULL) - PHP_FE(udm_error, NULL) - - PHP_FE(udm_find, NULL) - PHP_FE(udm_get_res_param, NULL) - PHP_FE(udm_get_res_field, NULL) - - PHP_FE(udm_cat_list, NULL) - PHP_FE(udm_cat_path, NULL) - - PHP_FE(udm_free_res, NULL) - PHP_FE(udm_free_agent, NULL) - -#if UDM_VERSION_ID > 30110 - PHP_FE(udm_get_doc_count, NULL) -#endif - - {NULL, NULL, NULL} -}; -/* }}} */ - -zend_module_entry mnogosearch_module_entry = { - STANDARD_MODULE_HEADER, - "mnogosearch", - mnogosearch_functions, - PHP_MINIT(mnogosearch), - PHP_MSHUTDOWN(mnogosearch), - PHP_RINIT(mnogosearch), - NULL, - PHP_MINFO(mnogosearch), - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES -}; - - -#ifdef COMPILE_DL_MNOGOSEARCH -ZEND_GET_MODULE(mnogosearch) -#endif - -static void _free_udm_agent(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - UDM_AGENT * Agent = (UDM_AGENT *)rsrc->ptr; -#if UDM_VERSION_ID >= 30204 - UdmEnvFree(Agent->Conf); - UdmAgentFree(Agent); -#else - UdmFreeEnv(Agent->Conf); - UdmFreeAgent(Agent); -#endif -} - -static void _free_udm_res(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - UDM_RESULT * Res = (UDM_RESULT *)rsrc->ptr; - -#if UDM_VERSION_ID >= 30204 - UdmResultFree(Res); -#else - UdmFreeResult(Res); -#endif -} - -/* {{{ PHP_MINIT_FUNCTION - */ -DLEXPORT PHP_MINIT_FUNCTION(mnogosearch) -{ - UdmInit(); - le_link = zend_register_list_destructors_ex(_free_udm_agent,NULL,"mnogosearch agent",module_number); - le_res = zend_register_list_destructors_ex(_free_udm_res,NULL,"mnogosearch result",module_number); - - REGISTER_LONG_CONSTANT("UDM_FIELD_URLID", UDM_FIELD_URLID,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_URL", UDM_FIELD_URL,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_CONTENT", UDM_FIELD_CONTENT,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_TITLE", UDM_FIELD_TITLE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_KEYWORDS", UDM_FIELD_KEYWORDS,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_DESC", UDM_FIELD_DESC,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_DESCRIPTION", UDM_FIELD_DESC,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_TEXT", UDM_FIELD_TEXT,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_SIZE", UDM_FIELD_SIZE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_RATING", UDM_FIELD_RATING,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_SCORE", UDM_FIELD_RATING,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_MODIFIED", UDM_FIELD_MODIFIED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_ORDER", UDM_FIELD_ORDER,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_CRC", UDM_FIELD_CRC,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_CATEGORY", UDM_FIELD_CATEGORY,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_LANG", UDM_FIELD_LANG,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_CHARSET", UDM_FIELD_CHARSET,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_SITEID", UDM_FIELD_SITEID,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_POP_RANK", UDM_FIELD_POP_RANK,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_FIELD_ORIGINID", UDM_FIELD_ORIGINID,CONST_CS | CONST_PERSISTENT); - - /* udm_set_agent_param constants */ - REGISTER_LONG_CONSTANT("UDM_PARAM_PAGE_SIZE", UDM_PARAM_PAGE_SIZE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_PAGE_NUM", UDM_PARAM_PAGE_NUM,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_SEARCH_MODE", UDM_PARAM_SEARCH_MODE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_CACHE_MODE", UDM_PARAM_CACHE_MODE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_TRACK_MODE", UDM_PARAM_TRACK_MODE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_PHRASE_MODE", UDM_PARAM_PHRASE_MODE,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_CHARSET", UDM_PARAM_CHARSET,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_LOCAL_CHARSET",UDM_PARAM_LOCAL_CHARSET,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_BROWSER_CHARSET",UDM_PARAM_BROWSER_CHARSET,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_STOPTABLE", UDM_PARAM_STOPTABLE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_STOP_TABLE", UDM_PARAM_STOPTABLE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_STOPFILE", UDM_PARAM_STOPFILE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_STOP_FILE", UDM_PARAM_STOPFILE,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_WEIGHT_FACTOR",UDM_PARAM_WEIGHT_FACTOR,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_WORD_MATCH", UDM_PARAM_WORD_MATCH,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_MAX_WORD_LEN",UDM_PARAM_MAX_WORD_LEN,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_MAX_WORDLEN", UDM_PARAM_MAX_WORD_LEN,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_MIN_WORD_LEN",UDM_PARAM_MIN_WORD_LEN,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_MIN_WORDLEN", UDM_PARAM_MIN_WORD_LEN,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_ISPELL_PREFIXES",UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_ISPELL_PREFIX",UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_PREFIXES", UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_PREFIX", UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_CROSS_WORDS", UDM_PARAM_CROSS_WORDS,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_CROSSWORDS", UDM_PARAM_CROSS_WORDS,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_VARDIR", UDM_PARAM_VARDIR,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_DATADIR", UDM_PARAM_VARDIR,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_HLBEG", UDM_PARAM_HLBEG,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_HLEND", UDM_PARAM_HLEND,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_SYNONYM", UDM_PARAM_SYNONYM,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_STORED", UDM_PARAM_STORED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_GROUPBYSITE", UDM_PARAM_GROUPBYSITE,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_QSTRING", UDM_PARAM_QSTRING,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_REMOTE_ADDR", UDM_PARAM_REMOTE_ADDR,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_QUERY", UDM_PARAM_QUERY,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_SITEID", UDM_PARAM_SITEID,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_DETECT_CLONES",UDM_PARAM_DETECT_CLONES,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_SORT_ORDER",UDM_PARAM_SORT_ORDER,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_RESULTS_LIMIT",UDM_PARAM_RESULTS_LIMIT,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PARAM_EXCERPT_SIZE",UDM_PARAM_EXCERPT_SIZE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_EXCERPT_PADDING",UDM_PARAM_EXCERPT_PADDING,CONST_CS | CONST_PERSISTENT); - - /* udm_add_search_limit constants */ - REGISTER_LONG_CONSTANT("UDM_LIMIT_CAT", UDM_LIMIT_CAT,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_LIMIT_URL", UDM_LIMIT_URL,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_LIMIT_TAG", UDM_LIMIT_TAG,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_LIMIT_LANG", UDM_LIMIT_LANG,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_LIMIT_DATE", UDM_LIMIT_DATE,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_LIMIT_TYPE", UDM_LIMIT_TYPE,CONST_CS | CONST_PERSISTENT); - - /* udm_get_res_param constants */ - REGISTER_LONG_CONSTANT("UDM_PARAM_FOUND", UDM_PARAM_FOUND,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_NUM_ROWS", UDM_PARAM_NUM_ROWS,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_WORDINFO", UDM_PARAM_WORDINFO,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_WORDINFO_ALL",UDM_PARAM_WORDINFO_ALL,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_WORD_INFO", UDM_PARAM_WORDINFO,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_SEARCHTIME", UDM_PARAM_SEARCHTIME,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_SEARCH_TIME", UDM_PARAM_SEARCHTIME,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_FIRST_DOC", UDM_PARAM_FIRST_DOC,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PARAM_LAST_DOC", UDM_PARAM_LAST_DOC,CONST_CS | CONST_PERSISTENT); - - /* search modes */ - REGISTER_LONG_CONSTANT("UDM_MODE_ALL", UDM_MODE_ALL,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_MODE_ANY", UDM_MODE_ANY,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_MODE_BOOL", UDM_MODE_BOOL,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_MODE_PHRASE", UDM_MODE_PHRASE,CONST_CS | CONST_PERSISTENT); - - /* search cache params */ - REGISTER_LONG_CONSTANT("UDM_CACHE_ENABLED", UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_CACHE_DISABLED", UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - - /* track mode params */ - REGISTER_LONG_CONSTANT("UDM_TRACK_ENABLED", UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_TRACK_DISABLED", UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - - /* phrase mode params */ - REGISTER_LONG_CONSTANT("UDM_PHRASE_ENABLED", UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PHRASE_DISABLED", UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - - /* general params */ - REGISTER_LONG_CONSTANT("UDM_ENABLED", UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_DISABLED", UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - - /* crosswords mode params */ - REGISTER_LONG_CONSTANT("UDM_CROSS_WORDS_ENABLED",UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_CROSSWORDS_ENABLED",UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_CROSS_WORDS_DISABLED",UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_CROSSWORDS_DISABLED",UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - - /* prefixes mode params */ - REGISTER_LONG_CONSTANT("UDM_PREFIXES_ENABLED", UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PREFIX_ENABLED", UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_PREFIXES_ENABLED",UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_PREFIX_ENABLED",UDM_ENABLED,CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UDM_PREFIXES_DISABLED", UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_PREFIX_DISABLED", UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_PREFIXES_DISABLED",UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_PREFIX_DISABLED",UDM_DISABLED,CONST_CS | CONST_PERSISTENT); - - /* ispell type params */ - REGISTER_LONG_CONSTANT("UDM_ISPELL_TYPE_AFFIX", UDM_ISPELL_TYPE_AFFIX,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_TYPE_SPELL", UDM_ISPELL_TYPE_SPELL,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_TYPE_DB", UDM_ISPELL_TYPE_DB,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_ISPELL_TYPE_SERVER",UDM_ISPELL_TYPE_SERVER,CONST_CS | CONST_PERSISTENT); - - /* word match mode params */ - REGISTER_LONG_CONSTANT("UDM_MATCH_WORD", UDM_MATCH_WORD,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_MATCH_BEGIN", UDM_MATCH_BEGIN,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_MATCH_SUBSTR", UDM_MATCH_SUBSTR,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("UDM_MATCH_END", UDM_MATCH_END,CONST_CS | CONST_PERSISTENT); - - return SUCCESS; -} -/* }}} */ - -DLEXPORT PHP_MSHUTDOWN_FUNCTION(mnogosearch) -{ - return SUCCESS; -} - - -DLEXPORT PHP_RINIT_FUNCTION(mnogosearch) -{ - return SUCCESS; -} - - -DLEXPORT PHP_MINFO_FUNCTION(mnogosearch) -{ - char buf[32]; - - php_info_print_table_start(); - php_info_print_table_row(2, "mnoGoSearch Support", "enabled" ); - - sprintf(buf,"%d", UDM_VERSION_ID); - php_info_print_table_row(2, "mnoGoSearch library version", buf ); - php_info_print_table_end(); -} - -static char* MyRemoveHiLightDup(const char *s){ - size_t len=strlen(s)+1; - char *d, *res = (char*)emalloc(len); - - for(d=res; s[0]; s++) - { - switch(s[0]) - { - case '\2': - case '\3': - break; - case '&': - if (s[1] == '#') - { - char *e; - int code= 0; - - for (e= (char *)s+2; (*e >= '0') && (*e <= '9'); code= code*10 + e[0]-'0', e++); - if (*e == ';') - { - *d++= (code < 128) ? code : '?'; - s= e; - break; - } - } - /* pass through */ - - default: - *d++=*s; - } - } - *d='\0'; - return res; -} - -/* {{{ proto int udm_alloc_agent(string dbaddr [, string dbmode]) - Allocate mnoGoSearch session */ -DLEXPORT PHP_FUNCTION(udm_alloc_agent) -{ - switch(ZEND_NUM_ARGS()){ - - case 1: { - pval **yydbaddr; - char *dbaddr; - UDM_ENV * Env; - UDM_AGENT * Agent; - - if(zend_get_parameters_ex(1,&yydbaddr)==FAILURE){ - RETURN_FALSE; - } - convert_to_string_ex(yydbaddr); - dbaddr = Z_STRVAL_PP(yydbaddr); - -#if UDM_VERSION_ID >= 30204 - Env=UdmEnvInit(NULL); - UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7"); -#if UDM_VERSION_ID >= 30215 - UdmSetLogLevel(NULL,0); -#else - UdmSetLogLevel(Env,0); -#endif - UdmOpenLog("mnoGoSearch-php",Env,0); -#if UDM_VERSION_ID <= 30210 - if(!memcmp(dbaddr,"searchd:",8)){ - UDM_URL Url; - UdmURLParse(&Url,dbaddr); - UdmDBListAdd(&Env->sdcl,Url.hostinfo); - } - - UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr); - - if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){ - sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr); -#if UDM_VERSION_ID <= 30207 - Env->errcode=1; -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Invalid DBAddr"); - RETURN_FALSE; - } -#else - UdmDBListAdd(&Env->dbl,dbaddr, UDM_OPEN_MODE_WRITE); -#endif - Agent=UdmAgentInit(NULL,Env,0); -#elif UDM_VERSION_ID >= 30200 - Env=UdmAllocEnv(); - Env->vars=UdmAllocVarList(); - Env->DBAddr=strdup(dbaddr); - UdmEnvSetDBMode(Env,"single"); - Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ); -#else - Env=UdmAllocEnv(); - UdmEnvSetDBAddr(Env,dbaddr); - Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ); -#endif - ZEND_REGISTER_RESOURCE(return_value,Agent,le_link); - } - break; - - case 2: { - pval **yydbaddr; - pval **yydbmode; - char *dbaddr; - char *dbmode; - UDM_ENV * Env; - UDM_AGENT * Agent; - - if(zend_get_parameters_ex(2,&yydbaddr,&yydbmode)==FAILURE){ - RETURN_FALSE; - } - convert_to_string_ex(yydbaddr); - convert_to_string_ex(yydbmode); - dbaddr = Z_STRVAL_PP(yydbaddr); - dbmode = Z_STRVAL_PP(yydbmode); - -#if UDM_VERSION_ID >= 30204 - Env=UdmEnvInit(NULL); - UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7"); -#if UDM_VERSION_ID >= 30215 - UdmSetLogLevel(NULL,0); -#else - UdmSetLogLevel(Env,0); -#endif - UdmOpenLog("mnoGoSearch-php",Env,0); -#if UDM_VERSION_ID <= 30210 - if(!memcmp(dbaddr,"searchd:",8)){ - UDM_URL Url; - UdmURLParse(&Url,dbaddr); - UdmDBListAdd(&Env->sdcl,Url.hostinfo); - } - UdmVarListReplaceStr(&Env->Vars,"DBAddr",dbaddr); - if(UDM_OK!=UdmDBSetAddr(Env->db,dbaddr,UDM_OPEN_MODE_READ)){ - sprintf(Env->errstr,"Invalid DBAddr: '%s'",dbaddr); -#if UDM_VERSION_ID <= 30207 - Env->errcode=1; -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Invalid DBAddr"); - RETURN_FALSE; - } -#else - UdmDBListAdd(&Env->dbl,dbaddr, UDM_OPEN_MODE_WRITE); -#endif - Agent=UdmAgentInit(NULL,Env,0); -#elif UDM_VERSION_ID >= 30200 - Env=UdmAllocEnv(); - Env->vars=UdmAllocVarList(); - Env->DBAddr=strdup(dbaddr); - UdmEnvSetDBMode(Env,dbmode); - Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ); -#else - Env=UdmAllocEnv(); - UdmEnvSetDBAddr(Env,dbaddr); - UdmEnvSetDBMode(Env,dbmode); - Agent=UdmAllocAgent(Env,0,UDM_OPEN_MODE_READ); -#endif - ZEND_REGISTER_RESOURCE(return_value,Agent,le_link); - } - break; - - default: - WRONG_PARAM_COUNT; - break; - } -} -/* }}} */ - -/* {{{ proto int udm_set_agent_param(int agent, int var, string val) - Set mnoGoSearch agent session parameters */ -DLEXPORT PHP_FUNCTION(udm_set_agent_param) -{ - pval **yyagent, **yyvar, **yyval; - char *val; - int var; - UDM_AGENT * Agent; - - switch(ZEND_NUM_ARGS()){ - - case 3: - if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){ - RETURN_FALSE; - } - convert_to_long_ex(yyvar); - convert_to_string_ex(yyval); - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); - var = Z_LVAL_PP(yyvar); - val = Z_STRVAL_PP(yyval); - - break; - - default: - WRONG_PARAM_COUNT; - break; - } - - switch(var){ - case UDM_PARAM_PAGE_SIZE: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"ps",val); -#else - Agent->page_size=atoi(val); - if(Agent->page_size<1)Agent->page_size=20; -#endif - break; - - case UDM_PARAM_PAGE_NUM: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"np",val); -#else - Agent->page_number=atoi(val); - if(Agent->page_number<0)Agent->page_number=0; -#endif - break; - - case UDM_PARAM_SEARCH_MODE: - switch (atoi(val)){ - case UDM_MODE_ALL: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"m","all"); -#else - Agent->search_mode=UDM_MODE_ALL; -#endif - break; - - case UDM_MODE_ANY: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"m","any"); -#else - Agent->search_mode=UDM_MODE_ANY; -#endif - break; - - case UDM_MODE_BOOL: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"m","bool"); -#else - Agent->search_mode=UDM_MODE_BOOL; -#endif - break; - - case UDM_MODE_PHRASE: -#if UDM_VERSION_ID >= 30200 - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown search mode"); - RETURN_FALSE; -#else - Agent->search_mode=UDM_MODE_PHRASE; -#endif - break; - - default: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"m","all"); -#else - Agent->search_mode=UDM_MODE_ALL; -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown search mode"); - RETURN_FALSE; - break; - } - break; - - case UDM_PARAM_WORD_MATCH: - switch (atoi(val)){ - case UDM_MATCH_WORD: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","wrd"); -#else - Agent->word_match=UDM_MATCH_WORD; -#endif - break; - - case UDM_MATCH_BEGIN: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","beg"); -#else - Agent->word_match=UDM_MATCH_BEGIN; -#endif - break; - - case UDM_MATCH_END: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","end"); -#else - Agent->word_match=UDM_MATCH_END; -#endif - break; - - case UDM_MATCH_SUBSTR: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","sub"); -#else - Agent->word_match=UDM_MATCH_SUBSTR; -#endif - break; - - default: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"wm","wrd"); -#else - Agent->word_match=UDM_MATCH_WORD; -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown word match mode"); - RETURN_FALSE; - break; - } - break; - case UDM_PARAM_CACHE_MODE: - switch (atoi(val)){ - case UDM_ENABLED: -#if UDM_VERSION_ID < 30200 - Agent->cache_mode=UDM_ENABLED; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"Cache","yes"); -#else - UdmReplaceStrVar(Agent->Conf->vars,"Cache","yes",UDM_VARSRC_GLOBAL); -#endif - break; - - case UDM_DISABLED: -#if UDM_VERSION_ID < 30200 - Agent->cache_mode=UDM_DISABLED; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"Cache","no"); -#else - UdmReplaceStrVar(Agent->Conf->vars,"Cache","no",UDM_VARSRC_GLOBAL); -#endif - break; - - default: -#if UDM_VERSION_ID < 30200 - Agent->cache_mode=UDM_DISABLED; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"Cache","no"); -#else - UdmReplaceStrVar(Agent->Conf->vars,"Cache","no",UDM_VARSRC_GLOBAL); -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown cache mode"); - RETURN_FALSE; - break; - } - - break; - - case UDM_PARAM_TRACK_MODE: - switch (atoi(val)){ - case UDM_ENABLED: -#if UDM_VERSION_ID < 30200 - Agent->track_mode|=UDM_TRACK_QUERIES; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"TrackQuery","yes"); -#else - UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","yes",UDM_VARSRC_GLOBAL); -#endif - break; - - case UDM_DISABLED: -#if UDM_VERSION_ID < 30200 - Agent->track_mode &= ~(UDM_TRACK_QUERIES); -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"TrackQuery","no"); -#else - UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","no",UDM_VARSRC_GLOBAL); -#endif - - break; - - default: -#if UDM_VERSION_ID < 30200 - Agent->track_mode &= ~(UDM_TRACK_QUERIES); -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"TrackQuery","no"); -#else - UdmReplaceStrVar(Agent->Conf->vars,"TrackQuery","no",UDM_VARSRC_GLOBAL); -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown track mode"); - RETURN_FALSE; - break; - } - - break; - - case UDM_PARAM_PHRASE_MODE: -#if UDM_VERSION_ID < 30200 - switch (atoi(val)){ - case UDM_ENABLED: - Agent->Conf->use_phrases=UDM_ENABLED; - break; - - case UDM_DISABLED: - Agent->Conf->use_phrases=UDM_DISABLED; - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown phrase mode"); - RETURN_FALSE; - break; - } -#endif - break; - - case UDM_PARAM_ISPELL_PREFIXES: - switch (atoi(val)){ - case UDM_ENABLED: -#if UDM_VERSION_ID < 30200 - Agent->Conf->ispell_mode |= UDM_ISPELL_USE_PREFIXES; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"IspellUsePrefixes","1"); -#else - UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 1, UDM_VARSRC_GLOBAL); -#endif - break; - - case UDM_DISABLED: -#if UDM_VERSION_ID < 30200 - Agent->Conf->ispell_mode &= ~UDM_ISPELL_USE_PREFIXES; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"IspellUsePrefixes","0"); -#else - UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 0, UDM_VARSRC_GLOBAL); -#endif - break; - - - default: -#if UDM_VERSION_ID < 30200 - Agent->Conf->ispell_mode |= UDM_ISPELL_USE_PREFIXES; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"IspellUsePrefixes","0"); -#else - UdmAddIntVar(Agent->Conf->vars, "IspellUsePrefixes", 1, UDM_VARSRC_GLOBAL); -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown ispell prefixes mode"); - RETURN_FALSE; - break; - } - - break; - - case UDM_PARAM_CHARSET: - case UDM_PARAM_LOCAL_CHARSET: -#if UDM_VERSION_ID < 30200 - Agent->Conf->local_charset=UdmGetCharset(val); - Agent->charset=Agent->Conf->local_charset; -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"LocalCharset",val); - { - const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"LocalCharset","iso-8859-1"); - Agent->Conf->lcs=UdmGetCharSet(charset); - } -#else - Agent->Conf->local_charset=strdup(val); - UdmReplaceStrVar(Agent->Conf->vars,"LocalCharset",val,UDM_VARSRC_GLOBAL); -#endif - - break; - -#if UDM_VERSION_ID >= 30200 - case UDM_PARAM_BROWSER_CHARSET: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"BrowserCharset",val); - { - const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"BrowserCharset","iso-8859-1"); - Agent->Conf->bcs=UdmGetCharSet(charset); - } -#else - Agent->Conf->browser_charset=strdup(val); - UdmReplaceStrVar(Agent->Conf->vars,"BrowserCharset",val,UDM_VARSRC_GLOBAL); -#endif - break; - - case UDM_PARAM_HLBEG: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"HlBeg",val); -#else - UdmReplaceStrVar(Agent->Conf->vars,"HlBeg",val,UDM_VARSRC_GLOBAL); -#endif - break; - - case UDM_PARAM_HLEND: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"HlEnd",val); -#else - UdmReplaceStrVar(Agent->Conf->vars,"HlEnd",val,UDM_VARSRC_GLOBAL); -#endif - break; - - case UDM_PARAM_SYNONYM: - if (UdmSynonymListLoad(Agent->Conf,val)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",Agent->Conf->errstr); - RETURN_FALSE; -#if UDM_VERSION_ID >= 30204 - } else UdmSynonymListSort(&(Agent->Conf->Synonyms)); -#else - } else UdmSynonymListSort(&(Agent->Conf->SynList)); -#endif - break; - - case UDM_PARAM_QSTRING: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"QUERY_STRING",val); -#else - UdmReplaceStrVar(Agent->Conf->vars,"QUERY_STRING",val,UDM_VARSRC_GLOBAL); -#endif - break; - - - case UDM_PARAM_REMOTE_ADDR: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"IP",val); -#else - UdmReplaceStrVar(Agent->Conf->vars,"IP",val,UDM_VARSRC_GLOBAL); -#endif - break; -#endif - - case UDM_PARAM_STOPTABLE: -#if UDM_VERSION_ID < 30200 - strcat(Agent->Conf->stop_tables," "); - strcat(Agent->Conf->stop_tables,val); -#endif - break; - - case UDM_PARAM_STOPFILE: -#if UDM_VERSION_ID >= 30204 - if (UdmStopListLoad(Agent->Conf,val)) { -#else - if (UdmFileLoadStopList(Agent->Conf,val)) { -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", Agent->Conf->errstr); - RETURN_FALSE; - } - break; - - case UDM_PARAM_WEIGHT_FACTOR: -#if UDM_VERSION_ID < 30200 - Agent->weight_factor=strdup(val); -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"wf",val); -#else - UdmReplaceStrVar(Agent->Conf->vars,"wf",val,UDM_VARSRC_GLOBAL); - { - size_t len; - - len=strlen(val); - if((len>0)&&(len<256)){ - const char *sec; - int sn; - - for(sn=0;sn<256;sn++){ - Agent->wf[sn]=0; - } - - for(sec=val+len-1;sec>=val;sec--){ - Agent->wf[len-(sec-val)]=UdmHex2Int(*sec); - } - } - } -#endif - break; - - case UDM_PARAM_MIN_WORD_LEN: -#if UDM_VERSION_ID >= 30204 - Agent->Conf->WordParam.min_word_len=atoi(val); -#else - Agent->Conf->min_word_len=atoi(val); -#endif - break; - - case UDM_PARAM_MAX_WORD_LEN: -#if UDM_VERSION_ID >= 30204 - Agent->Conf->WordParam.max_word_len=atoi(val); -#else - Agent->Conf->max_word_len=atoi(val); -#endif - break; - - case UDM_PARAM_CROSS_WORDS: - switch (atoi(val)){ - case UDM_ENABLED: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"CrossWords","yes"); -#else - Agent->Conf->use_crossword=UDM_ENABLED; -#endif - break; - - case UDM_DISABLED: -#if UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"CrossWords","no"); -#else - Agent->Conf->use_crossword=UDM_DISABLED; -#endif - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown crosswords mode"); - RETURN_FALSE; - break; - } - - break; - -#if UDM_VERSION_ID > 30112 - - case UDM_PARAM_VARDIR: -#if UDM_VERSION_ID < 30200 - udm_snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); -#elif UDM_VERSION_ID >= 30208 - UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val); -#elif UDM_VERSION_ID >= 30204 - UdmVarListReplaceStr(&Agent->Conf->Vars,"Vardir",val); - snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); -#else - snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); -#endif - break; -#endif - -#if UDM_VERSION_ID >= 30204 - case UDM_PARAM_QUERY: - UdmVarListReplaceStr(&Agent->Conf->Vars,"q",val); - - break; - - case UDM_PARAM_STORED: - UdmVarListReplaceStr(&Agent->Conf->Vars,"StoredAddr",val); - - break; -#endif - -#if UDM_VERSION_ID >= 30207 - case UDM_PARAM_GROUPBYSITE: - switch (atoi(val)){ - case UDM_ENABLED: - UdmVarListReplaceStr(&Agent->Conf->Vars,"GroupBySite","yes"); - - break; - - case UDM_DISABLED: - UdmVarListReplaceStr(&Agent->Conf->Vars,"GroupBySite","no"); - - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown groupbysite mode"); - RETURN_FALSE; - break; - } - - break; - - case UDM_PARAM_SITEID: - UdmVarListReplaceStr(&Agent->Conf->Vars,"site",val); - - break; - - case UDM_PARAM_DETECT_CLONES: - switch (atoi(val)){ - case UDM_ENABLED: - UdmVarListReplaceStr(&Agent->Conf->Vars,"DetectClones","yes"); - - break; - - case UDM_DISABLED: - UdmVarListReplaceStr(&Agent->Conf->Vars,"DetectClones","no"); - - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown clones mode"); - RETURN_FALSE; - break; - } - - break; -#endif - -#if UDM_VERSION_ID >= 30214 - case UDM_PARAM_SORT_ORDER: - UdmVarListReplaceStr(&Agent->Conf->Vars,"s",val); - - break; -#endif - -#if UDM_VERSION_ID >= 30215 - case UDM_PARAM_RESULTS_LIMIT: - UdmVarListReplaceStr(&Agent->Conf->Vars,"ResultsLimit",val); - - break; -#endif - -#if UDM_VERSION_ID >= 30216 - case UDM_PARAM_EXCERPT_SIZE: - UdmVarListReplaceStr(&Agent->Conf->Vars,"ExcerptSize",val); - - break; - case UDM_PARAM_EXCERPT_PADDING: - UdmVarListReplaceStr(&Agent->Conf->Vars,"ExcerptPadding",val); - - break; -#endif - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown agent session parameter"); - RETURN_FALSE; - break; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_load_ispell_data(int agent, int var, string val1, [string charset], string val2, int flag) - Load ispell data */ -DLEXPORT PHP_FUNCTION(udm_load_ispell_data) -{ - pval **yyagent, **yyvar, **yyval1, **yyval2, **yyflag, **yycharset ; - char *val1, *val2, *charset; - int var, flag; - UDM_AGENT * Agent; - - switch(ZEND_NUM_ARGS()){ - - case 5: - if(zend_get_parameters_ex(5,&yyagent,&yyvar,&yyval1,&yyval2,&yyflag)==FAILURE){ - RETURN_FALSE; - } - convert_to_long_ex(yyvar); - convert_to_long_ex(yyflag); - convert_to_string_ex(yyval1); - convert_to_string_ex(yyval2); - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); - var = Z_LVAL_PP(yyvar); - flag = Z_LVAL_PP(yyflag); - val1 = Z_STRVAL_PP(yyval1); - val2 = Z_STRVAL_PP(yyval2); - charset = "us-ascii"; - - break; - - case 6: - if(zend_get_parameters_ex(6,&yyagent,&yyvar,&yyval1,&yycharset,&yyval2,&yyflag)==FAILURE){ - RETURN_FALSE; - } - convert_to_long_ex(yyvar); - convert_to_long_ex(yyflag); - convert_to_string_ex(yyval1); - convert_to_string_ex(yyval2); - convert_to_string_ex(yycharset); - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); - var = Z_LVAL_PP(yyvar); - flag = Z_LVAL_PP(yyflag); - val1 = Z_STRVAL_PP(yyval1); - val2 = Z_STRVAL_PP(yyval2); - charset = Z_STRVAL_PP(yycharset); - - break; - - default: - WRONG_PARAM_COUNT; - break; - } - - - switch(var){ -#if UDM_VERSION_ID < 30200 - case UDM_ISPELL_TYPE_DB: - Agent->Conf->ispell_mode |= UDM_ISPELL_MODE_DB; - - if (UdmDBImportAffixes(Agent,Agent->charset) || - UdmImportDictionaryFromDB(Agent)) { - RETURN_FALSE; - } - - break; - -#if UDM_VERSION_ID > 30111 - - case UDM_ISPELL_TYPE_SERVER: - Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; - Agent->Conf->ispell_mode |= UDM_ISPELL_MODE_SERVER; - - Agent->Conf->spellhost = strdup(val1); - - break; - -#endif -#endif - - case UDM_ISPELL_TYPE_AFFIX: -#if UDM_VERSION_ID < 30200 - Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; -#if UDM_VERSION_ID > 30111 - Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_SERVER; -#endif - if (UdmImportAffixes(Agent->Conf,val1,val2,NULL,0)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load affix file %s",val2); - RETURN_FALSE; - } -#elif UDM_VERSION_ID < 30225 - if (UdmImportAffixes(Agent->Conf,val1,charset,val2)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load affix file %s",val2); - RETURN_FALSE; - } -#else - if(UdmAffixListListAdd(&Agent->Conf->Affixes,val1,charset,val2)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load affix file %s",val2); - RETURN_FALSE; - } -#endif - break; - - case UDM_ISPELL_TYPE_SPELL: -#if UDM_VERSION_ID < 30200 - Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_DB; -#if UDM_VERSION_ID > 30111 - Agent->Conf->ispell_mode &= ~UDM_ISPELL_MODE_SERVER; -#endif - if (UdmImportDictionary(Agent->Conf,val1,val2,1,"")) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load spell file %s",val2); - RETURN_FALSE; - } -#elif UDM_VERSION_ID < 30225 - if (UdmImportDictionary(Agent->Conf,val1,charset,val2,0,"")) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load spell file %s",val2); - RETURN_FALSE; - } -#else - if(UdmSpellListListAdd(&Agent->Conf->Spells,val1,charset,val2)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot load spell file %s",val2); - RETURN_FALSE; - } -#endif - break; - - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown ispell type parameter"); - RETURN_FALSE; - break; - } - - if (flag) { -#if UDM_VERSION_ID < 30225 -#if UDM_VERSION_ID >= 30204 - if(Agent->Conf->Spells.nspell) { - UdmSortDictionary(&Agent->Conf->Spells); - UdmSortAffixes(&Agent->Conf->Affixes,&Agent->Conf->Spells); - } -#else - if(Agent->Conf->nspell) { - UdmSortDictionary(Agent->Conf); - UdmSortAffixes(Agent->Conf); - } -#endif -#else - if(Agent->Conf->Spells.nitems && Agent->Conf->Affixes.nitems) { - char *err= Agent->Conf->errstr; - int flags= strcasecmp(UdmVarListFindStr(&Agent->Conf->Vars, - "IspellUsePrefixes","no"),"no"); - flags= flags ? 0 : UDM_SPELL_NOPREFIX; - if (UdmSpellListListLoad(&Agent->Conf->Spells, err, 128) || - UdmAffixListListLoad(&Agent->Conf->Affixes, flags, err, 128)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error loading ispell data"); - RETURN_FALSE; - } - } -#endif - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_free_ispell_data(int agent) - Free memory allocated for ispell data */ -DLEXPORT PHP_FUNCTION(udm_free_ispell_data) -{ - pval ** yyagent; - UDM_AGENT * Agent; - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link); - -#if UDM_VERSION_ID >= 30225 - UdmSpellListListFree(&Agent->Conf->Spells); - UdmAffixListListFree(&Agent->Conf->Affixes); -#elif UDM_VERSION_ID >= 30204 - UdmSpellListFree(&Agent->Conf->Spells); - UdmAffixListFree(&Agent->Conf->Affixes); -#elif UDM_VERSION_ID > 30111 - UdmFreeIspell(Agent->Conf); -#endif - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_add_search_limit(int agent, int var, string val) - Add mnoGoSearch search restrictions */ -DLEXPORT PHP_FUNCTION(udm_add_search_limit) -{ - pval **yyagent, **yyvar, **yyval; - char *val; - int var; - UDM_AGENT * Agent; - - switch(ZEND_NUM_ARGS()){ - - case 3: - if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){ - RETURN_FALSE; - } - convert_to_long_ex(yyvar); - convert_to_string_ex(yyval); - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); - var = Z_LVAL_PP(yyvar); - val = Z_STRVAL_PP(yyval); - - break; - - default: - WRONG_PARAM_COUNT; - break; - } - - switch(var){ - case UDM_LIMIT_URL: -#if UDM_VERSION_ID >= 30204 - UdmVarListAddStr(&Agent->Conf->Vars,"ul",val); -#else - UdmAddURLLimit(Agent->Conf,val); -#endif - break; - - case UDM_LIMIT_TAG: -#if UDM_VERSION_ID >= 30204 - UdmVarListAddStr(&Agent->Conf->Vars,"t",val); -#else - UdmAddTagLimit(Agent->Conf,val); -#endif - break; - - case UDM_LIMIT_LANG: -#if UDM_VERSION_ID >= 30204 - UdmVarListAddStr(&Agent->Conf->Vars,"lang",val); -#else - UdmAddLangLimit(Agent->Conf,val); -#endif - break; - - case UDM_LIMIT_CAT: -#if UDM_VERSION_ID >= 30204 - UdmVarListAddStr(&Agent->Conf->Vars,"cat",val); -#else - UdmAddCatLimit(Agent->Conf,val); -#endif - break; - - case UDM_LIMIT_TYPE: -#if UDM_VERSION_ID >= 30207 - UdmVarListAddStr(&Agent->Conf->Vars,"type",val); -#endif - break; - - case UDM_LIMIT_DATE: -#if UDM_VERSION_ID < 30200 - { - struct udm_stl_info_t stl_info = { 0, 0, 0 }; - char *edate; - - if (val[0] == '>') { - Z_TYPE(stl_info)=1; - } else if (val[0] == '<') { - Z_TYPE(stl_info)=-1; - } else if((val[0]=='#')&&(edate=strchr(val,','))){ - Z_TYPE(stl_info)=2; - stl_info.t2=(time_t)(atol(edate+1)); - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Incorrect date limit format"); - RETURN_FALSE; - } - - stl_info.t1=(time_t)(atol(val+1)); - UdmAddTimeLimit(Agent->Conf,&stl_info); - } -#elif UDM_VERSION_ID >= 30210 - { - struct tm *d_tm; - time_t d_t; - char *d_val2; - char d_db[20], d_de[20]; - d_t = atol (val+1); - d_tm = localtime (&d_t); - if (val[0] == '>') { - UdmVarListReplaceStr(&Agent->Conf->Vars,"dt","er"); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dx","1"); - sprintf (d_db, "%d", d_tm->tm_mday); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dd",d_db); - sprintf (d_db, "%d", d_tm->tm_mon); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dm",d_db); - sprintf (d_db, "%d", d_tm->tm_year+1900); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dy",d_db); - RETURN_TRUE; - } else if (val[0] == '<') { - UdmVarListReplaceStr(&Agent->Conf->Vars,"dt","er"); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dx","-1"); - sprintf (d_db, "%d", d_tm->tm_mday); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dd",d_db); - sprintf (d_db, "%d", d_tm->tm_mon); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dm",d_db); - sprintf (d_db, "%d", d_tm->tm_year+1900); - UdmVarListReplaceStr(&Agent->Conf->Vars,"dy",d_db); - RETURN_TRUE; - } else if ( (val[0]=='#') && (d_val2 = strchr(val,',')) ){ - UdmVarListReplaceStr(&Agent->Conf->Vars,"dt","range"); - sprintf (d_db, "%d/%d/%d", d_tm->tm_mday, d_tm->tm_mon+1, d_tm->tm_year+1900); - d_t = atol (d_val2+1); - d_tm = localtime (&d_t); - sprintf (d_de, "%d/%d/%d", d_tm->tm_mday, d_tm->tm_mon+1, d_tm->tm_year+1900); - UdmVarListReplaceStr(&Agent->Conf->Vars,"db",d_db); - UdmVarListReplaceStr(&Agent->Conf->Vars,"de",d_de); - RETURN_TRUE; - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Incorrect date limit format"); - RETURN_FALSE; - } - } -#endif - break; - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown search limit parameter"); - RETURN_FALSE; - break; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_clear_search_limits(int agent) - Clear all mnoGoSearch search restrictions */ -DLEXPORT PHP_FUNCTION(udm_clear_search_limits) -{ - pval ** yyagent; - UDM_AGENT * Agent; - int i; - - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link); -#if UDM_VERSION_ID >= 30204 - for(i=0;iConf->Vars.nvars;i++){ - if ((!strcasecmp("ul",Agent->Conf->Vars.Var[i].name))|| - (!strcasecmp("cat",Agent->Conf->Vars.Var[i].name))|| - (!strcasecmp("t",Agent->Conf->Vars.Var[i].name))|| - (!strcasecmp("type",Agent->Conf->Vars.Var[i].name))|| - (!strcasecmp("lang",Agent->Conf->Vars.Var[i].name))) { - UDM_FREE(Agent->Conf->Vars.Var[i].name); - UDM_FREE(Agent->Conf->Vars.Var[i].val); - Agent->Conf->Vars.nvars--; - } - } -#else - UdmClearLimits(Agent->Conf); -#endif - RETURN_TRUE; -} -/* }}} */ - -#if UDM_VERSION_ID >= 30200 -/* {{{ proto int udm_check_charset(int agent, string charset) - Check if the given charset is known to mnogosearch */ -DLEXPORT PHP_FUNCTION(udm_check_charset) -{ - pval ** yycharset, ** yyagent; - UDM_AGENT * Agent; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yycharset)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - convert_to_string_ex(yycharset); - - - if (UdmGetCharSet(Z_STRVAL_PP(yycharset))) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ -#endif - -#if UDM_VERSION_ID >= 30203 -/* {{{ proto int udm_crc32(int agent, string str) - Return CRC32 checksum of gived string */ -DLEXPORT PHP_FUNCTION(udm_crc32) -{ - pval ** yystr, ** yyagent; - char *str; - int crc32; - char buf[32]; - UDM_AGENT * Agent; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yystr)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - convert_to_string_ex(yystr); - str = Z_STRVAL_PP(yystr); - - crc32=UdmCRC32((str),strlen(str)); - snprintf(buf,sizeof(buf)-1,"%u",crc32); - - RETURN_STRING(buf,1); -} -/* }}} */ -#endif - -#if UDM_VERSION_ID >= 30204 -/* {{{ proto int udm_parse_query_string(int agent, string str) - Parses query string, initialises variables and search limits taken from it */ -DLEXPORT PHP_FUNCTION(udm_parse_query_string) -{ - pval ** yystr, ** yyagent; - char *str; - UDM_AGENT * Agent; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yystr)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - convert_to_string_ex(yystr); - str = Z_STRVAL_PP(yystr); - - UdmParseQueryString(Agent,&Agent->Conf->Vars,str); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_make_excerpt(int agent, int res, int row) - Perform search */ -DLEXPORT PHP_FUNCTION(udm_make_excerpt) -{ - pval ** yyagent, **yyres, **yyrow_num; - UDM_RESULT * Res; - UDM_AGENT * Agent; - int id=-1, row; - - switch(ZEND_NUM_ARGS()){ - case 3: { - if (zend_get_parameters_ex(3, &yyagent, &yyres, &yyrow_num)==FAILURE) { - RETURN_FALSE; - } - convert_to_string_ex(yyrow_num); - row=atoi(Z_STRVAL_PP(yyrow_num)); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res); - - if(rownum_rows){ - char *al; - char *Excerpt; - -#if UDM_VERSION_ID >= 30216 - size_t ExcerptSize, ExcerptPadding; - - ExcerptSize = (size_t)UdmVarListFindInt(&Agent->Conf->Vars, "ExcerptSize", 256); - ExcerptPadding = (size_t)UdmVarListFindInt(&Agent->Conf->Vars, "ExcerptPadding", 40); -#endif - - al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), "URL", ""))); - UdmVarListReplaceInt(&(Res->Doc[row].Sections), "STORED_ID", UdmCRC32(al, strlen(al))); - efree(al); - -#if UDM_VERSION_ID >= 30216 - Excerpt = UdmExcerptDoc(Agent, Res, &(Res->Doc[row]), ExcerptSize, ExcerptPadding); - if (Excerpt) { - UdmVarListReplaceStr(&(Res->Doc[row].Sections),"Body",Excerpt); - UDM_FREE(Excerpt); - } -#else - Excerpt = UdmExcerptDoc(Agent, Res, &(Res->Doc[row]), 256); - if ((Excerpt != NULL) && (strlen(Excerpt) > 6)) { - char *HlExcerpt = UdmHlConvert(&Res->WWList, Excerpt, Agent->Conf->lcs, Agent->Conf->bcs); - UdmVarListReplaceStr(&(Res->Doc[row].Sections),"Body",HlExcerpt); - UDM_FREE(HlExcerpt); - } -#endif - if (Excerpt != NULL && (UdmVarListFindStr(&(Res->Doc[row].Sections), "Z", NULL) == NULL)) { - UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",1); - UDM_FREE(Excerpt); - } else { - UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",0); - RETURN_FALSE; - } - }else{ - php_error_docref(NULL TSRMLS_CC, E_WARNING,"row number too large"); - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_set_agent_param_ex(int agent, string var, string val) - Set mnoGoSearch agent session parameters extended */ -DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex) -{ - pval **yyagent, **yyvar, **yyval; - char *val, *var; - UDM_AGENT * Agent; - - switch(ZEND_NUM_ARGS()){ - - case 3: - if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){ - RETURN_FALSE; - } - convert_to_string_ex(yyvar); - convert_to_string_ex(yyval); - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); - var = Z_STRVAL_PP(yyvar); - val = Z_STRVAL_PP(yyval); - - break; - - default: - WRONG_PARAM_COUNT; - break; - } - - UdmVarListReplaceStr(&Agent->Conf->Vars,var,val); - - if (!strcasecmp(var,"LocalCharset")) { - const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"LocalCharset","iso-8859-1"); - Agent->Conf->lcs=UdmGetCharSet(charset); - } else if (!strcasecmp(var,"BrowserCharset")) { - const char * charset=UdmVarListFindStr(&Agent->Conf->Vars,"BrowserCharset","iso-8859-1"); - Agent->Conf->bcs=UdmGetCharSet(charset); - } else if (!strcasecmp(var,"Synonym")) { - if (UdmSynonymListLoad(Agent->Conf,val)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",Agent->Conf->errstr); - RETURN_FALSE; - } else UdmSynonymListSort(&(Agent->Conf->Synonyms)); - } else if (!strcasecmp(var,"Stopwordfile")) { - if (UdmStopListLoad(Agent->Conf,val)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", Agent->Conf->errstr); - RETURN_FALSE; - } - } else if (!strcasecmp(var,"MinWordLen")) { - Agent->Conf->WordParam.min_word_len=atoi(val); - } else if (!strcasecmp(var,"MaxWordLen")) { - Agent->Conf->WordParam.max_word_len=atoi(val); -#if UDM_VERSION_ID <= 30207 - } else if (!strcasecmp(var,"VarDir")) { - snprintf(Agent->Conf->vardir,sizeof(Agent->Conf->vardir)-1,"%s%s",val,UDMSLASHSTR); -#endif - } - - RETURN_TRUE; -} - -/* {{{ proto string udm_get_agent_param_ex(int agent, string field) - Fetch mnoGoSearch environment parameters */ -DLEXPORT PHP_FUNCTION(udm_get_agent_param_ex) -{ - pval **yyagent, **yyfield_name; - - UDM_AGENT * Agent; - int row; - char *field; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yyfield_name)==FAILURE){ - RETURN_FALSE; - } - convert_to_string_ex(yyfield_name); - field = Z_STRVAL_PP(yyfield_name); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); - - RETURN_STRING((char *)UdmVarListFindStr(&Agent->Conf->Vars,field,""),1); -} -/* }}} */ - -/* {{{ proto string udm_get_res_field_ex(int res, int row, string field) - Fetch mnoGoSearch result field */ -DLEXPORT PHP_FUNCTION(udm_get_res_field_ex) -{ - pval **yyres, **yyrow_num, **yyfield_name; - - UDM_RESULT * Res; - int row; - char *field; - - switch(ZEND_NUM_ARGS()){ - case 3: { - if (zend_get_parameters_ex(3, &yyres,&yyrow_num,&yyfield_name)==FAILURE){ - RETURN_FALSE; - } - convert_to_string_ex(yyrow_num); - convert_to_string_ex(yyfield_name); - field = Z_STRVAL_PP(yyfield_name); - row = atoi(Z_STRVAL_PP(yyrow_num)); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - - ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res); - if(rownum_rows){ - if (!strcasecmp(field,"URL")) { - char *al; - al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), field, ""))); - UdmVarListReplaceStr(&Res->Doc[row].Sections,field,al); - efree(al); - } - RETURN_STRING((char *)UdmVarListFindStr(&Res->Doc[row].Sections,field,""),1); - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"row number too large"); - RETURN_FALSE; - } -} -/* }}} */ -#endif - -#if UDM_VERSION_ID >= 30216 -/* {{{ proto int udm_store_doc_cgi(int agent) - Get CachedCopy of document and return TRUE if cached copy found */ -DLEXPORT PHP_FUNCTION(udm_store_doc_cgi) -{ - pval ** yyagent; - UDM_AGENT * Agent; - int id=-1; - - const char *htok; - char *last = NULL; - UDM_DOCUMENT *Doc; - UDM_RESULT *Res; - UDM_HTMLTOK tag; - char *HDoc=NULL; - char *HEnd=NULL; - char ch; - const char *content_type, *charset; - UDM_CHARSET *cs; - - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - - Doc=UdmDocInit(NULL); - Res=UdmResultInit(NULL); - - UdmPrepare(Agent,Res); - UdmVarListReplaceStr(&Doc->Sections, "URL", UdmVarListFindStr(&Agent->Conf->Vars, "URL", "0")); - UdmVarListReplaceStr(&Doc->Sections, "dbnum", UdmVarListFindStr(&Agent->Conf->Vars, "dbnum", "0")); - UdmURLAction(Agent, Doc, UDM_URL_ACTION_GET_CACHED_COPY); - UdmVarListReplaceLst(&Agent->Conf->Vars, &Doc->Sections, NULL, "*"); - - charset = UdmVarListFindStr(&Agent->Conf->Vars,"Charset","iso-8859-1"); - cs = UdmGetCharSet(charset); - - /* UnStore Doc, Highlight and Display */ - - content_type = UdmVarListFindStr(&Agent->Conf->Vars, "Content-Type", "text/html"); - - if(!Doc->Buf.content) { - UdmResultFree(Res); - UdmDocFree(Doc); - - RETURN_FALSE; - } - - HEnd=HDoc = (char*)emalloc(UDM_MAXDOCSIZE + 32); - *HEnd='\0'; - - if (strncasecmp(content_type, "text/plain", 10) == 0) { - sprintf(HEnd, "
\n");
-	  HEnd += strlen(HEnd);
-	}
-
-	UdmHTMLTOKInit(&tag);
-	for(htok = UdmHTMLToken(Doc->Buf.content, (const char **)&last, &tag) ; htok ;) {
-		switch(tag.type) {
-		case UDM_HTML_COM:
-		case UDM_HTML_TAG:
-			memcpy(HEnd,htok,(size_t)(last-htok));
-			HEnd+=last-htok;
-			HEnd[0]='\0';
-				UdmHTMLParseTag(&tag,Doc);
-			break;
-		case UDM_HTML_TXT:
-		        ch = *last; *last = '\0';
-			if (tag.title || tag.script) {
-			  sprintf(HEnd, "%s", UdmHlConvert(NULL, htok, cs, cs));
-			} else {
-			  sprintf(HEnd, "%s", UdmHlConvert(&Res->WWList, htok, cs, cs));
-			}
-			HEnd=UDM_STREND(HEnd);
-			*last = ch;
-			break;
-		}
-		htok = UdmHTMLToken(NULL, (const char **)&last, &tag);
-	}
-
-	if (strncasecmp(content_type, "text/plain", 10) == 0) {
-	  sprintf(HEnd, "
\n"); - HEnd += strlen(HEnd); - } - - UdmVarListAddStr(&Agent->Conf->Vars, "document", HDoc); - - UdmResultFree(Res); - UdmDocFree(Doc); - efree(HDoc); - - RETURN_TRUE; -} -/* }}} */ -#endif - -#if UDM_VERSION_ID >= 30211 -/* {{{ proto int udm_alloc_agent_array(array dbaddr) - Allocate mnoGoSearch session */ -DLEXPORT PHP_FUNCTION(udm_alloc_agent_array) -{ - switch(ZEND_NUM_ARGS()){ - - case 1: { - pval **yydbaddr; - zval **tmp; - char *dbaddr; - UDM_ENV * Env; - UDM_AGENT * Agent; - HashPosition pos; - - if(zend_get_parameters_ex(1,&yydbaddr)==FAILURE){ - RETURN_FALSE; - } - - if (Z_TYPE_PP(yydbaddr) != IS_ARRAY) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument DBAddr must be an array."); - RETURN_FALSE; - } - convert_to_array_ex(yydbaddr); - - Env=UdmEnvInit(NULL); - UdmVarListReplaceStr(&Env->Vars,"SyslogFacility","local7"); -#if UDM_VERSION_ID >= 30215 - UdmSetLogLevel(NULL,0); -#else - UdmSetLogLevel(Env,0); -#endif - UdmOpenLog("mnoGoSearch-php",Env,0); - - zend_hash_internal_pointer_reset_ex(HASH_OF(*yydbaddr), &pos); - - while (zend_hash_get_current_data_ex(HASH_OF(*yydbaddr), (void **)&tmp, &pos) == SUCCESS) { - convert_to_string_ex(tmp); - dbaddr = Z_STRVAL_PP(tmp); - UdmDBListAdd(&Env->dbl,dbaddr, UDM_OPEN_MODE_WRITE); - - zend_hash_move_forward_ex(HASH_OF(*yydbaddr), &pos); - } - - Agent=UdmAgentInit(NULL,Env,0); - ZEND_REGISTER_RESOURCE(return_value,Agent,le_link); - } - break; - - default: - WRONG_PARAM_COUNT; - break; - } -} -/* }}} */ - -/* {{{ proto int udm_hash32(int agent, string str) - Return Hash32 checksum of gived string */ -DLEXPORT PHP_FUNCTION(udm_hash32) -{ - pval ** yystr, ** yyagent; - char *str; - udmhash32_t hash32; - char buf[32]; - UDM_AGENT * Agent; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yystr)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - convert_to_string_ex(yystr); - str = Z_STRVAL_PP(yystr); - - hash32=UdmHash32((str),strlen(str)); -#if UDM_VERSION_ID >= 30215 - snprintf(buf,sizeof(buf)-1,"%i",hash32); -#else - snprintf(buf,sizeof(buf)-1,"%u",hash32); -#endif - - RETURN_STRING(buf,1); -} -/* }}} */ -#endif - -/* {{{ proto int udm_find(int agent, string query) - Perform search */ -DLEXPORT PHP_FUNCTION(udm_find) -{ - pval ** yyquery=NULL, ** yyagent; - UDM_RESULT * Res; - UDM_AGENT * Agent; - int id=-1; - - switch(ZEND_NUM_ARGS()){ -#if UDM_VERSION_ID >= 30213 - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; -#endif - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yyquery)==FAILURE) { - RETURN_FALSE; - } - convert_to_string_ex(yyquery); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - -#if UDM_VERSION_ID < 30200 - if ((Res=UdmFind(Agent,UdmTolower(Z_STRVAL_PP(yyquery),Agent->charset)))) { -#else -#if UDM_VERSION_ID >= 30213 - if ((yyquery) && (strlen(Z_STRVAL_PP(yyquery)))) - UdmVarListReplaceStr(&Agent->Conf->Vars, "q", - Z_STRVAL_PP(yyquery)); - if ((Res=UdmFind(Agent))) { -#else - if ((Res=UdmFind(Agent,Z_STRVAL_PP(yyquery)))) { -#endif -#endif - ZEND_REGISTER_RESOURCE(return_value,Res,le_res); - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto string udm_get_res_field(int res, int row, int field) - Fetch mnoGoSearch result field */ -DLEXPORT PHP_FUNCTION(udm_get_res_field) -{ - pval **yyres, **yyrow_num, **yyfield_name; - - UDM_RESULT * Res; - int row,field; - - switch(ZEND_NUM_ARGS()){ - case 3: { - if (zend_get_parameters_ex(3, &yyres,&yyrow_num,&yyfield_name)==FAILURE){ - RETURN_FALSE; - } - convert_to_string_ex(yyrow_num); - convert_to_string_ex(yyfield_name); - field=atoi(Z_STRVAL_PP(yyfield_name)); - row=atoi(Z_STRVAL_PP(yyrow_num)); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res); - if(rownum_rows){ - switch(field){ - case UDM_FIELD_URL: -#if UDM_VERSION_ID >= 30204 - { - char *al; - al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), "URL", ""))); - UdmVarListReplaceStr(&Res->Doc[row].Sections,"URL",al); - efree(al); - - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"URL",""),1); - } -#else - RETURN_STRING((Res->Doc[row].url)?(Res->Doc[row].url):"",1); -#endif - break; - - case UDM_FIELD_CONTENT: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Content-Type",""),1); -#else - RETURN_STRING((Res->Doc[row].content_type)?(Res->Doc[row].content_type):"",1); -#endif - break; - - case UDM_FIELD_TITLE: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Title",""),1); -#else - RETURN_STRING((Res->Doc[row].title)?(Res->Doc[row].title):"",1); -#endif - break; - - case UDM_FIELD_KEYWORDS: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Meta.Keywords",""),1); -#else - RETURN_STRING((Res->Doc[row].keywords)?(Res->Doc[row].keywords):"",1); -#endif - break; - - case UDM_FIELD_DESC: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Meta.Description",""),1); -#else - RETURN_STRING((Res->Doc[row].description)?(Res->Doc[row].description):"",1); -#endif - break; - - case UDM_FIELD_TEXT: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Body",""),1); -#else - RETURN_STRING((Res->Doc[row].text)?(Res->Doc[row].text):"",1); -#endif - break; - - case UDM_FIELD_SIZE: -#if UDM_VERSION_ID >= 30204 - RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Content-Length",0)); -#else - RETURN_LONG((Res->Doc[row].size)); -#endif - break; - - case UDM_FIELD_URLID: -#if UDM_VERSION_ID >= 30204 - RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"ID",0)); -#else - RETURN_LONG((Res->Doc[row].url_id)); -#endif - break; - - case UDM_FIELD_RATING: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Score",""),1); -#else - RETURN_LONG((Res->Doc[row].rating)); -#endif - break; - - case UDM_FIELD_MODIFIED: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Last-Modified",""),1); -#else - RETURN_LONG((Res->Doc[row].last_mod_time)); -#endif - break; - - case UDM_FIELD_ORDER: -#if UDM_VERSION_ID >= 30204 - RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Order",0)); -#else - RETURN_LONG((Res->Doc[row].order)); -#endif - break; - - case UDM_FIELD_CRC: -#if UDM_VERSION_ID >= 30204 - RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"crc32",0)); -#else - RETURN_LONG((Res->Doc[row].crc32)); -#endif - break; - - case UDM_FIELD_CATEGORY: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Category",""),1); -#else - RETURN_STRING((Res->Doc[row].category)?(Res->Doc[row].category):"",1); -#endif - break; - -#if UDM_VERSION_ID >= 30203 - case UDM_FIELD_LANG: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Content-Language",""),1); -#else - RETURN_STRING((Res->Doc[row].lang)?(Res->Doc[row].lang):"",1); -#endif - break; - - case UDM_FIELD_CHARSET: -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Charset",""),1); -#else - RETURN_STRING((Res->Doc[row].charset)?(Res->Doc[row].charset):"",1); -#endif - break; -#endif - -#if UDM_VERSION_ID >= 30207 - case UDM_FIELD_SITEID: - RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Site_id",0)); - - break; - - case UDM_FIELD_POP_RANK: - RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"Pop_Rank",""),1); - - break; - - case UDM_FIELD_ORIGINID: - RETURN_LONG(UdmVarListFindInt(&(Res->Doc[row].Sections),"Origin-Id",0)); - - break; -#endif - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown mnoGoSearch field name"); - RETURN_FALSE; - break; - } - }else{ - php_error_docref(NULL TSRMLS_CC, E_WARNING,"row number too large"); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto string udm_get_res_param(int res, int param) - Get mnoGoSearch result parameters */ -DLEXPORT PHP_FUNCTION(udm_get_res_param) -{ - pval ** yyres, ** yyparam; - int param; - UDM_RESULT * Res; - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyres, &yyparam)==FAILURE) { - RETURN_FALSE; - } - convert_to_long_ex(yyparam); - param=(Z_LVAL_PP(yyparam)); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res); - switch(param){ - case UDM_PARAM_NUM_ROWS: - RETURN_LONG(Res->num_rows); - break; - - case UDM_PARAM_FOUND: - RETURN_LONG(Res->total_found); - break; - - case UDM_PARAM_WORDINFO: -#if UDM_VERSION_ID >= 30204 - { - int len,i; - for(len = i = 0; i < Res->WWList.nwords; i++) - len += Res->WWList.Word[i].len + 64; - { - size_t wsize=(1+len)*sizeof(char); - char *wordinfo = (char*) emalloc(wsize); - - *wordinfo = '\0'; - - for(i = 0; i < Res->WWList.nwords; i++){ - if ((Res->WWList.Word[i].count > 0) || - (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_QUERY)) { - if(wordinfo[0]) strcat(wordinfo,", "); - sprintf(UDM_STREND(wordinfo)," %s : %d", Res->WWList.Word[i].word, Res->WWList.Word[i].count); - } else if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) { - if(wordinfo[0]) strcat(wordinfo,", "); - sprintf(UDM_STREND(wordinfo)," %s : stopword", Res->WWList.Word[i].word); - } - } - RETURN_STRING(wordinfo,0); - } - } -#else - RETURN_STRING((Res->wordinfo)?(Res->wordinfo):"",1); -#endif - break; - -#if UDM_VERSION_ID >= 30204 - case UDM_PARAM_WORDINFO_ALL: - { - int len,i,j; - for(len = i = 0; i < Res->WWList.nwords; i++) - len += Res->WWList.Word[i].len + 64; - { - size_t wsize=(1+len)*sizeof(char); - char *wordinfo = (char*) emalloc(wsize); - int corder = (size_t)-1, ccount = 0; - - *wordinfo = '\0'; - - for(i = 0; i < Res->WWList.nwords; i++) { - corder = Res->WWList.Word[i].order; - ccount = 0; - for(j = 0; j < Res->WWList.nwords; j++) { - if (Res->WWList.Word[j].order == corder) { - ccount += Res->WWList.Word[j].count; - } - } - if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_STOP) { - sprintf(UDM_STREND(wordinfo),"%s%s : stopword", (*wordinfo) ? ", " : "", Res->WWList.Word[i].word); - } else if (Res->WWList.Word[i].origin == UDM_WORD_ORIGIN_QUERY) { - sprintf(UDM_STREND(wordinfo),"%s%s : %d / %d", (*wordinfo) ? ", " : "", Res->WWList.Word[i].word, Res->WWList.Word[i].count, ccount); - } else continue; - } - RETURN_STRING(wordinfo,0); - } - } - break; -#endif - - case UDM_PARAM_SEARCHTIME: - RETURN_DOUBLE(((double)Res->work_time)/1000); - break; - - case UDM_PARAM_FIRST_DOC: - RETURN_LONG(Res->first); - break; - - case UDM_PARAM_LAST_DOC: - RETURN_LONG(Res->last); - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unknown mnoGoSearch param name"); - RETURN_FALSE; - break; - } -} -/* }}} */ - -/* {{{ proto int udm_free_res(int res) - mnoGoSearch free result */ -DLEXPORT PHP_FUNCTION(udm_free_res) -{ - pval ** yyres; - UDM_RESULT * Res; - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyres)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res); - zend_list_delete(Z_LVAL_PP(yyres)); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_free_agent(int agent) - Free mnoGoSearch session */ -DLEXPORT PHP_FUNCTION(udm_free_agent) -{ - pval ** yyagent; - UDM_RESULT * Agent; - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_RESULT *, yyagent, -1, "mnoGoSearch-agent", le_link); - zend_list_delete(Z_LVAL_PP(yyagent)); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int udm_errno(int agent) - Get mnoGoSearch error number */ -DLEXPORT PHP_FUNCTION(udm_errno) -{ - pval ** yyagent; - UDM_AGENT * Agent; - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link); -#if UDM_VERSION_ID >= 30208 - if (UdmEnvErrMsg(Agent->Conf) && strlen(UdmEnvErrMsg(Agent->Conf))) { - RETURN_LONG(1); - } else { - RETURN_LONG(0); - } -#elif UDM_VERSION_ID >= 30204 - RETURN_LONG(UdmEnvErrCode(Agent->Conf)); -#else - RETURN_LONG(UdmDBErrorCode(Agent->db)); -#endif -} -/* }}} */ - -/* {{{ proto string udm_error(int agent) - Get mnoGoSearch error message */ -DLEXPORT PHP_FUNCTION(udm_error) -{ - pval ** yyagent; - UDM_AGENT * Agent; - - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-Agent", le_link); -#if UDM_VERSION_ID >= 30204 - RETURN_STRING((UdmEnvErrMsg(Agent->Conf))?(UdmEnvErrMsg(Agent->Conf)):"",1); -#else - RETURN_STRING((UdmDBErrorMsg(Agent->db))?(UdmDBErrorMsg(Agent->db)):"",1); -#endif -} -/* }}} */ - -/* {{{ proto int udm_api_version() - Get mnoGoSearch API version */ -DLEXPORT PHP_FUNCTION(udm_api_version) -{ - RETURN_LONG(UDM_VERSION_ID); -} -/* }}} */ - -/* {{{ proto array udm_cat_list(int agent, string category) - Get mnoGoSearch categories list with the same root */ -DLEXPORT PHP_FUNCTION(udm_cat_list) -{ - pval ** yycat, ** yyagent; - UDM_AGENT * Agent; - char *cat; -#if UDM_VERSION_ID >= 30204 - UDM_CATEGORY C; -#else - UDM_CATEGORY *c=NULL; -#endif - char *buf=NULL; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yycat)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - convert_to_string_ex(yycat); - cat = Z_STRVAL_PP(yycat); - -#if UDM_VERSION_ID >= 30204 - bzero(&C,sizeof(C)); - strncpy(C.addr,cat,sizeof(C.addr)-1); -#if UDM_VERSION_ID <= 30210 - if(!UdmCatAction(Agent,&C,UDM_CAT_ACTION_LIST,Agent->Conf->db)){ -#else - if(UDM_OK == UdmCatAction(Agent,&C,UDM_CAT_ACTION_LIST)){ -#endif -#else - if((c=UdmCatList(Agent,cat))){ -#endif - array_init(return_value); - - if (!(buf=ecalloc(1,UDMSTRSIZ+1))) { - RETURN_FALSE; - } - -#if UDM_VERSION_ID >= 30204 - { - int i; - if (C.ncategories) { - for(i=0;irec_id){ - snprintf(buf, UDMSTRSIZ, "%s%s",c->link[0]?"@ ":"", c->name); - add_next_index_string(return_value, c->link[0]?c->link:c->path, 1); - add_next_index_string(return_value, buf, 1); - c++; - } -#endif - efree(buf); - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto array udm_cat_path(int agent, string category) - Get mnoGoSearch categories path from the root to the given catgory */ -DLEXPORT PHP_FUNCTION(udm_cat_path) -{ - pval ** yycat, ** yyagent; - UDM_AGENT * Agent; - char *cat; -#if UDM_VERSION_ID >= 30204 - UDM_CATEGORY C; -#else - UDM_CATEGORY *c=NULL; -#endif - char *buf=NULL; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 2: { - if (zend_get_parameters_ex(2, &yyagent,&yycat)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); - convert_to_string_ex(yycat); - cat = Z_STRVAL_PP(yycat); - -#if UDM_VERSION_ID >= 30204 - bzero(&C,sizeof(C)); - strncpy(C.addr,cat,sizeof(C.addr)-1); -#if UDM_VERSION_ID <= 30210 - if(!UdmCatAction(Agent,&C,UDM_CAT_ACTION_PATH,Agent->Conf->db)){ -#else - if(UDM_OK == UdmCatAction(Agent,&C,UDM_CAT_ACTION_PATH)){ -#endif -#else - if((c=UdmCatPath(Agent,cat))){ -#endif - array_init(return_value); - - if (!(buf=ecalloc(1,UDMSTRSIZ+1))) { - RETURN_FALSE; - } - -#if UDM_VERSION_ID >= 30204 - { - int i; - if (C.ncategories) { - for(i=0;irec_id){ - snprintf(buf, UDMSTRSIZ, "%s%s",c->link[0]?"@ ":"", c->name); - add_next_index_string(return_value, c->link[0]?c->link:c->path, 1); - add_next_index_string(return_value, buf, 1); - c++; - } -#endif - efree(buf); - } else { - RETURN_FALSE; - } -} -/* }}} */ - -#if UDM_VERSION_ID > 30110 -/* {{{ proto int udm_get_doc_count(int agent) - Get total number of documents in database */ -DLEXPORT PHP_FUNCTION(udm_get_doc_count) -{ - pval ** yyagent; - UDM_AGENT * Agent; - int id=-1; - - switch(ZEND_NUM_ARGS()){ - case 1: { - if (zend_get_parameters_ex(1, &yyagent)==FAILURE) { - RETURN_FALSE; - } - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link); -#if UDM_VERSION_ID >= 30204 -#if UDM_VERSION_ID <= 30210 - if (!Agent->doccount) UdmURLAction(Agent,NULL,UDM_URL_ACTION_DOCCOUNT,Agent->Conf->db); -#else - if (!Agent->doccount) UdmURLAction(Agent,NULL,UDM_URL_ACTION_DOCCOUNT); -#endif - RETURN_LONG(Agent->doccount); -#else - RETURN_LONG(UdmGetDocCount(Agent)); -#endif -} -/* }}} */ -#endif - - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/mnogosearch/php_mnogo.h b/ext/mnogosearch/php_mnogo.h deleted file mode 100644 index a26fb48cdd..0000000000 --- a/ext/mnogosearch/php_mnogo.h +++ /dev/null @@ -1,113 +0,0 @@ -/* $Source$ */ -/* $Id$ */ - -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: | - | Initial version by Alex Barkov | - | and Ramil Kalimullin | - | Further development by Sergey Kartashoff | - +----------------------------------------------------------------------+ -*/ - -#ifndef _PHP_MNOGO_H -#define _PHP_MNOGO_H - -#if HAVE_MNOGOSEARCH - -#include -#include - -#if UDM_VERSION_ID >= 30203 -#include -#include -#endif - -extern zend_module_entry mnogosearch_module_entry; -#define mnogosearch_module_ptr &mnogosearch_module_entry - -#ifdef PHP_WIN32 -#define PHP_MNOGO_API __declspec(dllexport) -#else -#define PHP_MNOGO_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -/* mnoGoSearch functions */ -DLEXPORT PHP_MINIT_FUNCTION(mnogosearch); -DLEXPORT PHP_RINIT_FUNCTION(mnogosearch); -DLEXPORT PHP_MSHUTDOWN_FUNCTION(mnogosearch); -DLEXPORT PHP_MINFO_FUNCTION(mnogosearch); - -DLEXPORT PHP_FUNCTION(udm_api_version); -#if UDM_VERSION_ID >= 30200 -DLEXPORT PHP_FUNCTION(udm_check_charset); -#if UDM_VERSION_ID >= 30203 -DLEXPORT PHP_FUNCTION(udm_crc32); -#endif -#if UDM_VERSION_ID >= 30204 -DLEXPORT PHP_FUNCTION(udm_parse_query_string); -DLEXPORT PHP_FUNCTION(udm_make_excerpt); -DLEXPORT PHP_FUNCTION(udm_set_agent_param_ex); -DLEXPORT PHP_FUNCTION(udm_get_agent_param_ex); -DLEXPORT PHP_FUNCTION(udm_get_res_field_ex); -#endif -#if UDM_VERSION_ID >= 30211 -DLEXPORT PHP_FUNCTION(udm_hash32); -DLEXPORT PHP_FUNCTION(udm_alloc_agent_array); -#endif -#if UDM_VERSION_ID >= 30216 -DLEXPORT PHP_FUNCTION(udm_store_doc_cgi); -#endif -#endif - -DLEXPORT PHP_FUNCTION(udm_alloc_agent); -DLEXPORT PHP_FUNCTION(udm_set_agent_param); - -DLEXPORT PHP_FUNCTION(udm_load_ispell_data); -DLEXPORT PHP_FUNCTION(udm_free_ispell_data); - -DLEXPORT PHP_FUNCTION(udm_add_search_limit); -DLEXPORT PHP_FUNCTION(udm_clear_search_limits); - -DLEXPORT PHP_FUNCTION(udm_error); -DLEXPORT PHP_FUNCTION(udm_errno); - -DLEXPORT PHP_FUNCTION(udm_find); -DLEXPORT PHP_FUNCTION(udm_get_res_field); -DLEXPORT PHP_FUNCTION(udm_get_res_param); - -DLEXPORT PHP_FUNCTION(udm_cat_list); -DLEXPORT PHP_FUNCTION(udm_cat_path); - -DLEXPORT PHP_FUNCTION(udm_free_res); -DLEXPORT PHP_FUNCTION(udm_free_agent); - -#if UDM_VERSION_ID > 30110 -DLEXPORT PHP_FUNCTION(udm_get_doc_count); -#endif - -#else - -#define mnogosearch_module_ptr NULL - -#endif - -#define phpext_mnogosearch_ptr mnogosearch_module_ptr - -#endif /* _PHP_MNOGO_H */