--- /dev/null
+Version 2.0.2 (2008-04-30)\r
+ Added new EnchantSpell engine class contributed by Michel Weimerskirch.\r
+ Added new general.remote_rpc_url option, enables you to proxy requests to another server.\r
+ Fixed security hole in PSpellShell.php file if PSpellShell engine was used.\r
+Version 2.0.1 (2008-03-07)\r
+ Fixed bug where spellchecker was auto focusing the editor in IE.\r
+Version 2.0 (2008-01-30)\r
+ Fixed bug where the suggestions menu was placed at an incorrect location.\r
+Version 2.0rc1 (2008-01-14)\r
+ Moved package from beta to release candidate.\r
+Version 2.0b3 (2007-12-xx)\r
+ Fixed bug where the suggestions menu could appear at the wrong location.\r
+Version 2.0b2 (2007-11-29)\r
+ Fixed bug where the spellchecker was removing the word when it was ignored.\r
+Version 2.0b1 (2007-11-21)\r
+ Moved spellchecker from alpha to beta status.\r
+Version 2.0a2 (2007-11-13)\r
+ Updated plugin so it works correctly with the TinyMCE 3.0a3 version.\r
+Version 2.0a1 (2007-11-01)\r
+ Rewritten version for TinyMCE 3.0 this new version uses JSON RPC.\r
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * This class was contributed by Michel Weimerskirch.\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class EnchantSpell extends SpellChecker {\r
+ /**\r
+ * Spellchecks an array of words.\r
+ *\r
+ * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1\r
+ * @param Array $words Array of words to check.\r
+ * @return Array of misspelled words.\r
+ */\r
+ function &checkWords($lang, $words) {\r
+ $r = enchant_broker_init();\r
+ \r
+ if (enchant_broker_dict_exists($r,$lang)) {\r
+ $d = enchant_broker_request_dict($r, $lang);\r
+ \r
+ $returnData = array();\r
+ foreach($words as $key => $value) {\r
+ $correct = enchant_dict_check($d, $value);\r
+ if(!$correct) {\r
+ $returnData[] = trim($value);\r
+ }\r
+ }\r
+ \r
+ return $returnData;\r
+ enchant_broker_free_dict($d);\r
+ } else {\r
+\r
+ }\r
+ enchant_broker_free($r);\r
+ }\r
+\r
+ /**\r
+ * Returns suggestions for a specific word.\r
+ *\r
+ * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1\r
+ * @param String $word Specific word to get suggestions for.\r
+ * @return Array of suggestions for the specified word.\r
+ */\r
+ function &getSuggestions($lang, $word) {\r
+ $r = enchant_broker_init();\r
+ $suggs = array();\r
+\r
+ if (enchant_broker_dict_exists($r,$lang)) {\r
+ $d = enchant_broker_request_dict($r, $lang);\r
+ $suggs = enchant_dict_suggest($d, $word);\r
+\r
+ enchant_broker_free_dict($d);\r
+ } else {\r
+\r
+ }\r
+ enchant_broker_free($r);\r
+\r
+ return $suggs;\r
+ }\r
+}\r
+\r
+?>\r
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class GoogleSpell extends SpellChecker {\r
+ /**\r
+ * Spellchecks an array of words.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {Array} $words Array of words to spellcheck.\r
+ * @return {Array} Array of misspelled words.\r
+ */\r
+ function &checkWords($lang, $words) {\r
+ $wordstr = implode(' ', $words);\r
+ $matches = $this->_getMatches($lang, $wordstr);\r
+ $words = array();\r
+\r
+ for ($i=0; $i<count($matches); $i++)\r
+ $words[] = $this->_unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8"));\r
+\r
+ return $words;\r
+ }\r
+\r
+ /**\r
+ * Returns suggestions of for a specific word.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {String} $word Specific word to get suggestions for.\r
+ * @return {Array} Array of suggestions for the specified word.\r
+ */\r
+ function &getSuggestions($lang, $word) {\r
+ $sug = array();\r
+ $osug = array();\r
+ $matches = $this->_getMatches($lang, $word);\r
+\r
+ if (count($matches) > 0)\r
+ $sug = explode("\t", utf8_encode($this->_unhtmlentities($matches[0][4])));\r
+\r
+ // Remove empty\r
+ foreach ($sug as $item) {\r
+ if ($item)\r
+ $osug[] = $item;\r
+ }\r
+\r
+ return $osug;\r
+ }\r
+\r
+ function &_getMatches($lang, $str) {\r
+ $server = "www.google.com";\r
+ $port = 443;\r
+ $path = "/tbproxy/spell?lang=" . $lang . "&hl=en";\r
+ $host = "www.google.com";\r
+ $url = "https://" . $server;\r
+\r
+ // Setup XML request\r
+ $xml = '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' . $str . '</text></spellrequest>';\r
+\r
+ $header = "POST ".$path." HTTP/1.0 \r\n";\r
+ $header .= "MIME-Version: 1.0 \r\n";\r
+ $header .= "Content-type: application/PTI26 \r\n";\r
+ $header .= "Content-length: ".strlen($xml)." \r\n";\r
+ $header .= "Content-transfer-encoding: text \r\n";\r
+ $header .= "Request-number: 1 \r\n";\r
+ $header .= "Document-type: Request \r\n";\r
+ $header .= "Interface-Version: Test 1.4 \r\n";\r
+ $header .= "Connection: close \r\n\r\n";\r
+ $header .= $xml;\r
+\r
+ // Use curl if it exists\r
+ if (function_exists('curl_init')) {\r
+ // Use curl\r
+ $ch = curl_init();\r
+ curl_setopt($ch, CURLOPT_URL,$url);\r
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\r
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);\r
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);\r
+ $xml = curl_exec($ch);\r
+ curl_close($ch);\r
+ } else {\r
+ // Use raw sockets\r
+ $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30);\r
+ if ($fp) {\r
+ // Send request\r
+ fwrite($fp, $header);\r
+\r
+ // Read response\r
+ $xml = "";\r
+ while (!feof($fp))\r
+ $xml .= fgets($fp, 128);\r
+\r
+ fclose($fp);\r
+ } else\r
+ echo "Could not open SSL connection to google.";\r
+ }\r
+\r
+ // Grab and parse content\r
+ $matches = array();\r
+ preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER);\r
+\r
+ return $matches;\r
+ }\r
+\r
+ function _unhtmlentities($string) {\r
+ $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);\r
+ $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);\r
+\r
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);\r
+ $trans_tbl = array_flip($trans_tbl);\r
+\r
+ return strtr($string, $trans_tbl);\r
+ }\r
+}\r
+\r
+// Patch in multibyte support\r
+if (!function_exists('mb_substr')) {\r
+ function mb_substr($str, $start, $len = '', $encoding="UTF-8"){\r
+ $limit = strlen($str);\r
+\r
+ for ($s = 0; $start > 0;--$start) {// found the real start\r
+ if ($s >= $limit)\r
+ break;\r
+\r
+ if ($str[$s] <= "\x7F")\r
+ ++$s;\r
+ else {\r
+ ++$s; // skip length\r
+\r
+ while ($str[$s] >= "\x80" && $str[$s] <= "\xBF")\r
+ ++$s;\r
+ }\r
+ }\r
+\r
+ if ($len == '')\r
+ return substr($str, $s);\r
+ else\r
+ for ($e = $s; $len > 0; --$len) {//found the real end\r
+ if ($e >= $limit)\r
+ break;\r
+\r
+ if ($str[$e] <= "\x7F")\r
+ ++$e;\r
+ else {\r
+ ++$e;//skip length\r
+\r
+ while ($str[$e] >= "\x80" && $str[$e] <= "\xBF" && $e < $limit)\r
+ ++$e;\r
+ }\r
+ }\r
+\r
+ return substr($str, $s, $e - $s);\r
+ }\r
+}\r
+\r
+?>\r
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class PSpell extends SpellChecker {\r
+ /**\r
+ * Spellchecks an array of words.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {Array} $words Array of words to spellcheck.\r
+ * @return {Array} Array of misspelled words.\r
+ */\r
+ function &checkWords($lang, $words) {\r
+ $plink = $this->_getPLink($lang);\r
+\r
+ $outWords = array();\r
+ foreach ($words as $word) {\r
+ if (!pspell_check($plink, trim($word)))\r
+ $outWords[] = utf8_encode($word);\r
+ }\r
+\r
+ return $outWords;\r
+ }\r
+\r
+ /**\r
+ * Returns suggestions of for a specific word.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {String} $word Specific word to get suggestions for.\r
+ * @return {Array} Array of suggestions for the specified word.\r
+ */\r
+ function &getSuggestions($lang, $word) {\r
+ $words = pspell_suggest($this->_getPLink($lang), $word);\r
+\r
+ for ($i=0; $i<count($words); $i++)\r
+ $words[$i] = utf8_encode($words[$i]);\r
+\r
+ return $words;\r
+ }\r
+\r
+ /**\r
+ * Opens a link for pspell.\r
+ */\r
+ function &_getPLink($lang) {\r
+ // Check for native PSpell support\r
+ if (!function_exists("pspell_new"))\r
+ $this->throwError("PSpell support not found in PHP installation.");\r
+\r
+ // Setup PSpell link\r
+ $plink = pspell_new(\r
+ $lang,\r
+ $this->_config['PSpell.spelling'],\r
+ $this->_config['PSpell.jargon'],\r
+ $this->_config['PSpell.encoding'],\r
+ $this->_config['PSpell.mode']\r
+ );\r
+\r
+ // Setup PSpell link\r
+/* if (!$plink) {\r
+ $pspellConfig = pspell_config_create(\r
+ $lang,\r
+ $this->_config['PSpell.spelling'],\r
+ $this->_config['PSpell.jargon'],\r
+ $this->_config['PSpell.encoding']\r
+ );\r
+\r
+ $plink = pspell_new_config($pspell_config);\r
+ }*/\r
+\r
+ if (!$plink)\r
+ $this->throwError("No PSpell link found opened.");\r
+\r
+ return $plink;\r
+ }\r
+}\r
+\r
+?>\r
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class PSpellShell extends SpellChecker {\r
+ /**\r
+ * Spellchecks an array of words.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {Array} $words Array of words to spellcheck.\r
+ * @return {Array} Array of misspelled words.\r
+ */\r
+ function &checkWords($lang, $words) {\r
+ $cmd = $this->_getCMD($lang);\r
+\r
+ if ($fh = fopen($this->_tmpfile, "w")) {\r
+ fwrite($fh, "!\n");\r
+\r
+ foreach($words as $key => $value)\r
+ fwrite($fh, "^" . $value . "\n");\r
+\r
+ fclose($fh);\r
+ } else\r
+ $this->throwError("PSpell support was not found.");\r
+\r
+ $data = shell_exec($cmd);\r
+ @unlink($this->_tmpfile);\r
+\r
+ $returnData = array();\r
+ $dataArr = preg_split("/[\r\n]/", $data, -1, PREG_SPLIT_NO_EMPTY);\r
+\r
+ foreach ($dataArr as $dstr) {\r
+ $matches = array();\r
+\r
+ // Skip this line.\r
+ if (strpos($dstr, "@") === 0)\r
+ continue;\r
+\r
+ preg_match("/\& ([^ ]+) .*/i", $dstr, $matches);\r
+\r
+ if (!empty($matches[1]))\r
+ $returnData[] = utf8_encode(trim($matches[1]));\r
+ }\r
+\r
+ return $returnData;\r
+ }\r
+\r
+ /**\r
+ * Returns suggestions of for a specific word.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {String} $word Specific word to get suggestions for.\r
+ * @return {Array} Array of suggestions for the specified word.\r
+ */\r
+ function &getSuggestions($lang, $word) {\r
+ $cmd = $this->_getCMD($lang);\r
+\r
+ if (function_exists("mb_convert_encoding"))\r
+ $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8"));\r
+ else\r
+ $word = utf8_encode($word);\r
+\r
+ if ($fh = fopen($this->_tmpfile, "w")) {\r
+ fwrite($fh, "!\n");\r
+ fwrite($fh, "^$word\n");\r
+ fclose($fh);\r
+ } else\r
+ $this->throwError("Error opening tmp file.");\r
+\r
+ $data = shell_exec($cmd);\r
+ @unlink($this->_tmpfile);\r
+\r
+ $returnData = array();\r
+ $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);\r
+\r
+ foreach($dataArr as $dstr) {\r
+ $matches = array();\r
+\r
+ // Skip this line.\r
+ if (strpos($dstr, "@") === 0)\r
+ continue;\r
+\r
+ preg_match("/\&[^:]+:(.*)/i", $dstr, $matches);\r
+\r
+ if (!empty($matches[1])) {\r
+ $words = array_slice(explode(',', $matches[1]), 0, 10);\r
+\r
+ for ($i=0; $i<count($words); $i++)\r
+ $words[$i] = trim($words[$i]);\r
+\r
+ return $words;\r
+ }\r
+ }\r
+\r
+ return array();\r
+ }\r
+\r
+ function _getCMD($lang) {\r
+ $this->_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell");\r
+\r
+ if(preg_match("#win#i", php_uname()))\r
+ return $this->_config['PSpellShell.aspell'] . " -a --lang=". escapeshellarg($lang) . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1";\r
+\r
+ return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". escapeshellarg($lang);\r
+ }\r
+}\r
+\r
+?>\r
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+class SpellChecker {\r
+ /**\r
+ * Constructor.\r
+ *\r
+ * @param $config Configuration name/value array.\r
+ */\r
+ function SpellChecker(&$config) {\r
+ $this->_config = $config;\r
+ }\r
+\r
+ /**\r
+ * Simple loopback function everything that gets in will be send back.\r
+ *\r
+ * @param $args.. Arguments.\r
+ * @return {Array} Array of all input arguments. \r
+ */\r
+ function &loopback(/* args.. */) {\r
+ return func_get_args();\r
+ }\r
+\r
+ /**\r
+ * Spellchecks an array of words.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {Array} $words Array of words to spellcheck.\r
+ * @return {Array} Array of misspelled words.\r
+ */\r
+ function &checkWords($lang, $words) {\r
+ return $words;\r
+ }\r
+\r
+ /**\r
+ * Returns suggestions of for a specific word.\r
+ *\r
+ * @param {String} $lang Language code like sv or en.\r
+ * @param {String} $word Specific word to get suggestions for.\r
+ * @return {Array} Array of suggestions for the specified word.\r
+ */\r
+ function &getSuggestions($lang, $word) {\r
+ return array();\r
+ }\r
+\r
+ /**\r
+ * Throws an error message back to the user. This will stop all execution.\r
+ *\r
+ * @param {String} $str Message to send back to user.\r
+ */\r
+ function throwError($str) {\r
+ die('{"result":null,"id":null,"error":{"errstr":"' . addslashes($str) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');\r
+ }\r
+}\r
+\r
+?>\r
--- /dev/null
+<?php
+/**
+ * $Id$
+ *
+ * @package MCManager.utils
+ * @author Moxiecode
+ * @copyright Copyright © 2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+define('JSON_BOOL', 1);
+define('JSON_INT', 2);
+define('JSON_STR', 3);
+define('JSON_FLOAT', 4);
+define('JSON_NULL', 5);
+define('JSON_START_OBJ', 6);
+define('JSON_END_OBJ', 7);
+define('JSON_START_ARRAY', 8);
+define('JSON_END_ARRAY', 9);
+define('JSON_KEY', 10);
+define('JSON_SKIP', 11);
+
+define('JSON_IN_ARRAY', 30);
+define('JSON_IN_OBJECT', 40);
+define('JSON_IN_BETWEEN', 50);
+
+class Moxiecode_JSONReader {
+ var $_data, $_len, $_pos;
+ var $_value, $_token;
+ var $_location, $_lastLocations;
+ var $_needProp;
+
+ function Moxiecode_JSONReader($data) {
+ $this->_data = $data;
+ $this->_len = strlen($data);
+ $this->_pos = -1;
+ $this->_location = JSON_IN_BETWEEN;
+ $this->_lastLocations = array();
+ $this->_needProp = false;
+ }
+
+ function getToken() {
+ return $this->_token;
+ }
+
+ function getLocation() {
+ return $this->_location;
+ }
+
+ function getTokenName() {
+ switch ($this->_token) {
+ case JSON_BOOL:
+ return 'JSON_BOOL';
+
+ case JSON_INT:
+ return 'JSON_INT';
+
+ case JSON_STR:
+ return 'JSON_STR';
+
+ case JSON_FLOAT:
+ return 'JSON_FLOAT';
+
+ case JSON_NULL:
+ return 'JSON_NULL';
+
+ case JSON_START_OBJ:
+ return 'JSON_START_OBJ';
+
+ case JSON_END_OBJ:
+ return 'JSON_END_OBJ';
+
+ case JSON_START_ARRAY:
+ return 'JSON_START_ARRAY';
+
+ case JSON_END_ARRAY:
+ return 'JSON_END_ARRAY';
+
+ case JSON_KEY:
+ return 'JSON_KEY';
+ }
+
+ return 'UNKNOWN';
+ }
+
+ function getValue() {
+ return $this->_value;
+ }
+
+ function readToken() {
+ $chr = $this->read();
+
+ if ($chr != null) {
+ switch ($chr) {
+ case '[':
+ $this->_lastLocation[] = $this->_location;
+ $this->_location = JSON_IN_ARRAY;
+ $this->_token = JSON_START_ARRAY;
+ $this->_value = null;
+ $this->readAway();
+ return true;
+
+ case ']':
+ $this->_location = array_pop($this->_lastLocation);
+ $this->_token = JSON_END_ARRAY;
+ $this->_value = null;
+ $this->readAway();
+
+ if ($this->_location == JSON_IN_OBJECT)
+ $this->_needProp = true;
+
+ return true;
+
+ case '{':
+ $this->_lastLocation[] = $this->_location;
+ $this->_location = JSON_IN_OBJECT;
+ $this->_needProp = true;
+ $this->_token = JSON_START_OBJ;
+ $this->_value = null;
+ $this->readAway();
+ return true;
+
+ case '}':
+ $this->_location = array_pop($this->_lastLocation);
+ $this->_token = JSON_END_OBJ;
+ $this->_value = null;
+ $this->readAway();
+
+ if ($this->_location == JSON_IN_OBJECT)
+ $this->_needProp = true;
+
+ return true;
+
+ // String
+ case '"':
+ case '\'':
+ return $this->_readString($chr);
+
+ // Null
+ case 'n':
+ return $this->_readNull();
+
+ // Bool
+ case 't':
+ case 'f':
+ return $this->_readBool($chr);
+
+ default:
+ // Is number
+ if (is_numeric($chr) || $chr == '-' || $chr == '.')
+ return $this->_readNumber($chr);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function _readBool($chr) {
+ $this->_token = JSON_BOOL;
+ $this->_value = $chr == 't';
+
+ if ($chr == 't')
+ $this->skip(3); // rue
+ else
+ $this->skip(4); // alse
+
+ $this->readAway();
+
+ if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+ $this->_needProp = true;
+
+ return true;
+ }
+
+ function _readNull() {
+ $this->_token = JSON_NULL;
+ $this->_value = null;
+
+ $this->skip(3); // ull
+ $this->readAway();
+
+ if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+ $this->_needProp = true;
+
+ return true;
+ }
+
+ function _readString($quote) {
+ $output = "";
+ $this->_token = JSON_STR;
+ $endString = false;
+
+ while (($chr = $this->peek()) != -1) {
+ switch ($chr) {
+ case '\\':
+ // Read away slash
+ $this->read();
+
+ // Read escape code
+ $chr = $this->read();
+ switch ($chr) {
+ case 't':
+ $output .= "\t";
+ break;
+
+ case 'b':
+ $output .= "\b";
+ break;
+
+ case 'f':
+ $output .= "\f";
+ break;
+
+ case 'r':
+ $output .= "\r";
+ break;
+
+ case 'n':
+ $output .= "\n";
+ break;
+
+ case 'u':
+ $output .= $this->_int2utf8(hexdec($this->read(4)));
+ break;
+
+ default:
+ $output .= $chr;
+ break;
+ }
+
+ break;
+
+ case '\'':
+ case '"':
+ if ($chr == $quote)
+ $endString = true;
+
+ $chr = $this->read();
+ if ($chr != -1 && $chr != $quote)
+ $output .= $chr;
+
+ break;
+
+ default:
+ $output .= $this->read();
+ }
+
+ // String terminated
+ if ($endString)
+ break;
+ }
+
+ $this->readAway();
+ $this->_value = $output;
+
+ // Needed a property
+ if ($this->_needProp) {
+ $this->_token = JSON_KEY;
+ $this->_needProp = false;
+ return true;
+ }
+
+ if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+ $this->_needProp = true;
+
+ return true;
+ }
+
+ function _int2utf8($int) {
+ $int = intval($int);
+
+ switch ($int) {
+ case 0:
+ return chr(0);
+
+ case ($int & 0x7F):
+ return chr($int);
+
+ case ($int & 0x7FF):
+ return chr(0xC0 | (($int >> 6) & 0x1F)) . chr(0x80 | ($int & 0x3F));
+
+ case ($int & 0xFFFF):
+ return chr(0xE0 | (($int >> 12) & 0x0F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr (0x80 | ($int & 0x3F));
+
+ case ($int & 0x1FFFFF):
+ return chr(0xF0 | ($int >> 18)) . chr(0x80 | (($int >> 12) & 0x3F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr(0x80 | ($int & 0x3F));
+ }
+ }
+
+ function _readNumber($start) {
+ $value = "";
+ $isFloat = false;
+
+ $this->_token = JSON_INT;
+ $value .= $start;
+
+ while (($chr = $this->peek()) != -1) {
+ if (is_numeric($chr) || $chr == '-' || $chr == '.') {
+ if ($chr == '.')
+ $isFloat = true;
+
+ $value .= $this->read();
+ } else
+ break;
+ }
+
+ $this->readAway();
+
+ if ($isFloat) {
+ $this->_token = JSON_FLOAT;
+ $this->_value = floatval($value);
+ } else
+ $this->_value = intval($value);
+
+ if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+ $this->_needProp = true;
+
+ return true;
+ }
+
+ function readAway() {
+ while (($chr = $this->peek()) != null) {
+ if ($chr != ':' && $chr != ',' && $chr != ' ')
+ return;
+
+ $this->read();
+ }
+ }
+
+ function read($len = 1) {
+ if ($this->_pos < $this->_len) {
+ if ($len > 1) {
+ $str = substr($this->_data, $this->_pos + 1, $len);
+ $this->_pos += $len;
+
+ return $str;
+ } else
+ return $this->_data[++$this->_pos];
+ }
+
+ return null;
+ }
+
+ function skip($len) {
+ $this->_pos += $len;
+ }
+
+ function peek() {
+ if ($this->_pos < $this->_len)
+ return $this->_data[$this->_pos + 1];
+
+ return null;
+ }
+}
+
+/**
+ * This class handles JSON stuff.
+ *
+ * @package MCManager.utils
+ */
+class Moxiecode_JSON {
+ function Moxiecode_JSON() {
+ }
+
+ function decode($input) {
+ $reader = new Moxiecode_JSONReader($input);
+
+ return $this->readValue($reader);
+ }
+
+ function readValue(&$reader) {
+ $this->data = array();
+ $this->parents = array();
+ $this->cur =& $this->data;
+ $key = null;
+ $loc = JSON_IN_ARRAY;
+
+ while ($reader->readToken()) {
+ switch ($reader->getToken()) {
+ case JSON_STR:
+ case JSON_INT:
+ case JSON_BOOL:
+ case JSON_FLOAT:
+ case JSON_NULL:
+ switch ($reader->getLocation()) {
+ case JSON_IN_OBJECT:
+ $this->cur[$key] = $reader->getValue();
+ break;
+
+ case JSON_IN_ARRAY:
+ $this->cur[] = $reader->getValue();
+ break;
+
+ default:
+ return $reader->getValue();
+ }
+ break;
+
+ case JSON_KEY:
+ $key = $reader->getValue();
+ break;
+
+ case JSON_START_OBJ:
+ case JSON_START_ARRAY:
+ if ($loc == JSON_IN_OBJECT)
+ $this->addArray($key);
+ else
+ $this->addArray(null);
+
+ $cur =& $obj;
+
+ $loc = $reader->getLocation();
+ break;
+
+ case JSON_END_OBJ:
+ case JSON_END_ARRAY:
+ $loc = $reader->getLocation();
+
+ if (count($this->parents) > 0) {
+ $this->cur =& $this->parents[count($this->parents) - 1];
+ array_pop($this->parents);
+ }
+ break;
+ }
+ }
+
+ return $this->data[0];
+ }
+
+ // This method was needed since PHP is crapy and doesn't have pointers/references
+ function addArray($key) {
+ $this->parents[] =& $this->cur;
+ $ar = array();
+
+ if ($key)
+ $this->cur[$key] =& $ar;
+ else
+ $this->cur[] =& $ar;
+
+ $this->cur =& $ar;
+ }
+
+ function getDelim($index, &$reader) {
+ switch ($reader->getLocation()) {
+ case JSON_IN_ARRAY:
+ case JSON_IN_OBJECT:
+ if ($index > 0)
+ return ",";
+ break;
+ }
+
+ return "";
+ }
+
+ function encode($input) {
+ switch (gettype($input)) {
+ case 'boolean':
+ return $input ? 'true' : 'false';
+
+ case 'integer':
+ return (int) $input;
+
+ case 'float':
+ case 'double':
+ return (float) $input;
+
+ case 'NULL':
+ return 'null';
+
+ case 'string':
+ return $this->encodeString($input);
+
+ case 'array':
+ return $this->_encodeArray($input);
+
+ case 'object':
+ return $this->_encodeArray(get_object_vars($input));
+ }
+
+ return '';
+ }
+
+ function encodeString($input) {
+ // Needs to be escaped
+ if (preg_match('/[^a-zA-Z0-9]/', $input)) {
+ $output = '';
+
+ for ($i=0; $i<strlen($input); $i++) {
+ switch ($input[$i]) {
+ case "\b":
+ $output .= "\\b";
+ break;
+
+ case "\t":
+ $output .= "\\t";
+ break;
+
+ case "\f":
+ $output .= "\\f";
+ break;
+
+ case "\r":
+ $output .= "\\r";
+ break;
+
+ case "\n":
+ $output .= "\\n";
+ break;
+
+ case '\\':
+ $output .= "\\\\";
+ break;
+
+ case '\'':
+ $output .= "\\'";
+ break;
+
+ case '"':
+ $output .= '\"';
+ break;
+
+ default:
+ $byte = ord($input[$i]);
+
+ if (($byte & 0xE0) == 0xC0) {
+ $char = pack('C*', $byte, ord($input[$i + 1]));
+ $i += 1;
+ $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+ } if (($byte & 0xF0) == 0xE0) {
+ $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]));
+ $i += 2;
+ $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+ } if (($byte & 0xF8) == 0xF0) {
+ $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3])));
+ $i += 3;
+ $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+ } if (($byte & 0xFC) == 0xF8) {
+ $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4])));
+ $i += 4;
+ $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+ } if (($byte & 0xFE) == 0xFC) {
+ $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5])));
+ $i += 5;
+ $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+ } else if ($byte < 128)
+ $output .= $input[$i];
+ }
+ }
+
+ return '"' . $output . '"';
+ }
+
+ return '"' . $input . '"';
+ }
+
+ function _utf82utf16($utf8) {
+ if (function_exists('mb_convert_encoding'))
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
+
+ switch (strlen($utf8)) {
+ case 1:
+ return $utf8;
+
+ case 2:
+ return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1])));
+
+ case 3:
+ return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2])));
+ }
+
+ return '';
+ }
+
+ function _encodeArray($input) {
+ $output = '';
+ $isIndexed = true;
+
+ $keys = array_keys($input);
+ for ($i=0; $i<count($keys); $i++) {
+ if (!is_int($keys[$i])) {
+ $output .= $this->encodeString($keys[$i]) . ':' . $this->encode($input[$keys[$i]]);
+ $isIndexed = false;
+ } else
+ $output .= $this->encode($input[$keys[$i]]);
+
+ if ($i != count($keys) - 1)
+ $output .= ',';
+ }
+
+ return $isIndexed ? '[' . $output . ']' : '{' . $output . '}';
+ }
+}
+
+?>
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * @package MCFileManager.filesystems\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+// File type contstants\r
+define('MC_LOGGER_DEBUG', 0);\r
+define('MC_LOGGER_INFO', 10);\r
+define('MC_LOGGER_WARN', 20);\r
+define('MC_LOGGER_ERROR', 30);\r
+define('MC_LOGGER_FATAL', 40);\r
+\r
+/**\r
+ * Logging utility class. This class handles basic logging with levels, log rotation and custom log formats. It's\r
+ * designed to be compact but still powerful and flexible.\r
+ */\r
+class Moxiecode_Logger {\r
+ // Private fields\r
+ var $_path;\r
+ var $_filename;\r
+ var $_maxSize;\r
+ var $_maxFiles;\r
+ var $_maxSizeBytes;\r
+ var $_level;\r
+ var $_format;\r
+\r
+ /**\r
+ * Constructs a new logger instance.\r
+ */\r
+ function Moxiecode_Logger() {\r
+ $this->_path = "";\r
+ $this->_filename = "{level}.log";\r
+ $this->setMaxSize("100k");\r
+ $this->_maxFiles = 10;\r
+ $this->_level = MC_LOGGER_DEBUG;\r
+ $this->_format = "[{time}] [{level}] {message}";\r
+ }\r
+\r
+ /**\r
+ * Sets the current log level, use the MC_LOGGER constants.\r
+ *\r
+ * @param int $level Log level instance for example MC_LOGGER_DEBUG.\r
+ */\r
+ function setLevel($level) {\r
+ if (is_string($level)) {\r
+ switch (strtolower($level)) {\r
+ case "debug":\r
+ $level = MC_LOGGER_DEBUG;\r
+ break;\r
+\r
+ case "info":\r
+ $level = MC_LOGGER_INFO;\r
+ break;\r
+\r
+ case "warn":\r
+ case "warning":\r
+ $level = MC_LOGGER_WARN;\r
+ break;\r
+\r
+ case "error":\r
+ $level = MC_LOGGER_ERROR;\r
+ break;\r
+\r
+ case "fatal":\r
+ $level = MC_LOGGER_FATAL;\r
+ break;\r
+\r
+ default:\r
+ $level = MC_LOGGER_FATAL;\r
+ }\r
+ }\r
+\r
+ $this->_level = $level;\r
+ }\r
+\r
+ /**\r
+ * Returns the current log level for example MC_LOGGER_DEBUG.\r
+ *\r
+ * @return int Current log level for example MC_LOGGER_DEBUG.\r
+ */\r
+ function getLevel() {\r
+ return $this->_level;\r
+ }\r
+\r
+ function setPath($path) {\r
+ $this->_path = $path;\r
+ }\r
+\r
+ function getPath() {\r
+ return $this->_path;\r
+ }\r
+\r
+ function setFileName($file_name) {\r
+ $this->_filename = $file_name;\r
+ }\r
+\r
+ function getFileName() {\r
+ return $this->_filename;\r
+ }\r
+\r
+ function setFormat($format) {\r
+ $this->_format = $format;\r
+ }\r
+\r
+ function getFormat() {\r
+ return $this->_format;\r
+ }\r
+\r
+ function setMaxSize($size) {\r
+ // Fix log max size\r
+ $logMaxSizeBytes = intval(preg_replace("/[^0-9]/", "", $size));\r
+\r
+ // Is KB\r
+ if (strpos((strtolower($size)), "k") > 0)\r
+ $logMaxSizeBytes *= 1024;\r
+\r
+ // Is MB\r
+ if (strpos((strtolower($size)), "m") > 0)\r
+ $logMaxSizeBytes *= (1024 * 1024);\r
+\r
+ $this->_maxSizeBytes = $logMaxSizeBytes;\r
+ $this->_maxSize = $size;\r
+ }\r
+\r
+ function getMaxSize() {\r
+ return $this->_maxSize;\r
+ }\r
+\r
+ function setMaxFiles($max_files) {\r
+ $this->_maxFiles = $max_files;\r
+ }\r
+\r
+ function getMaxFiles() {\r
+ return $this->_maxFiles;\r
+ }\r
+\r
+ function debug($msg) {\r
+ $args = func_get_args();\r
+ $this->_logMsg(MC_LOGGER_DEBUG, implode(', ', $args));\r
+ }\r
+\r
+ function info($msg) {\r
+ $args = func_get_args();\r
+ $this->_logMsg(MC_LOGGER_INFO, implode(', ', $args));\r
+ }\r
+\r
+ function warn($msg) {\r
+ $args = func_get_args();\r
+ $this->_logMsg(MC_LOGGER_WARN, implode(', ', $args));\r
+ }\r
+\r
+ function error($msg) {\r
+ $args = func_get_args();\r
+ $this->_logMsg(MC_LOGGER_ERROR, implode(', ', $args));\r
+ }\r
+\r
+ function fatal($msg) {\r
+ $args = func_get_args();\r
+ $this->_logMsg(MC_LOGGER_FATAL, implode(', ', $args));\r
+ }\r
+\r
+ function isDebugEnabled() {\r
+ return $this->_level >= MC_LOGGER_DEBUG;\r
+ }\r
+\r
+ function isInfoEnabled() {\r
+ return $this->_level >= MC_LOGGER_INFO;\r
+ }\r
+\r
+ function isWarnEnabled() {\r
+ return $this->_level >= MC_LOGGER_WARN;\r
+ }\r
+\r
+ function isErrorEnabled() {\r
+ return $this->_level >= MC_LOGGER_ERROR;\r
+ }\r
+\r
+ function isFatalEnabled() {\r
+ return $this->_level >= MC_LOGGER_FATAL;\r
+ }\r
+\r
+ function _logMsg($level, $message) {\r
+ $roll = false;\r
+\r
+ if ($level < $this->_level)\r
+ return;\r
+\r
+ $logFile = $this->toOSPath($this->_path . "/" . $this->_filename);\r
+\r
+ switch ($level) {\r
+ case MC_LOGGER_DEBUG:\r
+ $levelName = "DEBUG";\r
+ break;\r
+\r
+ case MC_LOGGER_INFO:\r
+ $levelName = "INFO";\r
+ break;\r
+\r
+ case MC_LOGGER_WARN:\r
+ $levelName = "WARN";\r
+ break;\r
+\r
+ case MC_LOGGER_ERROR:\r
+ $levelName = "ERROR";\r
+ break;\r
+\r
+ case MC_LOGGER_FATAL:\r
+ $levelName = "FATAL";\r
+ break;\r
+ }\r
+\r
+ $logFile = str_replace('{level}', strtolower($levelName), $logFile);\r
+\r
+ $text = $this->_format;\r
+ $text = str_replace('{time}', date("Y-m-d H:i:s"), $text);\r
+ $text = str_replace('{level}', strtolower($levelName), $text);\r
+ $text = str_replace('{message}', $message, $text);\r
+ $message = $text . "\r\n";\r
+\r
+ // Check filesize\r
+ if (file_exists($logFile)) {\r
+ $size = @filesize($logFile);\r
+\r
+ if ($size + strlen($message) > $this->_maxSizeBytes)\r
+ $roll = true;\r
+ }\r
+\r
+ // Roll if the size is right\r
+ if ($roll) {\r
+ for ($i=$this->_maxFiles-1; $i>=1; $i--) {\r
+ $rfile = $this->toOSPath($logFile . "." . $i);\r
+ $nfile = $this->toOSPath($logFile . "." . ($i+1));\r
+\r
+ if (@file_exists($rfile))\r
+ @rename($rfile, $nfile);\r
+ }\r
+\r
+ @rename($logFile, $this->toOSPath($logFile . ".1"));\r
+\r
+ // Delete last logfile\r
+ $delfile = $this->toOSPath($logFile . "." . ($this->_maxFiles + 1));\r
+ if (@file_exists($delfile))\r
+ @unlink($delfile);\r
+ }\r
+\r
+ // Append log line\r
+ if (($fp = @fopen($logFile, "a")) != null) {\r
+ @fputs($fp, $message);\r
+ @fflush($fp);\r
+ @fclose($fp);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Converts a Unix path to OS specific path.\r
+ *\r
+ * @param String $path Unix path to convert.\r
+ */\r
+ function toOSPath($path) {\r
+ return str_replace("/", DIRECTORY_SEPARATOR, $path);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+ // General settings\r
+ $config['general.engine'] = 'GoogleSpell';\r
+ //$config['general.engine'] = 'PSpell';\r
+ //$config['general.engine'] = 'PSpellShell';\r
+ //$config['general.remote_rpc_url'] = 'http://some.other.site/some/url/rpc.php';\r
+\r
+ // PSpell settings\r
+ $config['PSpell.mode'] = PSPELL_FAST;\r
+ $config['PSpell.spelling'] = "";\r
+ $config['PSpell.jargon'] = "";\r
+ $config['PSpell.encoding'] = "";\r
+\r
+ // PSpellShell settings\r
+ $config['PSpellShell.mode'] = PSPELL_FAST;\r
+ $config['PSpellShell.aspell'] = '/usr/bin/aspell';\r
+ $config['PSpellShell.tmp'] = '/tmp';\r
+\r
+ // Windows PSpellShell settings\r
+ //$config['PSpellShell.aspell'] = '"c:\Program Files\Aspell\bin\aspell.exe"';\r
+ //$config['PSpellShell.tmp'] = 'c:/temp';\r
+?>\r
--- /dev/null
+<?php
+/**
+ * general.php
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+@error_reporting(E_ALL ^ E_NOTICE);
+$config = array();
+
+require_once(dirname(__FILE__) . "/../classes/utils/Logger.php");
+require_once(dirname(__FILE__) . "/../classes/utils/JSON.php");
+require_once(dirname(__FILE__) . "/../config.php");
+require_once(dirname(__FILE__) . "/../classes/SpellChecker.php");
+
+if (isset($config['general.engine']))
+ require_once(dirname(__FILE__) . "/../classes/" . $config["general.engine"] . ".php");
+
+/**
+ * Returns an request value by name without magic quoting.
+ *
+ * @param String $name Name of parameter to get.
+ * @param String $default_value Default value to return if value not found.
+ * @return String request value by name without magic quoting or default value.
+ */
+function getRequestParam($name, $default_value = false, $sanitize = false) {
+ if (!isset($_REQUEST[$name]))
+ return $default_value;
+
+ if (is_array($_REQUEST[$name])) {
+ $newarray = array();
+
+ foreach ($_REQUEST[$name] as $name => $value)
+ $newarray[formatParam($name, $sanitize)] = formatParam($value, $sanitize);
+
+ return $newarray;
+ }
+
+ return formatParam($_REQUEST[$name], $sanitize);
+}
+
+function &getLogger() {
+ global $mcLogger, $man;
+
+ if (isset($man))
+ $mcLogger = $man->getLogger();
+
+ if (!$mcLogger) {
+ $mcLogger = new Moxiecode_Logger();
+
+ // Set logger options
+ $mcLogger->setPath(dirname(__FILE__) . "/../logs");
+ $mcLogger->setMaxSize("100kb");
+ $mcLogger->setMaxFiles("10");
+ $mcLogger->setFormat("{time} - {message}");
+ }
+
+ return $mcLogger;
+}
+
+function debug($msg) {
+ $args = func_get_args();
+
+ $log = getLogger();
+ $log->debug(implode(', ', $args));
+}
+
+function info($msg) {
+ $args = func_get_args();
+
+ $log = getLogger();
+ $log->info(implode(', ', $args));
+}
+
+function error($msg) {
+ $args = func_get_args();
+
+ $log = getLogger();
+ $log->error(implode(', ', $args));
+}
+
+function warn($msg) {
+ $args = func_get_args();
+
+ $log = getLogger();
+ $log->warn(implode(', ', $args));
+}
+
+function fatal($msg) {
+ $args = func_get_args();
+
+ $log = getLogger();
+ $log->fatal(implode(', ', $args));
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+/**\r
+ * $Id$\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+require_once("./includes/general.php");\r
+\r
+// Set RPC response headers\r
+header('Content-Type: text/plain');\r
+header('Content-Encoding: UTF-8');\r
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");\r
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");\r
+header("Cache-Control: no-store, no-cache, must-revalidate");\r
+header("Cache-Control: post-check=0, pre-check=0", false);\r
+header("Pragma: no-cache");\r
+\r
+$raw = "";\r
+\r
+// Try param\r
+if (isset($_POST["json_data"]))\r
+ $raw = getRequestParam("json_data");\r
+\r
+// Try globals array\r
+if (!$raw && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"]))\r
+ $raw = $_GLOBALS["HTTP_RAW_POST_DATA"];\r
+\r
+// Try globals variable\r
+if (!$raw && isset($HTTP_RAW_POST_DATA))\r
+ $raw = $HTTP_RAW_POST_DATA;\r
+\r
+// Try stream\r
+if (!$raw) {\r
+ if (!function_exists('file_get_contents')) {\r
+ $fp = fopen("php://input", "r");\r
+ if ($fp) {\r
+ $raw = "";\r
+\r
+ while (!feof($fp))\r
+ $raw = fread($fp, 1024);\r
+\r
+ fclose($fp);\r
+ }\r
+ } else\r
+ $raw = "" . file_get_contents("php://input");\r
+}\r
+\r
+// No input data\r
+if (!$raw)\r
+ die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');\r
+\r
+// Passthrough request to remote server\r
+if (isset($config['general.remote_rpc_url'])) {\r
+ $url = parse_url($config['general.remote_rpc_url']);\r
+\r
+ // Setup request\r
+ $req = "POST " . $url["path"] . " HTTP/1.0\r\n";\r
+ $req .= "Connection: close\r\n";\r
+ $req .= "Host: " . $url['host'] . "\r\n";\r
+ $req .= "Content-Length: " . strlen($raw) . "\r\n";\r
+ $req .= "\r\n" . $raw;\r
+\r
+ if (!isset($url['port']) || !$url['port'])\r
+ $url['port'] = 80;\r
+\r
+ $errno = $errstr = "";\r
+\r
+ $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);\r
+ if ($socket) {\r
+ // Send request headers\r
+ fputs($socket, $req);\r
+\r
+ // Read response headers and data\r
+ $resp = "";\r
+ while (!feof($socket))\r
+ $resp .= fgets($socket, 4096);\r
+\r
+ fclose($socket);\r
+\r
+ // Split response header/data\r
+ $resp = explode("\r\n\r\n", $resp);\r
+ echo $resp[1]; // Output body\r
+ }\r
+\r
+ die();\r
+}\r
+\r
+// Get JSON data\r
+$json = new Moxiecode_JSON();\r
+$input = $json->decode($raw);\r
+\r
+// Execute RPC\r
+if (isset($config['general.engine'])) {\r
+ $spellchecker = new $config['general.engine']($config);\r
+ $result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);\r
+} else\r
+ die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');\r
+\r
+// Request and response id should always be the same\r
+$output = array(\r
+ "id" => $input->id,\r
+ "result" => $result,\r
+ "error" => null\r
+);\r
+\r
+// Return JSON encoded string\r
+echo $json->encode($output);\r
+\r
+?>
\ No newline at end of file