From 8f9f70fba2806725b3332c9a5d5871434ba7585d Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 18 Sep 2011 13:00:28 +0200 Subject: [PATCH] MDL-29081 add proxy support to googlespell --- .../spellchecker/classes/GoogleSpell.php | 20 +++++++++++ .../3.4.5/plugins/spellchecker/config.php | 35 +++++++++++-------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/classes/GoogleSpell.php b/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/classes/GoogleSpell.php index e0aa5f1eb81..4682e1a9763 100644 --- a/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/classes/GoogleSpell.php +++ b/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/classes/GoogleSpell.php @@ -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 { diff --git a/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/config.php b/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/config.php index be64e8d0e6e..303dd507398 100644 --- a/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/config.php +++ b/lib/editor/tinymce/tiny_mce/3.4.5/plugins/spellchecker/config.php @@ -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'; +} ?> -- 2.43.0