<?php
@set_time_limit(0);
function _GT($text = '', $from = 'en', $to = 'es', $intermediary = false) {
if ($intermediary) {
$tmp = DameContenido('http://translate.google.com/', 'js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&text='.urlencode(strip_tags($text)).'&file=&sl='.$from.'&tl='.$intermediary);
preg_match("/id=[\"']?result_box[\"']?[^>]+?>(.+?)<div/ims", $tmp, $output);
$text = $output[1];
$from = $intermediary;
}
$final = DameContenido('http://translate.google.com/', 'js=y&prev=_t&hl=en&ie=UTF-8&text='.urlencode(strip_tags($text)).'&sl='.$from.'&tl='.$to);
preg_match("/id=[\"']?result_box[\"']?[^>]*?>(.+?)<div/ims", $final, $output);
return htmlentities(utf8_decode(strip_tags($output[1])));
}
function DameContenido($_URL,$_P=0){
global $_DIR;
$_S = parse_url($_URL);
$_SERVER = $_S['host'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $_URL);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; es-AR; rv:1.9.0.2) Gecko/'.time().' Firefox/3.0.2');
curl_setopt($curl, CURLOPT_REFERER, 'http://'.$_SERVER);
curl_setopt($curl, CURLOPT_COOKIEFILE, $_DIR."cokkie.txt");
curl_setopt($curl, CURLOPT_COOKIEJAR, $_DIR."cokkie.txt");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
if($_P!=""){
curl_setopt($curl, CURLOPT_POSTFIELDS, $_P);
curl_setopt($curl, CURLOPT_POST, 1);
}
$_DTO = curl_exec($curl);
curl_close($curl);
$_DTO = str_replace("\r","",$_DTO);
$_DTO = str_replace("\n","",$_DTO);
$_DTO = str_replace("\n\r","",$_DTO);
$_DTO = str_replace("\r\n","",$_DTO);
$_DTO = str_replace("\t","",$_DTO);
while(eregi(' ',$_DTO)){
$_DTO = str_replace(" "," ",$_DTO);
}
return $_DTO;
}
?>