MDL-29081 add proxy support to googlespell
authorPetr Skoda <commits@skodak.org>
Sun, 18 Sep 2011 11:00:28 +0000 (13:00 +0200)
committerPetr Skoda <commits@skodak.org>
Sun, 18 Sep 2011 11:00:28 +0000 (13:00 +0200)
lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/classes/GoogleSpell.php
lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/config.php

index e0aa5f1..4682e1a 100644 (file)
@@ -79,6 +79,26 @@ class GoogleSpell extends SpellChecker {
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
                        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+                       if (!empty($this->_config['GoogleSpell.proxyhost'])) {
+                               if (!empty($this->_config['GoogleSpell.proxytype']) and ($this->_config['GoogleSpell.proxytype'] === 'SOCKS5')) {
+                    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+                               } else {
+                    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTML);
+                    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, FALSE);
+                }
+                               if (empty($this->_config['GoogleSpell.proxyport'])) {
+                                       curl_setopt($ch, CURLOPT_PROXY, $this->_config['GoogleSpell.proxyhost']);
+                               } else {
+                                       curl_setopt($ch, CURLOPT_PROXY, $this->_config['GoogleSpell.proxyhost'].':'.$this->_config['GoogleSpell.proxyport']);
+                               }
+                               if (!empty($this->_config['GoogleSpell.proxyuser']) and !empty($this->_config['GoogleSpell.proxypassword'])) {
+                                       curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->_config['GoogleSpell.proxyuser'].':'.$this->_config['GoogleSpell.proxypassword']);
+                                       if (defined('CURLOPT_PROXYAUTH')) {
+                                               // any proxy authentication if PHP 5.1
+                                               curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
+                                       }
+                               }
+                       }
                        $xml = curl_exec($ch);
                        curl_close($ch);
                } else {
index be64e8d..303dd50 100644 (file)
@@ -14,20 +14,27 @@ require_once(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__F
        //$config['general.engine'] = 'PSpellShell';
        //$config['general.remote_rpc_url'] = 'http://some.other.site/some/url/rpc.php';
 
-    if ($config['general.engine'] === 'PSpell' or $config['general.engine'] === 'PSpellShell') {
-        // PSpell settings
-        $config['PSpell.mode'] = PSPELL_FAST;
-        $config['PSpell.spelling'] = "";
-        $config['PSpell.jargon'] = "";
-        $config['PSpell.encoding'] = "";
+       // GoogleSpell settings
+       $config['GoogleSpell.proxyhost'] = isset($CFG->proxyhost) ? $CFG->proxyhost : '';
+       $config['GoogleSpell.proxyport'] = isset($CFG->proxyport) ? $CFG->proxyport : '';
+       $config['GoogleSpell.proxytype'] = isset($CFG->proxytype) ? $CFG->proxytype : 'HTML';
+       $config['GoogleSpell.proxyuser'] = isset($CFG->proxyuser) ? $CFG->proxyuser : '';
+       $config['GoogleSpell.proxypassword'] = isset($CFG->proxypassword) ? $CFG->proxypassword : '';
 
-        // PSpellShell settings
-        $config['PSpellShell.mode'] = PSPELL_FAST;
-        $config['PSpellShell.aspell'] = $CFG->aspellpath;
-        $config['PSpellShell.tmp'] = '/tmp';
+if ($config['general.engine'] === 'PSpell' or $config['general.engine'] === 'PSpellShell') { // moodlehack
+       // PSpell settings
+       $config['PSpell.mode'] = PSPELL_FAST;
+       $config['PSpell.spelling'] = "";
+       $config['PSpell.jargon'] = "";
+       $config['PSpell.encoding'] = "";
 
-        // Windows PSpellShell settings
-        //$config['PSpellShell.aspell'] = '"c:\Program Files\Aspell\bin\aspell.exe"';
-        //$config['PSpellShell.tmp'] = 'c:/temp';
-    }
+       // PSpellShell settings
+       $config['PSpellShell.mode'] = PSPELL_FAST;
+       $config['PSpellShell.aspell'] = $CFG->aspellpath;
+       $config['PSpellShell.tmp'] = '/tmp';
+
+       // Windows PSpellShell settings
+       //$config['PSpellShell.aspell'] = '"c:\Program Files\Aspell\bin\aspell.exe"';
+       //$config['PSpellShell.tmp'] = 'c:/temp';
+}
 ?>