HEX
Server: Apache
System: Linux dotw660 5.10.0-37-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64
User: web350 (1012)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/clients/client125/web350/web/wp-content/plugins/wp-automatic/inc/translator.Google.php
<?php
/**
 * Class:Translator to translate using Google
 * @author sweetheatmn (sweetheatmn@gmail.com)
 * @version 1.1.0 
 * updated to cope with new gtranslate changes @18 september 2016
 */

class GoogleTranslator{
	
	public $ch; //curl handler to use 
	
	/**
	 * Constructor to recieve curl handler
	 * @param curl $ch
	 */
	function __construct(&$ch){
		$this->ch = $ch;
	}
	
	/**
	 * 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){
		
		// Post 
		$curlurl="https://translate.google.com/translate_a/single?client=gtx&sl=$fromLanguage&tl=$toLanguage&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=1&tk=50754.457190";
		$curlpost="q=".urlencode($sourceText);
		curl_setopt($this->ch, CURLOPT_URL, $curlurl);
		curl_setopt($this->ch, CURLOPT_POST, true);
		curl_setopt($this->ch, CURLOPT_POSTFIELDS, $curlpost);
	    curl_setopt($this->ch, CURLOPT_REFERER, "https://translate.google.com/" );

		$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 response result box 
		if( !  stristr($exec, '[[[') ){
			throw new Exception('Got the reply from Google but no Translated content');
		}
		
		// Extract results
		//get sentenses
		preg_match_all('{\["(.*?)",".*?",,,0\]}', $exec,$matches);
		 
		$sentenses_plain = '["'. implode('","', $matches[1]) . '"]';
		 
		$sentenses_json = json_decode($sentenses_plain);
		$translated = implode('', $sentenses_json);
		
		return $translated ;
 		
	}
	
}