Next revision | Previous revision | ||
private:koding:hostcms:modules:jadro:ispravlenie_problemy_s_transliteraciej [17.08.15 в 14:43] scherbakov_kad.systems создано |
private:koding:hostcms:modules:jadro:ispravlenie_problemy_s_transliteraciej [27.06.17 в 14:35] (current) maximzasorin_gmail.com ↷ Страница перемещена из private:koding:hostcms:jadro:ispravlenie_problemy_s_transliteraciej в private:koding:hostcms:modules:jadro:ispravlenie_problemy_s_transliteraciej |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Исправление проблемы с транслитерацией ====== | ||
+ | |||
В связи с прекращением поддержки протокола Яндекс.Translate 1.0 режим перевода/транслитерации в версиях HostCMS до 6.5.1 прекратил работу.\\ | В связи с прекращением поддержки протокола Яндекс.Translate 1.0 режим перевода/транслитерации в версиях HostCMS до 6.5.1 прекратил работу.\\ | ||
Для поддержкит протокола Яндекс.Translate 1.5 необходимо: | Для поддержкит протокола Яндекс.Translate 1.5 необходимо: | ||
- | - В константу YANDEX_TRANSLATE_KEY внести ключ, получить который можно на странице https://tech.yandex.ru/key/form.xml?service=trnsl | + | - В константу **YANDEX_TRANSLATE_KEY** внести ключ, получить который можно на странице https://tech.yandex.ru/key/form.xml?service=trnsl |
- | - Заменить метод core_str::translate | + | - Заменить метод **core_str::translate** \\ <code php> |
- | <code php> | + | |
/** | /** | ||
* Translation from russian to english | * Translation from russian to english | ||
Line 45: | Line 46: | ||
} | } | ||
</code> | </code> | ||
+ | - Заменить метод **core_http::execute** <code php>/** | ||
+ | * Executes the business logic. | ||
+ | */ | ||
+ | public function execute() | ||
+ | { | ||
+ | $aUrl = @parse_url(trim($this->_url)); | ||
+ | |||
+ | $scheme = strtolower(Core_Array::get($aUrl, 'scheme', 'http')); | ||
+ | |||
+ | // Change https port | ||
+ | $scheme == 'https' && $this->_port == 80 | ||
+ | && $this->_port = 443; | ||
+ | |||
+ | $path = isset($aUrl['host']) && isset($aUrl['path']) | ||
+ | ? $aUrl['path'] | ||
+ | : '/'; | ||
+ | |||
+ | $host = Core_Array::get($aUrl, 'host', ''); | ||
+ | |||
+ | $query = isset($aUrl['query']) ? | ||
+ | '?' . $aUrl['query'] | ||
+ | : ''; | ||
+ | |||
+ | $this->_referer = is_null($this->_referer) | ||
+ | ? "{$scheme}://{$host}" | ||
+ | : $this->_referer; | ||
+ | |||
+ | return $this->_execute($host, $path, $query); | ||
+ | }</code> | ||
+ | - Заменить класс (на некоторых версиях не нужно) **core_http_socket** <code php> | ||
+ | <?php | ||
+ | |||
+ | defined('HOSTCMS') || exit('HostCMS: access denied.'); | ||
+ | |||
+ | /** | ||
+ | * Http socket driver | ||
+ | * | ||
+ | * @package HostCMS 6\Core\Http | ||
+ | * @version 6.x | ||
+ | * @author Hostmake LLC | ||
+ | * @copyright © 2005-2015 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru | ||
+ | */ | ||
+ | class Core_Http_Socket extends Core_Http | ||
+ | { | ||
+ | /** | ||
+ | * Send request | ||
+ | * @param string $host host | ||
+ | * @param string $path path | ||
+ | * @param string $query query | ||
+ | * @return self | ||
+ | */ | ||
+ | protected function _execute($host, $path, $query) | ||
+ | { | ||
+ | // для 443 порта в fsockopen перед хостом нужно добавлять ssl:// | ||
+ | $socketHost = $this->_port == 443 | ||
+ | ? 'ssl://' . $host | ||
+ | : $host; | ||
+ | |||
+ | if (!function_exists('fsockopen')) | ||
+ | { | ||
+ | throw new Core_Exception("Fsockopen has been disabled, please contact your system administrator!"); | ||
+ | } | ||
+ | |||
+ | $fp = @fsockopen($socketHost, $this->_port, $errno, $errstr, $this->_timeout); | ||
+ | |||
+ | if (!$fp) | ||
+ | { | ||
+ | throw new Core_Exception("Fsockopen failed '%errstr' (%errno)", | ||
+ | array('%errstr' => $errstr, '%errno' => $errno), $errno | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | $out = "{$this->_method} {$path}{$query} HTTP/1.0\r\n"; | ||
+ | $out .= "Content-Type: {$this->_contentType}\r\n"; | ||
+ | $out .= "Referer: {$this->_referer}\r\n"; | ||
+ | $out .= "User-Agent: {$this->_userAgent}\r\n"; | ||
+ | |||
+ | // Additional headers | ||
+ | foreach ($this->_additionalHeaders as $name => $value) | ||
+ | { | ||
+ | $out .= "{$name}: {$value}\r\n"; | ||
+ | } | ||
+ | |||
+ | $out .= "Host: {$host}\r\n"; | ||
+ | |||
+ | $bIsPost = $this->_method != 'GET' && ($this->_rawData || count($this->_data) > 0); | ||
+ | |||
+ | if ($bIsPost) | ||
+ | { | ||
+ | if ($this->_rawData) | ||
+ | { | ||
+ | $sPost = $this->_rawData; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | $aData = array(); | ||
+ | foreach ($this->_data as $key => $value) | ||
+ | { | ||
+ | $aData[] = urlencode($key) . '=' . urlencode($value); | ||
+ | } | ||
+ | |||
+ | $sPost = implode('&', $aData); | ||
+ | } | ||
+ | |||
+ | $out .= "Content-length: " . strlen($sPost) . "\r\n"; | ||
+ | } | ||
+ | |||
+ | $out .= "Connection: Close\r\n\r\n"; | ||
+ | |||
+ | if ($bIsPost) | ||
+ | { | ||
+ | $out .= $sPost . "\r\n\r\n"; | ||
+ | } | ||
+ | |||
+ | fwrite($fp, $out); | ||
+ | |||
+ | if (function_exists('stream_set_timeout')) | ||
+ | { | ||
+ | stream_set_timeout($fp, $this->_timeout); | ||
+ | } | ||
+ | |||
+ | $datastr = ''; | ||
+ | |||
+ | while (!feof($fp)) | ||
+ | { | ||
+ | $datastr .= fgets($fp, 65536); | ||
+ | } | ||
+ | |||
+ | fclose($fp); | ||
+ | |||
+ | $aTmp = explode("\r\n\r\n", $datastr, 2); | ||
+ | unset ($datastr); | ||
+ | |||
+ | $this->_headers = Core_Array::get($aTmp, 0); | ||
+ | $this->_body = Core_Array::get($aTmp, 1); | ||
+ | |||
+ | return $this; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | |||
+ |