2

I'm using the stats plugin for wordpress which uses a core wordpress class IXR_Client in class-IXR. Although according to documentation it uses the proxy config found in wp-config.php I see no way it can as it uses the same address for host as it does in fsockopen (looking at fsockopen it should be the proxy address)

I've modified the fsockopen to point to my proxy and it does receive a response now from the proxy although 'TCP_DENIED/400 4139 POST error:invalid-request - NONE/- text/html' comes up in the proxy logs and the proxy returns an error. I have a feeling I'm not wrapping the request right for the proxy.

The request: (some things changed)

POST /xmlrpc.php HTTP/1.0 Host: wordpress.com Content-Type: 
text/xml User-Agent: The Incutio XML-RPC PHP Library Content-Length: 1770 <?xml 
version="1.0"?> <methodCall> <methodName>wpStats.check_key</methodName> <params> 
<param><value><string>123456789012</string></value></param> <param><value><struct> 
<member><name>host</name><value><string>thedomainoftheblog.com</string></value></member> 
<member><name>path</name><value><string>/</string></value></member> 
<member><name>admin_bar</name><value><string>1</string></value></member> 
<member><name>wp_me</name><value><string>1</string></value></member> 
<member><name>reg_users</name><value><string></string></value></member> 
<member><name>footer</name><value><string>1</string></value></member> 
<member><name>version</name><value><string>7</string></value></member> 
<member><name>error</name><value><string></string></value></member> 
<member><name>blogname</name><value><string>THE | BLOG NAMEFUL</string></value></member> 
<member><name>blogdescription</name><value><string>blogs name norma 
l</string></value></member><member><name>siteurl</name>
<value><string>http://thedomainoftheblog.com</string></value></member> 
<member><name>gmt_offset</name><value><string>0</string></value></member> 
<member><name>timezone_string</name><value><string></string></value></member> 
<member><name>stats_version</name><value><string>7</string></value></member> 
<member><name>stats_api</name><value><string>jetpack</string></value></member> 
<member><name>page_on_front</name><value><string>0</string></value></member>
<member><name>permalink_structure</name><value>
<string>/%year%/%monthnum%/%day%/%postname%/</string></value></member> 
<member><name>category_base</name><value><string></string></value></member> 
<member><name>tag_base</name><value><string></string></value></member> </struct></value></param> </params></methodCall>

If you need more information let me know.

Cheers

Rudiger
  • 6,749
  • 13
  • 51
  • 102

2 Answers2

1

The trick seems to be to add http://your.domain.name/ on the POST request (i.e. not only POST/name-of-file, as class-IXR.php has by default), at least according to the following link: http://thedeadone.net/how-to/livejournal-and-wordpress/

I've tried it out and it certainly works.

0

There are a few proxy-related constants in WP, as well as a whole bunch of other constants used in wp-includes/class-http.php. Have you tried to set any or all of them? e.g.:

WP_PROXY_HOST
WP_PROXY_PORT
WP_PROXY_USERNAME
WP_PROXY_PASSWORD
WP_PROXY_BYPASS_HOSTS
Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154
  • IXR_Client does not use any proxy constants and fsocksopen uses the same address as the host, as I said in the first paragraph. – Rudiger May 15 '11 at 12:06
  • Might you have missed that WP uses two extended classes located in (both wp-includes/) class-wp-xmlrpc-server.php and class-wp-http-ixr-client.php? These both use the http objects referenced in the above file, and thus all of the http-related constants. – Denis de Bernardy May 15 '11 at 12:13
  • To connect to a proxy through fsocksopen you must use the proxy address when you call @fsockopen. In the WP code it uses the same address for host and @fsockopen so no constant would be used. According to the documentation this is the only way to connect @fsockopen to a proxy, so no global can be used. – Rudiger May 15 '11 at 22:38