Merge pull request #4512 from sminnee/4511-fix-tinymce-spellcheck-deprecation

Fix tinymce spellcheck deprecation
This commit is contained in:
Will Morgan 2015-08-19 10:11:32 +01:00
commit 7fc58f75aa

View File

@ -1,112 +1,104 @@
<?php <?php
/** /**
* $Id: rpc.php 915 2008-09-03 08:45:28Z spocke $ * $Id: rpc.php 915 2008-09-03 08:45:28Z spocke $
* *
* @package MCManager.includes * @package MCManager.includes
* @author Moxiecode * @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/ */
require_once("./includes/general.php"); require_once("./includes/general.php");
// Set RPC response headers // Set RPC response headers
header('Content-Type: text/plain'); header('Content-Type: text/plain');
header('Content-Encoding: UTF-8'); header('Content-Encoding: UTF-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false); header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Pragma: no-cache");
$raw = ""; $raw = "";
// Try param // Try param
if (isset($_POST["json_data"])) if (isset($_POST["json_data"]))
$raw = getRequestParam("json_data"); $raw = getRequestParam("json_data");
// Try globals array // Try stream
if (!$raw && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"])) if (!$raw) {
$raw = $_GLOBALS["HTTP_RAW_POST_DATA"]; if (!function_exists('file_get_contents')) {
$fp = fopen("php://input", "r");
// Try globals variable if ($fp) {
if (!$raw && isset($HTTP_RAW_POST_DATA)) $raw = "";
$raw = $HTTP_RAW_POST_DATA;
while (!feof($fp))
// Try stream $raw = fread($fp, 1024);
if (!$raw) {
if (!function_exists('file_get_contents')) { fclose($fp);
$fp = fopen("php://input", "r"); }
if ($fp) { } else
$raw = ""; $raw = "" . file_get_contents("php://input");
}
while (!feof($fp))
$raw = fread($fp, 1024); // No input data
if (!$raw)
fclose($fp); die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
}
} else // Passthrough request to remote server
$raw = "" . file_get_contents("php://input"); if (isset($config['general.remote_rpc_url'])) {
} $url = parse_url($config['general.remote_rpc_url']);
// No input data // Setup request
if (!$raw) $req = "POST " . $url["path"] . " HTTP/1.0\r\n";
die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); $req .= "Connection: close\r\n";
$req .= "Host: " . $url['host'] . "\r\n";
// Passthrough request to remote server $req .= "Content-Length: " . strlen($raw) . "\r\n";
if (isset($config['general.remote_rpc_url'])) { $req .= "\r\n" . $raw;
$url = parse_url($config['general.remote_rpc_url']);
if (!isset($url['port']) || !$url['port'])
// Setup request $url['port'] = 80;
$req = "POST " . $url["path"] . " HTTP/1.0\r\n";
$req .= "Connection: close\r\n"; $errno = $errstr = "";
$req .= "Host: " . $url['host'] . "\r\n";
$req .= "Content-Length: " . strlen($raw) . "\r\n"; $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);
$req .= "\r\n" . $raw; if ($socket) {
// Send request headers
if (!isset($url['port']) || !$url['port']) fputs($socket, $req);
$url['port'] = 80;
// Read response headers and data
$errno = $errstr = ""; $resp = "";
while (!feof($socket))
$socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30); $resp .= fgets($socket, 4096);
if ($socket) {
// Send request headers fclose($socket);
fputs($socket, $req);
// Split response header/data
// Read response headers and data $resp = explode("\r\n\r\n", $resp);
$resp = ""; echo $resp[1]; // Output body
while (!feof($socket)) }
$resp .= fgets($socket, 4096);
die();
fclose($socket); }
// Split response header/data // Get JSON data
$resp = explode("\r\n\r\n", $resp); $json = new Moxiecode_JSON();
echo $resp[1]; // Output body $input = $json->decode($raw);
}
// Execute RPC
die(); if (isset($config['general.engine'])) {
} $spellchecker = new $config['general.engine']($config);
$result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);
// Get JSON data } else
$json = new Moxiecode_JSON(); die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
$input = $json->decode($raw);
// Request and response id should always be the same
// Execute RPC $output = array(
if (isset($config['general.engine'])) { "id" => $input->id,
$spellchecker = new $config['general.engine']($config); "result" => $result,
$result = call_user_func_array(array($spellchecker, $input['method']), $input['params']); "error" => null
} else );
die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
// Return JSON encoded string
// Request and response id should always be the same echo $json->encode($output);
$output = array(
"id" => $input->id, ?>
"result" => $result,
"error" => null
);
// Return JSON encoded string
echo $json->encode($output);
?>