[Mapbender-commits] r9307 - trunk/mapbender/tools

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Nov 23 06:21:44 PST 2015


Author: armin11
Date: 2015-11-23 06:21:44 -0800 (Mon, 23 Nov 2015)
New Revision: 9307

Modified:
   trunk/mapbender/tools/send_post_curl.php
Log:
Option to handle proxy exceptions

Modified: trunk/mapbender/tools/send_post_curl.php
===================================================================
--- trunk/mapbender/tools/send_post_curl.php	2015-11-23 13:07:58 UTC (rev 9306)
+++ trunk/mapbender/tools/send_post_curl.php	2015-11-23 14:21:44 UTC (rev 9307)
@@ -89,9 +89,26 @@
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 		curl_setopt($ch, CURLOPT_POST, 1);
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
-		if(CONNECTION_PROXY != ""){
-			curl_setopt($ch, CURLOPT_PROXY,CONNECTION_PROXY.":".CONNECTION_PORT);	
-		}		
+	    	$NOT_PROXY_HOSTS_array = explode(",", NOT_PROXY_HOSTS);
+ 	    	//check if http_proxy is set as env, if yes, unset it for the curl action here, it will be reset somewhere below - normally not needed, cause it will be only available when at execution time of the script http://php.net/manual/en/function.putenv.php
+		if (getenv('http_proxy')) {
+			$e = new mb_notice("class_connector.php: current http_proxy: ".getenv('http_proxy')." will be unset by putenv('http_proxy')");
+			$tmpHttpProxy = getenv('http_proxy');
+			putenv("http_proxy"); //this should unset the variable???
+		} else {
+			$e = new mb_notice("class_connector.php: http_proxy is not set as env variable!");
+			$tmpHttpProxy = getenv('http_proxy');
+		}
+		//check if proxy is set and server not in NOT_PROXY_HOSTS
+ 	    	if(CONNECTION_PROXY != "" AND (in_array($host, $NOT_PROXY_HOSTS_array)!= true)){
+			curl_setopt($ch, CURLOPT_PROXY,CONNECTION_PROXY.":".CONNECTION_PORT);
+			$e = new mb_notice("class_connector.php: Proxy will be used!");
+			if(CONNECTION_PASSWORD != ""){
+				curl_setopt ($ch, CURLOPT_PROXYUSERPWD, CONNECTION_USER.':'.CONNECTION_PASSWORD);
+			}
+		} else {
+			$e = new mb_notice("class_connector.php: Proxy will not be used!");
+		}
 		if(CONNECTION_PASSWORD != ""){
 			curl_setopt ($ch, CURLOPT_PROXYUSERPWD, CONNECTION_USER.':'.CONNECTION_PASSWORD);	
 		}



More information about the Mapbender_commits mailing list