]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/spellchecker/rpc.php
Wordpress 3.1.4-scripts
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / spellchecker / rpc.php
index d7b74362e7069891a5f405173edf79037f63dcf5..6a567348ced8f40804cf9bbde525c0b53fea5b7c 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 /**
- * $Id: rpc.php 354 2007-11-05 20:48:49Z spocke $
+ * $Id: rpc.php 915 2008-09-03 08:45:28Z spocke $
  *
+ * @package MCManager.includes
  * @author Moxiecode
  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
  */
@@ -51,6 +52,42 @@ if (!$raw) {
 if (!$raw)
        die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
 
+// Passthrough request to remote server
+if (isset($config['general.remote_rpc_url'])) {
+       $url = parse_url($config['general.remote_rpc_url']);
+
+       // Setup request
+       $req = "POST " . $url["path"] . " HTTP/1.0\r\n";
+       $req .= "Connection: close\r\n";
+       $req .= "Host: " . $url['host'] . "\r\n";
+       $req .= "Content-Length: " . strlen($raw) . "\r\n";
+       $req .= "\r\n" . $raw;
+
+       if (!isset($url['port']) || !$url['port'])
+               $url['port'] = 80;
+
+       $errno = $errstr = "";
+
+       $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);
+       if ($socket) {
+               // Send request headers
+               fputs($socket, $req);
+
+               // Read response headers and data
+               $resp = "";
+               while (!feof($socket))
+                               $resp .= fgets($socket, 4096);
+
+               fclose($socket);
+
+               // Split response header/data
+               $resp = explode("\r\n\r\n", $resp);
+               echo $resp[1]; // Output body
+       }
+
+       die();
+}
+
 // Get JSON data
 $json = new Moxiecode_JSON();
 $input = $json->decode($raw);
@@ -72,4 +109,4 @@ $output = array(
 // Return JSON encoded string
 echo $json->encode($output);
 
-?>
\ No newline at end of file
+?>