diff options
Diffstat (limited to 'ext/standard')
86 files changed, 2563 insertions, 1885 deletions
diff --git a/ext/standard/Makefile.frag b/ext/standard/Makefile.frag index 4e94962183..8b6e3e233a 100644 --- a/ext/standard/Makefile.frag +++ b/ext/standard/Makefile.frag @@ -1,9 +1,9 @@ $(srcdir)/var_unserializer.c: $(srcdir)/var_unserializer.re - @(cd $(top_srcdir); $(RE2C) -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re) + @(cd $(top_srcdir); $(RE2C) --no-generation-date -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re) $(srcdir)/url_scanner_ex.c: $(srcdir)/url_scanner_ex.re - @(cd $(top_srcdir); $(RE2C) -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re) + @(cd $(top_srcdir); $(RE2C) --no-generation-date -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re) $(builddir)/info.lo: $(builddir)/../../main/build-defs.h diff --git a/ext/standard/array.c b/ext/standard/array.c index 1deacc7159..360a691d38 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -927,24 +927,12 @@ PHP_FUNCTION(current) PHP_FUNCTION(key) { HashTable *array; - char *string_key; - uint string_length; - ulong num_key; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) { return; } - switch (zend_hash_get_current_key_ex(array, &string_key, &string_length, &num_key, 0, NULL)) { - case HASH_KEY_IS_STRING: - RETVAL_STRINGL(string_key, string_length - 1, 1); - break; - case HASH_KEY_IS_LONG: - RETVAL_LONG(num_key); - break; - case HASH_KEY_NON_EXISTANT: - return; - } + zend_hash_get_current_key_zval(array, return_value); } /* }}} */ @@ -1055,9 +1043,6 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive zval **args[3], /* Arguments to userland function */ *retval_ptr = NULL, /* Return value - unused */ *key=NULL; /* Entry key */ - char *string_key; - uint string_key_len; - ulong num_key; /* Set up known arguments */ args[1] = &key; @@ -1103,17 +1088,7 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive } else { /* Allocate space for key */ MAKE_STD_ZVAL(key); - - /* Set up the key */ - switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 0, NULL)) { - case HASH_KEY_IS_LONG: - Z_TYPE_P(key) = IS_LONG; - Z_LVAL_P(key) = num_key; - break; - case HASH_KEY_IS_STRING: - ZVAL_STRINGL(key, string_key, string_key_len - 1, 1); - break; - } + zend_hash_get_current_key_zval(target_hash, key); /* Call the userland function */ if (zend_call_function(&BG(array_walk_fci), &BG(array_walk_fci_cache) TSRMLS_CC) == SUCCESS) { @@ -1205,9 +1180,6 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ res; /* comparison result */ HashPosition pos; /* hash iterator */ zend_bool strict = 0; /* strict comparison or not */ - ulong num_key; - uint str_key_len; - char *string_key; int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za|b", &value, &array, &strict) == FAILURE) { @@ -1225,15 +1197,8 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ if (behavior == 0) { RETURN_TRUE; } else { - /* Return current key */ - switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &string_key, &str_key_len, &num_key, 0, &pos)) { - case HASH_KEY_IS_STRING: - RETURN_STRINGL(string_key, str_key_len - 1, 1); - break; - case HASH_KEY_IS_LONG: - RETURN_LONG(num_key); - break; - } + zend_hash_get_current_key_zval_ex(Z_ARRVAL_P(array), return_value, &pos); + return; } } zend_hash_move_forward_ex(Z_ARRVAL_P(array), &pos); @@ -2257,13 +2222,14 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS case HASH_KEY_IS_STRING: if (recursive && zend_hash_find(dest, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) { HashTable *thash = Z_TYPE_PP(dest_entry) == IS_ARRAY ? Z_ARRVAL_PP(dest_entry) : NULL; + zval *src_zval; + zval *tmp = NULL; if ((thash && thash->nApplyCount > 1) || (*src_entry == *dest_entry && Z_ISREF_PP(dest_entry) && (Z_REFCOUNT_PP(dest_entry) % 2))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); return 0; } SEPARATE_ZVAL(dest_entry); - SEPARATE_ZVAL(src_entry); if (Z_TYPE_PP(dest_entry) == IS_NULL) { convert_to_array_ex(dest_entry); @@ -2271,23 +2237,34 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS } else { convert_to_array_ex(dest_entry); } - if (Z_TYPE_PP(src_entry) == IS_NULL) { - convert_to_array_ex(src_entry); - add_next_index_null(*src_entry); + if (Z_TYPE_PP(src_entry) == IS_OBJECT) { + ALLOC_ZVAL(src_zval); + INIT_PZVAL_COPY(src_zval, *src_entry); + zval_copy_ctor(src_zval); + convert_to_array(src_zval); + tmp = src_zval; } else { - convert_to_array_ex(src_entry); + src_zval = *src_entry; } - if (thash) { - thash->nApplyCount++; - } - if (!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_PP(src_entry), recursive TSRMLS_CC)) { + if (Z_TYPE_P(src_zval) == IS_ARRAY) { + if (thash) { + thash->nApplyCount++; + } + if (!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_P(src_zval), recursive TSRMLS_CC)) { + if (thash) { + thash->nApplyCount--; + } + return 0; + } if (thash) { thash->nApplyCount--; } - return 0; + } else { + Z_ADDREF_PP(src_entry); + zend_hash_next_index_insert(Z_ARRVAL_PP(dest_entry), &src_zval, sizeof(zval *), NULL); } - if (thash) { - thash->nApplyCount--; + if (tmp) { + zval_ptr_dtor(&tmp); } } else { Z_ADDREF_PP(src_entry); @@ -2391,7 +2368,6 @@ static void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETERS, int array_init_size(return_value, init_size); for (i = 0; i < argc; i++) { - SEPARATE_ZVAL(args[i]); if (!replace) { php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(args[i]), recursive TSRMLS_CC); } else if (recursive && i > 0) { /* First array will be copied directly instead */ @@ -2447,9 +2423,6 @@ PHP_FUNCTION(array_keys) res, /* Result of comparison */ *new_val; /* New value */ int add_key; /* Flag to indicate whether a key should be added */ - char *string_key; /* String key */ - uint string_key_len; - ulong num_key; /* Numeric key */ zend_bool strict = 0; /* do strict comparison */ HashPosition pos; int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function; @@ -2480,19 +2453,8 @@ PHP_FUNCTION(array_keys) if (add_key) { MAKE_STD_ZVAL(new_val); - - switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 1, &pos)) { - case HASH_KEY_IS_STRING: - ZVAL_STRINGL(new_val, string_key, string_key_len - 1, 0); - zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val, sizeof(zval *), NULL); - break; - - case HASH_KEY_IS_LONG: - Z_TYPE_P(new_val) = IS_LONG; - Z_LVAL_P(new_val) = num_key; - zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val, sizeof(zval *), NULL); - break; - } + zend_hash_get_current_key_zval_ex(Z_ARRVAL_P(input), new_val, &pos); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val, sizeof(zval *), NULL); } zend_hash_move_forward_ex(Z_ARRVAL_P(input), &pos); @@ -2573,6 +2535,100 @@ PHP_FUNCTION(array_count_values) } /* }}} */ +/* {{{ array_column_param_helper + * Specialized conversion rules for array_column() function + */ +static inline +zend_bool array_column_param_helper(zval **param, + const char *name TSRMLS_DC) { + switch (Z_TYPE_PP(param)) { + case IS_DOUBLE: + convert_to_long_ex(param); + /* fallthrough */ + case IS_LONG: + return 1; + + case IS_OBJECT: + convert_to_string_ex(param); + /* fallthrough */ + case IS_STRING: + return 1; + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The %s key should be either a string or an integer", name); + return 0; + } +} + +/* {{{ proto array array_column(array input, mixed column_key[, mixed index_key]) + Return the values from a single column in the input array, identified by the + value_key and optionally indexed by the index_key */ +PHP_FUNCTION(array_column) +{ + zval **zcolumn = NULL, **zkey = NULL, **data; + HashTable *arr_hash; + HashPosition pointer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "hZ!|Z!", &arr_hash, &zcolumn, &zkey) == FAILURE) { + return; + } + + if ((zcolumn && !array_column_param_helper(zcolumn, "column" TSRMLS_CC)) || + (zkey && !array_column_param_helper(zkey, "index" TSRMLS_CC))) { + RETURN_FALSE; + } + + array_init(return_value); + for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); + zend_hash_get_current_data_ex(arr_hash, (void**)&data, &pointer) == SUCCESS; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + zval **zcolval, **zkeyval = NULL; + HashTable *ht; + + if (Z_TYPE_PP(data) != IS_ARRAY) { + /* Skip elemens which are not sub-arrays */ + continue; + } + ht = Z_ARRVAL_PP(data); + + if (!zcolumn) { + /* NULL column ID means use entire subarray as data */ + zcolval = data; + + /* Otherwise, skip if the value doesn't exist in our subarray */ + } else if ((Z_TYPE_PP(zcolumn) == IS_STRING) && + (zend_hash_find(ht, Z_STRVAL_PP(zcolumn), Z_STRLEN_PP(zcolumn) + 1, (void**)&zcolval) == FAILURE)) { + continue; + } else if ((Z_TYPE_PP(zcolumn) == IS_LONG) && + (zend_hash_index_find(ht, Z_LVAL_PP(zcolumn), (void**)&zcolval) == FAILURE)) { + continue; + } + + /* Failure will leave zkeyval alone which will land us on the final else block below + * which is to append the value as next_index + */ + if (zkey && (Z_TYPE_PP(zkey) == IS_STRING)) { + zend_hash_find(ht, Z_STRVAL_PP(zkey), Z_STRLEN_PP(zkey) + 1, (void**)&zkeyval); + } else if (zkey && (Z_TYPE_PP(zkey) == IS_LONG)) { + zend_hash_index_find(ht, Z_LVAL_PP(zkey), (void**)&zkeyval); + } + + Z_ADDREF_PP(zcolval); + if (zkeyval && Z_TYPE_PP(zkeyval) == IS_STRING) { + add_assoc_zval(return_value, Z_STRVAL_PP(zkeyval), *zcolval); + } else if (zkeyval && Z_TYPE_PP(zkeyval) == IS_LONG) { + add_index_zval(return_value, Z_LVAL_PP(zkeyval), *zcolval); + } else if (zkeyval && Z_TYPE_PP(zkeyval) == IS_OBJECT) { + SEPARATE_ZVAL(zkeyval); + convert_to_string(*zkeyval); + add_assoc_zval(return_value, Z_STRVAL_PP(zkeyval), *zcolval); + } else { + add_next_index_zval(return_value, *zcolval); + } + } +} +/* }}} */ + /* {{{ proto array array_reverse(array input [, bool preserve keys]) Return input as a new array with the order of the entries reversed */ PHP_FUNCTION(array_reverse) @@ -2691,9 +2747,6 @@ PHP_FUNCTION(array_pad) PHP_FUNCTION(array_flip) { zval *array, **entry, *data; - char *string_key; - uint str_key_len; - ulong num_key; HashPosition pos; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) { @@ -2705,15 +2758,7 @@ PHP_FUNCTION(array_flip) zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(array), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(array), (void **)&entry, &pos) == SUCCESS) { MAKE_STD_ZVAL(data); - switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &string_key, &str_key_len, &num_key, 1, &pos)) { - case HASH_KEY_IS_STRING: - ZVAL_STRINGL(data, string_key, str_key_len - 1, 0); - break; - case HASH_KEY_IS_LONG: - Z_TYPE_P(data) = IS_LONG; - Z_LVAL_P(data) = num_key; - break; - } + zend_hash_get_current_key_zval_ex(Z_ARRVAL_P(array), data, &pos); if (Z_TYPE_PP(entry) == IS_LONG) { zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_PP(entry), &data, sizeof(data), NULL); @@ -3983,7 +4028,7 @@ PHP_FUNCTION(array_rand) /* We can't use zend_hash_index_find() because the array may have string keys or gaps. */ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &pos); - while (num_req && (key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT) { + while (num_req && (key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT) { randval = php_rand(TSRMLS_C); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index ba0051630f..96b3c30bbd 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -128,6 +128,8 @@ typedef struct _user_tick_function_entry { static void user_shutdown_function_dtor(php_shutdown_function_entry *shutdown_function_entry); static void user_tick_function_dtor(user_tick_function_entry *tick_function_entry); +static HashTable basic_submodules; + #undef sprintf /* {{{ arginfo */ @@ -434,6 +436,12 @@ ZEND_BEGIN_ARG_INFO(arginfo_array_count_values, 0) ZEND_ARG_INFO(0, arg) /* ARRAY_INFO(0, arg, 0) */ ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_array_column, 0, 0, 2) + ZEND_ARG_INFO(0, arg) /* ARRAY_INFO(0, arg, 0) */ + ZEND_ARG_INFO(0, column_key) + ZEND_ARG_INFO(0, index_key) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_array_reverse, 0, 0, 1) ZEND_ARG_INFO(0, input) /* ARRAY_INFO(0, arg, 0) */ ZEND_ARG_INFO(0, preserve_keys) @@ -1548,18 +1556,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phpcredits, 0, 0, 0) ZEND_ARG_INFO(0, flag) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_php_logo_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_php_real_logo_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_php_egg_logo_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_zend_logo_guid, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(arginfo_php_sapi_name, 0) ZEND_END_ARG_INFO() @@ -1793,8 +1789,8 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_number_format, 0, 0, 1) ZEND_ARG_INFO(0, number) ZEND_ARG_INFO(0, num_decimal_places) - ZEND_ARG_INFO(0, dec_seperator) - ZEND_ARG_INFO(0, thousands_seperator) + ZEND_ARG_INFO(0, dec_separator) + ZEND_ARG_INFO(0, thousands_separator) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_fmod, 0) @@ -1864,6 +1860,25 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_getlastmod, 0) ZEND_END_ARG_INFO() /* }}} */ +/* {{{ password.c */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_hash, 0, 0, 2) + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, algo) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_get_info, 0, 0, 1) + ZEND_ARG_INFO(0, hash) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_needs_rehash, 0, 0, 2) + ZEND_ARG_INFO(0, hash) + ZEND_ARG_INFO(0, algo) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_verify, 0, 0, 2) + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, hash) +ZEND_END_ARG_INFO() +/* }}} */ /* {{{ proc_open.c */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN ZEND_BEGIN_ARG_INFO_EX(arginfo_proc_terminate, 0, 0, 1) @@ -2520,6 +2535,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_strval, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_boolval, 0) + ZEND_ARG_INFO(0, var) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_is_null, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() @@ -2717,10 +2736,6 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(phpinfo, arginfo_phpinfo) PHP_FE(phpversion, arginfo_phpversion) PHP_FE(phpcredits, arginfo_phpcredits) - PHP_FE(php_logo_guid, arginfo_php_logo_guid) - PHP_FE(php_real_logo_guid, arginfo_php_real_logo_guid) - PHP_FE(php_egg_logo_guid, arginfo_php_egg_logo_guid) - PHP_FE(zend_logo_guid, arginfo_zend_logo_guid) PHP_FE(php_sapi_name, arginfo_php_sapi_name) PHP_FE(php_uname, arginfo_php_uname) PHP_FE(php_ini_scanned_files, arginfo_php_ini_scanned_files) @@ -2874,6 +2889,10 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(base64_decode, arginfo_base64_decode) PHP_FE(base64_encode, arginfo_base64_encode) + PHP_FE(password_hash, arginfo_password_hash) + PHP_FE(password_get_info, arginfo_password_get_info) + PHP_FE(password_needs_rehash, arginfo_password_needs_rehash) + PHP_FE(password_verify, arginfo_password_verify) PHP_FE(convert_uuencode, arginfo_convert_uuencode) PHP_FE(convert_uudecode, arginfo_convert_uudecode) @@ -3043,6 +3062,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(floatval, arginfo_floatval) PHP_FALIAS(doubleval, floatval, arginfo_floatval) PHP_FE(strval, arginfo_strval) + PHP_FE(boolval, arginfo_boolval) PHP_FE(gettype, arginfo_gettype) PHP_FE(settype, arginfo_settype) PHP_FE(is_null, arginfo_is_null) @@ -3309,6 +3329,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(array_keys, arginfo_array_keys) PHP_FE(array_values, arginfo_array_values) PHP_FE(array_count_values, arginfo_array_count_values) + PHP_FE(array_column, arginfo_array_column) PHP_FE(array_reverse, arginfo_array_reverse) PHP_FE(array_reduce, arginfo_array_reduce) PHP_FE(array_pad, arginfo_array_pad) @@ -3513,6 +3534,34 @@ PHPAPI double php_get_inf(void) /* {{{ */ } /* }}} */ +#define BASIC_MINIT_SUBMODULE(module) \ + if (PHP_MINIT(module)(INIT_FUNC_ARGS_PASSTHRU) == SUCCESS) {\ + BASIC_ADD_SUBMODULE(module); \ + } + +#define BASIC_ADD_SUBMODULE(module) \ + zend_hash_add_empty_element(&basic_submodules, #module, strlen(#module)); + +#define BASIC_RINIT_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_RINIT(module)(INIT_FUNC_ARGS_PASSTHRU); \ + } + +#define BASIC_MINFO_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); \ + } + +#define BASIC_RSHUTDOWN_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU); \ + } + +#define BASIC_MSHUTDOWN_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU); \ + } + PHP_MINIT_FUNCTION(basic) /* {{{ */ { #ifdef ZTS @@ -3527,6 +3576,8 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ #endif #endif + zend_hash_init(&basic_submodules, 0, NULL, NULL, 1); + BG(incomplete_class) = incomplete_class_entry = php_create_incomplete_class(TSRMLS_C); REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT); @@ -3586,39 +3637,43 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ register_html_constants(INIT_FUNC_ARGS_PASSTHRU); register_string_constants(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(file)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(pack)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(browscap)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(standard_filters)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(user_filters)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_ADD_SUBMODULE(dl) + BASIC_ADD_SUBMODULE(mail) + BASIC_ADD_SUBMODULE(streams) + BASIC_MINIT_SUBMODULE(file) + BASIC_MINIT_SUBMODULE(pack) + BASIC_MINIT_SUBMODULE(browscap) + BASIC_MINIT_SUBMODULE(standard_filters) + BASIC_MINIT_SUBMODULE(user_filters) + BASIC_MINIT_SUBMODULE(password) #if defined(HAVE_LOCALECONV) && defined(ZTS) - PHP_MINIT(localeconv)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(localeconv) #endif #if defined(HAVE_NL_LANGINFO) - PHP_MINIT(nl_langinfo)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(nl_langinfo) #endif #if HAVE_CRYPT - PHP_MINIT(crypt)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(crypt) #endif - PHP_MINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(lcg) - PHP_MINIT(dir)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(dir) #ifdef HAVE_SYSLOG_H - PHP_MINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(syslog) #endif - PHP_MINIT(array)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(assert)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(array) + BASIC_MINIT_SUBMODULE(assert) + BASIC_MINIT_SUBMODULE(url_scanner_ex) #ifdef PHP_CAN_SUPPORT_PROC_OPEN - PHP_MINIT(proc_open)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(proc_open) #endif - PHP_MINIT(user_streams)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(imagetypes)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(user_streams) + BASIC_MINIT_SUBMODULE(imagetypes) php_register_url_stream_wrapper("php", &php_stream_php_wrapper TSRMLS_CC); php_register_url_stream_wrapper("file", &php_plain_files_wrapper TSRMLS_CC); @@ -3626,14 +3681,12 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ php_register_url_stream_wrapper("glob", &php_glob_stream_wrapper TSRMLS_CC); #endif php_register_url_stream_wrapper("data", &php_stream_rfc2397_wrapper TSRMLS_CC); -#ifndef PHP_CURL_URL_WRAPPERS php_register_url_stream_wrapper("http", &php_stream_http_wrapper TSRMLS_CC); php_register_url_stream_wrapper("ftp", &php_stream_ftp_wrapper TSRMLS_CC); -#endif #if defined(PHP_WIN32) || (HAVE_DNS_SEARCH_FUNC && !(defined(__BEOS__) || defined(NETWARE))) # if defined(PHP_WIN32) || HAVE_FULL_DNS_FUNCS - PHP_MINIT(dns)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(dns) # endif #endif @@ -3659,24 +3712,23 @@ PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */ #endif php_unregister_url_stream_wrapper("php" TSRMLS_CC); -#ifndef PHP_CURL_URL_WRAPPERS php_unregister_url_stream_wrapper("http" TSRMLS_CC); php_unregister_url_stream_wrapper("ftp" TSRMLS_CC); -#endif - PHP_MSHUTDOWN(browscap)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(array)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(file)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(standard_filters)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_MSHUTDOWN_SUBMODULE(browscap) + BASIC_MSHUTDOWN_SUBMODULE(array) + BASIC_MSHUTDOWN_SUBMODULE(assert) + BASIC_MSHUTDOWN_SUBMODULE(url_scanner_ex) + BASIC_MSHUTDOWN_SUBMODULE(file) + BASIC_MSHUTDOWN_SUBMODULE(standard_filters) #if defined(HAVE_LOCALECONV) && defined(ZTS) - PHP_MSHUTDOWN(localeconv)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_MSHUTDOWN_SUBMODULE(localeconv) #endif #if HAVE_CRYPT - PHP_MSHUTDOWN(crypt)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_MSHUTDOWN_SUBMODULE(crypt) #endif + zend_hash_destroy(&basic_submodules); return SUCCESS; } /* }}} */ @@ -3710,10 +3762,10 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU); #ifdef HAVE_SYSLOG_H - PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_RINIT_SUBMODULE(syslog) #endif - PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU); - PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_RINIT_SUBMODULE(dir) + BASIC_RINIT_SUBMODULE(url_scanner_ex) /* Setup default context */ FG(default_context) = NULL; @@ -3759,14 +3811,14 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #ifdef HAVE_SYSLOG_H #ifdef PHP_WIN32 - PHP_RSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #endif #endif - PHP_RSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_RSHUTDOWN(streams)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(assert) + BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex) + BASIC_RSHUTDOWN_SUBMODULE(streams) #ifdef PHP_WIN32 - PHP_RSHUTDOWN(win32_core_globals)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(win32_core_globals) #endif if (BG(user_tick_functions)) { @@ -3775,8 +3827,8 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ BG(user_tick_functions) = NULL; } - PHP_RSHUTDOWN(user_filters)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_RSHUTDOWN(browscap)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(user_filters) + BASIC_RSHUTDOWN_SUBMODULE(browscap) BG(page_uid) = -1; BG(page_gid) = -1; @@ -3787,10 +3839,10 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ PHP_MINFO_FUNCTION(basic) /* {{{ */ { php_info_print_table_start(); - PHP_MINFO(dl)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); - PHP_MINFO(mail)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); + BASIC_MINFO_SUBMODULE(dl) + BASIC_MINFO_SUBMODULE(mail) php_info_print_table_end(); - PHP_MINFO(assert)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); + BASIC_MINFO_SUBMODULE(assert) } /* }}} */ @@ -5056,12 +5108,12 @@ void php_free_shutdown_functions(TSRMLS_D) /* {{{ */ } /* }}} */ -/* {{{ proto void register_shutdown_function(string function_name) U +/* {{{ proto void register_shutdown_function(callback function) U Register a user-level function to be called on request termination */ PHP_FUNCTION(register_shutdown_function) { php_shutdown_function_entry shutdown_function_entry; - char *function_name = NULL; + char *callback_name = NULL; int i; shutdown_function_entry.arg_count = ZEND_NUM_ARGS(); @@ -5078,8 +5130,8 @@ PHP_FUNCTION(register_shutdown_function) } /* Prevent entering of anything but valid callback (syntax check only!) */ - if (!zend_is_callable(shutdown_function_entry.arguments[0], 0, &function_name TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", function_name); + if (!zend_is_callable(shutdown_function_entry.arguments[0], 0, &callback_name TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", callback_name); efree(shutdown_function_entry.arguments); RETVAL_FALSE; } else { @@ -5093,8 +5145,8 @@ PHP_FUNCTION(register_shutdown_function) } zend_hash_next_index_insert(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL); } - if (function_name) { - efree(function_name); + if (callback_name) { + efree(callback_name); } } /* }}} */ diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index c1f5aff7c2..3d00d88dda 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -182,12 +182,12 @@ AC_TRY_RUN([ main() { #if HAVE_CRYPT - char salt[30], answer[80]; - - salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0'; + char salt[21], answer[21+86]; + + strcpy(salt,"\$6\$rasmuslerdorf\$"); strcpy(answer, salt); - strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu."); - exit (strcmp((char *)crypt("foo",salt),answer)); + strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/"); + exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer)); #else exit(0); #endif @@ -211,12 +211,13 @@ AC_TRY_RUN([ main() { #if HAVE_CRYPT - char salt[30], answer[80]; - salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t'; salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0'; - strcat(salt,""); + char salt[21], answer[21+43]; + + strcpy(salt,"\$5\$rasmuslerdorf\$"); strcpy(answer, salt); - strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5"); - exit (strcmp((char *)crypt("foo",salt),answer)); + strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23"); + exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer)); + #else exit(0); #endif @@ -602,7 +603,7 @@ PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32. incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ - filters.c proc_open.c streamsfuncs.c http.c) + filters.c proc_open.c streamsfuncs.c http.c password.c) PHP_ADD_MAKEFILE_FRAGMENT PHP_INSTALL_HEADERS([ext/standard/]) diff --git a/ext/standard/config.w32 b/ext/standard/config.w32 index d14b859e9d..5f24641b4d 100644 --- a/ext/standard/config.w32 +++ b/ext/standard/config.w32 @@ -19,7 +19,7 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \ versioning.c assert.c strnatcmp.c levenshtein.c incomplete_class.c \ url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \ php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \ - user_filters.c uuencode.c filters.c proc_open.c \ + user_filters.c uuencode.c filters.c proc_open.c password.c \ streamsfuncs.c http.c flock_compat.c", false /* never shared */); PHP_INSTALL_HEADERS("", "ext/standard"); if (PHP_MBREGEX != "no") { diff --git a/ext/standard/credits.c b/ext/standard/credits.c index 7ce0819491..530c8d0e63 100644 --- a/ext/standard/credits.c +++ b/ext/standard/credits.c @@ -105,7 +105,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */ if (flag & PHP_CREDITS_QA) { php_info_print_table_start(); php_info_print_table_header(1, "PHP Quality Assurance Team"); - php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena"); + php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena, David Soria Parra"); php_info_print_table_end(); } diff --git a/ext/standard/credits_ext.h b/ext/standard/credits_ext.h index 7bdb41e608..2770d162fb 100644 --- a/ext/standard/credits_ext.h +++ b/ext/standard/credits_ext.h @@ -17,8 +17,8 @@ CREDIT_LINE("COM and .Net", "Wez Furlong"); CREDIT_LINE("ctype", "Hartmut Holzgraefe"); CREDIT_LINE("cURL", "Sterling Hughes"); CREDIT_LINE("Date/Time Support", "Derick Rethans"); -CREDIT_LINE("DB-LIB (MS SQL, Sybase)", "Wez Furlong, Frank M. Kromann"); CREDIT_LINE("DBA", "Sascha Schumann, Marcus Boerger"); +CREDIT_LINE("DB-LIB (MS SQL, Sybase)", "Wez Furlong, Frank M. Kromann"); CREDIT_LINE("DOM", "Christian Stocker, Rob Richards, Marcus Boerger"); CREDIT_LINE("enchant", "Pierre-Alain Joye, Ilia Alshanetsky"); CREDIT_LINE("ereg", "Rasmus Lerdorf, Jim Winstead, Jaakko Hyvätti"); @@ -41,13 +41,13 @@ CREDIT_LINE("mcrypt", "Sascha Schumann, Derick Rethans"); CREDIT_LINE("MS SQL", "Frank M. Kromann"); CREDIT_LINE("Multibyte String Functions", "Tsukada Takuya, Rui Hirokawa"); CREDIT_LINE("MySQL driver for PDO", "George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter"); -CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter"); CREDIT_LINE("MySQLi", "Zak Greant, Georg Richter, Andrey Hristov, Ulf Wendel"); -CREDIT_LINE("MySQLnd", "Andrey Hristov, Ulf Wendel, Georg Richter"); +CREDIT_LINE("MySQLnd", "Andrey Hristov, Ulf Wendel, Georg Richter, Johannes Schlueter"); +CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter, Andrey Hristov"); CREDIT_LINE("OCI8", "Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong, Christopher Jones, Oracle Corporation"); CREDIT_LINE("ODBC driver for PDO", "Wez Furlong"); CREDIT_LINE("ODBC", "Stig Bakken, Andreas Karajannis, Frank M. Kromann, Daniel R. Kalowsky"); -CREDIT_LINE("OpenSSL", "Stig Venaas, Wez Furlong, Sascha Kettler"); +CREDIT_LINE("OpenSSL", "Stig Venaas, Wez Furlong, Sascha Kettler, Scott MacVicar"); CREDIT_LINE("Oracle (OCI) driver for PDO", "Wez Furlong"); CREDIT_LINE("pcntl", "Jason Greene, Arnaud Le Blanc"); CREDIT_LINE("Perl Compatible Regexps", "Andrei Zmievski"); @@ -68,8 +68,8 @@ CREDIT_LINE("SNMP", "Rasmus Lerdorf, Harrie Hazewinkel, Mike Jackson, Steven Law CREDIT_LINE("SOAP", "Brad Lafountain, Shane Caraveo, Dmitry Stogov"); CREDIT_LINE("Sockets", "Chris Vandomelen, Sterling Hughes, Daniel Beulshausen, Jason Greene"); CREDIT_LINE("SPL", "Marcus Boerger, Etienne Kneuss"); -CREDIT_LINE("SQLite 3.x driver for PDO", "Wez Furlong"); CREDIT_LINE("SQLite3", "Scott MacVicar, Ilia Alshanetsky, Brad Dewar"); +CREDIT_LINE("SQLite 3.x driver for PDO", "Wez Furlong"); CREDIT_LINE("Sybase-CT", "Zeev Suraski, Tom May, Timm Friebe"); CREDIT_LINE("System V Message based IPC", "Wez Furlong"); CREDIT_LINE("System V Semaphores", "Tom May"); @@ -77,9 +77,9 @@ CREDIT_LINE("System V Shared Memory", "Christian Cartus"); CREDIT_LINE("tidy", "John Coggeshall, Ilia Alshanetsky"); CREDIT_LINE("tokenizer", "Andrei Zmievski, Johannes Schlueter"); CREDIT_LINE("WDDX", "Andrei Zmievski"); -CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen, Sterling Hughes"); CREDIT_LINE("XMLReader", "Rob Richards"); CREDIT_LINE("xmlrpc", "Dan Libby"); +CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen, Sterling Hughes"); CREDIT_LINE("XMLWriter", "Rob Richards, Pierre-Alain Joye"); CREDIT_LINE("XSL", "Christian Stocker, Rob Richards"); CREDIT_LINE("Zip", "Pierre-Alain Joye"); diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index c6e0351af2..113a5bd0f5 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -145,44 +145,9 @@ static void php_to64(char *s, long v, int n) /* {{{ */ } /* }}} */ -/* {{{ proto string crypt(string str [, string salt]) - Hash a string */ -PHP_FUNCTION(crypt) +PHPAPI int php_crypt(const char *password, const int pass_len, const char *salt, int salt_len, char **result) { - char salt[PHP_MAX_SALT_LEN + 1]; - char *str, *salt_in = NULL; - int str_len, salt_in_len = 0; char *crypt_res; - salt[0] = salt[PHP_MAX_SALT_LEN] = '\0'; - - /* This will produce suitable results if people depend on DES-encryption - * available (passing always 2-character salt). At least for glibc6.1 */ - memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) { - return; - } - - if (salt_in) { - memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len)); - } - - /* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */ - if (!*salt) { -#if PHP_MD5_CRYPT - strncpy(salt, "$1$", PHP_MAX_SALT_LEN); - php_to64(&salt[3], PHP_CRYPT_RAND, 4); - php_to64(&salt[7], PHP_CRYPT_RAND, 4); - strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11); -#elif PHP_STD_DES_CRYPT - php_to64(&salt[0], PHP_CRYPT_RAND, 2); - salt[2] = '\0'; -#endif - salt_in_len = strlen(salt); - } else { - salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len); - } - /* Windows (win32/crypt) has a stripped down version of libxcrypt and a CryptoApi md5_crypt implementation */ #if PHP_USE_PHP_CRYPT_R @@ -190,55 +155,44 @@ PHP_FUNCTION(crypt) struct php_crypt_extended_data buffer; if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$') { - char output[MD5_HASH_MAX_LEN]; + char output[MD5_HASH_MAX_LEN], *out; - RETURN_STRING(php_md5_crypt_r(str, salt, output), 1); + out = php_md5_crypt_r(password, salt, output); + if (out) { + *result = estrdup(out); + return SUCCESS; + } + return FAILURE; } else if (salt[0]=='$' && salt[1]=='6' && salt[2]=='$') { - const char sha512_salt_prefix[] = "$6$"; - const char sha512_rounds_prefix[] = "rounds="; char *output; - int needed = (sizeof(sha512_salt_prefix) - 1 - + sizeof(sha512_rounds_prefix) + 9 + 1 - + salt_in_len + 1 + 86 + 1); - output = emalloc(needed); - salt[salt_in_len] = '\0'; + output = emalloc(PHP_MAX_SALT_LEN); - crypt_res = php_sha512_crypt_r(str, salt, output, needed); + crypt_res = php_sha512_crypt_r(password, salt, output, PHP_MAX_SALT_LEN); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETVAL_STRING("*1", 1); - } else { - RETVAL_STRING("*0", 1); - } + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return FAILURE; } else { - RETVAL_STRING(output, 1); + *result = estrdup(output); + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return SUCCESS; } - - memset(output, 0, needed); - efree(output); } else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') { - const char sha256_salt_prefix[] = "$5$"; - const char sha256_rounds_prefix[] = "rounds="; char *output; - int needed = (sizeof(sha256_salt_prefix) - 1 - + sizeof(sha256_rounds_prefix) + 9 + 1 - + salt_in_len + 1 + 43 + 1); - output = emalloc(needed); - salt[salt_in_len] = '\0'; + output = emalloc(PHP_MAX_SALT_LEN); - crypt_res = php_sha256_crypt_r(str, salt, output, needed); + crypt_res = php_sha256_crypt_r(password, salt, output, PHP_MAX_SALT_LEN); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETVAL_STRING("*1", 1); - } else { - RETVAL_STRING("*0", 1); - } + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return FAILURE; } else { - RETVAL_STRING(output, 1); + *result = estrdup(output); + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return SUCCESS; } - - memset(output, 0, needed); - efree(output); } else if ( salt[0] == '$' && salt[1] == '2' && @@ -251,31 +205,25 @@ PHP_FUNCTION(crypt) memset(output, 0, PHP_MAX_SALT_LEN + 1); - crypt_res = php_crypt_blowfish_rn(str, salt, output, sizeof(output)); + crypt_res = php_crypt_blowfish_rn(password, salt, output, sizeof(output)); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETVAL_STRING("*1", 1); - } else { - RETVAL_STRING("*0", 1); - } + memset(output, 0, PHP_MAX_SALT_LEN + 1); + return FAILURE; } else { - RETVAL_STRING(output, 1); + *result = estrdup(output); + memset(output, 0, PHP_MAX_SALT_LEN + 1); + return SUCCESS; } - - memset(output, 0, PHP_MAX_SALT_LEN + 1); } else { memset(&buffer, 0, sizeof(buffer)); _crypt_extended_init_r(); - crypt_res = _crypt_extended_r(str, salt, &buffer); + crypt_res = _crypt_extended_r(password, salt, &buffer); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETURN_STRING("*1", 1); - } else { - RETURN_STRING("*0", 1); - } + return FAILURE; } else { - RETURN_STRING(crypt_res, 1); + *result = estrdup(crypt_res); + return SUCCESS; } } } @@ -291,21 +239,68 @@ PHP_FUNCTION(crypt) # else # error Data struct used by crypt_r() is unknown. Please report. # endif - crypt_res = crypt_r(str, salt, &buffer); + crypt_res = crypt_r(password, salt, &buffer); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETURN_STRING("*1", 1); - } else { - RETURN_STRING("*0", 1); - } + return FAILURE; } else { - RETURN_STRING(crypt_res, 1); + *result = estrdup(crypt_res); + return SUCCESS; } } # endif #endif } /* }}} */ + + +/* {{{ proto string crypt(string str [, string salt]) + Hash a string */ +PHP_FUNCTION(crypt) +{ + char salt[PHP_MAX_SALT_LEN + 1]; + char *str, *salt_in = NULL, *result = NULL; + int str_len, salt_in_len = 0; + salt[0] = salt[PHP_MAX_SALT_LEN] = '\0'; + + /* This will produce suitable results if people depend on DES-encryption + * available (passing always 2-character salt). At least for glibc6.1 */ + memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) { + return; + } + + if (salt_in) { + memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len)); + } + + /* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */ + if (!*salt) { +#if PHP_MD5_CRYPT + strncpy(salt, "$1$", PHP_MAX_SALT_LEN); + php_to64(&salt[3], PHP_CRYPT_RAND, 4); + php_to64(&salt[7], PHP_CRYPT_RAND, 4); + strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11); +#elif PHP_STD_DES_CRYPT + php_to64(&salt[0], PHP_CRYPT_RAND, 2); + salt[2] = '\0'; +#endif + salt_in_len = strlen(salt); + } else { + salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len); + } + salt[salt_in_len] = '\0'; + + if (php_crypt(str, str_len, salt, salt_in_len, &result) == FAILURE) { + if (salt[0] == '*' && salt[1] == '0') { + RETURN_STRING("*1", 1); + } else { + RETURN_STRING("*0", 1); + } + } + RETURN_STRING(result, 0); +} +/* }}} */ #endif /* diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 4d6a94766a..ceb975e93b 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -97,9 +97,9 @@ PHPAPI PHP_FUNCTION(dl) #define USING_ZTS 0 #endif -/* {{{ php_dl +/* {{{ php_load_extension */ -PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC) /* {{{ */ +PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC) { void *handle; char *libpath; @@ -171,6 +171,11 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC) } if (!get_module) { + if (DL_FETCH_SYMBOL(handle, "zend_extension_entry") || DL_FETCH_SYMBOL(handle, "_zend_extension_entry")) { + DL_UNLOAD(handle); + php_error_docref(NULL TSRMLS_CC, error_type, "Invalid library (appears to be a Zend Extension, try loading using zend_extension=%s from php.ini)", filename); + return FAILURE; + } DL_UNLOAD(handle); php_error_docref(NULL TSRMLS_CC, error_type, "Invalid library (maybe not a PHP library) '%s'", filename); return FAILURE; diff --git a/ext/standard/file.c b/ext/standard/file.c index f7af63bcf4..ad6bdad34f 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -159,6 +159,7 @@ static ZEND_RSRC_DTOR_FUNC(file_context_dtor) static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC) { FG(pclose_ret) = 0; + FG(pclose_wait) = 0; FG(user_stream_current_filename) = NULL; FG(def_chunk_size) = PHP_SOCK_CHUNK_SIZE; FG(wrapper_errors) = NULL; @@ -817,7 +818,7 @@ PHP_FUNCTION(tempnam) if (p_len > 64) { p[63] = '\0'; } - + RETVAL_FALSE; if ((fd = php_open_temporary_fd_ex(dir, p, &opened_path, 1 TSRMLS_CC)) >= 0) { @@ -960,7 +961,9 @@ PHP_FUNCTION(pclose) PHP_STREAM_TO_ZVAL(stream, &arg1); + FG(pclose_wait) = 1; zend_list_delete(stream->rsrc_id); + FG(pclose_wait) = 0; RETURN_LONG(FG(pclose_ret)); } /* }}} */ @@ -1377,13 +1380,13 @@ PHP_FUNCTION(umask) { long arg1 = 0; int oldumask; - + oldumask = umask(077); if (BG(umask) == -1) { BG(umask) = oldumask; } - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &arg1) == FAILURE) { RETURN_FALSE; } @@ -1796,22 +1799,23 @@ quit_loop: #define FPUTCSV_FLD_CHK(c) memchr(Z_STRVAL(field), c, Z_STRLEN(field)) -/* {{{ proto int fputcsv(resource fp, array fields [, string delimiter [, string enclosure]]) +/* {{{ proto int fputcsv(resource fp, array fields [, string delimiter [, string enclosure [, string escape_char]]]) Format line as CSV and write to file pointer */ PHP_FUNCTION(fputcsv) { - char delimiter = ','; /* allow this to be set as parameter */ - char enclosure = '"'; /* allow this to be set as parameter */ - const char escape_char = '\\'; + char delimiter = ','; /* allow this to be set as parameter */ + char enclosure = '"'; /* allow this to be set as parameter */ + char escape_char = '\\'; /* allow this to be set as parameter */ php_stream *stream; zval *fp = NULL, *fields = NULL; int ret; - char *delimiter_str = NULL, *enclosure_str = NULL; - int delimiter_str_len = 0, enclosure_str_len = 0; + char *delimiter_str = NULL, *enclosure_str = NULL, *escape_str = NULL; + int delimiter_str_len = 0, enclosure_str_len = 0, escape_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|ss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|sss", &fp, &fields, &delimiter_str, &delimiter_str_len, - &enclosure_str, &enclosure_str_len) == FAILURE) { + &enclosure_str, &enclosure_str_len, + &escape_str, &escape_str_len) == FAILURE) { return; } @@ -1839,6 +1843,17 @@ PHP_FUNCTION(fputcsv) enclosure = *enclosure_str; } + if (escape_str != NULL) { + if (escape_str_len < 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "escape must be a character"); + RETURN_FALSE; + } else if (escape_str_len > 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "escape must be a single character"); + } + /* use first character from string */ + escape_char = *escape_str; + } + PHP_STREAM_TO_ZVAL(stream, &fp); ret = php_fputcsv(stream, fields, delimiter, enclosure, escape_char TSRMLS_CC); @@ -2054,11 +2069,11 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char char *tmp = bptr; while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) { tmp++; - } + } if (*tmp == enclosure) { bptr = tmp; } - } + } if (first_field && bptr == line_end) { add_next_index_null(return_value); @@ -2445,7 +2460,7 @@ PHP_FUNCTION(sys_get_temp_dir) if (zend_parse_parameters_none() == FAILURE) { return; } - RETURN_STRING((char *)php_get_temporary_directory(), 1); + RETURN_STRING((char *)php_get_temporary_directory(TSRMLS_C), 1); } /* }}} */ diff --git a/ext/standard/file.h b/ext/standard/file.h index 0a4512ecd4..2bcdfd64bf 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -115,7 +115,7 @@ typedef struct _php_meta_tags_data { php_meta_tags_token php_next_meta_token(php_meta_tags_data * TSRMLS_DC); typedef struct { - int pclose_ret; + int pclose_ret; size_t def_chunk_size; long auto_detect_line_endings; long default_socket_timeout; @@ -126,6 +126,7 @@ typedef struct { HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */ HashTable *stream_filters; /* per-request copy of stream_filters_hash */ HashTable *wrapper_errors; /* key: wrapper address; value: linked list of char* */ + int pclose_wait; } php_file_globals; #ifdef ZTS diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 73be21d9a9..2713d23f1d 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -803,7 +803,7 @@ PHP_FUNCTION(touch) PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, int filename_len TSRMLS_DC) { /* always clear CurrentStatFile and CurrentLStatFile even if filename is not NULL - * as it may contains outdated data (e.g. "nlink" for a directory when deleting a file + * as it may contain outdated data (e.g. "nlink" for a directory when deleting a file * in this directory, as shown by lstat_stat_variation9.phpt) */ if (BG(CurrentStatFile)) { efree(BG(CurrentStatFile)); diff --git a/ext/standard/head.c b/ext/standard/head.c index da08c36cf8..5310ff6c03 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -40,11 +40,11 @@ PHP_FUNCTION(header) { zend_bool rep = 1; sapi_header_line ctr = {0}; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bl", &ctr.line, &ctr.line_len, &rep, &ctr.response_code) == FAILURE) return; - + sapi_header_op(rep ? SAPI_HEADER_REPLACE:SAPI_HEADER_ADD, &ctr TSRMLS_CC); } /* }}} */ @@ -80,7 +80,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t char *dt; sapi_header_line ctr = {0}; int result; - + if (name && strpbrk(name, "=,; \t\r\n\013\014") != NULL) { /* man isspace for \013 and \014 */ zend_error( E_WARNING, "Cookie names cannot contain any of the following '=,; \\t\\r\\n\\013\\014'" ); return FAILURE; @@ -111,18 +111,19 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t cookie = emalloc(len + 100); if (value && value_len == 0) { - /* + /* * MSIE doesn't delete a cookie when you set it to a null value * so in order to force cookies to be deleted, even on MSIE, we * pick an expiry date in the past */ dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, 1, 0 TSRMLS_CC); - snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s", name, dt); + snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s; Max-Age=0", name, dt); efree(dt); } else { snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : ""); if (expires > 0) { const char *p; + char tsdelta[13]; strlcat(cookie, "; expires=", len + 100); dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC); /* check to make sure that the year does not exceed 4 digits in length */ @@ -136,6 +137,10 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t } strlcat(cookie, dt, len + 100); efree(dt); + + snprintf(tsdelta, sizeof(tsdelta), "%li", (long) difftime(expires, time(NULL))); + strlcat(cookie, "; Max-Age=", len + 100); + strlcat(cookie, tsdelta, len + 100); } } @@ -237,11 +242,11 @@ PHP_FUNCTION(headers_sent) ZVAL_LONG(arg2, line); case 1: zval_dtor(arg1); - if (file) { + if (file) { ZVAL_STRING(arg1, file, 1); } else { ZVAL_STRING(arg1, "", 1); - } + } break; } diff --git a/ext/standard/http.c b/ext/standard/http.c index 3e5073591e..f9b8021950 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -56,7 +56,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, arg_sep_len = strlen(arg_sep); for (zend_hash_internal_pointer_reset(ht); - (key_type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL)) != HASH_KEY_NON_EXISTANT; + (key_type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward(ht) ) { if (key_type == HASH_KEY_IS_STRING && key_len && key[key_len-1] == '\0') { @@ -69,12 +69,11 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *tmp; zend_object *zobj = zend_objects_get_address(type TSRMLS_CC); - if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) != SUCCESS) { + if (zend_check_property_access(zobj, key, key_len TSRMLS_CC) != SUCCESS) { /* private or protected property access outside of the class */ continue; } - zend_unmangle_property_name(key, key_len-1, &tmp, (const char**)&key); - key_len = strlen(key); + zend_unmangle_property_name_ex(key, key_len, &tmp, (const char**)&key, &key_len); } if (zend_hash_get_current_data_ex(ht, (void **)&zdata, NULL) == FAILURE || !zdata || !(*zdata)) { diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 9af70f2856..f854fddf49 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -40,12 +40,12 @@ static void incomplete_class_message(zval *object, int error_type TSRMLS_DC) zend_bool class_name_alloced = 1; class_name = php_lookup_class_name(object, NULL); - + if (!class_name) { class_name_alloced = 0; class_name = "unknown"; } - + php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name); if (class_name_alloced) { @@ -57,7 +57,7 @@ static void incomplete_class_message(zval *object, int error_type TSRMLS_DC) static zval *incomplete_class_get_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */ { incomplete_class_message(object, E_NOTICE TSRMLS_CC); - + if (type == BP_VAR_W || type == BP_VAR_RW) { return EG(error_zval_ptr); } else { @@ -71,8 +71,8 @@ static void incomplete_class_write_property(zval *object, zval *member, zval *va incomplete_class_message(object, E_NOTICE TSRMLS_CC); } /* }}} */ - -static zval **incomplete_class_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */ + +static zval **incomplete_class_get_property_ptr_ptr(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */ { incomplete_class_message(object, E_NOTICE TSRMLS_CC); return &EG(error_zval_ptr); @@ -105,12 +105,12 @@ static zend_object_value php_create_incomplete_object(zend_class_entry *class_ty { zend_object *object; zend_object_value value; - + value = zend_objects_new(&object, class_type TSRMLS_CC); value.handlers = &php_incomplete_object_handlers; - + object_properties_init(object, class_type); - + return value; } @@ -128,7 +128,7 @@ PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D) php_incomplete_object_handlers.write_property = incomplete_class_write_property; php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr; php_incomplete_object_handlers.get_method = incomplete_class_get_method; - + return zend_register_internal_class(&incomplete_class TSRMLS_CC); } /* }}} */ diff --git a/ext/standard/info.c b/ext/standard/info.c index cb2e469845..48e0e85cc5 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -92,14 +92,6 @@ static int php_info_printf(const char *fmt, ...) /* {{{ */ } /* }}} */ -static void php_info_print_request_uri(TSRMLS_D) /* {{{ */ -{ - if (SG(request_info).request_uri) { - php_info_print_html_esc(SG(request_info).request_uri, strlen(SG(request_info).request_uri)); - } -} -/* }}} */ - static int php_info_print(const char *str) /* {{{ */ { TSRMLS_FETCH(); @@ -328,7 +320,7 @@ char* php_get_windows_name() } if (VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion > 4 ) { - if (osvi.dwMajorVersion == 6) { + if (osvi.dwMajorVersion == 6) { if( osvi.dwMinorVersion == 0 ) { if( osvi.wProductType == VER_NT_WORKSTATION ) { major = "Windows Vista"; @@ -342,6 +334,12 @@ char* php_get_windows_name() } else { major = "Windows Server 2008 R2"; } + } else if ( osvi.dwMinorVersion == 2 ) { + if( osvi.wProductType == VER_NT_WORKSTATION ) { + major = "Windows 8"; + } else { + major = "Windows Server 2012"; + } } else { major = "Unknown Windows version"; } @@ -664,7 +662,6 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) { char **env, *tmp1, *tmp2; char *php_uname; - int expose_php = INI_INT("expose_php"); if (!sapi_module.phpinfo_as_text) { php_print_info_htmlhead(TSRMLS_C); @@ -675,7 +672,6 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) if (flag & PHP_INFO_GENERAL) { char *zend_version = get_zend_version(); char temp_api[10]; - char *logo_guid; php_uname = php_get_uname('a'); @@ -683,14 +679,19 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print_box_start(1); } - if (expose_php && !sapi_module.phpinfo_as_text) { - php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\""); - php_info_print_request_uri(TSRMLS_C); - php_info_print("?="); - logo_guid = php_logo_guid(); - php_info_print(logo_guid); - efree(logo_guid); - php_info_print("\" alt=\"PHP Logo\" /></a>"); + if (!sapi_module.phpinfo_as_text) { + time_t the_time; + struct tm *ta, tmbuf; + + the_time = time(NULL); + ta = php_localtime_r(&the_time, &tmbuf); + + php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\""); + if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) { + php_info_print(PHP_EGG_LOGO_DATA_URI "\" alt=\"PHP logo\" /></a>"); + } else { + php_info_print(PHP_LOGO_DATA_URI "\" alt=\"PHP logo\" /></a>"); + } } if (!sapi_module.phpinfo_as_text) { @@ -791,10 +792,9 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) /* Zend Engine */ php_info_print_box_start(0); - if (expose_php && !sapi_module.phpinfo_as_text) { + if (!sapi_module.phpinfo_as_text) { php_info_print("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\""); - php_info_print_request_uri(TSRMLS_C); - php_info_print("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n"); + php_info_print(ZEND_LOGO_DATA_URI "\" alt=\"Zend logo\" /></a>\n"); } php_info_print("This program makes use of the Zend Scripting Language Engine:"); php_info_print(!sapi_module.phpinfo_as_text?"<br />":"\n"); @@ -807,15 +807,6 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) efree(php_uname); } - if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) { - php_info_print_hr(); - php_info_print("<h1><a href=\""); - php_info_print_request_uri(TSRMLS_C); - php_info_print("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">"); - php_info_print("PHP Credits"); - php_info_print("</a></h1>\n"); - } - zend_ini_sort_entries(TSRMLS_C); if (flag & PHP_INFO_CONFIGURATION) { @@ -897,6 +888,12 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print_table_end(); } + + if ((flag & PHP_INFO_CREDITS) && !sapi_module.phpinfo_as_text) { + php_info_print_hr(); + php_print_credits(PHP_CREDITS_ALL & ~PHP_CREDITS_FULLPAGE TSRMLS_CC); + } + if (flag & PHP_INFO_LICENSE) { if (!sapi_module.phpinfo_as_text) { SECTION("PHP License"); @@ -930,6 +927,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print("questions about PHP licensing, please contact license@php.net.\n"); } } + if (!sapi_module.phpinfo_as_text) { php_info_print("</div></body></html>"); } @@ -1195,77 +1193,6 @@ PHP_FUNCTION(phpcredits) } /* }}} */ -/* {{{ php_logo_guid - */ -PHPAPI char *php_logo_guid(void) -{ - char *logo_guid; - - time_t the_time; - struct tm *ta, tmbuf; - - the_time = time(NULL); - ta = php_localtime_r(&the_time, &tmbuf); - - if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) { - logo_guid = PHP_EGG_LOGO_GUID; - } else { - logo_guid = PHP_LOGO_GUID; - } - - return estrdup(logo_guid); - -} -/* }}} */ - -/* {{{ proto string php_logo_guid(void) - Return the special ID used to request the PHP logo in phpinfo screens*/ -PHP_FUNCTION(php_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRING(php_logo_guid(), 0); -} -/* }}} */ - -/* {{{ proto string php_real_logo_guid(void) - Return the special ID used to request the PHP logo in phpinfo screens*/ -PHP_FUNCTION(php_real_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1); -} -/* }}} */ - -/* {{{ proto string php_egg_logo_guid(void) - Return the special ID used to request the PHP logo in phpinfo screens*/ -PHP_FUNCTION(php_egg_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1); -} -/* }}} */ - -/* {{{ proto string zend_logo_guid(void) - Return the special ID used to request the Zend logo in phpinfo screens*/ -PHP_FUNCTION(zend_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1); -} -/* }}} */ - /* {{{ proto string php_sapi_name(void) Return the current SAPI module name */ PHP_FUNCTION(php_sapi_name) diff --git a/ext/standard/info.h b/ext/standard/info.h index aca20796fc..46a0dfc240 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -50,19 +50,14 @@ #endif /* HAVE_CREDITS_DEFS */ -#define PHP_LOGO_GUID "PHPE9568F34-D428-11d2-A769-00AA001ACF42" -#define PHP_EGG_LOGO_GUID "PHPE9568F36-D428-11d2-A769-00AA001ACF42" -#define ZEND_LOGO_GUID "PHPE9568F35-D428-11d2-A769-00AA001ACF42" -#define PHP_CREDITS_GUID "PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000" +#define PHP_LOGO_DATA_URI "data:image/gif;base64,R0lGODlheABDAOZqAH+CuDk3RyglKszN4qGky9PV57K01ENCWIOGuYKDs1JScpCSwsLE3qqs0ExLY1tcg93e7Ds4PG5xpWptnWFjjXV5sXt+teXm8JmcxoyNwbm62Wtrkk5Oa3F0qXp6o4iLvXJ0o3RzmI6QwVpbfuLj73t9raSl0G1wonJ2rJWWyLu92XR4roWIu5KVw9jZ6pKSxGRmkmtun6WozpSWxS4rL1NRaLO012xqjFxbdoqNv2ZolmhqmpyfyDEuOa6w05yczVVWeJ6hypaZxYGCr2dplz89ULy+2l5giZiZyIyOv4mKuldYfLa319XX6CIeIGxvns7Q5L/A3Hd7tHZ4p19efZmZzG5vmHN3riIeH////5COj1lWV8fGx+7u9dXU1fb2+oKAgayqq3Ryc/Hw8Z6cnePi40tISbm4uWdkZYmJtgD/AEdGX9/g7ZuczGlrnG9zp4yMuri52bi615q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s86gsADBABEJSgbit7ZDjzFgKRgC1lEJgPdiw2g2Ta70lvOkINeACXhTzNdPgUDAX24zR+asN4MjiSAS73AX5WjZxPhMA9Q/ABdbYGVY1aJuiGsBFZxqUjhhFGDlwgP4aN4HWwC2nXLOjQiLJIInbUy0Wt4pQa2IUH/ydQwARmKr8RiDSkJW3T/TCJMXpadKX/ZEBWKEqAFgDgBjCYgAJAetO75VSZjuKpEuYpgKQBlR8lYqZdhsCBhTG1qSR96pMkREcvUNWq/CBPXOixBA5QIGdN5dpTsTPWBkk1CmftR0N+YACkhUUEgJOGD0jwVa7l7LCvy2ld33TXKeQ1HiuxQQ5eUIUVoEBdS5kAAJ7gghM84G45Y9jtSgCCCHjAA2PzwGHqOqF4KuKxagkaJTmngxcIzycU+AH+iFADFCwVtCAgTwRQEIALQEAEIlBBB15QJtbKZrdpqAEMqhrbGiIThx0pgHWJgAMJ/NawDxhADzj3DBioSwQGAIfADpyLUloIpCbbHQJPlsIAGCxhBxa4HcM6at865qCcRFlsWXORA5MwIYMyWQADBBBfIdzgBRpAwVtvpzkjhCM1lHQMZKb4DY/xozsiEMAPeNDeJNDAMT/YwAkkwICJcpgsL9mMgglyGRxMlAmiAoCN2zIFeoZ4xK6NLo+nYIMX3XjISNZKEAAAOw==" BEGIN_EXTERN_C() PHP_FUNCTION(phpversion); PHP_FUNCTION(phpinfo); PHP_FUNCTION(phpcredits); -PHP_FUNCTION(php_logo_guid); -PHP_FUNCTION(php_real_logo_guid); -PHP_FUNCTION(zend_logo_guid); -PHP_FUNCTION(php_egg_logo_guid); PHP_FUNCTION(php_sapi_name); PHP_FUNCTION(php_uname); PHP_FUNCTION(php_ini_scanned_files); @@ -83,7 +78,6 @@ PHPAPI void php_info_print_box_start(int bg); PHPAPI void php_info_print_box_end(void); PHPAPI void php_info_print_hr(void); PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC); -PHPAPI char *php_logo_guid(void); PHPAPI char *php_get_uname(char mode); void register_phpinfo_constants(INIT_FUNC_ARGS); diff --git a/ext/standard/mail.c b/ext/standard/mail.c index b4f6a926c1..9499981f27 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -21,10 +21,12 @@ #include <stdlib.h> #include <ctype.h> #include <stdio.h> +#include <time.h> #include "php.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" #include "ext/standard/basic_functions.h" +#include "ext/date/php_date.h" #if HAVE_SYSEXITS_H #include <sysexits.h> @@ -246,8 +248,16 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char return val; \ if (mail_log && *mail_log) { - char *tmp; - int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + char *tmp, *date_str; + time_t curtime; + int l; + + time(&curtime); + date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1 TSRMLS_CC); + + l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", date_str, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + + efree(date_str); if (hdr) { php_mail_log_crlf_to_spaces(tmp); diff --git a/ext/standard/math.c b/ext/standard/math.c index be2d655263..f6b3d5406e 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1226,7 +1226,7 @@ PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, } /* }}} */ -/* {{{ proto string number_format(float number [, int num_decimal_places [, string dec_seperator, string thousands_seperator]]) +/* {{{ proto string number_format(float number [, int num_decimal_places [, string dec_separator, string thousands_separator]]) Formats a number with grouped thousands */ PHP_FUNCTION(number_format) { diff --git a/ext/standard/pack.c b/ext/standard/pack.c index eb80395f53..3f525a793a 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -99,7 +99,7 @@ static void php_pack(zval **val, int size, int *map, char *output) /* }}} */ /* pack() idea stolen from Perl (implemented formats behave the same as there) - * Implemented formats are A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. + * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. */ /* {{{ proto string pack(string format, mixed arg1 [, mixed arg2 [, mixed ...]]) Takes one or more arguments and packs them into a binary string according to the format argument */ @@ -170,6 +170,7 @@ PHP_FUNCTION(pack) /* Always uses one arg */ case 'a': case 'A': + case 'Z': case 'h': case 'H': if (currentarg >= num_args) { @@ -186,6 +187,12 @@ PHP_FUNCTION(pack) } convert_to_string_ex(argv[currentarg]); arg = Z_STRLEN_PP(argv[currentarg]); + if (code == 'Z') { + /* add one because Z is always NUL-terminated: + * pack("Z*", "aa") === "aa\0" + * pack("Z2", "aa") === "a\0" */ + arg++; + } } currentarg++; @@ -250,6 +257,7 @@ PHP_FUNCTION(pack) case 'a': case 'A': + case 'Z': case 'c': case 'C': case 'x': @@ -315,16 +323,19 @@ PHP_FUNCTION(pack) switch ((int) code) { case 'a': case 'A': - memset(&output[outputpos], (code == 'a') ? '\0' : ' ', arg); + case 'Z': { + int arg_cp = (code != 'Z') ? arg : MAX(0, arg - 1); + memset(&output[outputpos], (code == 'a' || code == 'Z') ? '\0' : ' ', arg); val = argv[currentarg++]; if (Z_ISREF_PP(val)) { SEPARATE_ZVAL(val); } convert_to_string_ex(val); memcpy(&output[outputpos], Z_STRVAL_PP(val), - (Z_STRLEN_PP(val) < arg) ? Z_STRLEN_PP(val) : arg); + (Z_STRLEN_PP(val) < arg_cp) ? Z_STRLEN_PP(val) : arg_cp); outputpos += arg; break; + } case 'h': case 'H': { @@ -511,7 +522,7 @@ static long php_unpack(char *data, int size, int issigned, int *map) * chars1, chars2, and ints. * Numeric pack types will return numbers, a and A will return strings, * f and d will return doubles. - * Implemented formats are A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. + * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. */ /* {{{ proto array unpack(string format, string input) Unpack binary string into named array elements according to format argument */ @@ -586,6 +597,7 @@ PHP_FUNCTION(unpack) case 'a': case 'A': + case 'Z': size = arg; arg = 1; break; @@ -662,9 +674,23 @@ PHP_FUNCTION(unpack) if ((inputpos + size) <= inputlen) { switch ((int) type) { - case 'a': + case 'a': { + /* a will not strip any trailing whitespace or null padding */ + int len = inputlen - inputpos; /* Remaining string */ + + /* If size was given take minimum of len and size */ + if ((size >= 0) && (len > size)) { + len = size; + } + + size = len; + + add_assoc_stringl(return_value, n, &input[inputpos], len, 1); + break; + } case 'A': { - char pad = (type == 'a') ? '\0' : ' '; + /* A will strip any trailing whitespace */ + char padn = '\0'; char pads = ' '; char padt = '\t'; char padc = '\r'; char padl = '\n'; int len = inputlen - inputpos; /* Remaining string */ /* If size was given take minimum of len and size */ @@ -674,15 +700,45 @@ PHP_FUNCTION(unpack) size = len; - /* Remove padding chars from unpacked data */ + /* Remove trailing white space and nulls chars from unpacked data */ while (--len >= 0) { - if (input[inputpos + len] != pad) + if (input[inputpos + len] != padn + && input[inputpos + len] != pads + && input[inputpos + len] != padt + && input[inputpos + len] != padc + && input[inputpos + len] != padl + ) break; } add_assoc_stringl(return_value, n, &input[inputpos], len + 1, 1); break; } + /* New option added for Z to remain in-line with the Perl implementation */ + case 'Z': { + /* Z will strip everything after the first null character */ + char pad = '\0'; + int s, + len = inputlen - inputpos; /* Remaining string */ + + /* If size was given take minimum of len and size */ + if ((size >= 0) && (len > size)) { + len = size; + } + + size = len; + + /* Remove everything after the first null */ + for (s=0 ; s < len ; s++) { + if (input[inputpos + s] == pad) + break; + } + len = s; + + add_assoc_stringl(return_value, n, &input[inputpos], len, 1); + break; + } + case 'h': case 'H': { diff --git a/ext/standard/password.c b/ext/standard/password.c new file mode 100644 index 0000000000..ca852038a6 --- /dev/null +++ b/ext/standard/password.c @@ -0,0 +1,460 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 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_01.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: Anthony Ferrara <ircmaxell@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#include <stdlib.h> + +#include "php.h" +#if HAVE_CRYPT + +#include "fcntl.h" +#include "php_password.h" +#include "php_rand.h" +#include "php_crypt.h" +#include "base64.h" +#include "zend_interfaces.h" +#include "info.h" + +#if PHP_WIN32 +#include "win32/winutil.h" +#endif + +PHP_MINIT_FUNCTION(password) /* {{{ */ +{ + REGISTER_LONG_CONSTANT("PASSWORD_DEFAULT", PHP_PASSWORD_DEFAULT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT", PHP_PASSWORD_BCRYPT, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT_DEFAULT_COST", PHP_PASSWORD_BCRYPT_COST, CONST_CS | CONST_PERSISTENT); + + return SUCCESS; +} +/* }}} */ + +static char* php_password_get_algo_name(const php_password_algo algo) +{ + switch (algo) { + case PHP_PASSWORD_BCRYPT: + return "bcrypt"; + case PHP_PASSWORD_UNKNOWN: + default: + return "unknown"; + } +} + +static php_password_algo php_password_determine_algo(const char *hash, const size_t len) +{ + if (len > 3 && hash[0] == '$' && hash[1] == '2' && hash[2] == 'y' && len == 60) { + return PHP_PASSWORD_BCRYPT; + } + + return PHP_PASSWORD_UNKNOWN; +} + +static int php_password_salt_is_alphabet(const char *str, const size_t len) /* {{{ */ +{ + size_t i = 0; + + for (i = 0; i < len; i++) { + if (!((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z') || (str[i] >= '0' && str[i] <= '9') || str[i] == '.' || str[i] == '/')) { + return FAILURE; + } + } + return SUCCESS; +} +/* }}} */ + +static int php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */ +{ + size_t pos = 0; + size_t ret_len = 0; + unsigned char *buffer; + if ((int) str_len < 0) { + return FAILURE; + } + buffer = php_base64_encode((unsigned char*) str, (int) str_len, (int*) &ret_len); + if (ret_len < out_len) { + /* Too short of an encoded string generated */ + efree(buffer); + return FAILURE; + } + for (pos = 0; pos < out_len; pos++) { + if (buffer[pos] == '+') { + ret[pos] = '.'; + } else if (buffer[pos] == '=') { + efree(buffer); + return FAILURE; + } else { + ret[pos] = buffer[pos]; + } + } + efree(buffer); + return SUCCESS; +} +/* }}} */ + +static int php_password_make_salt(size_t length, char *ret TSRMLS_DC) /* {{{ */ +{ + int buffer_valid = 0; + size_t i, raw_length; + char *buffer; + char *result; + + if (length > (INT_MAX / 3)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length is too large to safely generate"); + return FAILURE; + } + + raw_length = length * 3 / 4 + 1; + + buffer = (char *) safe_emalloc(raw_length, 1, 1); + +#if PHP_WIN32 + { + BYTE *iv_b = (BYTE *) buffer; + if (php_win32_get_random_bytes(iv_b, raw_length) == SUCCESS) { + buffer_valid = 1; + } + } +#else + { + int fd, n; + size_t read_bytes = 0; + fd = open("/dev/urandom", O_RDONLY); + if (fd >= 0) { + while (read_bytes < raw_length) { + n = read(fd, buffer + read_bytes, raw_length - read_bytes); + if (n < 0) { + break; + } + read_bytes += (size_t) n; + } + close(fd); + } + if (read_bytes >= raw_length) { + buffer_valid = 1; + } + } +#endif + if (!buffer_valid) { + for (i = 0; i < raw_length; i++) { + buffer[i] ^= (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX); + } + } + + result = safe_emalloc(length, 1, 1); + if (php_password_salt_to64(buffer, raw_length, length, result) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Generated salt too short"); + efree(buffer); + efree(result); + return FAILURE; + } + memcpy(ret, result, (int) length); + efree(result); + efree(buffer); + ret[length] = 0; + return SUCCESS; +} +/* }}} */ + +PHP_FUNCTION(password_get_info) +{ + php_password_algo algo; + int hash_len; + char *hash, *algo_name; + zval *options; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hash, &hash_len) == FAILURE) { + return; + } + + if (hash_len < 0 || (size_t) hash_len < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied password hash too long to safely identify"); + RETURN_FALSE; + } + + ALLOC_INIT_ZVAL(options); + array_init(options); + + algo = php_password_determine_algo(hash, (size_t) hash_len); + algo_name = php_password_get_algo_name(algo); + + switch (algo) { + case PHP_PASSWORD_BCRYPT: + { + long cost = PHP_PASSWORD_BCRYPT_COST; + sscanf(hash, "$2y$%ld$", &cost); + add_assoc_long(options, "cost", cost); + } + break; + case PHP_PASSWORD_UNKNOWN: + default: + break; + } + + array_init(return_value); + + add_assoc_long(return_value, "algo", algo); + add_assoc_string(return_value, "algoName", algo_name, 1); + add_assoc_zval(return_value, "options", options); +} + +PHP_FUNCTION(password_needs_rehash) +{ + long new_algo = 0; + php_password_algo algo; + int hash_len; + char *hash; + HashTable *options = 0; + zval **option_buffer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) { + return; + } + + if (hash_len < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied password hash too long to safely identify"); + RETURN_FALSE; + } + + algo = php_password_determine_algo(hash, (size_t) hash_len); + + if (algo != new_algo) { + RETURN_TRUE; + } + + switch (algo) { + case PHP_PASSWORD_BCRYPT: + { + long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0; + + if (options && zend_symtable_find(options, "cost", sizeof("cost"), (void **) &option_buffer) == SUCCESS) { + if (Z_TYPE_PP(option_buffer) != IS_LONG) { + zval cast_option_buffer; + MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer); + convert_to_long(&cast_option_buffer); + new_cost = Z_LVAL(cast_option_buffer); + zval_dtor(&cast_option_buffer); + } else { + new_cost = Z_LVAL_PP(option_buffer); + } + } + + sscanf(hash, "$2y$%ld$", &cost); + if (cost != new_cost) { + RETURN_TRUE; + } + } + break; + case PHP_PASSWORD_UNKNOWN: + default: + break; + } + RETURN_FALSE; +} + +/* {{{ proto boolean password_make_salt(string password, string hash) +Verify a hash created using crypt() or password_hash() */ +PHP_FUNCTION(password_verify) +{ + int status = 0, i; + int password_len, hash_len; + char *ret, *password, *hash; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &password, &password_len, &hash, &hash_len) == FAILURE) { + RETURN_FALSE; + } + if (php_crypt(password, password_len, hash, hash_len, &ret) == FAILURE) { + RETURN_FALSE; + } + + if (strlen(ret) != hash_len || hash_len < 13) { + efree(ret); + RETURN_FALSE; + } + + /* We're using this method instead of == in order to provide + * resistence towards timing attacks. This is a constant time + * equality check that will always check every byte of both + * values. */ + for (i = 0; i < hash_len; i++) { + status |= (ret[i] ^ hash[i]); + } + + efree(ret); + + RETURN_BOOL(status == 0); + +} +/* }}} */ + +/* {{{ proto string password_hash(string password, int algo, array options = array()) +Hash a password */ +PHP_FUNCTION(password_hash) +{ + char *hash_format, *hash, *salt, *password, *result; + long algo = 0; + int password_len = 0, hash_len; + size_t salt_len = 0, required_salt_len = 0, hash_format_len; + HashTable *options = 0; + zval **option_buffer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &password, &password_len, &algo, &options) == FAILURE) { + return; + } + + switch (algo) { + case PHP_PASSWORD_BCRYPT: + { + long cost = PHP_PASSWORD_BCRYPT_COST; + + if (options && zend_symtable_find(options, "cost", 5, (void **) &option_buffer) == SUCCESS) { + if (Z_TYPE_PP(option_buffer) != IS_LONG) { + zval cast_option_buffer; + MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer); + convert_to_long(&cast_option_buffer); + cost = Z_LVAL(cast_option_buffer); + zval_dtor(&cast_option_buffer); + } else { + cost = Z_LVAL_PP(option_buffer); + } + } + + if (cost < 4 || cost > 31) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid bcrypt cost parameter specified: %ld", cost); + RETURN_NULL(); + } + + required_salt_len = 22; + hash_format = emalloc(8); + sprintf(hash_format, "$2y$%02ld$", cost); + hash_format_len = 7; + } + break; + case PHP_PASSWORD_UNKNOWN: + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown password hashing algorithm: %ld", algo); + RETURN_NULL(); + } + + if (options && zend_symtable_find(options, "salt", 5, (void**) &option_buffer) == SUCCESS) { + char *buffer; + int buffer_len_int = 0; + size_t buffer_len; + switch (Z_TYPE_PP(option_buffer)) { + case IS_STRING: + buffer = estrndup(Z_STRVAL_PP(option_buffer), Z_STRLEN_PP(option_buffer)); + buffer_len_int = Z_STRLEN_PP(option_buffer); + break; + case IS_LONG: + case IS_DOUBLE: + case IS_OBJECT: { + zval cast_option_buffer; + MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer); + convert_to_string(&cast_option_buffer); + if (Z_TYPE(cast_option_buffer) == IS_STRING) { + buffer = estrndup(Z_STRVAL(cast_option_buffer), Z_STRLEN(cast_option_buffer)); + buffer_len_int = Z_STRLEN(cast_option_buffer); + zval_dtor(&cast_option_buffer); + break; + } + zval_dtor(&cast_option_buffer); + } + case IS_BOOL: + case IS_NULL: + case IS_RESOURCE: + case IS_ARRAY: + default: + efree(hash_format); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-string salt parameter supplied"); + RETURN_NULL(); + } + if (buffer_len_int < 0) { + efree(hash_format); + efree(buffer); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long"); + } + buffer_len = (size_t) buffer_len_int; + if (buffer_len < required_salt_len) { + efree(hash_format); + efree(buffer); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu expecting %lu", (unsigned long) buffer_len, (unsigned long) required_salt_len); + RETURN_NULL(); + } else if (php_password_salt_is_alphabet(buffer, buffer_len) == FAILURE) { + salt = safe_emalloc(required_salt_len, 1, 1); + if (php_password_salt_to64(buffer, buffer_len, required_salt_len, salt) == FAILURE) { + efree(hash_format); + efree(buffer); + efree(salt); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu", (unsigned long) buffer_len); + RETURN_NULL(); + } + salt_len = required_salt_len; + } else { + salt = safe_emalloc(required_salt_len, 1, 1); + memcpy(salt, buffer, (int) required_salt_len); + salt_len = required_salt_len; + } + efree(buffer); + } else { + salt = safe_emalloc(required_salt_len, 1, 1); + if (php_password_make_salt(required_salt_len, salt TSRMLS_CC) == FAILURE) { + efree(hash_format); + efree(salt); + RETURN_FALSE; + } + salt_len = required_salt_len; + } + + salt[salt_len] = 0; + + hash = safe_emalloc(salt_len + hash_format_len, 1, 1); + sprintf(hash, "%s%s", hash_format, salt); + hash[hash_format_len + salt_len] = 0; + + efree(hash_format); + efree(salt); + + /* This cast is safe, since both values are defined here in code and cannot overflow */ + hash_len = (int) (hash_format_len + salt_len); + + if (php_crypt(password, password_len, hash, hash_len, &result) == FAILURE) { + efree(hash); + RETURN_FALSE; + } + + efree(hash); + + if (strlen(result) < 13) { + efree(result); + RETURN_FALSE; + } + + RETURN_STRING(result, 0); +} +/* }}} */ + +#endif /* HAVE_CRYPT */ +/* + * 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/standard/php_array.h b/ext/standard/php_array.h index 942c33f9e8..1cf2779071 100644 --- a/ext/standard/php_array.h +++ b/ext/standard/php_array.h @@ -71,6 +71,7 @@ PHP_FUNCTION(array_replace_recursive); PHP_FUNCTION(array_keys); PHP_FUNCTION(array_values); PHP_FUNCTION(array_count_values); +PHP_FUNCTION(array_column); PHP_FUNCTION(array_reverse); PHP_FUNCTION(array_reduce); PHP_FUNCTION(array_pad); diff --git a/ext/standard/php_crypt.h b/ext/standard/php_crypt.h index 47d78377c5..6025685539 100644 --- a/ext/standard/php_crypt.h +++ b/ext/standard/php_crypt.h @@ -23,6 +23,7 @@ #ifndef PHP_CRYPT_H #define PHP_CRYPT_H +PHPAPI int php_crypt(const char *password, const int pass_len, const char *salt, int salt_len, char **result); PHP_FUNCTION(crypt); #if HAVE_CRYPT PHP_MINIT_FUNCTION(crypt); diff --git a/ext/standard/php_password.h b/ext/standard/php_password.h new file mode 100644 index 0000000000..abc343d66e --- /dev/null +++ b/ext/standard/php_password.h @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 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_01.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: Anthony Ferrara <ircmaxell@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_PASSWORD_H +#define PHP_PASSWORD_H + +PHP_FUNCTION(password_hash); +PHP_FUNCTION(password_verify); +PHP_FUNCTION(password_needs_rehash); +PHP_FUNCTION(password_get_info); + +PHP_MINIT_FUNCTION(password); + +#define PHP_PASSWORD_DEFAULT PHP_PASSWORD_BCRYPT + +#define PHP_PASSWORD_BCRYPT_COST 10 + +typedef enum { + PHP_PASSWORD_UNKNOWN, + PHP_PASSWORD_BCRYPT +} php_password_algo; + +#endif + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ diff --git a/ext/standard/php_standard.h b/ext/standard/php_standard.h index 2ec851632e..3c7535da1f 100644 --- a/ext/standard/php_standard.h +++ b/ext/standard/php_standard.h @@ -58,6 +58,7 @@ #include "php_versioning.h" #include "php_ftok.h" #include "php_type.h" +#include "php_password.h" #define phpext_standard_ptr basic_functions_module_ptr PHP_MINIT_FUNCTION(standard_filters); diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index 292b66710f..e434ae05f4 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -24,6 +24,7 @@ PHP_FUNCTION(intval); PHP_FUNCTION(floatval); PHP_FUNCTION(strval); +PHP_FUNCTION(boolval); PHP_FUNCTION(gettype); PHP_FUNCTION(settype); PHP_FUNCTION(is_null); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 6373751107..d78ca9976b 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -172,7 +172,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent #endif p += el_len + 1; break; - case HASH_KEY_NON_EXISTANT: + case HASH_KEY_NON_EXISTENT: break; } } @@ -208,6 +208,7 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) DWORD wstatus; #elif HAVE_SYS_WAIT_H int wstatus; + int waitpid_options = 0; pid_t wait_pid; #endif @@ -220,18 +221,27 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } #ifdef PHP_WIN32 - WaitForSingleObject(proc->childHandle, INFINITE); + if (FG(pclose_wait)) { + WaitForSingleObject(proc->childHandle, INFINITE); + } GetExitCodeProcess(proc->childHandle, &wstatus); - FG(pclose_ret) = wstatus; + if (wstatus == STILL_ACTIVE) { + FG(pclose_ret) = -1; + } else { + FG(pclose_ret) = wstatus; + } CloseHandle(proc->childHandle); #elif HAVE_SYS_WAIT_H + if (!FG(pclose_wait)) { + waitpid_options = WNOHANG; + } do { - wait_pid = waitpid(proc->child, &wstatus, 0); + wait_pid = waitpid(proc->child, &wstatus, waitpid_options); } while (wait_pid == -1 && errno == EINTR); - if (wait_pid == -1) { + if (wait_pid <= 0) { FG(pclose_ret) = -1; } else { if (WIFEXITED(wstatus)) @@ -300,7 +310,9 @@ PHP_FUNCTION(proc_close) ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open); + FG(pclose_wait) = 1; zend_list_delete(Z_LVAL_P(zproc)); + FG(pclose_wait) = 0; RETURN_LONG(FG(pclose_ret)); } /* }}} */ @@ -438,6 +450,7 @@ PHP_FUNCTION(proc_open) DWORD dwCreateFlags = 0; char *command_with_cmd; UINT old_error_mode; + char cur_cwd[MAXPATHLEN]; #endif #ifdef NETWARE char** child_argv = NULL; @@ -676,13 +689,13 @@ PHP_FUNCTION(proc_open) #ifdef PHP_WIN32 if (cwd == NULL) { - char cur_cwd[MAXPATHLEN]; char *getcwd_result; getcwd_result = VCWD_GETCWD(cur_cwd, MAXPATHLEN); if (!getcwd_result) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot get current directory"); goto exit_fail; } + cwd = cur_cwd; } memset(&si, 0, sizeof(si)); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index f487763b9e..0610ecfc49 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -583,7 +583,7 @@ PHP_FUNCTION(stream_get_wrappers) HashPosition pos; array_init(return_value); for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos); - (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT; + (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) { if (key_flags == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1); @@ -668,7 +668,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC) type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array), &key, &key_len, &num_ind, 0, NULL); - if (type == HASH_KEY_NON_EXISTANT || + if (type == HASH_KEY_NON_EXISTENT || zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == FAILURE) { continue; /* should not happen */ } diff --git a/ext/standard/string.c b/ext/standard/string.c index c744cb46fc..b9d7427eb9 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -280,6 +280,7 @@ PHP_FUNCTION(hex2bin) result = php_hex2bin((unsigned char *)data, datalen, &newlen); if (!result) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input string must be hexadecimal string"); RETURN_FALSE; } @@ -2851,7 +2852,7 @@ static inline void php_strtr_populate_shift(PATNREPL *patterns, int patnum, int } /* }}} */ /* {{{ php_strtr_compare_hash_suffix */ -static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx_g) +static int php_strtr_compare_hash_suffix(const void *a, const void *b TSRMLS_DC, void *ctx_g) { const PPRES *res = ctx_g; const PATNREPL *pnr_a = a, @@ -2877,62 +2878,6 @@ static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx } } /* }}} */ -/* {{{ Sorting (no zend_qsort_r in this PHP version) */ -#define HS_LEFT(i) ((i) * 2 + 1) -#define HS_RIGHT(i) ((i) * 2 + 2) -#define HS_PARENT(i) (((i) - 1) / 2); -#define HS_OFF(data, i) ((void *)(&((data)->arr)[i])) -#define HS_CMP_CALL(data, i1, i2) \ - (php_strtr_compare_hash_suffix(HS_OFF((data), (i1)), HS_OFF((data), (i2)), (data)->res)) -struct hs_data { - PATNREPL *arr; - size_t nel; - size_t heapel; - PPRES *res; -}; -static inline void php_strtr_swap(PATNREPL *a, PATNREPL *b) -{ - PATNREPL tmp = *a; - *a = *b; - *b = tmp; -} -static inline void php_strtr_fix_heap(struct hs_data *data, size_t i) -{ - size_t li = HS_LEFT(i), - ri = HS_RIGHT(i), - largei; - if (li < data->heapel && HS_CMP_CALL(data, li, i) > 0) { - largei = li; - } else { - largei = i; - } - if (ri < data->heapel && HS_CMP_CALL(data, ri, largei) > 0) { - largei = ri; - } - if (largei != i) { - php_strtr_swap(HS_OFF(data, i), HS_OFF(data, largei)); - php_strtr_fix_heap(data, largei); - } -} -static inline void php_strtr_build_heap(struct hs_data *data) -{ - size_t i; - for (i = data->nel / 2; i > 0; i--) { - php_strtr_fix_heap(data, i - 1); - } -} -static inline void php_strtr_heapsort(PATNREPL *arr, size_t nel, PPRES *res) -{ - struct hs_data data = { arr, nel, nel, res }; - size_t i; - php_strtr_build_heap(&data); - for (i = nel; i > 1; i--) { - php_strtr_swap(arr, HS_OFF(&data, i - 1)); - data.heapel--; - php_strtr_fix_heap(&data, 0); - } -} -/* }}} */ /* {{{ php_strtr_free_strp */ static void php_strtr_free_strp(void *strp) { @@ -3030,7 +2975,13 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, res->patterns = safe_emalloc(patnum, sizeof(*res->patterns), 0); memcpy(res->patterns, patterns, sizeof(*patterns) * patnum); - php_strtr_heapsort(res->patterns, patnum, res); +#ifdef ZTS + zend_qsort_r(res->patterns, patnum, sizeof(*res->patterns), + php_strtr_compare_hash_suffix, res, NULL); /* tsrmls not needed */ +#else + zend_qsort_r(res->patterns, patnum, sizeof(*res->patterns), + php_strtr_compare_hash_suffix, res); +#endif res->prefix = safe_emalloc(patnum, sizeof(*res->prefix), 0); for (i = 0; i < patnum; i++) { @@ -5652,7 +5603,7 @@ PHP_FUNCTION(substr_compare) if (!cs) { RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); } else { - RETURN_LONG(zend_binary_strncasecmp(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); + RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); } } /* }}} */ diff --git a/ext/standard/tests/array/array_column_basic.phpt b/ext/standard/tests/array/array_column_basic.phpt new file mode 100644 index 0000000000..418f373872 --- /dev/null +++ b/ext/standard/tests/array/array_column_basic.phpt @@ -0,0 +1,327 @@ +--TEST-- +Test array_column() function: basic functionality +--FILE-- +<?php +/* Prototype: + * array array_column(array $input, mixed $column_key[, mixed $index_key]); + * Description: + * Returns an array containing all the values from + * the specified "column" in a two-dimensional array. + */ + +echo "*** Testing array_column() : basic functionality ***\n"; +/* Array representing a possible record set returned from a database */ +$records = array( + array( + 'id' => 1, + 'first_name' => 'John', + 'last_name' => 'Doe' + ), + array( + 'id' => 2, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), + array( + 'id' => 3, + 'first_name' => 'Jane', + 'last_name' => 'Jones' + ) +); + +echo "-- first_name column from recordset --\n"; +var_dump(array_column($records, 'first_name')); + +echo "-- id column from recordset --\n"; +var_dump(array_column($records, 'id')); + +echo "-- last_name column from recordset, keyed by value from id column --\n"; +var_dump(array_column($records, 'last_name', 'id')); + +echo "-- last_name column from recordset, keyed by value from first_name column --\n"; +var_dump(array_column($records, 'last_name', 'first_name')); + +echo "\n*** Testing multiple data types ***\n"; +$fh = fopen(__FILE__, 'r', true); +$values = array( + array( + 'id' => 1, + 'value' => new stdClass + ), + array( + 'id' => 2, + 'value' => 34.2345 + ), + array( + 'id' => 3, + 'value' => true + ), + array( + 'id' => 4, + 'value' => false + ), + array( + 'id' => 5, + 'value' => null + ), + array( + 'id' => 6, + 'value' => 1234 + ), + array( + 'id' => 7, + 'value' => 'Foo' + ), + array( + 'id' => 8, + 'value' => $fh + ) +); +var_dump(array_column($values, 'value')); +var_dump(array_column($values, 'value', 'id')); + +echo "\n*** Testing numeric column keys ***\n"; +$numericCols = array( + array('aaa', '111'), + array('bbb', '222'), + array('ccc', '333', -1 => 'ddd') +); +var_dump(array_column($numericCols, 1)); +var_dump(array_column($numericCols, 1, 0)); +var_dump(array_column($numericCols, 1, 0.123)); +var_dump(array_column($numericCols, 1, -1)); + +echo "\n*** Testing failure to find specified column ***\n"; +var_dump(array_column($numericCols, 2)); +var_dump(array_column($numericCols, 'foo')); +var_dump(array_column($numericCols, 0, 'foo')); +var_dump(array_column($numericCols, 3.14)); + +echo "\n*** Testing single dimensional array ***\n"; +$singleDimension = array('foo', 'bar', 'baz'); +var_dump(array_column($singleDimension, 1)); + +echo "\n*** Testing columns not present in all rows ***\n"; +$mismatchedColumns = array( + array('a' => 'foo', 'b' => 'bar', 'e' => 'bbb'), + array('a' => 'baz', 'c' => 'qux', 'd' => 'aaa'), + array('a' => 'eee', 'b' => 'fff', 'e' => 'ggg'), +); +var_dump(array_column($mismatchedColumns, 'c')); +var_dump(array_column($mismatchedColumns, 'c', 'a')); +var_dump(array_column($mismatchedColumns, 'a', 'd')); +var_dump(array_column($mismatchedColumns, 'a', 'e')); +var_dump(array_column($mismatchedColumns, 'b')); +var_dump(array_column($mismatchedColumns, 'b', 'a')); + +echo "\n*** Testing use of object converted to string ***\n"; +class Foo +{ + public function __toString() + { + return 'last_name'; + } +} +class Bar +{ + public function __toString() + { + return 'first_name'; + } +} +$f = new Foo(); +$b = new Bar(); +var_dump(array_column($records, $f)); +var_dump(array_column($records, $f, $b)); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_column() : basic functionality *** +-- first_name column from recordset -- +array(3) { + [0]=> + string(4) "John" + [1]=> + string(5) "Sally" + [2]=> + string(4) "Jane" +} +-- id column from recordset -- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +-- last_name column from recordset, keyed by value from id column -- +array(3) { + [1]=> + string(3) "Doe" + [2]=> + string(5) "Smith" + [3]=> + string(5) "Jones" +} +-- last_name column from recordset, keyed by value from first_name column -- +array(3) { + ["John"]=> + string(3) "Doe" + ["Sally"]=> + string(5) "Smith" + ["Jane"]=> + string(5) "Jones" +} + +*** Testing multiple data types *** +array(8) { + [0]=> + object(stdClass)#%d (0) { + } + [1]=> + float(34.2345) + [2]=> + bool(true) + [3]=> + bool(false) + [4]=> + NULL + [5]=> + int(1234) + [6]=> + string(3) "Foo" + [7]=> + resource(%d) of type (stream) +} +array(8) { + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + float(34.2345) + [3]=> + bool(true) + [4]=> + bool(false) + [5]=> + NULL + [6]=> + int(1234) + [7]=> + string(3) "Foo" + [8]=> + resource(%d) of type (stream) +} + +*** Testing numeric column keys *** +array(3) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + [2]=> + string(3) "333" +} +array(3) { + ["aaa"]=> + string(3) "111" + ["bbb"]=> + string(3) "222" + ["ccc"]=> + string(3) "333" +} +array(3) { + ["aaa"]=> + string(3) "111" + ["bbb"]=> + string(3) "222" + ["ccc"]=> + string(3) "333" +} +array(3) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + ["ddd"]=> + string(3) "333" +} + +*** Testing failure to find specified column *** +array(0) { +} +array(0) { +} +array(3) { + [0]=> + string(3) "aaa" + [1]=> + string(3) "bbb" + [2]=> + string(3) "ccc" +} +array(0) { +} + +*** Testing single dimensional array *** +array(0) { +} + +*** Testing columns not present in all rows *** +array(1) { + [0]=> + string(3) "qux" +} +array(1) { + ["baz"]=> + string(3) "qux" +} +array(3) { + [0]=> + string(3) "foo" + ["aaa"]=> + string(3) "baz" + [1]=> + string(3) "eee" +} +array(3) { + ["bbb"]=> + string(3) "foo" + [0]=> + string(3) "baz" + ["ggg"]=> + string(3) "eee" +} +array(2) { + [0]=> + string(3) "bar" + [1]=> + string(3) "fff" +} +array(2) { + ["foo"]=> + string(3) "bar" + ["eee"]=> + string(3) "fff" +} + +*** Testing use of object converted to string *** +array(3) { + [0]=> + string(3) "Doe" + [1]=> + string(5) "Smith" + [2]=> + string(5) "Jones" +} +array(3) { + ["John"]=> + string(3) "Doe" + ["Sally"]=> + string(5) "Smith" + ["Jane"]=> + string(5) "Jones" +} +Done diff --git a/ext/standard/tests/array/array_column_error.phpt b/ext/standard/tests/array/array_column_error.phpt new file mode 100644 index 0000000000..bdcbec0062 --- /dev/null +++ b/ext/standard/tests/array/array_column_error.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test array_column() function: error conditions +--FILE-- +<?php +/* Prototype: + * array array_column(array $input, mixed $column_key[, mixed $index_key]); + * Description: + * Returns an array containing all the values from + * the specified "column" in a two-dimensional array. + */ + +echo "*** Testing array_column() : error conditions ***\n"; + +echo "\n-- Testing array_column() function with Zero arguments --\n"; +var_dump(array_column()); + +echo "\n-- Testing array_column() function with One argument --\n"; +var_dump(array_column(array())); + +echo "\n-- Testing array_column() function with string as first parameter --\n"; +var_dump(array_column('foo', 0)); + +echo "\n-- Testing array_column() function with int as first parameter --\n"; +var_dump(array_column(1, 'foo')); + +echo "\n-- Testing array_column() column key parameter should be a string or an integer (testing bool) --\n"; +var_dump(array_column(array(), true)); + +echo "\n-- Testing array_column() column key parameter should be a string or integer (testing array) --\n"; +var_dump(array_column(array(), array())); + +echo "\n-- Testing array_column() index key parameter should be a string or an integer (testing bool) --\n"; +var_dump(array_column(array(), 'foo', true)); + +echo "\n-- Testing array_column() index key parameter should be a string or integer (testing array) --\n"; +var_dump(array_column(array(), 'foo', array())); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_column() : error conditions *** + +-- Testing array_column() function with Zero arguments -- + +Warning: array_column() expects at least 2 parameters, 0 given in %s on line %d +NULL + +-- Testing array_column() function with One argument -- + +Warning: array_column() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing array_column() function with string as first parameter -- + +Warning: array_column() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Testing array_column() function with int as first parameter -- + +Warning: array_column() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Testing array_column() column key parameter should be a string or an integer (testing bool) -- + +Warning: array_column(): The column key should be either a string or an integer in %s on line %d +bool(false) + +-- Testing array_column() column key parameter should be a string or integer (testing array) -- + +Warning: array_column(): The column key should be either a string or an integer in %s on line %d +bool(false) + +-- Testing array_column() index key parameter should be a string or an integer (testing bool) -- + +Warning: array_column(): The index key should be either a string or an integer in %s on line %d +bool(false) + +-- Testing array_column() index key parameter should be a string or integer (testing array) -- + +Warning: array_column(): The index key should be either a string or an integer in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_column_object_cast.phpt b/ext/standard/tests/array/array_column_object_cast.phpt new file mode 100644 index 0000000000..762aaa81f4 --- /dev/null +++ b/ext/standard/tests/array/array_column_object_cast.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test array_column() function: basic functionality +--FILE-- +<?php +class ColumnKeyClass { + function __toString() { return 'first_name'; } +} + +class IndexKeyClass { + function __toString() { return 'id'; } +} + +class ValueClass { + function __toString() { return '2135'; } +} + + +$column_key = new ColumnKeyClass(); +$index_key = new IndexKeyClass(); +$value = new ValueClass(); + + +// Array representing a possible record set returned from a database +$records = array( + array( + 'id' => $value, + 'first_name' => 'John', + 'last_name' => 'XXX' + ), + array( + 'id' => 3245, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), +); +$firstNames = array_column($records, $column_key, $index_key); +print_r($firstNames); +var_dump($column_key); +var_dump($index_key); +var_dump($value); +--EXPECTF-- +Array +( + [2135] => John + [3245] => Sally +) +object(ColumnKeyClass)#%d (0) { +} +object(IndexKeyClass)#%d (0) { +} +object(ValueClass)#%d (0) { +} diff --git a/ext/standard/tests/array/array_column_variant.phpt b/ext/standard/tests/array/array_column_variant.phpt new file mode 100644 index 0000000000..0af0869497 --- /dev/null +++ b/ext/standard/tests/array/array_column_variant.phpt @@ -0,0 +1,85 @@ +--TEST-- +Test array_column() function: variant functionality +--FILE-- +<?php +/* Array from Bug Request #64493 test script */ +$rows = array( + 456 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'), + 457 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'), +); + +echo "-- pass null as second parameter to get back all columns indexed by third parameter --\n"; +var_dump(array_column($rows, null, 'id')); + +echo "-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns --\n"; +var_dump(array_column($rows, null, 'foo')); + +echo "-- pass null as second parameter and no third param to get back array_values(input) --\n"; +var_dump(array_column($rows, null)); + +echo "Done\n"; +--EXPECTF-- +-- pass null as second parameter to get back all columns indexed by third parameter -- +array(2) { + [3]=> + array(3) { + ["id"]=> + string(1) "3" + ["title"]=> + string(3) "Foo" + ["date"]=> + string(10) "2013-03-25" + } + [5]=> + array(3) { + ["id"]=> + string(1) "5" + ["title"]=> + string(3) "Bar" + ["date"]=> + string(10) "2012-05-20" + } +} +-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns -- +array(2) { + [0]=> + array(3) { + ["id"]=> + string(1) "3" + ["title"]=> + string(3) "Foo" + ["date"]=> + string(10) "2013-03-25" + } + [1]=> + array(3) { + ["id"]=> + string(1) "5" + ["title"]=> + string(3) "Bar" + ["date"]=> + string(10) "2012-05-20" + } +} +-- pass null as second parameter and no third param to get back array_values(input) -- +array(2) { + [0]=> + array(3) { + ["id"]=> + string(1) "3" + ["title"]=> + string(3) "Foo" + ["date"]=> + string(10) "2013-03-25" + } + [1]=> + array(3) { + ["id"]=> + string(1) "5" + ["title"]=> + string(3) "Bar" + ["date"]=> + string(10) "2012-05-20" + } +} +Done diff --git a/ext/standard/tests/array/compact.phpt b/ext/standard/tests/array/compact.phpt index 4b4bfbb732..02df44ebd8 100644 --- a/ext/standard/tests/array/compact.phpt +++ b/ext/standard/tests/array/compact.phpt @@ -1,8 +1,5 @@ --TEST-- compact() ---INI-- -unicode.script_encoding=UTF-8 -unicode.output_encoding=UTF-8 --FILE-- <?php diff --git a/ext/standard/tests/array/locale_sort.phpt b/ext/standard/tests/array/locale_sort.phpt index 1db96042e8..c2f66c01df 100644 --- a/ext/standard/tests/array/locale_sort.phpt +++ b/ext/standard/tests/array/locale_sort.phpt @@ -9,9 +9,6 @@ if (false == setlocale(LC_CTYPE, "fr_FR.ISO8859-1", "fr_FR")) { die("skip setlocale() failed\n"); } ?> ---INI-- -unicode.script_encoding=ISO8859-1 -unicode.output_encoding=ISO8859-1 --FILE-- <?php setlocale(LC_ALL, 'fr_FR.ISO8859-1', 'fr_FR'); diff --git a/ext/standard/tests/array/uasort_variation9.phpt b/ext/standard/tests/array/uasort_variation9.phpt index 486042e5e7..85578b0207 100644 --- a/ext/standard/tests/array/uasort_variation9.phpt +++ b/ext/standard/tests/array/uasort_variation9.phpt @@ -14,7 +14,7 @@ echo "*** Testing uasort() : 'cmp_function' with reference arguments ***\n"; // comparison function /* Prototype : int cmp(mixed &$value1, mixed &$value2) - * Parameters : $value1 and $value2 - values recieved by reference + * Parameters : $value1 and $value2 - values received by reference * Return value : 0 - if both values are same * 1 - if value1 is greater than value2 * -1 - if value1 is less than value2 diff --git a/ext/standard/tests/bug64370_var1.phpt b/ext/standard/tests/bug64370_var1.phpt index ff64d61616..aca46a594d 100644 --- a/ext/standard/tests/bug64370_var1.phpt +++ b/ext/standard/tests/bug64370_var1.phpt @@ -1,10 +1,5 @@ --TEST-- Test bug #64370 microtime(true) less than $_SERVER['REQUEST_TIME_FLOAT'] ---SKIPIF-- -<?php - if (PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4)) { - die('skip PHP 5.4+ only'); - } --FILE-- <?php echo "\$_SERVER['REQUEST_TIME']: {$_SERVER['REQUEST_TIME']}\n"; diff --git a/ext/standard/tests/dir/dir_variation1-win32.phpt b/ext/standard/tests/dir/dir_variation1-win32.phpt deleted file mode 100644 index 1f7f4a2cf3..0000000000 --- a/ext/standard/tests/dir/dir_variation1-win32.phpt +++ /dev/null @@ -1,170 +0,0 @@ ---TEST-- -Test dir() function : usage variations - unexpected value for 'dir' argument ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* - * Prototype : object dir(string $directory[, resource $context]) - * Description: Directory class with properties, handle and class and methods read, rewind and close - * Source code: ext/standard/dir.c - */ - -/* - * Passing non string values to 'directory' argument of dir() and see - * that the function outputs proper warning messages wherever expected. - */ - -echo "*** Testing dir() : unexpected values for \$directory argument ***\n"; - -// get an unset variable -$unset_var = 10; -unset($unset_var); - -class A -{ - public $var; - public function init() { - $this->var = 10; - } -} - -// get a resource variable -$fp = fopen(__FILE__, "r"); // get a file handle -$dfp = opendir( dirname(__FILE__) ); // get a dir handle - -// unexpected values to be passed to $directory argument -$unexpected_values = array ( - - // array data -/*1*/ array(), - array(0), - array(1), - array(1, 2), - array('color' => 'red', 'item' => 'pen'), - - // null data -/*6*/ NULL, - null, - - // boolean data -/*8*/ true, - false, - TRUE, - FALSE, - - // empty data -/*12*/ "", - '', - - // undefined data -/*14*/ @$undefined_var, - - // unset data -/*15*/ @$unset_var, - - // resource variable(dir and file handle) -/*16*/ $fp, - $dfp, - - // object data -/*18*/ new A() -); - -// loop through various elements of $unexpected_values to check the behavior of dir() -$iterator = 1; -foreach( $unexpected_values as $unexpected_value ) { - echo "\n-- Iteration $iterator --\n"; - var_dump( dir($unexpected_value) ); - $iterator++; -} - -fclose($fp); -closedir($dfp); -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : unexpected values for $directory argument *** - --- Iteration 1 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 2 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 3 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 4 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 5 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 6 -- -bool(false) - --- Iteration 7 -- -bool(false) - --- Iteration 8 -- - -Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: dir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 9 -- -bool(false) - --- Iteration 10 -- - -Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: dir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 11 -- -bool(false) - --- Iteration 12 -- -bool(false) - --- Iteration 13 -- -bool(false) - --- Iteration 14 -- -bool(false) - --- Iteration 15 -- -bool(false) - --- Iteration 16 -- - -Warning: dir() expects parameter 1 to be string, resource given in %s on line %d -NULL - --- Iteration 17 -- - -Warning: dir() expects parameter 1 to be string, resource given in %s on line %d -NULL - --- Iteration 18 -- - -Warning: dir() expects parameter 1 to be string, object given in %s on line %d -NULL -Done
\ No newline at end of file diff --git a/ext/standard/tests/dir/dir_variation5-win32.phpt b/ext/standard/tests/dir/dir_variation5-win32.phpt deleted file mode 100644 index e70b9d3533..0000000000 --- a/ext/standard/tests/dir/dir_variation5-win32.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test dir() function : usage variations - open a file instead of directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* - * Prototype : object dir(string $directory[, resource $context]) - * Description: Directory class with properties, handle and class and methods read, rewind and close - * Source code: ext/standard/dir.c - */ - -/* - * Passing a file as argument to dir() function instead of a directory - * and checking if proper warning message is generated. - */ - -echo "*** Testing dir() : open a file instead of a directory ***\n"; - -// open the file instead of directory -$d = dir(__FILE__); -var_dump( $d ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : open a file instead of a directory *** - -Warning: dir(%s): The directory name is invalid. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation6-win32.phpt b/ext/standard/tests/dir/dir_variation6-win32.phpt deleted file mode 100644 index e0e4749809..0000000000 --- a/ext/standard/tests/dir/dir_variation6-win32.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -Test dir() function : usage variations - non-existent directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* - * Prototype : object dir(string $directory[, resource $context]) - * Description: Directory class with properties, handle and class and methods read, rewind and close - * Source code: ext/standard/dir.c - */ - -/* - * Passing a non-existent directory as argument to dir() function - * and checking to see if proper warning message is output. - */ -echo "*** Testing dir() : open a non-existent directory ***\n"; - -// create the temporary directory -$file_path = dirname(__FILE__); -$dir_path = $file_path."/dir_variation6"; -@mkdir($dir_path); - -// open existent directory -$d = dir($dir_path); -$d->close(); //close the dir - -// remove directory and try to open the same(non-existent) directory again -rmdir($dir_path); -clearstatcache(); - -echo "-- opening previously removed directory --\n"; -var_dump( dir($dir_path) ); - -// point to a non-existent directory -$non_existent_dir = $file_path."/non_existent_dir"; -echo "-- opening non-existent directory --\n"; -$d = dir($non_existent_dir); -var_dump( $d ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : open a non-existent directory *** --- opening previously removed directory -- - -Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) --- opening non-existent directory -- - -Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation8-win32.phpt b/ext/standard/tests/dir/dir_variation8-win32.phpt deleted file mode 100644 index a56c98b880..0000000000 --- a/ext/standard/tests/dir/dir_variation8-win32.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Test dir() function : usage variations - checking with wildcard characters ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* - * Prototype : object dir(string $directory[, resource $context]) - * Description: Directory class with properties, handle and class and methods read, rewind and close - * Source code: ext/standard/dir.c - */ - -/* - * Create more than one temporary directory & subdirectory and check if dir() function can open - * those directories when wildcard characters are used to refer to them. - */ - -echo "*** Testing dir() : checking with wildcard characters ***\n"; - -// create the temporary directories -$file_path = dirname(__FILE__); -$dir_path = $file_path."/dir_variation81"; -$sub_dir_path = $dir_path."/sub_dir1"; - -@mkdir($dir_path1); -@mkdir($sub_dir_path); - -/* with different wildcard characters */ - -echo "-- wildcard = '*' --\n"; -var_dump( dir($file_path."/dir_var*") ); -var_dump( dir($file_path."/*") ); - -echo "-- wildcard = '?' --\n"; -var_dump( dir($dir_path."/sub_dir?") ); -var_dump( dir($dir_path."/sub?dir1") ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : checking with wildcard characters *** --- wildcard = '*' -- - -Warning: dir(%s/dir_var*,%s/dir_var*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_var*): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%s/*,%s/*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/*): failed to open dir: %s in %s on line %d -bool(false) --- wildcard = '?' -- - -Warning: dir(%s/dir_variation81/sub_dir?,%s/dir_variation81/sub_dir?): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_variation81/sub_dir?): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%s/dir_variation81/sub?dir1,%s/dir_variation81/sub?dir1): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_variation81/sub?dir1): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation9-win32.phpt b/ext/standard/tests/dir/dir_variation9-win32.phpt deleted file mode 100644 index 32b0bd946b..0000000000 --- a/ext/standard/tests/dir/dir_variation9-win32.phpt +++ /dev/null @@ -1,125 +0,0 @@ ---TEST-- -Test dir() function : usage variations - relative valid and invalid paths ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* - * Prototype : object dir(string $directory[, resource $context]) - * Description: Directory class with properties, handle and class and methods read, rewind and close - * Source code: ext/standard/dir.c - */ - -/* - * Checking the behavior of dir() function by passing directories which - * have valid and invalid relative path. - */ - -echo "*** Testing dir() : checking with valid and invalid paths ***\n"; - -/* create the temporary directories */ - -$file_path = dirname(__FILE__); - -// directory dir_variation91 with one sub-directory sub_dir11 and sub-sub-directory sub_dir111 -$dir_path1 = $file_path."/dir_variation91"; -$sub_dir11 = $dir_path1."/sub_dir11"; -$sub_dir111 = $sub_dir11."/sub_dir111"; - -// directory dir_variation92 with one sub-directory sub_dir21 -$dir_path2 = $file_path."/dir_variation92"; -$sub_dir21 = $dir_path2."/sub_dir21"; - -@mkdir($dir_path1); -@mkdir($dir_path2); -@mkdir($sub_dir11); -@mkdir($sub_dir111); -@mkdir($sub_dir21); - -// open the directory with valid paths -echo "\n-- With valid paths --\n"; -var_dump( dir("$dir_path1/sub_dir11/sub_dir111/..") ); -var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91") ); -var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir11/..") ); -var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/..") ); - -// open the directory with invalid path -echo "\n-- With invalid paths --\n"; -var_dump( dir("$dir_path1/sub_dir12/sub_dir111/..") ); -var_dump( dir("$dir_path2/sub_dir21/../dir_variation91") ); -var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir12/..") ); -var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..") ); - -echo "Done"; -?> ---CLEAN-- -<?php -$file_path = dirname(__FILE__); - -$dir_path1 = $file_path."/dir_variation91"; -$sub_dir11 = $dir_path1."/sub_dir11"; -$sub_dir111 = $sub_dir11."/sub_dir111"; -$dir_path2 = $file_path."/dir_variation92"; -$sub_dir21 = $dir_path2."/sub_dir21"; - -rmdir($sub_dir21); -rmdir($sub_dir111); -rmdir($sub_dir11); -rmdir($dir_path1); -rmdir($dir_path2); -?> ---EXPECTF-- -*** Testing dir() : checking with valid and invalid paths *** - --- With valid paths -- -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/.." - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91" - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir11/.." - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/.." - ["handle"]=> - resource(%d) of type (stream) -} - --- With invalid paths -- - -Warning: dir(%sdir_variation91/sub_dir12/sub_dir111/..,%sdir_variation91/sub_dir12/sub_dir111/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation91/sub_dir12/sub_dir111/..): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation92/sub_dir21/../dir_variation91,%sdir_variation92/sub_dir21/../dir_variation91): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation92/sub_dir21/../dir_variation91): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..,%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..,%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/opendir_error2-win32.phpt b/ext/standard/tests/dir/opendir_error2-win32.phpt deleted file mode 100644 index c3ecd35349..0000000000 --- a/ext/standard/tests/dir/opendir_error2-win32.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test opendir() function : error conditions - Non-existent directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : mixed opendir(string $path[, resource $context]) - * Description: Open a directory and return a dir_handle - * Source code: ext/standard/dir.c - */ - -/* - * Pass a non-existent directory as $path argument to opendir() to test behaviour - */ - -echo "*** Testing opendir() : error conditions ***\n"; - -echo "\n-- Pass a non-existent absolute path: --\n"; -$path = dirname(__FILE__) . "/idonotexist"; -var_dump(opendir($path)); - -echo "\n-- Pass a non-existent relative path: --\n"; -chdir(dirname(__FILE__)); -var_dump(opendir('idonotexist')); -?> -===DONE=== ---EXPECTF-- -*** Testing opendir() : error conditions *** - --- Pass a non-existent absolute path: -- - -Warning: opendir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: opendir(%s/idonotexist): failed to open dir: %s in %s on line %d -bool(false) - --- Pass a non-existent relative path: -- - -Warning: opendir(idonotexist,idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: opendir(idonotexist): failed to open dir: %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/dir/opendir_variation1-win32.phpt b/ext/standard/tests/dir/opendir_variation1-win32.phpt deleted file mode 100644 index 9a75a5b6a7..0000000000 --- a/ext/standard/tests/dir/opendir_variation1-win32.phpt +++ /dev/null @@ -1,248 +0,0 @@ ---TEST-- -Test opendir() function : usage variations - different data types as $path arg ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : mixed opendir(string $path[, resource $context]) - * Description: Open a directory and return a dir_handle - * Source code: ext/standard/dir.c - */ - -/* - * Pass different data types as $path argument to opendir() to test behaviour - * Where possible, an existing directory has been entered as a string value - */ - -echo "*** Testing opendir() : usage variations ***\n"; - -// create directory to be passed as string value where possible -$path = dirname(__FILE__) . "/opendir_variation1"; -mkdir($path); - -//get an unset variable -$unset_var = 10; -unset ($unset_var); - -// get a class -class classA { - - var $path; - function __construct($path) { - $this->path = $path; - } - public function __toString() { - return $this->path; - } -} - -// heredoc string -$heredoc = <<<EOT -$path -EOT; - -// get a resource variable -$fp = fopen(__FILE__, "r"); - -// unexpected values to be passed to $path argument -$inputs = array( - - // int data -/*1*/ 0, - 1, - 12345, - -2345, - - // float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // null data -/*10*/ NULL, - null, - - // boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // empty data -/*16*/ "", - '', - array(), - - // string data -/*19*/ "$path", - 'string', - $heredoc, - - // object data -/*22*/ new classA($path), - - // undefined data -/*23*/ @$undefined_var, - - // unset data -/*24*/ @$unset_var, - - // resource variable -/*25*/ $fp -); - -// loop through each element of $inputs to check the behavior of opendir() -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( $dh = opendir($input) ); - if ($dh) { - closedir($dh); - } - $iterator++; -}; - -fclose($fp); -?> -===DONE=== ---CLEAN-- -<?php -$path = dirname(__FILE__) . "/opendir_variation1"; -rmdir($path); -?> ---EXPECTF-- -*** Testing opendir() : usage variations *** - --- Iteration 1 -- - -Warning: opendir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(0): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 2 -- - -Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 3 -- - -Warning: opendir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(12345): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 4 -- - -Warning: opendir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(-2345): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 5 -- - -Warning: opendir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(10.5): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 6 -- - -Warning: opendir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(-10.5): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 7 -- - -Warning: opendir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(123456789000): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 8 -- - -Warning: opendir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1.23456789E-9): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 9 -- - -Warning: opendir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(0.5): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 10 -- -bool(false) - --- Iteration 11 -- -bool(false) - --- Iteration 12 -- - -Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 13 -- -bool(false) - --- Iteration 14 -- - -Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 15 -- -bool(false) - --- Iteration 16 -- -bool(false) - --- Iteration 17 -- -bool(false) - --- Iteration 18 -- - -Warning: opendir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 19 -- -resource(%d) of type (stream) - --- Iteration 20 -- - -Warning: opendir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(string): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 21 -- -resource(%d) of type (stream) - --- Iteration 22 -- -resource(%d) of type (stream) - --- Iteration 23 -- -bool(false) - --- Iteration 24 -- -bool(false) - --- Iteration 25 -- - -Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d -NULL -===DONE=== diff --git a/ext/standard/tests/dir/scandir_error2-win32.phpt b/ext/standard/tests/dir/scandir_error2-win32.phpt deleted file mode 100644 index 9920be747d..0000000000 --- a/ext/standard/tests/dir/scandir_error2-win32.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -Test scandir() function : error conditions - Non-existent directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) - * Description: List files & directories inside the specified path - * Source code: ext/standard/dir.c - */ - -/* - * Pass a directory that does not exist to scandir() to test error messages - */ - -echo "*** Testing scandir() : error conditions ***\n"; - -$directory = dirname(__FILE__) . '/idonotexist'; - -echo "\n-- Pass scandir() an absolute path that does not exist --\n"; -var_dump(scandir($directory)); - -echo "\n-- Pass scandir() a relative path that does not exist --\n"; -var_dump(scandir('/idonotexist')); -?> -===DONE=== ---EXPECTF-- -*** Testing scandir() : error conditions *** - --- Pass scandir() an absolute path that does not exist -- - -Warning: scandir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(%s/idonotexist): failed to open dir: %s in %s on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Pass scandir() a relative path that does not exist -- - -Warning: scandir(/idonotexist,/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(/idonotexist): failed to open dir: %s in %s on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation1-win32.phpt b/ext/standard/tests/dir/scandir_variation1-win32.phpt deleted file mode 100644 index a2b5bd4672..0000000000 --- a/ext/standard/tests/dir/scandir_variation1-win32.phpt +++ /dev/null @@ -1,289 +0,0 @@ ---TEST-- -Test scandir() function : usage variations - different data types as $dir arg ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) - * Description: List files & directories inside the specified path - * Source code: ext/standard/dir.c - */ - -/* - * Pass different data types as $dir argument to test behaviour of scandir() - */ - -echo "*** Testing scandir() : usage variations ***\n"; - -//get an unset variable -$unset_var = 10; -unset ($unset_var); - -// get a class -class classA -{ - public function __toString() { - return "Class A object"; - } -} - -// heredoc string -$heredoc = <<<EOT -hello world -EOT; - -// get a resource variable -$fp = fopen(__FILE__, "r"); - -// unexpected values to be passed to $dir argument -$inputs = array( - - // int data -/*1*/ 0, - 1, - 12345, - -2345, - - // float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // null data -/*10*/ NULL, - null, - - // boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // empty data -/*16*/ "", - '', - array(), - - // string data -/*19*/ "string", - 'string', - $heredoc, - - // object data -/*22*/ new classA(), - - // undefined data -/*23*/ @$undefined_var, - - // unset data -/*24*/ @$unset_var, - - // resource variable -/*25*/ $fp -); - -// loop through each element of $inputs to check the behavior of scandir() -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( scandir($input) ); - $iterator++; -}; - -fclose($fp); -?> -===DONE=== ---EXPECTF-- -*** Testing scandir() : usage variations *** - --- Iteration 1 -- - -Warning: scandir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(0): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 2 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 3 -- - -Warning: scandir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(12345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 4 -- - -Warning: scandir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(-2345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 5 -- - -Warning: scandir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 6 -- - -Warning: scandir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(-10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 7 -- - -Warning: scandir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(123456789000): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 8 -- - -Warning: scandir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1.23456789E-9): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 9 -- - -Warning: scandir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(0.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 10 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 11 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 12 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 13 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 14 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 15 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 16 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 17 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 18 -- - -Warning: scandir() expects parameter 1 to be a valid path, array given in %s on line %d -NULL - --- Iteration 19 -- - -Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 20 -- - -Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 21 -- - -Warning: scandir(hello world,hello world): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(hello world): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 22 -- - -Warning: scandir(Class A object,Class A object): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(Class A object): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 23 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 24 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 25 -- - -Warning: scandir() expects parameter 1 to be a valid path, resource given in %s on line %d -NULL -===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation6-win32.phpt b/ext/standard/tests/dir/scandir_variation6-win32.phpt deleted file mode 100644 index 040dc787cc..0000000000 --- a/ext/standard/tests/dir/scandir_variation6-win32.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -Test scandir() function : usage variations - Wildcards in directory path ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) - * Description: List files & directories inside the specified path - * Source code: ext/standard/dir.c - */ - -/* - * Pass a directory path using wildcards as $dir argument to test how scandir() behaves - */ - -echo "*** Testing scandir() : usage variations ***\n"; - -// create the temporary directories -$file_path = dirname(__FILE__); -$dir_path = $file_path . "/scandir_variation6"; -$sub_dir_path = $dir_path . "/sub_dir1"; - -mkdir($dir_path); -mkdir($sub_dir_path); - -// with different wildcard characters - -echo "\n-- Wildcard = '*' --\n"; -var_dump( scandir($file_path . "/scandir_var*") ); -var_dump( scandir($file_path . "/*") ); - -echo "\n-- Wildcard = '?' --\n"; -var_dump( scandir($dir_path . "/sub_dir?") ); -var_dump( scandir($dir_path . "/sub?dir1") ); - -?> -===DONE=== ---CLEAN-- -<?php -$dir_path = dirname(__FILE__) . "/scandir_variation6"; -$sub_dir_path = $dir_path . "/sub_dir1"; - -rmdir($sub_dir_path); -rmdir($dir_path); -?> ---EXPECTF-- -*** Testing scandir() : usage variations *** - --- Wildcard = '*' -- - -Warning: scandir(%s/scandir_var*,%s/scandir_var*): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_var*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - -Warning: scandir(%s/*,%s/*): No such file or directory in %s on line %d - -Warning: scandir(%s/*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Wildcard = '?' -- - -Warning: scandir(%s/scandir_variation6/sub_dir?,%s/scandir_variation6/sub_dir?): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - -Warning: scandir(%s/scandir_variation6/sub?dir1,%s/scandir_variation6/sub?dir1): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt index 9538c8ede8..fcd85489f3 100644 --- a/ext/standard/tests/file/bug22414.phpt +++ b/ext/standard/tests/file/bug22414.phpt @@ -7,7 +7,7 @@ output_handler= $php = getenv('TEST_PHP_EXECUTABLE'); $tmpfile = tempnam(__DIR__, 'phpt'); - $args = ' -n '; + $args = ' -n -dsafe_mode=off '; /* Regular Data Test */ passthru($php . $args . ' -r " echo \"HELLO\"; "'); diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index 9dc663ae16..200e92ab43 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -37,7 +37,7 @@ echo "\n Free Space after writing to a file\n"; $space2 = disk_free_space($file_path.$dir); var_dump( $space2 ); -if( $space1 > $space2 ) +if($space1 > $space2 ) echo "\n Free Space Value Is Correct\n"; else echo "\n Free Space Value Is Incorrect\n"; diff --git a/ext/standard/tests/file/fputcsv_error.phpt b/ext/standard/tests/file/fputcsv_error.phpt index 9403cf446a..ebffd45425 100644 --- a/ext/standard/tests/file/fputcsv_error.phpt +++ b/ext/standard/tests/file/fputcsv_error.phpt @@ -48,7 +48,7 @@ Warning: fputcsv() expects at least 2 parameters, 0 given in %s on line %d NULL -- Testing fputcsv() with more than expected number of arguments -- -Warning: fputcsv() expects at most 4 parameters, 5 given in %s on line %d +Warning: fputcsv() expects parameter 5 to be string, resource given in %s on line %d NULL -- Testing fputcsv() with invalid arguments -- -- Iteration 1 -- diff --git a/ext/standard/tests/file/fputcsv_variation15.phpt b/ext/standard/tests/file/fputcsv_variation15.phpt new file mode 100755 index 0000000000..dc4a9e2dbd --- /dev/null +++ b/ext/standard/tests/file/fputcsv_variation15.phpt @@ -0,0 +1,107 @@ +--TEST-- +various fputcsv() functionality tests +--CREDITS-- +Lee Leathers <leeleathers@gmail.com> +--FILE-- +<?php + +$list = array ( + 0 => 'aaa,bbb', + 1 => 'aaa,"bbb"', + 2 => '"aaa","bbb"', + 3 => 'aaa,bbb', + 4 => '"aaa",bbb', + 5 => '"aaa", "bbb"', + 6 => ',', + 7 => 'aaa,', + 8 => ',"aaa"', + 9 => '"",""', + 10 => '"""""",', + 11 => '""""",aaa', + 12 => 'aaa,bbb ', + 13 => 'aaa,"bbb "', + 14 => 'aaa"aaa","bbb"bbb', + 15 => 'aaa"aaa""",bbb', + 16 => 'aaa,"/"bbb,ccc', + 17 => 'aaa"/"a","bbb"', + 18 => '"/"","aaa"', + 19 => '"/""",aaa', +); + +$file = dirname(__FILE__) . 'fgetcsv.csv'; +@unlink($file); + +$fp = fopen($file, "w"); +foreach ($list as $v) { + fputcsv($fp, explode(',', $v), ',', '"', '/'); +} +fclose($fp); + +$res = file($file); +foreach($res as &$val) +{ + $val = substr($val, 0, -1); +} +echo '$list = ';var_export($res);echo ";\n"; + +$fp = fopen($file, "r"); +$res = array(); +while($l=fgetcsv($fp, 0, ',', '"', '/')) +{ + $res[] = join(',',$l); +} +fclose($fp); + +echo '$list = ';var_export($res);echo ";\n"; + +@unlink($file); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +$list = array ( + 0 => 'aaa,bbb', + 1 => 'aaa,"""bbb"""', + 2 => '"""aaa""","""bbb"""', + 3 => 'aaa,bbb', + 4 => '"""aaa""",bbb', + 5 => '"""aaa"""," ""bbb"""', + 6 => ',', + 7 => 'aaa,', + 8 => ',"""aaa"""', + 9 => '"""""",""""""', + 10 => '"""""""""""""",', + 11 => '"""""""""""",aaa', + 12 => 'aaa,"bbb "', + 13 => 'aaa,"""bbb """', + 14 => '"aaa""aaa""","""bbb""bbb"', + 15 => '"aaa""aaa""""""",bbb', + 16 => 'aaa,"""/"bbb",ccc', + 17 => '"aaa""/"a""","""bbb"""', + 18 => '"""/"""","""aaa"""', + 19 => '"""/"""""",aaa', +); +$list = array ( + 0 => 'aaa,bbb', + 1 => 'aaa,"bbb"', + 2 => '"aaa","bbb"', + 3 => 'aaa,bbb', + 4 => '"aaa",bbb', + 5 => '"aaa", "bbb"', + 6 => ',', + 7 => 'aaa,', + 8 => ',"aaa"', + 9 => '"",""', + 10 => '"""""",', + 11 => '""""",aaa', + 12 => 'aaa,bbb ', + 13 => 'aaa,"bbb "', + 14 => 'aaa"aaa","bbb"bbb', + 15 => 'aaa"aaa""",bbb', + 16 => 'aaa,"/"bbb,ccc', + 17 => 'aaa"/"a","bbb"', + 18 => '"/"","aaa"', + 19 => '"/""",aaa', +); +===DONE=== diff --git a/ext/standard/tests/file/parse_ini_file.phpt b/ext/standard/tests/file/parse_ini_file.phpt index dab07e56e7..db14c7a9b4 100644 --- a/ext/standard/tests/file/parse_ini_file.phpt +++ b/ext/standard/tests/file/parse_ini_file.phpt @@ -57,15 +57,15 @@ Non_alpha4 = % Non_alpha5 = <> Non_alpha6 = @ Non_alpha7 = # -Non_alpha8 = ^ -Non_alpha9 = - -Non_alpha10 = : -Non_alpha11 = ? -Non_alpha12 = / -Non_alpha13 = \ +Non_alpha8 = - +Non_alpha9 = : +Non_alpha10 = ? +Non_alpha11 = / +Non_alpha12 = \ ;These chars have a special meaning when used in the value, ; hence parser throws an error -;Non_alpha14 = & +;Non_alpha13 = & +;Non_alpha14 = ^ ;Non_alpha15 = {} ;Non_alpha16 = | ;Non_alpha17 = ~ @@ -249,12 +249,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * @@ -385,12 +384,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * diff --git a/ext/standard/tests/general_functions/boolval.phpt b/ext/standard/tests/general_functions/boolval.phpt new file mode 100644 index 0000000000..9d0eac4ebd --- /dev/null +++ b/ext/standard/tests/general_functions/boolval.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing boolval() +--FILE-- +<?php + var_dump(boolval(false)); + var_dump(boolval(NULL)); + var_dump(boolval("")); + var_dump(boolval(0)); + var_dump(boolval(array())); + + var_dump(boolval(true)); + var_dump(boolval("abc")); + var_dump(boolval(0.5)); + var_dump(boolval(100)); + var_dump(boolval(new stdClass())); + var_dump(boolval(STDIN)); +?> +--EXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/general_functions/parse_ini_string_001.phpt b/ext/standard/tests/general_functions/parse_ini_string_001.phpt index e135210aa6..c5e70cb900 100644 --- a/ext/standard/tests/general_functions/parse_ini_string_001.phpt +++ b/ext/standard/tests/general_functions/parse_ini_string_001.phpt @@ -55,15 +55,15 @@ Non_alpha4 = % Non_alpha5 = <> Non_alpha6 = @ Non_alpha7 = # -Non_alpha8 = ^ -Non_alpha9 = - -Non_alpha10 = : -Non_alpha11 = ? -Non_alpha12 = / -Non_alpha13 = \ +Non_alpha8 = - +Non_alpha9 = : +Non_alpha10 = ? +Non_alpha11 = / +Non_alpha12 = \ ;These chars have a special meaning when used in the value, ; hence parser throws an error -;Non_alpha14 = & +;Non_alpha13 = & +;Non_alpha14 = ^ ;Non_alpha15 = {} ;Non_alpha16 = | ;Non_alpha17 = ~ @@ -239,12 +239,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * @@ -375,12 +374,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt new file mode 100644 index 0000000000..86346ec307 --- /dev/null +++ b/ext/standard/tests/mail/mail_log.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test mail() function : mail.log ini setting +--INI-- +sendmail_path=tee /tmp/mail.out >/dev/null +mail.log = /tmp/mail.log +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +date_default_timezone_set("UTC"); + +$logfile = ini_get("mail.log"); +if (file_exists($logfile)) { + unlink($logfile); +} +touch($logfile); +clearstatcache(); + +$to = "test@example.com"; +$subject = "mail.log test"; +$message = "Testing mail.log"; +$headers = "X-Test: 1"; + +var_dump(filesize($logfile) == 0); +clearstatcache(); + +var_dump(mail($to, $subject, $message, $headers)); + +var_dump(filesize($logfile) > 0); +clearstatcache(); + +echo file_get_contents($logfile); +?> +Done +--CLEAN-- +<?php +unlink("/tmp/mail.log"); +unlink("/tmp/mail.out"); +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1 +Done diff --git a/ext/standard/tests/network/ip2long_variation1.phpt b/ext/standard/tests/network/ip2long_variation1.phpt index f87282ae75..b228c9bd14 100644 --- a/ext/standard/tests/network/ip2long_variation1.phpt +++ b/ext/standard/tests/network/ip2long_variation1.phpt @@ -1,10 +1,5 @@ --TEST-- -Test ip2long() function : usage variation ---SKIPIF-- -<?php -if(substr(PHP_OS, 0, 3) == "WIN") - die("skip. Windows is more compliant (like 0 for localhost, etc.)"); -?> +Test ip2long() function : usage variation 1 --FILE-- <?php /* Prototype : int ip2long(string ip_address) diff --git a/ext/standard/tests/network/ip2long_variation2.phpt b/ext/standard/tests/network/ip2long_variation2.phpt new file mode 100644 index 0000000000..752956320c --- /dev/null +++ b/ext/standard/tests/network/ip2long_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test ip2long() function : usage variation 2, 32 bit +--SKIPIF-- +<?php if(PHP_INT_SIZE != 4) {die('skip 32 bit only');} ?> +--FILE-- +<?php +/* Prototype : int ip2long(string ip_address) + * Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address + * Source code: ext/standard/basic_functions.c + * Alias to functions: + */ + +$ips = array( + "1.1.011.011", + "127.0.0.1", + "1.1.071.071", + "0.0.0.0", + "1.1.081.081", + "192.168.0.0", + "256.0.0.1", + "192.168.0xa.5", +); + +foreach($ips as $ip) { + var_dump(ip2long($ip)); +} + +?> +===DONE=== +--EXPECT-- +bool(false) +int(2130706433) +bool(false) +int(0) +bool(false) +int(-1062731776) +bool(false) +bool(false) +===DONE=== diff --git a/ext/standard/tests/network/ip2long_variation2_x64.phpt b/ext/standard/tests/network/ip2long_variation2_x64.phpt new file mode 100644 index 0000000000..a6fde5bdd9 --- /dev/null +++ b/ext/standard/tests/network/ip2long_variation2_x64.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test ip2long() function : usage variation 2, 64 bit +--SKIPIF-- +<?php +/* from man inet_pton : + All numbers supplied as ``parts'' in a `.' notation may be decimal, octal, or hexadecimal, as specified + in the C language (i.e., a leading 0x or 0X implies hexadecimal; otherwise, a leading 0 implies octal; + otherwise, the number is interpreted as decimal). +*/ +if(PHP_OS == 'Darwin') die("skip - inet_pton behaves differently on Darwin"); +if(PHP_INT_SIZE != 8) {die('skip 64 bit only');} +?> +--FILE-- +<?php +/* Prototype : int ip2long(string ip_address) + * Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address + * Source code: ext/standard/basic_functions.c + * Alias to functions: + */ + +$ips = array( + "1.1.011.011", + "127.0.0.1", + "1.1.071.071", + "0.0.0.0", + "1.1.081.081", + "192.168.0.0", + "256.0.0.1", + "192.168.0xa.5", +); + +foreach($ips as $ip) { + var_dump(ip2long($ip)); +} + +?> +===DONE=== +--EXPECT-- +bool(false) +int(2130706433) +bool(false) +int(0) +bool(false) +int(3232235520) +bool(false) +bool(false) +===DONE=== diff --git a/ext/standard/tests/network/setcookie.phpt b/ext/standard/tests/network/setcookie.phpt new file mode 100644 index 0000000000..bf04ec78de --- /dev/null +++ b/ext/standard/tests/network/setcookie.phpt @@ -0,0 +1,70 @@ +--TEST-- +setcookie() tests +--DESCRIPTION-- +--INI-- +date.timezone=UTC +--FILE-- +<?php +setcookie('name'); +setcookie('name', 'value'); +setcookie('name', 'space value'); +setcookie('name', 'value', 0); +setcookie('name', 'value', $tsp = time() + 5); +setcookie('name', 'value', $tsn = time() - 6); +setcookie('name', 'value', $tsc = time()); +setcookie('name', 'value', 0, '/path/'); +setcookie('name', 'value', 0, '', 'domain.tld'); +setcookie('name', 'value', 0, '', '', TRUE); +setcookie('name', 'value', 0, '', '', FALSE, TRUE); + + +$expected = array( + 'Set-Cookie: name=', + 'Set-Cookie: name=value', + 'Set-Cookie: name=space+value', + 'Set-Cookie: name=value', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsp).' GMT; Max-Age=5', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsn).' GMT; Max-Age=-6', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsc).' GMT; Max-Age=0', + 'Set-Cookie: name=value; path=/path/', + 'Set-Cookie: name=value; domain=domain.tld', + 'Set-Cookie: name=value; secure', + 'Set-Cookie: name=value; httponly' +); + +$headers = headers_list(); +if (($i = count($expected)) > count($headers)) +{ + echo "Less headers are being sent than expected - aborting"; + return; +} + +do +{ + if (strncmp(current($headers), 'Set-Cookie:', 11) !== 0) + { + continue; + } + + if (current($headers) === current($expected)) + { + $i--; + } + else + { + echo "Header mismatch:\n\tExpected: " + .current($expected) + ."\n\tReceived: ".current($headers)."\n"; + } + + next($expected); +} +while (next($headers) !== FALSE); + +echo ($i === 0) + ? 'OK' + : 'A total of '.$i.' errors found.'; +--EXPECTHEADERS-- + +--EXPECT-- +OK
\ No newline at end of file diff --git a/ext/standard/tests/password/password_bcrypt_errors.phpt b/ext/standard/tests/password/password_bcrypt_errors.phpt new file mode 100644 index 0000000000..2548c9accb --- /dev/null +++ b/ext/standard/tests/password/password_bcrypt_errors.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test error operation of password_hash() with bcrypt hashing +--FILE-- +<?php +//-=-=-=- + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 3))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 32))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => "foo"))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => "123456789012345678901"))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => 123))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => "foo"))); + +?> +--EXPECTF-- +Warning: password_hash(): Invalid bcrypt cost parameter specified: 3 in %s on line %d +NULL + +Warning: password_hash(): Invalid bcrypt cost parameter specified: 32 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 3 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 21 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 3 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Invalid bcrypt cost parameter specified: 0 in %s on line %d +NULL + + diff --git a/ext/standard/tests/password/password_get_info.phpt b/ext/standard/tests/password/password_get_info.phpt new file mode 100644 index 0000000000..4c8dc04ff8 --- /dev/null +++ b/ext/standard/tests/password/password_get_info.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test normal operation of password_get_info() +--FILE-- +<?php +//-=-=-=- +// Test Bcrypt +var_dump(password_get_info('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y')); +// Test Bcrypt Cost +var_dump(password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y')); +// Test Bcrypt Invalid Length +var_dump(password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100')); +// Test Non-Bcrypt +var_dump(password_get_info('$1$rasmusle$rISCgZzpwk3UhDidwXvin0')); + +echo "OK!"; +?> +--EXPECT-- +array(3) { + ["algo"]=> + int(1) + ["algoName"]=> + string(6) "bcrypt" + ["options"]=> + array(1) { + ["cost"]=> + int(10) + } +} +array(3) { + ["algo"]=> + int(1) + ["algoName"]=> + string(6) "bcrypt" + ["options"]=> + array(1) { + ["cost"]=> + int(11) + } +} +array(3) { + ["algo"]=> + int(0) + ["algoName"]=> + string(7) "unknown" + ["options"]=> + array(0) { + } +} +array(3) { + ["algo"]=> + int(0) + ["algoName"]=> + string(7) "unknown" + ["options"]=> + array(0) { + } +} +OK! diff --git a/ext/standard/tests/password/password_get_info_error.phpt b/ext/standard/tests/password/password_get_info_error.phpt new file mode 100644 index 0000000000..af676744c8 --- /dev/null +++ b/ext/standard/tests/password/password_get_info_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test error operation of password_get_info() +--FILE-- +<?php +//-=-=-=- +var_dump(password_get_info()); +var_dump(password_get_info(array())); + +echo "OK!"; +?> +--EXPECTF-- +Warning: password_get_info() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: password_get_info() expects parameter 1 to be string, array given in %s on line %d +NULL +OK! diff --git a/ext/standard/tests/password/password_hash.phpt b/ext/standard/tests/password/password_hash.phpt new file mode 100644 index 0000000000..f59d3d5e48 --- /dev/null +++ b/ext/standard/tests/password/password_hash.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test normal operation of password_hash() +--FILE-- +<?php +//-=-=-=- + +var_dump(strlen(password_hash("foo", PASSWORD_BCRYPT))); + +$hash = password_hash("foo", PASSWORD_BCRYPT); + +var_dump($hash === crypt("foo", $hash)); + +var_dump(password_hash("rasmuslerdorf", PASSWORD_BCRYPT, array("cost" => 7, "salt" => "usesomesillystringforsalt"))); + +var_dump(password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0)))); + +echo "OK!"; +?> +--EXPECT-- +int(60) +bool(true) +string(60) "$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi" +string(60) "$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y" +OK! + diff --git a/ext/standard/tests/password/password_hash_error.phpt b/ext/standard/tests/password/password_hash_error.phpt new file mode 100644 index 0000000000..952250cb30 --- /dev/null +++ b/ext/standard/tests/password/password_hash_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test error operation of password_hash() +--FILE-- +<?php +//-=-=-=- + +var_dump(password_hash()); + +var_dump(password_hash("foo")); + +var_dump(password_hash("foo", array())); + +var_dump(password_hash("foo", 19, new StdClass)); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, "baz")); + +var_dump(password_hash(array(), PASSWORD_BCRYPT)); + +var_dump(password_hash("123", PASSWORD_BCRYPT, array("salt" => array()))); + +/* Non-string salt, checking for memory leaks */ +var_dump(password_hash('123', PASSWORD_BCRYPT, array('salt' => 1234))); + +?> +--EXPECTF-- +Warning: password_hash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: password_hash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: password_hash() expects parameter 2 to be long, array given in %s on line %d +NULL + +Warning: password_hash(): Unknown password hashing algorithm: 19 in %s on line %d +NULL + +Warning: password_hash() expects parameter 3 to be array, string given in %s on line %d +NULL + +Warning: password_hash() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: password_hash(): Non-string salt parameter supplied in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 4 expecting 22 in %s on line %d +NULL diff --git a/ext/standard/tests/password/password_needs_rehash.phpt b/ext/standard/tests/password/password_needs_rehash.phpt new file mode 100644 index 0000000000..734729e63d --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test normal operation of password_needs_rehash() +--FILE-- +<?php +//-=-=-=- + +// Invalid Hash, always rehash +var_dump(password_needs_rehash('', PASSWORD_BCRYPT)); + +// Valid, as it's an unknown algorithm +var_dump(password_needs_rehash('', 0)); + +// Valid with cost the same +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10))); + +// Valid with cost the same, additional params +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10, 'foo' => 3))); + +// Invalid, different (lower) cost +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 09))); + +// Invalid, different (higher) cost +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 11))); + +// Valid with cost the default +$cost = str_pad(PASSWORD_BCRYPT_DEFAULT_COST, 2, '0', STR_PAD_LEFT); +var_dump(password_needs_rehash('$2y$'.$cost.'$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT)); + +// Should Issue Needs Rehash, Since Foo is cast to 0... +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 'foo'))); + + + +echo "OK!"; +?> +--EXPECT-- +bool(true) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +OK! diff --git a/ext/standard/tests/password/password_needs_rehash_error.phpt b/ext/standard/tests/password/password_needs_rehash_error.phpt new file mode 100644 index 0000000000..e25ef8db3f --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test error operation of password_needs_rehash() +--FILE-- +<?php +//-=-=-=- +var_dump(password_needs_rehash()); + +var_dump(password_needs_rehash('')); + +var_dump(password_needs_rehash('', "foo")); + +var_dump(password_needs_rehash(array(), 1)); + +var_dump(password_needs_rehash("", 1, "foo")); + +echo "OK!"; +?> +--EXPECTF-- +Warning: password_needs_rehash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: password_needs_rehash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 2 to be long, string given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 3 to be array, string given in %s on line %d +NULL +OK! diff --git a/ext/standard/tests/password/password_verify.phpt b/ext/standard/tests/password/password_verify.phpt new file mode 100644 index 0000000000..e7ecc7edd3 --- /dev/null +++ b/ext/standard/tests/password/password_verify.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test normal operation of password_verify) +--FILE-- +<?php +//-=-=-=- + +var_dump(password_verify(123, 123)); + +var_dump(password_verify("foo", '$2a$07$usesomesillystringforsalt$')); + +var_dump(password_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); + +var_dump(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); +echo "OK!"; +?> +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(true) +OK! diff --git a/ext/standard/tests/password/password_verify_error.phpt b/ext/standard/tests/password/password_verify_error.phpt new file mode 100644 index 0000000000..3e653fa04e --- /dev/null +++ b/ext/standard/tests/password/password_verify_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test error operation of password_verify() +--FILE-- +<?php +//-=-=-=- + +var_dump(password_verify()); + +var_dump(password_verify("foo")); + +?> +--EXPECTF-- +Warning: password_verify() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: password_verify() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt index 747e0196f1..7d441582ee 100644 --- a/ext/standard/tests/php_ini_loaded_file.phpt +++ b/ext/standard/tests/php_ini_loaded_file.phpt @@ -10,5 +10,5 @@ precision=12 <?php var_dump(php_ini_loaded_file()); ?> ---EXPECTF-- -string(%d) "%sphp.ini" +--EXPECTREGEX-- +string\(\d+\) ".*php\.ini"|bool\(false\) diff --git a/ext/standard/tests/php_logo_guid.phpt b/ext/standard/tests/php_logo_guid.phpt deleted file mode 100644 index c644b2893b..0000000000 --- a/ext/standard/tests/php_logo_guid.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Check the output of the php_logo_guid() function ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- -<?php -echo php_logo_guid(); -?> ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 - diff --git a/ext/standard/tests/php_real_logo_guid.phpt b/ext/standard/tests/php_real_logo_guid.phpt deleted file mode 100644 index a9fa7d35d5..0000000000 --- a/ext/standard/tests/php_real_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Testing the undocumented function php_real_logo_guid() ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- -<?php -echo php_real_logo_guid(); -?> ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/tests/strings/bug61038.phpt b/ext/standard/tests/strings/bug61038.phpt new file mode 100644 index 0000000000..7130804fa4 --- /dev/null +++ b/ext/standard/tests/strings/bug61038.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #61038: unpack("a5", "str\0\0") does not work as expected +--FILE-- +<?php +var_dump(unpack("a4", "str\0\0")); +var_dump(unpack("a5", "str\0\0")); +var_dump(unpack("a6", "str\0\0")); +var_dump(unpack("a*", "str\0\0")); +?> +--EXPECTF-- +array(1) { + [1]=> + string(4) "str%c" +} +array(1) { + [1]=> + string(5) "str%c%c" +} + +Warning: unpack(): Type a: not enough input, need 6, have 5 in %s on line %d +bool(false) +array(1) { + [1]=> + string(5) "str%c%c" +} + diff --git a/ext/standard/tests/strings/bug63874.phpt b/ext/standard/tests/strings/bug63874.phpt new file mode 100644 index 0000000000..066cc155df --- /dev/null +++ b/ext/standard/tests/strings/bug63874.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #63874 (Segfault if php_strip_whitespace has heredoc) +--FILE-- +<?php +echo php_strip_whitespace(__FILE__); + +return <<<A +a +A; +?> +--EXPECT-- +<?php +echo php_strip_whitespace(__FILE__); return <<<A +a +A; +?> diff --git a/ext/standard/tests/strings/pack_A.phpt b/ext/standard/tests/strings/pack_A.phpt new file mode 100644 index 0000000000..59fc22e122 --- /dev/null +++ b/ext/standard/tests/strings/pack_A.phpt @@ -0,0 +1,25 @@ +--TEST-- +pack()/unpack(): "A" modifier +--FILE-- +<?php +var_dump( + pack("A5", "foo "), + pack("A4", "fooo"), + pack("A4", "foo"), + unpack("A*", "foo\0\rbar\0 \t\r\n"), + unpack("A4", "foo\0\rbar\0 \t\r\n") +); +?> +--EXPECTF-- +string(5) "foo " +string(4) "fooo" +string(4) "foo " +array(1) { + [1]=> + string(8) "foo%c%cbar" +} +array(1) { + [1]=> + string(3) "foo" +} + diff --git a/ext/standard/tests/strings/pack_Z.phpt b/ext/standard/tests/strings/pack_Z.phpt new file mode 100644 index 0000000000..4fd007ae0f --- /dev/null +++ b/ext/standard/tests/strings/pack_Z.phpt @@ -0,0 +1,50 @@ +--TEST-- +pack()/unpack(): "Z" format +--FILE-- +<?php +var_dump( + pack("Z0", "f"), + pack("Z5", "foo\0"), + pack("Z4", "fooo"), + pack("Z4", "foo"), + pack("Z*", "foo"), + unpack("Z*", "foo\0\rbar\0 \t\r\n"), + unpack("Z9", "foo\0\rbar\0 \t\r\n"), + unpack("Z2", "\0"), + unpack("Z2", "\0\0"), + unpack("Z2", "A\0"), + unpack("Z2", "AB\0"), + unpack("Z2", "ABC") +); +--EXPECTF-- +Warning: unpack(): Type Z: not enough input, need 2, have 1 in %s on line %d +string(0) "" +string(5) "foo%c%c" +string(4) "foo%c" +string(4) "foo%c" +string(4) "foo%c" +array(1) { + [1]=> + string(3) "foo" +} +array(1) { + [1]=> + string(3) "foo" +} +bool(false) +array(1) { + [1]=> + string(0) "" +} +array(1) { + [1]=> + string(1) "A" +} +array(1) { + [1]=> + string(2) "AB" +} +array(1) { + [1]=> + string(2) "AB" +} diff --git a/ext/standard/tests/strings/parse_str_basic3.phpt b/ext/standard/tests/strings/parse_str_basic3.phpt Binary files differindex 619b1476ab..84f6a53bb1 100644 --- a/ext/standard/tests/strings/parse_str_basic3.phpt +++ b/ext/standard/tests/strings/parse_str_basic3.phpt diff --git a/ext/standard/tests/strings/unpack_error.phpt b/ext/standard/tests/strings/unpack_error.phpt index 43b2df1c0a..1ef97ccbaf 100644 --- a/ext/standard/tests/strings/unpack_error.phpt +++ b/ext/standard/tests/strings/unpack_error.phpt @@ -19,7 +19,7 @@ var_dump(unpack("I", pack("I", 65534), $extra_arg)); echo "\n-- Testing unpack() function with invalid format character --\n"; $extra_arg = 10; -var_dump(unpack("Z", pack("I", 65534))); +var_dump(unpack("G", pack("I", 65534))); ?> ===DONE=== --EXPECTF-- @@ -37,6 +37,6 @@ NULL -- Testing unpack() function with invalid format character -- -Warning: unpack(): Invalid format type Z in %s on line %d +Warning: unpack(): Invalid format type G in %s on line %d bool(false) ===DONE=== diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 226f17572b..0475d12e69 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -62,8 +62,8 @@ int(16) int(24) -- Iteration 3 -- - 1234000 0 120 -int(25) + 1234000 3875820019684212736 120 +int(34) -- Iteration 4 -- #1 0 $0 10 diff --git a/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt index 3af1738e56..af55ce966f 100644 --- a/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt @@ -58,7 +58,7 @@ string(16) "1234567 342391 0" string(24) "12345678900 u 1234 12345" -- Iteration 3 -- -string(25) " 1234000 0 120" +string(34) " 1234000 3875820019684212736 120" -- Iteration 4 -- string(10) "#1 0 $0 10" diff --git a/ext/standard/tests/time/strptime_basic.phpt b/ext/standard/tests/time/strptime_basic.phpt index 194a78f82b..30e3e82cc7 100644 --- a/ext/standard/tests/time/strptime_basic.phpt +++ b/ext/standard/tests/time/strptime_basic.phpt @@ -24,7 +24,7 @@ $input = "10:00:00 AM July 2 1963"; $tstamp = strtotime($input); $str = strftime("%r %B%e %Y %Z", $tstamp); -var_dump(strptime($str, '%H:%M:%S %p %B %d %Y %Z')); +var_dump(strptime($str, '%H:%M:%S %p %B %d %Y')); $str = strftime("%T %D", $tstamp); var_dump(strptime($str, '%H:%M:%S %m/%d/%y')); @@ -55,7 +55,7 @@ array(9) { ["tm_yday"]=> int(182) ["unparsed"]=> - string(3) "GMT" + string(4) " GMT" } array(9) { ["tm_sec"]=> diff --git a/ext/standard/tests/zend_logo_guid.phpt b/ext/standard/tests/zend_logo_guid.phpt deleted file mode 100644 index 44e213b25d..0000000000 --- a/ext/standard/tests/zend_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Checking the zend_logo_guid() function ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- -<?php -echo zend_logo_guid(); -?> ---EXPECT-- -PHPE9568F35-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/type.c b/ext/standard/type.c index 5c4085a28a..5d93f66f5b 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -176,6 +176,20 @@ PHP_FUNCTION(floatval) } /* }}} */ +/* {{{ proto bool boolval(mixed var) + Get the boolean value of a variable */ +PHP_FUNCTION(boolval) +{ + zval **val; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &val) == FAILURE) { + return; + } + + RETURN_BOOL(zend_is_true(*val)); +} +/* }}} */ + /* {{{ proto string strval(mixed var) Get the string value of a variable */ PHP_FUNCTION(strval) diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index 236276a648..2c2dfda1b1 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -544,56 +544,69 @@ state_next_arg: }; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - if (yych <= ' ') { + if (yych <= '.') { if (yych <= '\f') { - if (yych <= 0x08) goto yy34; - if (yych <= '\v') goto yy30; - goto yy34; + if (yych <= 0x08) goto yy36; + if (yych <= '\v') goto yy32; + goto yy36; } else { - if (yych <= '\r') goto yy30; - if (yych <= 0x1F) goto yy34; - goto yy30; + if (yych <= '\r') goto yy32; + if (yych == ' ') goto yy32; + goto yy36; } } else { if (yych <= '@') { - if (yych != '>') goto yy34; + if (yych <= '/') goto yy28; + if (yych == '>') goto yy30; + goto yy36; } else { - if (yych <= 'Z') goto yy32; - if (yych <= '`') goto yy34; - if (yych <= 'z') goto yy32; - goto yy34; + if (yych <= 'Z') goto yy34; + if (yych <= '`') goto yy36; + if (yych <= 'z') goto yy34; + goto yy36; } } +yy28: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '>') goto yy39; +yy29: +#line 323 "ext/standard/url_scanner_ex.re" + { passthru(STD_ARGS); goto state_plain_begin; } +#line 576 "ext/standard/url_scanner_ex.c" +yy30: ++YYCURSOR; +yy31: #line 320 "ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; } -#line 571 "ext/standard/url_scanner_ex.c" -yy30: +#line 582 "ext/standard/url_scanner_ex.c" +yy32: ++YYCURSOR; yych = *YYCURSOR; - goto yy37; -yy31: + goto yy38; +yy33: #line 321 "ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_next_arg; } -#line 579 "ext/standard/url_scanner_ex.c" -yy32: +#line 590 "ext/standard/url_scanner_ex.c" +yy34: ++YYCURSOR; #line 322 "ext/standard/url_scanner_ex.re" { --YYCURSOR; STATE = STATE_ARG; goto state_arg; } -#line 584 "ext/standard/url_scanner_ex.c" -yy34: - ++YYCURSOR; -#line 323 "ext/standard/url_scanner_ex.re" - { passthru(STD_ARGS); goto state_plain_begin; } -#line 589 "ext/standard/url_scanner_ex.c" +#line 595 "ext/standard/url_scanner_ex.c" yy36: + yych = *++YYCURSOR; + goto yy29; +yy37: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy37: +yy38: if (yybm[0+yych] & 128) { - goto yy36; + goto yy37; } + goto yy33; +yy39: + ++YYCURSOR; + yych = *YYCURSOR; goto yy31; } #line 324 "ext/standard/url_scanner_ex.re" @@ -602,7 +615,7 @@ yy37: state_arg: start = YYCURSOR; -#line 606 "ext/standard/url_scanner_ex.c" +#line 619 "ext/standard/url_scanner_ex.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -641,32 +654,32 @@ state_arg: }; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - if (yych <= '@') goto yy42; - if (yych <= 'Z') goto yy40; - if (yych <= '`') goto yy42; - if (yych >= '{') goto yy42; -yy40: + if (yych <= '@') goto yy44; + if (yych <= 'Z') goto yy42; + if (yych <= '`') goto yy44; + if (yych >= '{') goto yy44; +yy42: ++YYCURSOR; yych = *YYCURSOR; - goto yy45; -yy41: + goto yy47; +yy43: #line 329 "ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; } -#line 656 "ext/standard/url_scanner_ex.c" -yy42: +#line 669 "ext/standard/url_scanner_ex.c" +yy44: ++YYCURSOR; #line 330 "ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; } -#line 661 "ext/standard/url_scanner_ex.c" -yy44: +#line 674 "ext/standard/url_scanner_ex.c" +yy46: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy45: +yy47: if (yybm[0+yych] & 128) { - goto yy44; + goto yy46; } - goto yy41; + goto yy43; } #line 331 "ext/standard/url_scanner_ex.re" @@ -674,7 +687,7 @@ yy45: state_before_val: start = YYCURSOR; -#line 678 "ext/standard/url_scanner_ex.c" +#line 691 "ext/standard/url_scanner_ex.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -713,45 +726,45 @@ state_before_val: }; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - if (yych == ' ') goto yy48; - if (yych == '=') goto yy50; - goto yy52; -yy48: + if (yych == ' ') goto yy50; + if (yych == '=') goto yy52; + goto yy54; +yy50: yych = *(YYMARKER = ++YYCURSOR); - if (yych == ' ') goto yy55; - if (yych == '=') goto yy53; -yy49: + if (yych == ' ') goto yy57; + if (yych == '=') goto yy55; +yy51: #line 337 "ext/standard/url_scanner_ex.re" { --YYCURSOR; goto state_next_arg_begin; } -#line 727 "ext/standard/url_scanner_ex.c" -yy50: +#line 740 "ext/standard/url_scanner_ex.c" +yy52: ++YYCURSOR; yych = *YYCURSOR; - goto yy54; -yy51: + goto yy56; +yy53: #line 336 "ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; } -#line 735 "ext/standard/url_scanner_ex.c" -yy52: +#line 748 "ext/standard/url_scanner_ex.c" +yy54: yych = *++YYCURSOR; - goto yy49; -yy53: + goto yy51; +yy55: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy54: +yy56: if (yybm[0+yych] & 128) { - goto yy53; + goto yy55; } - goto yy51; -yy55: + goto yy53; +yy57: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == ' ') goto yy55; - if (yych == '=') goto yy53; + if (yych == ' ') goto yy57; + if (yych == '=') goto yy55; YYCURSOR = YYMARKER; - goto yy49; + goto yy51; } #line 338 "ext/standard/url_scanner_ex.re" @@ -760,7 +773,7 @@ yy55: state_val: start = YYCURSOR; -#line 764 "ext/standard/url_scanner_ex.c" +#line 777 "ext/standard/url_scanner_ex.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -801,83 +814,83 @@ state_val: yych = *YYCURSOR; if (yych <= ' ') { if (yych <= '\f') { - if (yych <= 0x08) goto yy63; - if (yych <= '\n') goto yy65; - goto yy63; - } else { - if (yych <= '\r') goto yy65; - if (yych <= 0x1F) goto yy63; + if (yych <= 0x08) goto yy65; + if (yych <= '\n') goto yy67; goto yy65; + } else { + if (yych <= '\r') goto yy67; + if (yych <= 0x1F) goto yy65; + goto yy67; } } else { if (yych <= '&') { - if (yych != '"') goto yy63; + if (yych != '"') goto yy65; } else { - if (yych <= '\'') goto yy62; - if (yych == '>') goto yy65; - goto yy63; + if (yych <= '\'') goto yy64; + if (yych == '>') goto yy67; + goto yy65; } } yych = *(YYMARKER = ++YYCURSOR); - if (yych != '>') goto yy74; -yy61: + if (yych != '>') goto yy76; +yy63: #line 347 "ext/standard/url_scanner_ex.re" { passthru(STD_ARGS); goto state_next_arg_begin; } -#line 827 "ext/standard/url_scanner_ex.c" -yy62: +#line 840 "ext/standard/url_scanner_ex.c" +yy64: yych = *(YYMARKER = ++YYCURSOR); - if (yych == '>') goto yy61; - goto yy69; -yy63: + if (yych == '>') goto yy63; + goto yy71; +yy65: ++YYCURSOR; yych = *YYCURSOR; - goto yy67; -yy64: + goto yy69; +yy66: #line 346 "ext/standard/url_scanner_ex.re" { handle_val(STD_ARGS, 0, ' '); goto state_next_arg_begin; } -#line 839 "ext/standard/url_scanner_ex.c" -yy65: +#line 852 "ext/standard/url_scanner_ex.c" +yy67: yych = *++YYCURSOR; - goto yy61; -yy66: + goto yy63; +yy68: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy67: +yy69: if (yybm[0+yych] & 32) { - goto yy66; + goto yy68; } - goto yy64; -yy68: + goto yy66; +yy70: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy69: +yy71: if (yybm[0+yych] & 64) { - goto yy68; + goto yy70; } - if (yych <= '=') goto yy71; -yy70: + if (yych <= '=') goto yy73; +yy72: YYCURSOR = YYMARKER; - goto yy61; -yy71: + goto yy63; +yy73: ++YYCURSOR; #line 345 "ext/standard/url_scanner_ex.re" { handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; } -#line 868 "ext/standard/url_scanner_ex.c" -yy73: +#line 881 "ext/standard/url_scanner_ex.c" +yy75: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy74: +yy76: if (yybm[0+yych] & 128) { - goto yy73; + goto yy75; } - if (yych >= '>') goto yy70; + if (yych >= '>') goto yy72; ++YYCURSOR; #line 344 "ext/standard/url_scanner_ex.re" { handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; } -#line 881 "ext/standard/url_scanner_ex.c" +#line 894 "ext/standard/url_scanner_ex.c" } #line 348 "ext/standard/url_scanner_ex.re" @@ -998,7 +1011,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char * PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC) { - char *encoded; + char *encoded = NULL; int encoded_len; smart_str val; diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index b44be124a1..1e5c38a373 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -559,7 +559,7 @@ PHP_FUNCTION(stream_get_filters) if (filters_hash) { for(zend_hash_internal_pointer_reset(filters_hash); - (key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT; + (key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward(filters_hash)) if (key_flags == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, filter_name, filter_name_len - 1, 1); diff --git a/ext/standard/var.c b/ext/standard/var.c index 2d0339a6a3..fb2a310f4c 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -647,7 +647,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt for (;; zend_hash_move_forward_ex(HASH_OF(retval_ptr), &pos)) { i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), &key, NULL, &index, 0, &pos); - if (i == HASH_KEY_NON_EXISTANT) { + if (i == HASH_KEY_NON_EXISTENT) { break; } @@ -858,7 +858,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var zend_hash_internal_pointer_reset_ex(myht, &pos); for (;; zend_hash_move_forward_ex(myht, &pos)) { i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos); - if (i == HASH_KEY_NON_EXISTANT) { + if (i == HASH_KEY_NON_EXISTENT) { break; } if (incomplete_class && strcmp(key, MAGIC_MEMBER) == 0) { diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index 8a35e0a5af..f7546428b1 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Mon Jul 29 17:57:26 2013 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ |