diff -uNr php-4.0RC1.orig/Zend/zend_globals.h php-4.0RC1/Zend/zend_globals.h --- php-4.0RC1.orig/Zend/zend_globals.h Fri May 12 15:28:24 2000 +++ php-4.0RC1/Zend/zend_globals.h Fri May 12 15:35:05 2000 @@ -121,6 +121,10 @@ struct _zend_executor_globals { + char *proxy; + char *port; + char *post; + zval **return_value_ptr_ptr; zval uninitialized_zval; diff -uNr php-4.0RC1.orig/ext/standard/basic_functions.c php-4.0RC1/ext/standard/basic_functions.c --- php-4.0RC1.orig/ext/standard/basic_functions.c Fri May 12 15:28:21 2000 +++ php-4.0RC1/ext/standard/basic_functions.c Fri May 12 15:41:26 2000 @@ -75,6 +75,9 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference); function_entry basic_functions[] = { + PHP_FE(proxy_host, NULL) + PHP_FE(proxy_port, NULL) + PHP_FE(post_method, NULL) PHP_FE(intval, NULL) PHP_FE(doubleval, NULL) PHP_FE(strval, NULL) @@ -856,6 +859,33 @@ /******************* * Basic Functions * *******************/ + +PHP_FUNCTION(proxy_host) +{ + pval **proxy; + if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &proxy) == FAILURE) + { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(proxy); + EG(proxy)=estrdup((*proxy)->value.str.val); +} + +PHP_FUNCTION(proxy_port) +{ + pval **port; + if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &port) == FAILURE) + { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(port); + EG(port)=estrdup((*port)->value.str.val); +} + +PHP_FUNCTION(post_method) +{ + EG(post)=estrdup("set"); +} PHP_FUNCTION(intval) { diff -uNr php-4.0RC1.orig/ext/standard/basic_functions.h php-4.0RC1/ext/standard/basic_functions.h --- php-4.0RC1.orig/ext/standard/basic_functions.h Fri May 12 15:28:21 2000 +++ php-4.0RC1/ext/standard/basic_functions.h Fri May 12 15:42:00 2000 @@ -48,6 +48,9 @@ PHP_MINFO_FUNCTION(basic); PHP_GINIT_FUNCTION(basic); +PHP_FUNCTION(proxy_host); +PHP_FUNCTION(proxy_port); +PHP_FUNCTION(post_method); PHP_FUNCTION(intval); PHP_FUNCTION(doubleval); PHP_FUNCTION(strval); diff -uNr php-4.0RC1.orig/fopen-wrappers.c php-4.0RC1/fopen-wrappers.c --- php-4.0RC1.orig/fopen-wrappers.c Fri May 12 15:28:14 2000 +++ php-4.0RC1/fopen-wrappers.c Fri May 12 16:21:58 2000 @@ -447,6 +447,34 @@ struct sockaddr_in server; unsigned short portno; + char *proxy=NULL; + char *port=NULL; + char *post=NULL; + + if(EG(proxy)!=NULL) + { + proxy=estrdup(EG(proxy)); + EG(proxy)=NULL; + } + else if(strcmp(PG(proxy),"")!=0) + proxy=estrdup(PG(proxy)); + + if(EG(port)!=NULL) + { + port=estrdup(EG(port)); + EG(port)=NULL; + } + else if(strcmp(PG(port),"")!=0) + port=estrdup(PG(port)); + + if(EG(post)!=NULL) + { + post=estrdup(EG(post)); + EG(post)=NULL; + } + else if(strcmp(PG(post),"")!=0) + post=estrdup(PG(post)); + if (!strncasecmp(path, "http://", 7)) { resource = url_parse((char *) path); if (resource == NULL) { @@ -467,13 +495,37 @@ } server.sin_family = AF_INET; - if (lookup_hostname(resource->host, &server.sin_addr)) { + if(proxy!=NULL) + { + if (lookup_hostname(proxy, &server.sin_addr)) + { + SOCK_FCLOSE(*socketd); + *socketd = 0; + free_url(resource); + return NULL; + } + } + else if (lookup_hostname(resource->host, &server.sin_addr)) { SOCK_FCLOSE(*socketd); *socketd = 0; free_url(resource); return NULL; } - server.sin_port = htons(resource->port); + if(proxy!=NULL) + { + if(port!=NULL) + { + server.sin_port = htons(atoi(port)); + } + else + { + server.sin_port = htons(8080); + } + } + else + { + server.sin_port = htons(resource->port); + } if (connect(*socketd, (struct sockaddr *) &server, sizeof(server)) == SOCK_CONN_ERR) { SOCK_FCLOSE(*socketd); @@ -494,8 +546,31 @@ #endif #endif /*win32 */ - strcpy(hdr_line, "GET "); + if(post!=NULL && strcmp(post,"set")==0) + { + strcpy(hdr_line, "POST "); + len = 5; + } + else + { + strcpy(hdr_line, "GET "); + len = 4; + } + if(proxy!=NULL) + { + strncat(hdr_line, "http://", sizeof(hdr_line)-len); + len += 7; + strncat(hdr_line, resource->host, sizeof(hdr_line)-len); + len += strlen(resource->host); + strncat(hdr_line, ":", sizeof(hdr_line)-len); + len++; + snprintf(tmp_line, sizeof(tmp_line)-1, "%i", resource->port); + tmp_line[sizeof(tmp_line)-1] = '\0'; + strncat(hdr_line, tmp_line, sizeof(hdr_line)-len); + len += strlen(tmp_line); + } + /* tell remote http which file to get */ if (resource->path != NULL) { strlcat(hdr_line, resource->path, sizeof(hdr_line)); @@ -598,6 +673,14 @@ } free_url(resource); *issock = 1; + + if(proxy!=NULL) + efree(proxy); + if(port!=NULL) + efree(port); + if(post!=NULL) + efree(post); + return (fp); } else if (!strncasecmp(path, "php://", 6)) { const char *res = path + 6; diff -uNr php-4.0RC1.orig/main.c php-4.0RC1/main.c --- php-4.0RC1.orig/main.c Fri May 12 15:28:15 2000 +++ php-4.0RC1/main.c Fri May 12 15:36:54 2000 @@ -109,7 +109,6 @@ static PHP_INI_MH(OnSetPrecision) { ELS_FETCH(); - EG(precision) = atoi(new_value); return SUCCESS; } @@ -204,6 +203,9 @@ STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals) STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals) STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("proxy", "", PHP_INI_ALL, OnUpdateString, proxy, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("port", "", PHP_INI_ALL, OnUpdateString, port, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("post_method", "", PHP_INI_ALL, OnUpdateString, post, php_core_globals, core_globals) STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct,sapi_globals) STD_PHP_INI_ENTRY("default_mimetype",SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals) STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals) diff -uNr php-4.0RC1.orig/php_globals.h php-4.0RC1/php_globals.h --- php-4.0RC1.orig/php_globals.h Fri May 12 15:28:15 2000 +++ php-4.0RC1/php_globals.h Fri May 12 15:39:35 2000 @@ -54,6 +54,10 @@ struct _php_tick_function_entry; struct _php_core_globals { + char *proxy; + char *port; + char *post; + zend_bool magic_quotes_gpc; zend_bool magic_quotes_runtime; zend_bool magic_quotes_sybase; @@ -67,7 +71,7 @@ zend_bool safe_mode; zend_bool sql_safe_mode; - char *safe_mode_exec_dir; + char *safe_mode_exec_dir; zend_bool enable_dl; long memory_limit;