[PHP-CVS] cvs: php-src /ext/interbase php_ibase_udf.c
abies Fri Jun 4 09:33:57 2004 EDT Modified files: /php-src/ext/interbase php_ibase_udf.c Log: Added support for arbitrary input types Added support for NULL input/output values http://cvs.php.net/diff.php/php-src/ext/interbase/php_ibase_udf.c?r1=1.4r2=1.5ty=u Index: php-src/ext/interbase/php_ibase_udf.c diff -u php-src/ext/interbase/php_ibase_udf.c:1.4 php-src/ext/interbase/php_ibase_udf.c:1.5 --- php-src/ext/interbase/php_ibase_udf.c:1.4 Thu Jun 3 19:18:36 2004 +++ php-src/ext/interbase/php_ibase_udf.c Fri Jun 4 09:33:56 2004 @@ -16,33 +16,38 @@ +--+ */ -/* $Id: php_ibase_udf.c,v 1.4 2004/06/03 23:18:36 abies Exp $ */ +/* $Id: php_ibase_udf.c,v 1.5 2004/06/04 13:33:56 abies Exp $ */ /** * This UDF library adds the ability to call PHP functions from SQL -* statements. You will have to declare a different external function for -* each number of parameters you require. Currently, only string arguments -* are supported as input, the output can be numeric as well. +* statements. Because of SQL's strong typing, you will have to declare +* an external function for every combination of input and output parameters +* your application requires. The types of the input arguments and the result +* type can be either [VAR]CHARs or unscaled integers or floats. * * Declare the functions like this: * * DECLARE EXTERNAL FUNCTION CALL_PHP1 -* CSTRING(xx),type BY DESCRIPTOR, CSTRING(xx) +* CSTRING(xx), +* return type BY DESCRIPTOR, +* arg type BY DESCRIPTOR * RETURNS PARAMETER 2 * ENTRY_POINT 'udf_call_php1' MODULE_NAME 'php_ibase_udf' * * DECLARE EXTERNAL FUNCTION CALL_PHP2 -* CSTRING(xx),type BY DESCRIPTOR, CSTRING(xx), CSTRING(xx) +* CSTRING(xx), +* return type BY DESCRIPTOR, +* arg type BY DESCRIPTOR, +* arg type BY DESCRIPTOR * RETURNS PARAMETER 2 * ENTRY_POINT 'udf_call_php2' MODULE_NAME 'php_ibase_udf' * -* ... and so on. +* ... and so on. [for up to 8 input arguments] * * The first input parameter contains the function you want to call. The * second argument is the result, and should not be passed as an argument. -* Subsequent arguments are passed to the called function. The lengths of -* the input strings can have any value 1. The type and length of the -* output depends on its declaration. +* [the DB will do this for you] Subsequent arguments are passed to the +* function in argument 1. * * The declared functions can be called from SQL like: * @@ -64,43 +69,66 @@ #include zend_API.h #include php.h -#include stdarg.h -#include ib_util.h #include ibase.h -#ifdef ZTS -#error This functionality is not available in ZTS mode -#endif - #define min(a,b) ((a)(b)?(a):(b)) -static void call_php(char *name, PARAMDSC *r, int argc, ...) +static void call_php(char *name, PARAMDSC *r, int argc, PARAMDSC **argv) { - zval callback, args[4], *argp[4], return_value; - va_list va; - int i; - PARAMVARY *res = (PARAMVARY*)(r-dsc_address); - - INIT_ZVAL(callback); - ZVAL_STRING(callback,name,0); do { + zval callback, args[4], *argp[4], return_value; + PARAMVARY *res = (PARAMVARY*)r-dsc_address; + int i; + + INIT_ZVAL(callback); + ZVAL_STRING(callback,name,0); + /* check if the requested function exists */ if (!zend_is_callable(callback, 0, NULL)) { break; } - va_start(va, argc); - /* create the argument array */ for (i = 0; i argc; ++i) { - char *arg = va_arg(va, char*); - + INIT_ZVAL(args[i]); - ZVAL_STRING(argp[i] = args[i], arg, 0); + argp[i] = args[i]; + + /* test arg for null */ + if (argv[i]-dsc_flags DSC_null) { + ZVAL_NULL(argp[i]); + continue; + } + + switch (argv[i]-dsc_dtype) { + case dtype_cstring: + ZVAL_STRING(argp[i], (char*)argv[i]-dsc_address,0); + break; + case dtype_text: + ZVAL_STRINGL(argp[i], (char*)argv[i]-dsc_address, argv[i]-dsc_length,0); + break; + case dtype_varying: + ZVAL_STRINGL(argp[i], ((PARAMVARY*)argv[i]-dsc_address)-vary_string, +
[PHP-CVS] cvs: php-src /ext/interbase php_ibase_udf.c
abies Fri Jun 4 10:26:33 2004 EDT Modified files: /php-src/ext/interbase php_ibase_udf.c Log: Added support for scaled integers http://cvs.php.net/diff.php/php-src/ext/interbase/php_ibase_udf.c?r1=1.5r2=1.6ty=u Index: php-src/ext/interbase/php_ibase_udf.c diff -u php-src/ext/interbase/php_ibase_udf.c:1.5 php-src/ext/interbase/php_ibase_udf.c:1.6 --- php-src/ext/interbase/php_ibase_udf.c:1.5 Fri Jun 4 09:33:56 2004 +++ php-src/ext/interbase/php_ibase_udf.c Fri Jun 4 10:26:33 2004 @@ -16,14 +16,14 @@ +--+ */ -/* $Id: php_ibase_udf.c,v 1.5 2004/06/04 13:33:56 abies Exp $ */ +/* $Id: php_ibase_udf.c,v 1.6 2004/06/04 14:26:33 abies Exp $ */ /** * This UDF library adds the ability to call PHP functions from SQL * statements. Because of SQL's strong typing, you will have to declare * an external function for every combination of input and output parameters * your application requires. The types of the input arguments and the result -* type can be either [VAR]CHARs or unscaled integers or floats. +* type can be either [VAR]CHARs, (un)scaled integers or doubles/floats. * * Declare the functions like this: * @@ -73,6 +73,16 @@ #define min(a,b) ((a)(b)?(a):(b)) +#ifdef PHP_WIN32 +#define LL_LIT(lit) lit ## I64 +#else +#define LL_LIT(lit) lit ## ll +#endif + +static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 1, 10, 100, 1, 10, + 10, LL_LIT(100),LL_LIT(1000),LL_LIT(10),LL_LIT(100), + LL_LIT(1000),LL_LIT(1000),LL_LIT(100) }; + static void call_php(char *name, PARAMDSC *r, int argc, PARAMDSC **argv) { @@ -102,27 +112,53 @@ } switch (argv[i]-dsc_dtype) { + ISC_INT64 l; + case dtype_cstring: ZVAL_STRING(argp[i], (char*)argv[i]-dsc_address,0); break; + case dtype_text: ZVAL_STRINGL(argp[i], (char*)argv[i]-dsc_address, argv[i]-dsc_length,0); break; + case dtype_varying: ZVAL_STRINGL(argp[i], ((PARAMVARY*)argv[i]-dsc_address)-vary_string, ((PARAMVARY*)argv[i]-dsc_address)-vary_length,0); break; case dtype_short: - ZVAL_LONG(argp[i], *(short*)argv[i]-dsc_address); + if (argv[i]-dsc_scale == 0) { + ZVAL_LONG(argp[i], *(short*)argv[i]-dsc_address); + } else { + ZVAL_DOUBLE(argp[i], + ((double)*(short*)argv[i]-dsc_address)/scales[-argv[i]-dsc_scale]); + } break; + case dtype_long: - ZVAL_LONG(argp[i], *(ISC_LONG*)argv[i]-dsc_address); + if (argv[i]-dsc_scale == 0) { + ZVAL_LONG(argp[i], *(ISC_LONG*)argv[i]-dsc_address); + } else { + ZVAL_DOUBLE(argp[i], + ((double)*(ISC_LONG*)argv[i]-dsc_address)/scales[-argv[i]-dsc_scale]); + } + break; + + case dtype_int64: + l = *(ISC_INT64*)argv[i]-dsc_address; + + if (argv[i]-dsc_scale == 0 l = LONG_MAX l = LONG_MIN) { + ZVAL_LONG(argp[i], (long)l); + } else { + ZVAL_DOUBLE(argp[i], ((double)l)/scales[-argv[i]-dsc_scale]); + } break; case dtype_real: ZVAL_DOUBLE(argp[i], *(float*)argv[i]-dsc_address); break; + case dtype_double: ZVAL_DOUBLE(argp[i], *(double*)argv[i]-dsc_address); break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit:
[PHP-CVS] cvs: php-src /ext/mysql php_mysql.c
iliaa Fri Jun 4 11:26:54 2004 EDT Modified files: /php-src/ext/mysql php_mysql.c Log: Fixed bug #28632 (Prevent open_basedir bypass in MySQL's LOAD DATA LOCAL). http://cvs.php.net/diff.php/php-src/ext/mysql/php_mysql.c?r1=1.208r2=1.209ty=u Index: php-src/ext/mysql/php_mysql.c diff -u php-src/ext/mysql/php_mysql.c:1.208 php-src/ext/mysql/php_mysql.c:1.209 --- php-src/ext/mysql/php_mysql.c:1.208 Fri Jun 4 09:49:31 2004 +++ php-src/ext/mysql/php_mysql.c Fri Jun 4 11:26:54 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: php_mysql.c,v 1.208 2004/06/04 13:49:31 iliaa Exp $ */ +/* $Id: php_mysql.c,v 1.209 2004/06/04 15:26:54 iliaa Exp $ */ /* TODO: * @@ -598,6 +598,11 @@ WRONG_PARAM_COUNT; break; } + /* disable local infile option for open_basedir */ +if (PG(open_basedir) strlen(PG(open_basedir)) (client_flags CLIENT_LOCAL_FILES)) { + client_flags ^= CLIENT_LOCAL_FILES; + } + if (z_host) { SEPARATE_ZVAL(z_host); /* We may modify z_host if it contains a port, separate */ convert_to_string_ex(z_host); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) / NEWS /ext/mysql php_mysql.c
iliaa Fri Jun 4 11:27:05 2004 EDT Modified files: (Branch: PHP_4_3) /php-srcNEWS /php-src/ext/mysql php_mysql.c Log: MFH: Fixed bug #28632 (Prevent open_basedir bypass in MySQL's LOAD DATA LOCAL). http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.674r2=1.1247.2.675ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1247.2.674 php-src/NEWS:1.1247.2.675 --- php-src/NEWS:1.1247.2.674 Fri Jun 4 09:49:44 2004 +++ php-src/NEWSFri Jun 4 11:27:05 2004 @@ -1,6 +1,8 @@ PHP 4 NEWS ||| ?? ??? 2004, Version 4.3.8 +- Fixed bug #28632 (Prevent open_basedir bypass via MySQL's LOAD DATA LOCAL). + (Ilia) - Fixed bug #28627 (When multiple MySQL links are used default link is leaked). (gavin at ipalsoftware dot com, Ilia) http://cvs.php.net/diff.php/php-src/ext/mysql/php_mysql.c?r1=1.174.2.26r2=1.174.2.27ty=u Index: php-src/ext/mysql/php_mysql.c diff -u php-src/ext/mysql/php_mysql.c:1.174.2.26 php-src/ext/mysql/php_mysql.c:1.174.2.27 --- php-src/ext/mysql/php_mysql.c:1.174.2.26Fri Jun 4 09:49:44 2004 +++ php-src/ext/mysql/php_mysql.c Fri Jun 4 11:27:05 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: php_mysql.c,v 1.174.2.26 2004/06/04 13:49:44 iliaa Exp $ */ +/* $Id: php_mysql.c,v 1.174.2.27 2004/06/04 15:27:05 iliaa Exp $ */ /* TODO: * @@ -593,7 +593,7 @@ break; } /* disable local infile option for open_basedir */ - if (PG(open_basedir) strlen(PG(open_basedir))) { + if (PG(open_basedir) strlen(PG(open_basedir)) (client_flags CLIENT_LOCAL_FILES)) { client_flags ^= CLIENT_LOCAL_FILES; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php