-
+ DCD30CE1321BB7891826B352582F3CBA30A5AB9B4BDF862B591E18FC1D986BDC01B91185270CE8929CA4952B29103CC040B87547FECD97B3EBE0852537FD1D71mp-wp/wp-includes/js/tinymce/plugins/spellchecker/rpc.php(0 . 0)(1 . 111)
124303 <?php
124304 /**
124305 * $Id: rpc.php 822 2008-04-28 13:45:03Z spocke $
124306 *
124307 * @package MCManager.includes
124308 * @author Moxiecode
124309 */
124310
124311 require_once("./includes/general.php");
124312
124313 // Set RPC response headers
124314 header('Content-Type: text/plain');
124315 header('Content-Encoding: UTF-8');
124316 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
124317 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
124318 header("Cache-Control: no-store, no-cache, must-revalidate");
124319 header("Cache-Control: post-check=0, pre-check=0", false);
124320 header("Pragma: no-cache");
124321
124322 $raw = "";
124323
124324 // Try param
124325 if (isset($_POST["json_data"]))
124326 $raw = getRequestParam("json_data");
124327
124328 // Try globals array
124329 if (!$raw && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"]))
124330 $raw = $_GLOBALS["HTTP_RAW_POST_DATA"];
124331
124332 // Try globals variable
124333 if (!$raw && isset($HTTP_RAW_POST_DATA))
124334 $raw = $HTTP_RAW_POST_DATA;
124335
124336 // Try stream
124337 if (!$raw) {
124338 if (!function_exists('file_get_contents')) {
124339 $fp = fopen("php://input", "r");
124340 if ($fp) {
124341 $raw = "";
124342
124343 while (!feof($fp))
124344 $raw = fread($fp, 1024);
124345
124346 fclose($fp);
124347 }
124348 } else
124349 $raw = "" . file_get_contents("php://input");
124350 }
124351
124352 // No input data
124353 if (!$raw)
124354 die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
124355
124356 // Passthrough request to remote server
124357 if (isset($config['general.remote_rpc_url'])) {
124358 $url = parse_url($config['general.remote_rpc_url']);
124359
124360 // Setup request
124361 $req = "POST " . $url["path"] . " HTTP/1.0\r\n";
124362 $req .= "Connection: close\r\n";
124363 $req .= "Host: " . $url['host'] . "\r\n";
124364 $req .= "Content-Length: " . strlen($raw) . "\r\n";
124365 $req .= "\r\n" . $raw;
124366
124367 if (!isset($url['port']) || !$url['port'])
124368 $url['port'] = 80;
124369
124370 $errno = $errstr = "";
124371
124372 $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);
124373 if ($socket) {
124374 // Send request headers
124375 fputs($socket, $req);
124376
124377 // Read response headers and data
124378 $resp = "";
124379 while (!feof($socket))
124380 $resp .= fgets($socket, 4096);
124381
124382 fclose($socket);
124383
124384 // Split response header/data
124385 $resp = explode("\r\n\r\n", $resp);
124386 echo $resp[1]; // Output body
124387 }
124388
124389 die();
124390 }
124391
124392 // Get JSON data
124393 $json = new Moxiecode_JSON();
124394 $input = $json->decode($raw);
124395
124396 // Execute RPC
124397 if (isset($config['general.engine'])) {
124398 $spellchecker = new $config['general.engine']($config);
124399 $result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);
124400 } else
124401 die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
124402
124403 // Request and response id should always be the same
124404 $output = array(
124405 "id" => $input->id,
124406 "result" => $result,
124407 "error" => null
124408 );
124409
124410 // Return JSON encoded string
124411 echo $json->encode($output);
124412
124413 ?>