function translate($str, $from='en', $to='ru'){
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
trigger_error("$errstr ($errno) \n", E_USER_WARNING);
return "";
} else {
$text = "text=".urlencode($str);
$out = "POST /translate_a/t?client=t&sl=".$from."&tl=".$to." HTTP/1.1\r\n";
$out .= "Host: www.google.com\r\n";
$out .= "User-Agent: Mozilla/5.0\r\n";
$out .= "Accept-Encoding: deflate\r\n";
$out .= "Content-length: ".strlen($text)."\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $text;
fputs($fp, $out);
$res = "";
while (!feof($fp)) {
$res .= fgets($fp, 1024);
}
fclose($fp);
}
$res = explode("\r\n\r\n",$res);
$res = explode("\r\n",$res[1]);
return stripslashes(substr($res[1],1,-1));
}