<?php
/*
*六速博客
*https://www.6su.cc/
*演示地址
*https://www.6su.cc/wyc/
*/
header('Access-Control-Allow-Origin:*');
header('Content-type:text/html;charset=utf-8');
function translate($text,$from,$to){
$url = "http://translate.google.cn/translate_a/single?client=gtx&dt=t&ie=UTF-8&oe=UTF-8&sl=$from&tl=$to&q=". urlencode($text);
set_time_limit(0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS,20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 40);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
if(!empty($result)){
foreach($result[0] as $k){
$v[] = $k[0];
}
return implode(" ", $v);
}
}
//去除无字数限制,为提高效率限字数为1000字
//增加判断如为空,返回相应的文字
if($_POST['info']){
$str = preg_replace('/[\x80-\xff]{1,3}/', ' ', $_POST['info'], -1);
$num = strlen($str);
if($num<1030){
$zh_en=translate($_POST['info'],'zh-CN','EN');
if($zh_en){
$en_zh=translate($zh_en,'EN','zh-CN');
if($en_zh){
$info=$en_zh;
}else{
$info="超过IP限制,请稍后重试,或者添加qq群:594788869进行反馈";
}
}else{
$info="超过IP限制,请稍后重试,或者添加qq群:594788869进行反馈";
}
}else{
$info="您的字数超过1000文字,请删除一些文字在使用。";
}
echo $info;
}
蝙蝠猫伪原创源码.zip
版权申诉
5星 · 超过95%的资源 122 浏览量
2021-02-22
18:46:15
上传
评论 1
收藏 23KB ZIP 举报
逐梦科技网络
- 粉丝: 295
- 资源: 835
最新资源
- Screenshot_2024-05-21-17-06-42-64_2332cb9b27b851b548ba47a91682926c.jpg
- 毕业设计参考 - 基于树莓派、OpenCV及Python的人脸识别
- node-v18.20.2-linux-arm64
- 222222222222
- 16张相机标定图片,可复现本文畸变矫正
- dbeaver-ce-23.3.1-x86_64-setup.zip
- 基于X86 AVX2指令的快速卷积实现
- VMware-ESXi-7.0U3n-21930508-depot.zip文件
- MySQL 在 Windows 系统下的安装教程.zip
- Access文件数据库访问的客户端
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈