alecpl
2008-05-21 2b962c1074c45695da0376f830ec63923743c39e
commit | author | age
dd53e2 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/spell.inc                                          |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
5349b7 8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
dd53e2 9  | Licensed under the GNU GPL                                            |
T 10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Submit request to Google's spell checking engine                    |
13  |                                                                       |
14  | CREDITS:                                                              |
15  |   Script from GoogieSpell by amix.dk                                  |
16  |                                                                       |
17  +-----------------------------------------------------------------------+
18  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
19  +-----------------------------------------------------------------------+
20
21  $Id$
22
23 */
24
25 $REMOTE_REQUEST = TRUE;
26
996066 27 // default settings
T 28 $host = "ssl://www.google.com";
bac9ff 29 $port = 443;
996066 30 $lang = get_input_value('lang', RCUBE_INPUT_GET);
dd53e2 31 $path = "/tbproxy/spell?lang=$lang";
996066 32
T 33 // spell check uri is configured
34 if (!empty($CONFIG['spellcheck_uri']))
35   {
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;
41   }
42
dd53e2 43 $data = file_get_contents('php://input');
T 44 $store = "";
45
996066 46 if ($fp = fsockopen($host, $port, $errno, $errstr, 30))
dd53e2 47   {
T 48   $out = "POST $path HTTP/1.0\r\n";
996066 49   $out .= "Host: $host\r\n";
dd53e2 50   $out .= "Content-Length: " . strlen($data) . "\r\n";
T 51   $out .= "Content-type: application/x-www-form-urlencoded\r\n";
52   $out .= "Connection: Close\r\n\r\n";
53   $out .= $data;
54   fwrite($fp, $out);
bac9ff 55   
dd53e2 56   while (!feof($fp))
T 57     $store .= fgets($fp, 128);
58   fclose($fp);
59   }
60
61 print $store;  
62 exit;
63
5349b7 64 ?>