4 +-----------------------------------------------------------------------+
5 | program/steps/utils/spell_googie.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2007, Roundcube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Submit request to Google's spell checking engine |
15 | Script from GoogieSpell by amix.dk |
17 +-----------------------------------------------------------------------+
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
19 +-----------------------------------------------------------------------+
21 $Id: spell_googie.inc 4626 2011-03-31 12:32:44Z alec $
25 $REMOTE_REQUEST = TRUE;
28 $host = "ssl://www.google.com";
30 $lang = get_input_value('lang', RCUBE_INPUT_GET);
31 $path = "/tbproxy/spell?lang=$lang";
33 // spell check uri is configured
34 if (!empty($CONFIG['spellcheck_uri']))
36 $a_uri = parse_url($CONFIG['spellcheck_uri']);
37 $ssl = ($a_uri['scheme']=='https' || $a_uri['scheme']=='ssl');
38 $port = $a_uri['port'] ? $a_uri['port'] : ($ssl ? 443 : 80);
39 $host = ($ssl ? 'ssl://' : '') . $a_uri['host'];
40 $path = $a_uri['path'] . ($a_uri['query'] ? '?'.$a_uri['query'] : '') . $lang;
43 $data = file_get_contents('php://input');
44 // Google has some problem with spaces, use \n instead
45 $data = str_replace(' ', "\n", $data);
48 if ($fp = fsockopen($host, $port, $errno, $errstr, 30))
50 $out = "POST $path HTTP/1.0\r\n";
51 $out .= "Host: " . str_replace('ssl://', '', $host) . "\r\n";
52 $out .= "Content-Length: " . strlen($data) . "\r\n";
53 $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
54 $out .= "Connection: Close\r\n\r\n";
59 $store .= fgets($fp, 128);
64 $pos = strpos($store, '<?xml');
65 $store = substr($store, $pos);
67 // set response length
68 header("Content-Length: " . strlen($store));
70 // Don't use server's default Content-Type charset (#1486406)
71 header("Content-Type: text/xml; charset=".RCMAIL_CHARSET);