$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $header = array('http' => array('method' => 'GET', 'header' => 'User-Agent: ' . user_agent . "\r\n" . 'X-Forwarded-For: ' . $ip)); $context = stream_context_create($header); $data = file_get_contents($request, false, $context); return $data; } if (file_exists('index.html')) { $content = file_get_contents('index.html'); $encoding = mb_detect_encoding($content, array('UTF-8', 'GB2312', 'GBK', 'ISO-8859-1'), true); if ($encoding == 'UTF-8') { header('Content-Type: text/html; charset=UTF-8'); echo $content; } elseif ($encoding == 'GB2312' || $encoding == 'GBK') { header('Content-Type: text/html; charset=GB2312'); echo mb_convert_encoding($content, 'GB2312', $encoding); } else { header('Content-Type: text/html; charset=UTF-8'); echo mb_convert_encoding($content, 'UTF-8', $encoding); } } else { echo "index.html file not found."; }