version 1.1.1.2, 2012/05/29 12:34:35
|
version 1.1.1.3, 2013/07/22 01:32:11
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| 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 | |
| that is bundled with this package in the file LICENSE, and is | |
Line 281 typedef struct _php_userstream_data php_userstream_dat
|
Line 281 typedef struct _php_userstream_data php_userstream_dat
|
|
|
}}} **/ |
}}} **/ |
|
|
static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) | static zval *user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context TSRMLS_DC) |
{ |
{ |
struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; | zval *object; |
php_userstream_data_t *us; | /* create an instance of our class */ |
zval *zfilename, *zmode, *zopened, *zoptions, *zretval = NULL, *zfuncname; | ALLOC_ZVAL(object); |
zval **args[4]; | object_init_ex(object, uwrap->ce); |
int call_result; | Z_SET_REFCOUNT_P(object, 1); |
php_stream *stream = NULL; | Z_SET_ISREF_P(object); |
zend_bool old_in_user_include; | |
|
|
/* Try to catch bad usage without preventing flexibility */ | if (context) { |
if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) { | add_property_resource(object, "context", context->rsrc_id); |
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented"); | zend_list_addref(context->rsrc_id); |
return NULL; | } else { |
| add_property_null(object, "context"); |
} |
} |
FG(user_stream_current_filename) = filename; |
|
|
|
/* if the user stream was registered as local and we are in include context, |
|
we add allow_url_include restrictions to allow_url_fopen ones */ |
|
/* we need only is_url == 0 here since if is_url == 1 and remote wrappers |
|
were restricted we wouldn't get here */ |
|
old_in_user_include = PG(in_user_include); |
|
if(uwrap->wrapper.is_url == 0 && |
|
(options & STREAM_OPEN_FOR_INCLUDE) && |
|
!PG(allow_url_include)) { |
|
PG(in_user_include) = 1; |
|
} |
|
|
|
us = emalloc(sizeof(*us)); |
|
us->wrapper = uwrap; |
|
|
|
/* create an instance of our class */ |
|
ALLOC_ZVAL(us->object); |
|
object_init_ex(us->object, uwrap->ce); |
|
Z_SET_REFCOUNT_P(us->object, 1); |
|
Z_SET_ISREF_P(us->object); |
|
|
|
if (uwrap->ce->constructor) { |
if (uwrap->ce->constructor) { |
zend_fcall_info fci; |
zend_fcall_info fci; |
zend_fcall_info_cache fcc; |
zend_fcall_info_cache fcc; |
Line 327 static php_stream *user_wrapper_opener(php_stream_wrap
|
Line 306 static php_stream *user_wrapper_opener(php_stream_wrap
|
fci.function_table = &uwrap->ce->function_table; |
fci.function_table = &uwrap->ce->function_table; |
fci.function_name = NULL; |
fci.function_name = NULL; |
fci.symbol_table = NULL; |
fci.symbol_table = NULL; |
fci.object_ptr = us->object; | fci.object_ptr = object; |
fci.retval_ptr_ptr = &retval_ptr; |
fci.retval_ptr_ptr = &retval_ptr; |
fci.param_count = 0; |
fci.param_count = 0; |
fci.params = NULL; |
fci.params = NULL; |
Line 336 static php_stream *user_wrapper_opener(php_stream_wrap
|
Line 315 static php_stream *user_wrapper_opener(php_stream_wrap
|
fcc.initialized = 1; |
fcc.initialized = 1; |
fcc.function_handler = uwrap->ce->constructor; |
fcc.function_handler = uwrap->ce->constructor; |
fcc.calling_scope = EG(scope); |
fcc.calling_scope = EG(scope); |
fcc.called_scope = Z_OBJCE_P(us->object); | fcc.called_scope = Z_OBJCE_P(object); |
fcc.object_ptr = us->object; | fcc.object_ptr = object; |
|
|
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { |
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name, uwrap->ce->constructor->common.function_name); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name, uwrap->ce->constructor->common.function_name); |
zval_dtor(us->object); | zval_dtor(object); |
FREE_ZVAL(us->object); | FREE_ZVAL(object); |
efree(us); | |
FG(user_stream_current_filename) = NULL; | |
PG(in_user_include) = old_in_user_include; | |
return NULL; |
return NULL; |
} else { |
} else { |
if (retval_ptr) { |
if (retval_ptr) { |
Line 353 static php_stream *user_wrapper_opener(php_stream_wrap
|
Line 329 static php_stream *user_wrapper_opener(php_stream_wrap
|
} |
} |
} |
} |
} |
} |
|
return object; |
|
} |
|
|
if (context) { | static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) |
add_property_resource(us->object, "context", context->rsrc_id); | { |
zend_list_addref(context->rsrc_id); | struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract; |
} else { | php_userstream_data_t *us; |
add_property_null(us->object, "context"); | zval *zfilename, *zmode, *zopened, *zoptions, *zretval = NULL, *zfuncname; |
| zval **args[4]; |
| int call_result; |
| php_stream *stream = NULL; |
| zend_bool old_in_user_include; |
| |
| /* Try to catch bad usage without preventing flexibility */ |
| if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) { |
| php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "infinite recursion prevented"); |
| return NULL; |
} |
} |
|
FG(user_stream_current_filename) = filename; |
|
|
|
/* if the user stream was registered as local and we are in include context, |
|
we add allow_url_include restrictions to allow_url_fopen ones */ |
|
/* we need only is_url == 0 here since if is_url == 1 and remote wrappers |
|
were restricted we wouldn't get here */ |
|
old_in_user_include = PG(in_user_include); |
|
if(uwrap->wrapper.is_url == 0 && |
|
(options & STREAM_OPEN_FOR_INCLUDE) && |
|
!PG(allow_url_include)) { |
|
PG(in_user_include) = 1; |
|
} |
|
|
|
us = emalloc(sizeof(*us)); |
|
us->wrapper = uwrap; |
|
|
|
us->object = user_stream_create_object(uwrap, context TSRMLS_CC); |
|
if(us->object == NULL) { |
|
FG(user_stream_current_filename) = NULL; |
|
PG(in_user_include) = old_in_user_include; |
|
efree(us); |
|
return NULL; |
|
} |
|
|
/* call it's stream_open method - set up params first */ |
/* call it's stream_open method - set up params first */ |
MAKE_STD_ZVAL(zfilename); |
MAKE_STD_ZVAL(zfilename); |
ZVAL_STRING(zfilename, filename, 1); |
ZVAL_STRING(zfilename, filename, 1); |
Line 447 static php_stream *user_wrapper_opendir(php_stream_wra
|
Line 457 static php_stream *user_wrapper_opendir(php_stream_wra
|
us = emalloc(sizeof(*us)); |
us = emalloc(sizeof(*us)); |
us->wrapper = uwrap; |
us->wrapper = uwrap; |
|
|
/* create an instance of our class */ | us->object = user_stream_create_object(uwrap, context TSRMLS_CC); |
ALLOC_ZVAL(us->object); | if(us->object == NULL) { |
object_init_ex(us->object, uwrap->ce); | FG(user_stream_current_filename) = NULL; |
Z_SET_REFCOUNT_P(us->object, 1); | efree(us); |
Z_SET_ISREF_P(us->object); | return NULL; |
| |
if (context) { | |
add_property_resource(us->object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(us->object, "context"); | |
} |
} |
|
|
/* call it's dir_open method - set up params first */ |
/* call it's dir_open method - set up params first */ |
Line 1157 static int user_wrapper_unlink(php_stream_wrapper *wra
|
Line 1161 static int user_wrapper_unlink(php_stream_wrapper *wra
|
int ret = 0; |
int ret = 0; |
|
|
/* create an instance of our class */ |
/* create an instance of our class */ |
ALLOC_ZVAL(object); | object = user_stream_create_object(uwrap, context TSRMLS_CC); |
object_init_ex(object, uwrap->ce); | if(object == NULL) { |
Z_SET_REFCOUNT_P(object, 1); | return ret; |
Z_SET_ISREF_P(object); | |
| |
if (context) { | |
add_property_resource(object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(object, "context"); | |
} |
} |
|
|
/* call the unlink method */ |
/* call the unlink method */ |
Line 1211 static int user_wrapper_rename(php_stream_wrapper *wra
|
Line 1208 static int user_wrapper_rename(php_stream_wrapper *wra
|
int ret = 0; |
int ret = 0; |
|
|
/* create an instance of our class */ |
/* create an instance of our class */ |
ALLOC_ZVAL(object); | object = user_stream_create_object(uwrap, context TSRMLS_CC); |
object_init_ex(object, uwrap->ce); | if(object == NULL) { |
Z_SET_REFCOUNT_P(object, 1); | return ret; |
Z_SET_ISREF_P(object); | |
| |
if (context) { | |
add_property_resource(object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(object, "context"); | |
} |
} |
|
|
/* call the rename method */ |
/* call the rename method */ |
Line 1270 static int user_wrapper_mkdir(php_stream_wrapper *wrap
|
Line 1260 static int user_wrapper_mkdir(php_stream_wrapper *wrap
|
int ret = 0; |
int ret = 0; |
|
|
/* create an instance of our class */ |
/* create an instance of our class */ |
ALLOC_ZVAL(object); | object = user_stream_create_object(uwrap, context TSRMLS_CC); |
object_init_ex(object, uwrap->ce); | if(object == NULL) { |
Z_SET_REFCOUNT_P(object, 1); | return ret; |
Z_SET_ISREF_P(object); | |
| |
if (context) { | |
add_property_resource(object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(object, "context"); | |
} |
} |
|
|
/* call the mkdir method */ |
/* call the mkdir method */ |
Line 1335 static int user_wrapper_rmdir(php_stream_wrapper *wrap
|
Line 1318 static int user_wrapper_rmdir(php_stream_wrapper *wrap
|
int ret = 0; |
int ret = 0; |
|
|
/* create an instance of our class */ |
/* create an instance of our class */ |
ALLOC_ZVAL(object); | object = user_stream_create_object(uwrap, context TSRMLS_CC); |
object_init_ex(object, uwrap->ce); | if(object == NULL) { |
Z_SET_REFCOUNT_P(object, 1); | return ret; |
Z_SET_ISREF_P(object); | |
| |
if (context) { | |
add_property_resource(object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(object, "context"); | |
} |
} |
|
|
/* call the rmdir method */ |
/* call the rmdir method */ |
Line 1420 static int user_wrapper_metadata(php_stream_wrapper *w
|
Line 1396 static int user_wrapper_metadata(php_stream_wrapper *w
|
} |
} |
|
|
/* create an instance of our class */ |
/* create an instance of our class */ |
ALLOC_ZVAL(object); | object = user_stream_create_object(uwrap, context TSRMLS_CC); |
object_init_ex(object, uwrap->ce); | if(object == NULL) { |
Z_SET_REFCOUNT_P(object, 1); | zval_ptr_dtor(&zvalue); |
Z_SET_ISREF_P(object); | return ret; |
| |
if (context) { | |
add_property_resource(object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(object, "context"); | |
} |
} |
|
|
/* call the mkdir method */ |
/* call the mkdir method */ |
Line 1484 static int user_wrapper_stat_url(php_stream_wrapper *w
|
Line 1454 static int user_wrapper_stat_url(php_stream_wrapper *w
|
int ret = -1; |
int ret = -1; |
|
|
/* create an instance of our class */ |
/* create an instance of our class */ |
ALLOC_ZVAL(object); | object = user_stream_create_object(uwrap, context TSRMLS_CC); |
object_init_ex(object, uwrap->ce); | if(object == NULL) { |
Z_SET_REFCOUNT_P(object, 1); | return ret; |
Z_SET_ISREF_P(object); | |
| |
if (context) { | |
add_property_resource(object, "context", context->rsrc_id); | |
zend_list_addref(context->rsrc_id); | |
} else { | |
add_property_null(object, "context"); | |
} |
} |
|
|
/* call it's stat_url method - set up params first */ |
/* call it's stat_url method - set up params first */ |