function shr32 ($x, $bits)
{
If ($bits & lt;=0) {
return $x;
}
If ($bits & gt; 32)={
return 0;
}
$bin=decbin ($x);
$l=strlen ($bin);
If ($l & gt; 32) {
$bin=substr ($bin, $32, l - 32);
} elseif ($l & lt; 32) {
$bin=str_pad ($bin, 32, '0', STR_PAD_LEFT);
}
Return bindec (str_pad (substr ($bin, 0, - $32 bits), 32, '0', STR_PAD_LEFT));
}
The function charCodeAt ($STR, $index)
{
$char=mb_substr ($STR, $index, 1, "utf-8");
If (mb_check_encoding ($char, 'utf-8))
{
$ret=mb_convert_encoding ($char, 'UTF - 32 be', 'utf-8');
Return hexdec (bin2hex ($ret));
}
The else
{
return null;
}
}
The function mb_str_split ($STR, $length=1)
{
If ($length & lt; 1) return false.
$result=array();
For ($I=0; $I & lt; Mb_strlen ($STR); $I +=${
length)$result []=mb_substr ($STR, $I $length);
}
return $result;
}
The function RL ($a, $b)
{
For ($c=0; $c & lt; Strlen ($b) - 2; ${c +=3)
{$d=$b $c + 2};
$d=$d & gt;='a'? CharCodeAt ($d, 0) - 87: intval ($d);
{$d=$b $c + 1}=='+'? Shr32 ($a, $d) : $a & lt; <$d;
$a=${$c b}=='+'? ($a + $d & amp; 4294967295) : $a ^ $d;
}
Return $a;
}
The function sendHttpRequest ($url, $post, $requestBody, $headers)
{
$ch=curl_init();
Curl_setopt ($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
Curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
Curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
Curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
If ($post) {
Curl_setopt ($ch, CURLOPT_POST, 1);
Curl_setopt ($ch, CURLOPT_POSTFIELDS, $requestBody);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
$response=the curl_exec ($ch);
$curl_errno=curl_errno ($ch);
$curl_error=curl_error ($ch);
Curl_close ($ch);
If ($curl_errno & gt; 0 {
Return "$curl_error";
}
Return $response;
}
The function TKK ()
{
$a=561666268;
$b=1526272306;
Return 406398. '. '. ($a + b);
}
The function TL ($a)
{
$TKK=explodes ('. ', TKK ());
$b=$TKK [0];
For ($d=array (), $e=0, $f=0; $f & lt; Mb_strlen ($a, "utf-8"); {$f + +)
$g=charCodeAt ($a, $f);
If (128 & gt; {$g)
[$$d e + +]=$g;
} else {
If (2048 & gt; {$g)
[$$d e + +]=$g & gt;> 6 | 192;
} else {
If (==55296 ($g & amp; 64512) & amp; & $f + 1 & lt; Mb_strlen ($a, 'utf-8) & amp; & 56320==(charCodeAt ($a, $f + 1) & amp; 64512)) {
$g=65536 + (($g & amp; 1023) & lt; <10) + (charCodeAt ($a, + + $f) & amp; 1023);
[$$d e + +]=$g & gt;> 18 | 240;
[$$d e + +]=$g & gt;> 12 & amp; 63 | 128;
} else {
[$$d e + +]=$g & gt;> 12 | 224;
[$$d e + +]=$g & gt;> 6 & amp; 63 | 128;
}
}
[$$d e + +]=$g & amp; 63 | 128;
}
}
$a=$b;
For ($e=0; $e & lt; Count ($d); ${e + +)
[$$a +=$d e];
$a=RL ($a, '^ + + - a 6');
}
$a=RL ($a, "+ - 3 ^ + b + f");
$a ^=$TKK [1].
If (0 & gt; {$a)
$a=($a & amp; 2147483647) + 2147483648;
}
$a=fmod ($a, pow (10, 6));
Return $a. ". ". ($^ $b);
}
The function translate ($sl, tl, $$q)
{
$tk=TL ($q);
$q=urlencode (stripslashes ($q));
$url="https://translate.google.com/translate_a/t? The client=webapp& Sl=". $sl. "& amp; Tl=". $tl. "& amp; Hl=". $tl. "& amp; Dt=bd& Dt=ex& Dt=ld& Dt=md& Dt=qca& Dt=rw& Dt=rm& Dt=ss& Dt=t& Dt=at& Ie=utf-8 & amp; Oe=utf-8 & amp; Otf=2 & amp; Ssel=0 & amp; Tsel=0 & amp; Kc=1 & amp; Tk=". $tk. "& amp; Q=". $q;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (the device; CPU OS 6 _0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version 6.0/Mobile/10 a5355d Safari/8536.25 ');
Curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
$output=the curl_exec ($ch);
Curl_close ($ch);
Return str_replace (' "', ' ', $output);
}
CodePudding user response:
This translation, and repair function,,,Looks like a translation function, try the baidu translation I write? http://blog.csdn.net/bakw/article/details/49782735
CodePudding user response:
Don't be A language code is modified to B language code busywork,Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, changed its name to bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull