int php_libxml_streams_IO_match_wrapper(const char *filename)
{
+ char *resolved_path;
+ int retval;
+
TSRMLS_FETCH();
if (zend_is_executing(TSRMLS_C)) {
- return php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC) ? 1 : 0;
+ resolved_path = xmlURIUnescapeString(filename, 0, NULL);
+ retval = php_stream_locate_url_wrapper(resolved_path, NULL, 0 TSRMLS_CC) ? 1 : 0;
+ if (resolved_path) {
+ xmlFree(resolved_path);
+ }
+ return retval;
}
return 0;
}
in xml processing (eg. DTD files) */
wrapper = php_stream_locate_url_wrapper(resolved_path, &path_to_open, ENFORCE_SAFE_MODE TSRMLS_CC);
if (wrapper && read_only && wrapper->wops->url_stat) {
- if (wrapper->wops->url_stat(wrapper, path_to_open, 0, &ssbuf, NULL TSRMLS_CC) == -1) {
+ if (wrapper->wops->url_stat(wrapper, path_to_open, PHP_STREAM_URL_STAT_QUIET, &ssbuf, NULL TSRMLS_CC) == -1) {
xmlFree(resolved_path);
return NULL;
}
if (LIBXML(stream_context)) {
context = zend_fetch_resource(&LIBXML(stream_context) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context());
- ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
- xmlFree(resolved_path);
- return ret_val;
}
- ret_val = php_stream_open_wrapper(path_to_open, (char *)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+
+ ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
xmlFree(resolved_path);
return ret_val;
}
}
}
+PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC) {
+ zval *oldcontext;
+
+ oldcontext = LIBXML(stream_context);
+ LIBXML(stream_context) = context;
+ return oldcontext;
+
+}
+
PHP_MINIT_FUNCTION(libxml)
{
php_libxml_initialize();
}
/* }}} */
-
/* {{{ Common functions shared by extensions */
int php_libxml_xmlCheckUTF8(const unsigned char *s)
{
/* $Id$ */
#include "php_soap.h"
+#include "ext/libxml/php_libxml.h"
#include "libxml/uri.h"
#include "ext/standard/md5.h"
return 1;
}
-static void load_wsdl_ex(char *struri, sdlCtx *ctx, int include)
+static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include TSRMLS_DC)
{
sdlPtr tmpsdl = ctx->sdl;
xmlDocPtr wsdl;
xmlNodePtr root, definitions, trav;
xmlAttrPtr targetNamespace;
+ php_stream_context *context=NULL;
+ zval **proxy_host, **proxy_port, *orig_context, *new_context;
if (zend_hash_exists(&ctx->docs, struri, strlen(struri)+1)) {
return;
}
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
+ Z_TYPE_PP(proxy_host) == IS_STRING &&
+ zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port"), (void **) &proxy_port) == SUCCESS &&
+ Z_TYPE_PP(proxy_port) == IS_LONG) {
+ zval str_port, *str_proxy;
+ smart_str proxy = {0};
+ str_port = **proxy_port;
+ zval_copy_ctor(&str_port);
+ convert_to_string(&str_port);
+ smart_str_appends(&proxy,"tcp://");
+ smart_str_appends(&proxy,Z_STRVAL_PP(proxy_host));
+ smart_str_appends(&proxy,":");
+ smart_str_appends(&proxy,Z_STRVAL(str_port));
+ zval_dtor(&str_port);
+ MAKE_STD_ZVAL(str_proxy);
+ ZVAL_STRING(str_proxy, proxy.c, 1);
+ smart_str_free(&proxy);
+
+ context = php_stream_context_alloc();
+ php_stream_context_set_option(context, "http", "proxy", str_proxy);
+ zval_ptr_dtor(&str_proxy);
+ MAKE_STD_ZVAL(new_context);
+ php_stream_context_to_zval(context, new_context);
+ orig_context = php_libxml_switch_context(new_context TSRMLS_CC);
+ }
+
wsdl = soap_xmlParseFile(struri);
+
+ if (context) {
+ php_libxml_switch_context(orig_context TSRMLS_CC);
+ zval_ptr_dtor(&new_context);
+ }
if (!wsdl) {
soap_error1(E_ERROR, "Parsing WSDL: Couldn't load from '%s'", struri);
uri = xmlBuildURI(tmp->children->content, base);
xmlFree(base);
}
- load_wsdl_ex(uri, ctx, 1);
+ load_wsdl_ex(this_ptr, uri, ctx, 1 TSRMLS_CC);
xmlFree(uri);
}
return parameters;
}
-static sdlPtr load_wsdl(char *struri)
+static sdlPtr load_wsdl(zval *this_ptr, char *struri TSRMLS_DC)
{
sdlCtx ctx;
int i,n;
zend_hash_init(&ctx.portTypes, 0, NULL, NULL, 0);
zend_hash_init(&ctx.services, 0, NULL, NULL, 0);
- load_wsdl_ex(struri,&ctx, 0);
+ load_wsdl_ex(this_ptr, struri,&ctx, 0 TSRMLS_CC);
schema_pass2(&ctx);
n = zend_hash_num_elements(&ctx.services);
zend_hash_destroy(&tmp_types);
}
-sdlPtr get_sdl(char *uri TSRMLS_DC)
+sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
{
sdlPtr sdl = NULL;
char* old_error_code = SOAP_GLOBAL(error_code);
if (strchr(uri,':') != NULL || IS_ABSOLUTE_PATH(uri, uri_len)) {
strcpy(fn, uri);
} else if (VCWD_REALPATH(uri, fn) == NULL) {
- sdl = load_wsdl(uri);
+ sdl = load_wsdl(this_ptr, uri TSRMLS_CC);
}
if (sdl == NULL) {
char* key;
memcpy(key+len+sizeof("/wsdl-")-1,md5str,sizeof(md5str));
if ((sdl = get_sdl_from_cache(key, fn, t-SOAP_GLOBAL(cache_ttl))) == NULL) {
- sdl = load_wsdl(fn);
+ sdl = load_wsdl(this_ptr, fn TSRMLS_CC);
if (sdl != NULL) {
add_sdl_to_cache(key, fn, t, sdl);
}
efree(key);
}
} else {
- sdl = load_wsdl(uri);
+ sdl = load_wsdl(this_ptr, uri TSRMLS_CC);
}
SOAP_GLOBAL(error_code) = old_error_code;
return sdl;