PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /home/trave494/flavoredfog.co.uk/wp-content/plugins/wp-automatic/inc/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : /home/trave494/flavoredfog.co.uk/wp-content/plugins/wp-automatic/inc/translator.Yandex.php |
<?php /** * Class:Translator to translate using Yandex * @author Atef (sweetheatmn@gmail.com) * @version 1.0.0 */ class YandexTranslator{ public $ch; //curl handler to use public $key; /** * Constructor to recieve curl handler * @param curl $ch */ function __construct(&$ch,$key){ $this->ch = $ch; $this->key = $key; } /** * Translate text using Google Post request to google translate * @param unknown $sourceText * @param unknown $fromLanguage * @param unknown $toLanguage * @return string translated text */ function translateText($sourceText , $fromLanguage ,$toLanguage){ //translating $x='error'; $curlurl='https://translate.yandex.net/api/v1.5/tr.json/translate?key='.trim($this->key).'&lang='.trim($fromLanguage).'-'.trim($toLanguage); $curlurl = str_replace('auto-','' , $curlurl); $curlpost= "text=" . urlencode($sourceText) ; curl_setopt($this->ch, CURLOPT_URL, $curlurl); curl_setopt($this->ch, CURLOPT_POST, true); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $curlpost); $x='error'; $exec=curl_exec($this->ch); $x=curl_error($this->ch); // Empty response check if(trim($exec) == ''){ throw new Exception('Empty translator reply with possible curl error '.$x); } // Validate JSON {" if( ! stristr($exec, '{"') ){ throw new Exception('No JSON was returned, unexpected reply from Yandex' . $exec); } //json decode $json_reply = json_decode($exec); //validate JSON if( ! isset($json_reply->code)){ throw new Exception('No code was found in JSON , unexpected reply from Yandex' . $exec); } $code = $json_reply->code; if($code != 200){ throw new Exception('Yandex error ' . $json_reply->message); } $translated_array = $json_reply->text; if ( trim($translated_array[0]) == ''){ throw new Exception('Can not extract returned translation' ); } return $translated_array[0] ; } }