jcwatson11
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Install Behind ProxyI successfully installed WordPress 2.6.2 behind a firewall and was able to modify some core WordPress code to enable proxy functionality. This fixed the dashboard page panels so they load immediately now. However, the plugins.php page still takes about 30 seconds to load. I don’t know if that’s a function of how many plugins we have installed or whether there is a place I missed in the code.
Note the last file patched in the code below is your wp-config.php file in WordPress’ root folder. Edit this file after you install the patch to add your proxy settings toward the bottom.
Here’s my patch. I hope it helps.
--- wp-includes/update.php.orig 2008-10-18 11:09:35.000000000 -0700 +++ wp-includes/update.php 2008-10-18 11:39:12.000000000 -0700 @@ -46,7 +46,12 @@ $http_request .= "\r\n"; $response = ''; - if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) && is_resource($fs) ) { + if(PROXY_HOST) { + $fs = @fsockopen( PROXY_HOST, PROXY_PORT, $errno, $errstr, 3); + } else { + $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ); + } + if ( false !== $fs && is_resource($fs) ) { fwrite( $fs, $http_request ); while ( !feof( $fs ) ) $response .= fgets( $fs, 1160 ); // One TCP-IP packet @@ -139,7 +144,12 @@ $http_request .= $request; $response = ''; - if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) { + if(PROXY_HOST) { + $fs = @fsockopen( PROXY_HOST, PROXY_PORT, $errno, $errstr, 3); + } else { + $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ); + } + if ( false !== $fs && is_resource($fs) ) { fwrite($fs, $http_request); while ( !feof($fs) ) --- wp-includes/functions.php.orig 2008-10-18 11:33:05.000000000 -0700 +++ wp-includes/functions.php 2008-10-18 12:43:27.000000000 -0700 @@ -834,9 +834,14 @@ else $request_type = 'HEAD'; - $head = "$request_type $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n"; + $head = "$request_type $file HTTP/1.1\r\nHOST: $host\r\nPORT: {$parts['port']}\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n"; - $fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 ); + if(PROXY_HOST) { + $fp = @fsockopen( PROXY_HOST, PROXY_PORT, $err_num, $err_msg, 3); + } else { + $fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 ); + } + //$fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 ); if ( !$fp ) return false; @@ -1097,6 +1102,10 @@ curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); + if(PROXY_HOST) { + $proxy_host = PROXY_HOST . ( (PROXY_PORT) ? ':'.PROXY_PORT:'' ); + curl_setopt( $handle, CURLOPT_PROXY, $proxy_host ); + } $buffer = curl_exec( $handle ); curl_close( $handle ); return $buffer; --- wp-config.php.orig 2008-10-18 12:47:28.000000000 -0700 +++ wp-config.php 2008-10-18 12:51:57.000000000 -0700 @@ -22,5 +22,8 @@ /* That's all, stop editing! Happy blogging. */ define('ABSPATH', dirname(__FILE__).'/'); +/* define proxy settings here */ +define('PROXY_HOST', 'myproxy.server.com'); // replace with your proxy server. +define('PROXY_PORT', '8080'); // replace with your proxy port number require_once(ABSPATH.'wp-settings.php'); ?>Note: You may want to update wp-includes/class-snoopy.php to enable proxy support also. To do this, you would need to change the following lines to include your proxy settings.
var $proxy_host = ""; // proxy host to use var $proxy_port = ""; // proxy port to useThese lines are found in my 2.6.2 install on lines 54 and 55.
Forum: Installing WordPress
In reply to: Fatal Error: Time exceeded update.php after local XAMPP install.We are having the same issue.
After some extensive searching, it appears there is no solution for the current version of WordPress. Version 2.6.2 is what we have installed. It appears that WordPress’s implementation of fsockopen() needs to be altered to account for a proxy server allowing WordPress to access the internet from behind a firewall.
Is it possible to write a plugin that adds this functionality to WordPress? If so, I would appreciate someone pointing us to documentation on how to write such a plugin.