lang = $lang; } // Returns array with bad words or false if failed. function checkWords($word_array) { $words = array(); $wordstr = implode(' ', $word_array); $matches = $this->_getMatches($wordstr); for ($i=0; $i_getMatches($word); if (count($matches) > 0) $sug = explode("\t", $matches[0][4]); return $sug; } function _getMatches($word_list) { $xml = ""; // Setup HTTP Client $client = new HttpClient('www.google.com'); $client->setUserAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR'); $client->setHandleRedirects(false); $client->setDebug(false); // Setup XML request $xml .= ''; $xml .= ''; $xml .= '' . htmlentities($word_list) . ''; // Execute HTTP Post to Google if (!$client->post('/tbproxy/spell?lang=' . $this->lang, $xml)) { $this->errorMsg[] = 'An error occurred: ' . $client->getError(); return array(); } // Grab and parse content $xml = $client->getContent(); preg_match_all('/([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); return $matches; } } // Setup classname, should be the same as the name of the spellchecker class $spellCheckerConfig['class'] = "TinyGoogleSpell"; ?>